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#include "../macros.hpp"
9
10namespace hi::inline v1 {
11
13 statement_vector children;
15
17 skeleton_node(std::move(location)), expression(std::move(expression))
18 {
19 }
20
23 bool append(std::unique_ptr<skeleton_node> x) noexcept override
24 {
25 append_child(children, std::move(x));
26 return true;
27 }
28
29 void post_process(formula_post_process_context &context) override
30 {
31 if (ssize(children) > 0) {
32 children.back()->left_align();
33 }
34
35 post_process_expression(context, *expression, location);
36 for (hilet &child : children) {
37 child->post_process(context);
38 }
39 }
40
41 datum evaluate(formula_evaluation_context &context) override
42 {
43 hilet output_size = context.output_size();
44
45 ssize_t loop_count = 0;
46 while (evaluate_formula_without_output(context, *expression, location)) {
47 context.loop_push(loop_count++);
48 auto tmp = evaluate_children(context, children);
49 context.loop_pop();
50 if (tmp.is_break()) {
51 break;
52 } else if (tmp.is_continue()) {
53 continue;
54 } else if (!tmp.is_undefined()) {
55 context.set_output_size(output_size);
56 return tmp;
57 }
58 }
59 return {};
60 }
61
62 std::string string() const noexcept override
63 {
64 std::string s = "<while ";
65 s += to_string(*expression);
66 s += join(transform<std::vector<std::string>>(children, [](auto &x) {
67 return to_string(*x);
68 }));
69 s += ">";
70 return s;
71 }
72};
73
74} // namespace hi::inline v1
DOXYGEN BUG.
Definition algorithm.hpp:16
constexpr Out narrow_cast(In const &rhs) noexcept
Cast numeric values without loss of precision.
Definition cast.hpp:377
Definition parse_location.hpp:18
Definition skeleton_node.hpp:16
Definition skeleton_while_node.hpp:12
datum evaluate(formula_evaluation_context &context) override
Evaluate the template.
Definition skeleton_while_node.hpp:41
bool append(std::unique_ptr< skeleton_node > x) noexcept override
Append a template-piece to the current template.
Definition skeleton_while_node.hpp:23
T move(T... args)