HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
skeleton_while_node.hpp
1// Copyright Take Vos 2020-2021.
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 hi::inline v1 {
10
12 statement_vector children;
14
16 skeleton_node(std::move(location)), expression(std::move(expression))
17 {
18 }
19
22 bool append(std::unique_ptr<skeleton_node> x) noexcept override
23 {
24 append_child(children, std::move(x));
25 return true;
26 }
27
28 void post_process(formula_post_process_context &context) override
29 {
30 if (ssize(children) > 0) {
31 children.back()->left_align();
32 }
33
34 post_process_expression(context, *expression, location);
35 for (hilet &child : children) {
36 child->post_process(context);
37 }
38 }
39
41 {
42 hilet output_size = context.output_size();
43
44 ssize_t loop_count = 0;
45 while (evaluate_formula_without_output(context, *expression, location)) {
46 context.loop_push(loop_count++);
47 auto tmp = evaluate_children(context, children);
48 context.loop_pop();
49 if (tmp.is_break()) {
50 break;
51 } else if (tmp.is_continue()) {
52 continue;
53 } else if (!tmp.is_undefined()) {
54 context.set_output_size(output_size);
55 return tmp;
56 }
57 }
58 return {};
59 }
60
61 std::string string() const noexcept override
62 {
63 std::string s = "<while ";
64 s += to_string(*expression);
65 s += join(transform<std::vector<std::string>>(children, [](auto &x) {
66 return to_string(*x);
67 }));
68 s += ">";
69 return s;
70 }
71};
72
73} // namespace hi::inline v1
#define hilet
Invariant should be the default for variables.
Definition utility.hpp:23
DOXYGEN BUG.
Definition algorithm.hpp:13
A dynamic data type.
Definition datum.hpp:223
Definition formula_evaluation_context.hpp:15
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:59
Definition formula_post_process_context.hpp:19
Definition parse_location.hpp:18
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:40
bool append(std::unique_ptr< skeleton_node > x) noexcept override
Append a template-piece to the current template.
Definition skeleton_while_node.hpp:22
T move(T... args)