HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
skeleton_while_node.hpp
1// Copyright Take Vos 2020.
2// Distributed under the Boost Software License, Version 1.0.
3// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
4
5#pragma once
6
7#include "skeleton_node.hpp"
8
9namespace tt {
10
12 statement_vector children;
14
16 skeleton_node(std::move(location)), expression(std::move(expression)) {}
17
20 bool append(std::unique_ptr<skeleton_node> x) noexcept override {
21 append_child(children, std::move(x));
22 return true;
23 }
24
25 void post_process(formula_post_process_context &context) override {
26 if (std::ssize(children) > 0) {
27 children.back()->left_align();
28 }
29
30 post_process_expression(context, *expression, location);
31 for (ttlet &child: children) {
32 child->post_process(context);
33 }
34 }
35
37 ttlet output_size = context.output_size();
38
39 ssize_t loop_count = 0;
40 while (evaluate_formula_without_output(context, *expression, location)) {
41 context.loop_push(loop_count++);
42 auto tmp = evaluate_children(context, children);
43 context.loop_pop();
44 if (tmp.is_break()) {
45 break;
46 } else if (tmp.is_continue()) {
47 continue;
48 } else if (!tmp.is_undefined()) {
49 context.set_output_size(output_size);
50 return tmp;
51 }
52 }
53 return {};
54 }
55
56 std::string string() const noexcept override {
57 std::string s = "<while ";
58 s += to_string(*expression);
59 s += join(transform<std::vector<std::string>>(children, [](auto &x) { return to_string(*x); }));
60 s += ">";
61 return s;
62 }
63};
64
65}
Definition formula_evaluation_context.hpp:16
void set_output_size(ssize_t new_size) noexcept
Set the size of the output.
Definition formula_evaluation_context.hpp:67
ssize_t output_size() const noexcept
Get the size of the output.
Definition formula_evaluation_context.hpp:60
Definition formula_post_process_context.hpp:18
Definition parse_location.hpp:16
Definition skeleton_node.hpp:16
Definition skeleton_while_node.hpp:11
datum evaluate(formula_evaluation_context &context) override
Evaluate the template.
Definition skeleton_while_node.hpp:36
bool append(std::unique_ptr< skeleton_node > x) noexcept override
Append a template-piece to the current template.
Definition skeleton_while_node.hpp:20
T move(T... args)