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 (!holds_alternative<datum::vector_type>(list_data)) {
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 (ttlet &item : list_data) {
73 name_expression->assign_without_output(context, item);
76 throw operation_error(
"{}: Could not evaluate for-loop expression.\n{}", location, e.
what());
79 context.loop_push(loop_count++, loop_size);
80 auto tmp = evaluate_children(context, children);
85 }
else if (tmp.is_continue()) {
87 }
else if (!tmp.is_undefined()) {
94 auto tmp = evaluate_children(context, else_children);
95 if (tmp.is_break() || tmp.is_continue()) {
97 }
else if (!tmp.is_undefined()) {
107 s += to_string(*name_expression);
109 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