diff options
author | dec05eba <dec05eba@protonmail.com> | 2019-09-18 14:28:12 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2020-07-25 14:36:46 +0200 |
commit | 142a13ad3f77c0ad1bd321d1a1f864a5117896d1 (patch) | |
tree | 9e7c89d3e1960ca833b01b4c7aafb27cc8a966b4 /src | |
parent | ab0c5259e5a3238e176e4b1aed942f5384a2d0c6 (diff) |
Fix import func call build
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler.c | 11 | ||||
-rw-r--r-- | src/ssa/ssa.c | 5 |
2 files changed, 14 insertions, 2 deletions
diff --git a/src/compiler.c b/src/compiler.c index 7fd4426..4d43329 100644 --- a/src/compiler.c +++ b/src/compiler.c @@ -57,6 +57,7 @@ static CHECK_RESULT int create_default_type_fixed_size(amal_compiler *compiler, } static CHECK_RESULT int init_default_types(amal_compiler *compiler) { + /* POD */ return_if_error(create_default_type_fixed_size(compiler, "i8", 1, &compiler->default_types.i8)); return_if_error(create_default_type_fixed_size(compiler, "i16", 2, &compiler->default_types.i16)); return_if_error(create_default_type_fixed_size(compiler, "i32", 4, &compiler->default_types.i32)); @@ -69,9 +70,19 @@ static CHECK_RESULT int init_default_types(amal_compiler *compiler) { return_if_error(create_default_type_num_pointers(compiler, "usize", 1, &compiler->default_types.usize)); return_if_error(create_default_type_fixed_size(compiler, "f32", 4, &compiler->default_types.f32)); return_if_error(create_default_type_fixed_size(compiler, "f64", 8, &compiler->default_types.f64)); + return_if_error(create_default_type_fixed_size(compiler, "bool", 1, &compiler->default_types.bool)); + /* TODO: str should be a struct with the fields @data (ptr) and @size (usize) */ + /* Types with more than one member */ return_if_error(create_default_type_num_pointers(compiler, "str", 1, &compiler->default_types.str)); + /* C types */ + return_if_error(create_default_type_fixed_size(compiler, "c_char", sizeof(char), &compiler->default_types.c_char)); + return_if_error(create_default_type_fixed_size(compiler, "c_short", sizeof(short), &compiler->default_types.c_short)); + return_if_error(create_default_type_fixed_size(compiler, "c_int", sizeof(int), &compiler->default_types.c_int)); + return_if_error(create_default_type_fixed_size(compiler, "c_long", sizeof(long), &compiler->default_types.c_long)); + return_if_error(create_default_type_num_pointers(compiler, "c_void", 0, &compiler->default_types.c_void)); + compiler->default_types.arithmetic_types[0] = compiler->default_types.i8; compiler->default_types.arithmetic_types[1] = compiler->default_types.u8; compiler->default_types.arithmetic_types[2] = compiler->default_types.i16; diff --git a/src/ssa/ssa.c b/src/ssa/ssa.c index d76ad28..9955d9d 100644 --- a/src/ssa/ssa.c +++ b/src/ssa/ssa.c @@ -658,7 +658,8 @@ static CHECK_RESULT SsaRegister funccall_generate_ssa(FunctionCall *self, SsaCom assert(resolve_data->type.type == RESOLVED_TYPE_FUNC_SIG); func_sig = resolve_data->type.value.func_sig; } else { - assert(bool_false); + assert(func_lhs_expr->rhs_expr && func_lhs_expr->rhs_expr->resolve_data.type.type == RESOLVED_TYPE_FUNC_SIG); + func_sig = func_lhs_expr->rhs_expr->resolve_data.type.value.func_sig; } func_decl = func_sig->func_decl; @@ -775,7 +776,7 @@ static CHECK_RESULT SsaRegister binop_generate_ssa(Binop *self, SsaCompilerConte const std = @import("std.amal"); std.printf */ - if(self->type == BINOP_DOT && self->rhs->resolve_data.type.type == RESOLVED_TYPE_FUNC_SIG) { + if(self->type == BINOP_DOT && self->rhs->type == AST_FUNCTION_CALL) { Import *lhs_import = binop_lhs_get_import_or_null(self); if(lhs_import) context->import_index = 1 + lhs_import->file_scope->import_index; |