mirror of
https://github.com/Ed94/Odin.git
synced 2026-07-19 16:11:30 +00:00
Handle calling conventions correctly
This commit is contained in:
@@ -1142,8 +1142,8 @@ void check_global_collect_entities_from_file(Checker *c, Scope *parent_scope, As
|
||||
for_array(iota, gd->specs) {
|
||||
AstNode *spec = gd->specs.e[iota];
|
||||
switch (spec->kind) {
|
||||
case_ast_node(bd, BadDecl, decl);
|
||||
case_end;
|
||||
case AstNode_BadDecl:
|
||||
break;
|
||||
case_ast_node(is, ImportSpec, spec);
|
||||
if (!parent_scope->is_file) {
|
||||
// NOTE(bill): _Should_ be caught by the parser
|
||||
|
||||
+1
-1
@@ -308,7 +308,7 @@ bool are_signatures_similar_enough(Type *a_, Type *b_) {
|
||||
void check_proc_decl(Checker *c, Entity *e, DeclInfo *d) {
|
||||
GB_ASSERT(e->type == NULL);
|
||||
|
||||
Type *proc_type = make_type_proc(c->allocator, e->scope, NULL, 0, NULL, 0, false);
|
||||
Type *proc_type = make_type_proc(c->allocator, e->scope, NULL, 0, NULL, 0, false, ProcCC_Odin);
|
||||
e->type = proc_type;
|
||||
ast_node(pd, ProcDecl, d->proc_decl);
|
||||
|
||||
|
||||
+7
-7
@@ -821,13 +821,13 @@ void check_procedure_type(Checker *c, Type *type, AstNode *proc_type_node) {
|
||||
if (params) param_count = params ->Tuple.variable_count;
|
||||
if (results) result_count = results->Tuple.variable_count;
|
||||
|
||||
type->Proc.scope = c->context.scope;
|
||||
type->Proc.params = params;
|
||||
type->Proc.param_count = param_count;
|
||||
type->Proc.results = results;
|
||||
type->Proc.result_count = result_count;
|
||||
type->Proc.variadic = variadic;
|
||||
// type->Proc.implicit_context = implicit_context;
|
||||
type->Proc.scope = c->context.scope;
|
||||
type->Proc.params = params;
|
||||
type->Proc.param_count = param_count;
|
||||
type->Proc.results = results;
|
||||
type->Proc.result_count = result_count;
|
||||
type->Proc.variadic = variadic;
|
||||
type->Proc.calling_convention = pt->calling_convention;
|
||||
}
|
||||
|
||||
|
||||
|
||||
+21
-3
@@ -110,6 +110,7 @@ typedef struct TypeRecord {
|
||||
i32 param_count; \
|
||||
i32 result_count; \
|
||||
bool variadic; \
|
||||
ProcCallingConvention calling_convention; \
|
||||
})
|
||||
|
||||
typedef enum TypeKind {
|
||||
@@ -382,7 +383,7 @@ Type *make_type_tuple(gbAllocator a) {
|
||||
return t;
|
||||
}
|
||||
|
||||
Type *make_type_proc(gbAllocator a, Scope *scope, Type *params, isize param_count, Type *results, isize result_count, bool variadic) {
|
||||
Type *make_type_proc(gbAllocator a, Scope *scope, Type *params, isize param_count, Type *results, isize result_count, bool variadic, ProcCallingConvention calling_convention) {
|
||||
Type *t = alloc_type(a, Type_Proc);
|
||||
|
||||
if (variadic) {
|
||||
@@ -403,6 +404,7 @@ Type *make_type_proc(gbAllocator a, Scope *scope, Type *params, isize param_coun
|
||||
t->Proc.results = results;
|
||||
t->Proc.result_count = result_count;
|
||||
t->Proc.variadic = variadic;
|
||||
t->Proc.calling_convention = calling_convention;
|
||||
return t;
|
||||
}
|
||||
|
||||
@@ -655,8 +657,9 @@ bool is_type_comparable(Type *t) {
|
||||
}
|
||||
|
||||
bool are_types_identical(Type *x, Type *y) {
|
||||
if (x == y)
|
||||
if (x == y) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((x == NULL && y != NULL) ||
|
||||
(x != NULL && y == NULL)) {
|
||||
@@ -747,7 +750,8 @@ bool are_types_identical(Type *x, Type *y) {
|
||||
|
||||
case Type_Proc:
|
||||
if (y->kind == Type_Proc) {
|
||||
return are_types_identical(x->Proc.params, y->Proc.params) &&
|
||||
return x->Proc.calling_convention == y->Proc.calling_convention &&
|
||||
are_types_identical(x->Proc.params, y->Proc.params) &&
|
||||
are_types_identical(x->Proc.results, y->Proc.results);
|
||||
}
|
||||
break;
|
||||
@@ -1547,6 +1551,20 @@ gbString write_type_to_string(gbString str, Type *type) {
|
||||
str = gb_string_appendc(str, " -> ");
|
||||
str = write_type_to_string(str, type->Proc.results);
|
||||
}
|
||||
switch (type->Proc.calling_convention) {
|
||||
case ProcCC_Odin:
|
||||
// str = gb_string_appendc(str, " #cc_odin");
|
||||
break;
|
||||
case ProcCC_C:
|
||||
str = gb_string_appendc(str, " #cc_c");
|
||||
break;
|
||||
case ProcCC_Std:
|
||||
str = gb_string_appendc(str, " #cc_std");
|
||||
break;
|
||||
case ProcCC_Fast:
|
||||
str = gb_string_appendc(str, " #cc_fast");
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user