From de837f23804e6349402736ffe6845cd63fe17ca6 Mon Sep 17 00:00:00 2001 From: "Wolfgang (Blub) Bumiller" Date: Sat, 1 Dec 2012 16:11:04 +0100 Subject: [PATCH] Add some more output and field types so you can now properly call 'get_a_function_which_gives_a_function()()()' without return values getting lost --- ast.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/ast.c b/ast.c index 57a098f..8ad77ca 100644 --- a/ast.c +++ b/ast.c @@ -855,9 +855,12 @@ ast_call* ast_call_new(lex_ctx ctx, self->params = NULL; self->func = funcexpr; +/* self->expression.vtype = funcexpr->expression.next->expression.vtype; if (funcexpr->expression.next->expression.next) self->expression.next = ast_type_copy(ctx, funcexpr->expression.next->expression.next); +*/ + ast_type_adopt(self, funcexpr->expression.next); return self; } @@ -1987,6 +1990,10 @@ bool ast_entfield_codegen(ast_entfield *self, ast_function *func, bool lvalue, i } else { *out = ir_block_create_load_from_ent(func->curblock, ast_ctx(self), ast_function_label(func, "efv"), ent, field, self->expression.vtype); + if ((*out)->vtype == TYPE_FIELD) + (*out)->fieldtype = self->expression.next->expression.vtype; + if ((*out)->vtype == TYPE_FUNCTION) + (*out)->outtype = self->expression.next->expression.vtype; } if (!*out) { compile_error(ast_ctx(self), "failed to create %s instruction (output type %s)", @@ -2870,6 +2877,11 @@ bool ast_call_codegen(ast_call *self, ast_function *func, bool lvalue, ir_value *out = ir_call_value(callinstr); self->expression.outr = *out; + if ((*out)->vtype == TYPE_FIELD) + (*out)->fieldtype = self->expression.next->expression.vtype; + if ((*out)->vtype == TYPE_FUNCTION) + (*out)->outtype = self->expression.next->expression.vtype; + vec_free(params); return true; error: -- 2.39.2