mem_d(self);
}
+ast_call* ast_call_new(lex_ctx ctx,
+ ast_expression *funcexpr)
+{
+ ast_instantiate(ast_call, ctx, ast_call_delete);
+ ast_expression_init((ast_expression*)self, (ast_expression_codegen*)&ast_call_codegen);
+
+ MEM_VECTOR_INIT(self, params);
+
+ return self;
+}
+
+void ast_call_delete(ast_call *self)
+{
+ size_t i;
+ for (i = 0; i < self->params_count; ++i)
+ ast_unref(self->params[i]);
+ MEM_VECTOR_CLEAR(self, params);
+
+ if (self->func)
+ ast_unref(self->func);
+
+ ast_expression_delete((ast_expression*)self);
+ mem_d(self);
+}
+
ast_store* ast_store_new(lex_ctx ctx, int op,
ast_value *dest, ast_expression *source)
{
return true;
}
+
+bool ast_call_codegen(ast_call *self, ast_function *func, bool lvalue, ir_value **out)
+{
+ /* TODO: call ir codegen */
+ return false;
+}
typedef struct ast_ifthen_s ast_ifthen;
typedef struct ast_ternary_s ast_ternary;
typedef struct ast_loop_s ast_loop;
+typedef struct ast_call_s ast_call;
/* Node interface with common components
*/
bool ast_loop_codegen(ast_loop*, ast_function*, bool lvalue, ir_value**);
+/* CALL node
+ *
+ * Contains an ast_expression as target, rather than an ast_function/value.
+ * Since it's how QC works, every ast_function has an ast_value
+ * associated anyway - in other words, the VM contains function
+ * pointers for every function anyway. Thus, this node will call
+ * expression.
+ * Additionally it contains a list of ast_expressions as parameters.
+ * Since calls can return values, an ast_call is also an ast_expression.
+ */
+struct ast_call_s
+{
+ ast_expression_common expression;
+ ast_expression *func;
+ MEM_VECTOR_MAKE(ast_expression*, params);
+};
+ast_call* ast_call_new(lex_ctx ctx,
+ ast_expression *funcexpr);
+void ast_call_delete(ast_call*);
+bool ast_call_codegen(ast_call*, ast_function*, bool lvalue, ir_value**);
+
+MEM_VECTOR_PROTO(ast_call, ast_expression*, params);
+
/* Blocks
*
*/