7#include "skeleton_node.hpp"
9namespace hi::inline
v1 {
14 bool has_else =
false;
15 statement_vector children;
16 statement_vector else_children;
23 name_expression(
std::move(name_expression)),
24 list_expression(
std::move(list_expression))
33 append_child(else_children,
std::move(x));
50 void post_process(formula_post_process_context &context)
override
52 if (ssize(children) > 0) {
53 children.back()->left_align();
55 if (ssize(else_children) > 0) {
56 else_children.back()->left_align();
59 post_process_expression(context, *name_expression, location);
60 post_process_expression(context, *list_expression, location);
62 for (
hilet &child : children) {
63 child->post_process(context);
65 for (
hilet &child : else_children) {
66 child->post_process(context);
72 auto list_data = evaluate_formula_without_output(context, *list_expression, location);
74 if (!holds_alternative<datum::vector_type>(list_data)) {
75 throw operation_error(std::format(
"{}: Expecting expression returns a vector, got {}", location, list_data));
79 if (
hilet loop_size = list_data.size()) {
80 ssize_t loop_count = 0;
81 for (
hilet &item : list_data) {
83 name_expression->assign_without_output(context, item);
86 throw operation_error(std::format(
"{}: Could not evaluate for-loop expression.\n{}", location, e.
what()));
89 context.loop_push(loop_count++, loop_size);
90 auto tmp = evaluate_children(context, children);
95 }
else if (tmp.is_continue()) {
97 }
else if (!tmp.is_undefined()) {
104 auto tmp = evaluate_children(context, else_children);
105 if (tmp.is_break() || tmp.is_continue()) {
107 }
else if (!tmp.is_undefined()) {
118 s += to_string(*name_expression);
120 s += to_string(*list_expression);
122 return to_string(*x);
127 return to_string(*x);
#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 parse_location.hpp:18
Definition skeleton_for_node.hpp:11
bool append(std::unique_ptr< skeleton_node > x) noexcept override
Append a template-piece to the current template.
Definition skeleton_for_node.hpp:30
datum evaluate(formula_evaluation_context &context) override
Evaluate the template.
Definition skeleton_for_node.hpp:70
Definition skeleton_node.hpp:16