diff options
author | dec05eba <dec05eba@protonmail.com> | 2019-09-17 22:05:40 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2020-07-25 14:36:46 +0200 |
commit | dcd26bcfcc691f24508a7b6bf04c15042a4668ea (patch) | |
tree | f47df3dc79a5ac0b89507890d25843e9c724161b /src/ssa | |
parent | b095aedd386e076d1f5a56b7384b836e653387d1 (diff) |
Fix function call resolved type
Diffstat (limited to 'src/ssa')
-rw-r--r-- | src/ssa/ssa.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/src/ssa/ssa.c b/src/ssa/ssa.c index 13f19a9..d76ad28 100644 --- a/src/ssa/ssa.c +++ b/src/ssa/ssa.c @@ -640,7 +640,7 @@ static CHECK_RESULT SsaRegister funcdecl_generate_ssa(FunctionDecl *self, SsaCom return 0; } -static CHECK_RESULT SsaRegister funccall_generate_ssa(FunctionCall *self, AstResolveData *resolve_data, SsaCompilerContext *context) { +static CHECK_RESULT SsaRegister funccall_generate_ssa(FunctionCall *self, SsaCompilerContext *context) { SsaRegister reg; FunctionSignature *func_sig; FunctionDecl *func_decl; @@ -649,12 +649,18 @@ static CHECK_RESULT SsaRegister funccall_generate_ssa(FunctionCall *self, AstRes context->import_index = 0; throw_if_error(ssa_get_unique_reg(context->ssa, ®)); - assert(resolve_data->type.type == RESOLVED_TYPE_FUNC_SIG); - func_sig = resolve_data->type.value.func_sig; + assert(self->func.resolved_var.type == NAMED_OBJECT_LHS_EXPR); + func_lhs_expr = self->func.resolved_var.value.lhs_expr; + if(func_lhs_expr->type.type == VARIABLE_TYPE_SIGNATURE) { + func_sig = func_lhs_expr->type.value.signature; + } else if(func_lhs_expr->type.type == VARIABLE_TYPE_VARIABLE) { + AstResolveData *resolve_data = func_lhs_expr->type.value.variable->resolved_var.resolve_data; + assert(resolve_data->type.type == RESOLVED_TYPE_FUNC_SIG); + func_sig = resolve_data->type.value.func_sig; + } else { + assert(bool_false); + } func_decl = func_sig->func_decl; - func_lhs_expr = NULL; - if(self->func.resolved_var.type == NAMED_OBJECT_LHS_EXPR) - func_lhs_expr = self->func.resolved_var.value.lhs_expr; /* Push return arguments */ { @@ -869,7 +875,7 @@ static CHECK_RESULT SsaRegister ast_generate_ssa_resolve_data(void *ast_data, As resolve_data->ssa_reg = funcdecl_generate_ssa(ast_data, context); break; case AST_FUNCTION_CALL: - resolve_data->ssa_reg = funccall_generate_ssa(ast_data, resolve_data, context); + resolve_data->ssa_reg = funccall_generate_ssa(ast_data, context); break; case AST_STRUCT_DECL: resolve_data->ssa_reg = structdecl_generate_ssa(ast_data, context); |