ast_call node; codegen dummy

This commit is contained in:
Wolfgang (Blub) Bumiller 2012-06-28 16:15:51 +02:00
parent 2073834b9a
commit e934e77cc5
2 changed files with 55 additions and 0 deletions

31
ast.c
View file

@ -308,6 +308,31 @@ void ast_loop_delete(ast_loop *self)
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)
{
@ -1148,3 +1173,9 @@ bool ast_loop_codegen(ast_loop *self, ast_function *func, bool lvalue, ir_value
return true;
}
bool ast_call_codegen(ast_call *self, ast_function *func, bool lvalue, ir_value **out)
{
/* TODO: call ir codegen */
return false;
}

24
ast.h
View file

@ -40,6 +40,7 @@ typedef struct ast_entfield_s ast_entfield;
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
*/
@ -284,6 +285,29 @@ void ast_loop_delete(ast_loop*);
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
*
*/