14 statement_vector children;
16 formula_post_process_context::function_type
function;
17 formula_post_process_context::function_type super_function;
21 formula_post_process_context &context,
22 formula_node
const &name_expression) noexcept :
25 name = name_expression.get_name();
28 context.set_function(name, [&](formula_evaluation_context &context, datum::vector_type
const &arguments) {
29 return this->evaluate_call(context, arguments);
41 void post_process(formula_post_process_context &context)
override
43 if (ssize(children) > 0) {
44 children.back()->left_align();
47 function = context.get_function(name);
50 context.push_super(super_function);
51 for (hilet &child : children) {
52 child->post_process(context);
57 datum
evaluate(formula_evaluation_context &context)
override
61 tmp =
function(context, datum::vector_type{});
64 throw operation_error(std::format(
"{}: Could not evaluate block.\n{}", location, e.
what()));
68 throw operation_error(std::format(
"{}: Found #break not inside a loop statement.", location));
70 }
else if (tmp.is_continue()) {
71 throw operation_error(std::format(
"{}: Found #continue not inside a loop statement.", location));
73 }
else if (tmp.is_undefined()) {
77 throw operation_error(std::format(
"{}: Can not use a #return statement inside a #block.", location));
81 datum evaluate_call(formula_evaluation_context &context, datum::vector_type
const &arguments)
84 auto tmp = evaluate_children(context, children);
88 throw operation_error(std::format(
"{}: Found #break not inside a loop statement.", location));
90 }
else if (tmp.is_continue()) {
91 throw operation_error(std::format(
"{}: Found #continue not inside a loop statement.", location));
93 }
else if (tmp.is_undefined()) {
97 throw operation_error(std::format(
"{}: Can not use a #return statement inside a #block.", location));
bool append(std::unique_ptr< skeleton_node > x) noexcept override
Append a template-piece to the current template.
Definition skeleton_block_node.hpp:35