aboutsummaryrefslogtreecommitdiff
path: root/src/checker
diff options
context:
space:
mode:
authorGinger Bill <bill@gingerbill.org>2016-12-22 23:06:31 +0000
committerGinger Bill <bill@gingerbill.org>2016-12-22 23:06:31 +0000
commitd714bece47ea058e482389452cd428dad9c28fd0 (patch)
tree5e4291d573e6f3d83f606bdf9d444d48ff7d943c /src/checker
parent923b039cf6e7b306f42c5319d66f0a382378935f (diff)
Handle calling conventions correctly
Diffstat (limited to 'src/checker')
-rw-r--r--src/checker/checker.c4
-rw-r--r--src/checker/decl.c2
-rw-r--r--src/checker/expr.c14
-rw-r--r--src/checker/types.c24
4 files changed, 31 insertions, 13 deletions
diff --git a/src/checker/checker.c b/src/checker/checker.c
index 8fc40b83d..2159eb95b 100644
--- a/src/checker/checker.c
+++ b/src/checker/checker.c
@@ -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
diff --git a/src/checker/decl.c b/src/checker/decl.c
index be735f3d4..cc2c48f78 100644
--- a/src/checker/decl.c
+++ b/src/checker/decl.c
@@ -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);
diff --git a/src/checker/expr.c b/src/checker/expr.c
index 79a8e8623..299dd55c9 100644
--- a/src/checker/expr.c
+++ b/src/checker/expr.c
@@ -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;
}
diff --git a/src/checker/types.c b/src/checker/types.c
index c3f3d2383..c3fff7e01 100644
--- a/src/checker/types.c
+++ b/src/checker/types.c
@@ -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;
}