14 bool has_else =
false;
15 statement_vector children;
16 statement_vector else_children;
25 append_child(else_children,
std::move(x));
41 void post_process(formula_post_process_context &context)
override {
42 if (std::ssize(children) > 0) {
43 children.back()->left_align();
45 if (std::ssize(else_children) > 0) {
46 else_children.back()->left_align();
49 post_process_expression(context, *name_expression, location);
50 post_process_expression(context, *list_expression, location);
52 for (ttlet &child: children) {
53 child->post_process(context);
55 for (ttlet &child: else_children) {
56 child->post_process(context);
61 auto list_data = evaluate_formula_without_output(context, *list_expression, location);
63 if (!list_data.is_vector()) {
64 throw operation_error(
"{}: Expecting expression returns a vector, got {}", location, list_data);
68 if (list_data.size() > 0) {
69 ttlet loop_size = std::ssize(list_data);
71 for (
auto i = list_data.vector_begin(); i != list_data.vector_end(); ++i) {
74 name_expression->assign_without_output(context, item);
77 throw operation_error(
"{}: Could not evaluate for-loop expression.\n{}", location, e.
what());
80 context.loop_push(loop_count++, loop_size);
81 auto tmp = evaluate_children(context, children);
86 }
else if (tmp.is_continue()) {
88 }
else if (!tmp.is_undefined()) {
95 auto tmp = evaluate_children(context, else_children);
96 if (tmp.is_break() || tmp.is_continue()) {
98 }
else if (!tmp.is_undefined()) {
108 s += to_string(*name_expression);
110 s += to_string(*list_expression);
bool append(std::unique_ptr< skeleton_node > x) noexcept override
Append a template-piece to the current template.
Definition skeleton_for_node.hpp:23