11struct skeleton_function_node final : skeleton_node {
14 statement_vector children;
16 formula_post_process_context::function_type super_function;
18 skeleton_function_node(
21 formula_node const &function_declaration_expression) noexcept :
25 hi_assert(name_and_arguments.size() >= 1);
27 name = name_and_arguments[0];
28 name_and_arguments.erase(name_and_arguments.begin());
29 argument_names =
std::move(name_and_arguments);
31 super_function = context.set_function(
34 return this->evaluate_call(context, arguments);
37 throw operation_error(std::format(
"{}: Failed during handling of function call.\n{}", location, e.
what()));
52 if (ssize(children) > 0) {
53 children.back()->left_align();
56 context.push_super(super_function);
57 for (hilet &child : children) {
58 child->post_process(context);
71 if (ssize(argument_names) != ssize(arguments)) {
72 throw operation_error(std::format(
73 "{}: Invalid number of arguments to function {}() expecting {} got {}.",
76 argument_names.
size(),
80 for (ssize_t i = 0; i != ssize(argument_names); ++i) {
81 context.set(argument_names[i], arguments[i]);
85 auto tmp = evaluate_children(context, children);
89 throw operation_error(std::format(
"{}: Found #break not inside a loop statement.", location));
91 }
else if (tmp.is_continue()) {
92 throw operation_error(std::format(
"{}: Found #continue not inside a loop statement.", location));
94 }
else if (tmp.is_undefined()) {
104 std::string string() const noexcept
override
106 std::string s =
"<function ";
109 s += join(argument_names,
",");
111 s += join(transform<std::vector<std::string>>(children, [](
auto &x) {
#define hi_assert(expression,...)
Assert if expression is true.
Definition assert.hpp:199
bool append(std::unique_ptr< skeleton_node > x) noexcept override
Append a template-piece to the current template.
Definition skeleton_function_node.hpp:44