aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2018-06-03 21:09:08 +0100
committergingerBill <bill@gingerbill.org>2018-06-03 21:09:08 +0100
commitb027b1d60fbceb3483464d4df9813d1d6b10c4fa (patch)
tree5f17fcff918b1dba761073baaac3c16b386ef9d7 /src
parentc39332c7e75eed6b21765b4f08376ff9afbb3c38 (diff)
Fix min type info for polymorphic procedures and named types
Diffstat (limited to 'src')
-rw-r--r--src/check_expr.cpp3
-rw-r--r--src/checker.cpp10
-rw-r--r--src/ir.cpp13
3 files changed, 9 insertions, 17 deletions
diff --git a/src/check_expr.cpp b/src/check_expr.cpp
index b2363be38..6926332d9 100644
--- a/src/check_expr.cpp
+++ b/src/check_expr.cpp
@@ -4709,6 +4709,7 @@ CallArgumentData check_call_arguments(CheckerContext *c, Operand *operand, Type
CallArgumentError err = call_checker(c, call, proc_type, e, operands, CallArgumentMode_ShowErrors, &data);
Entity *entity_to_use = data.gen_entity != nullptr ? data.gen_entity : e;
add_entity_use(c, ident, entity_to_use);
+
return data;
}
} else {
@@ -4719,10 +4720,12 @@ CallArgumentData check_call_arguments(CheckerContext *c, Operand *operand, Type
}
Entity *e = entity_of_ident(ident);
+
CallArgumentData data = {};
CallArgumentError err = call_checker(c, call, proc_type, e, operands, CallArgumentMode_ShowErrors, &data);
Entity *entity_to_use = data.gen_entity != nullptr ? data.gen_entity : e;
add_entity_use(c, ident, entity_to_use);
+
return data;
}
diff --git a/src/checker.cpp b/src/checker.cpp
index b1bf5e063..384094734 100644
--- a/src/checker.cpp
+++ b/src/checker.cpp
@@ -903,7 +903,7 @@ void add_entity_use(CheckerContext *c, AstNode *identifier, Entity *entity) {
}
}
entity->flags |= EntityFlag_Used;
- add_declaration_dependency(c, entity); // TODO(bill): Should this be here?
+ add_declaration_dependency(c, entity);
}
@@ -958,10 +958,11 @@ void add_type_info_type(CheckerContext *c, Type *t) {
return;
}
+ add_type_info_dependency(c->decl, t);
+
auto found = map_get(&c->info->type_info_map, hash_type(t));
if (found != nullptr) {
// Types have already been added
- add_type_info_dependency(c->decl, t);
return;
}
@@ -987,7 +988,6 @@ void add_type_info_type(CheckerContext *c, Type *t) {
if (prev) {
// NOTE(bill): If a previous one exists already, no need to continue
- add_type_info_dependency(c->decl, t);
return;
}
@@ -1356,7 +1356,7 @@ void generate_minimum_dependency_set(Checker *c, Entity *start) {
Entity *e = c->info.definitions[i];
// if (e->scope->is_global && !is_type_poly_proc(e->type)) { // TODO(bill): is the check enough?
if (e->scope == universal_scope) { // TODO(bill): is the check enough?
- if (e->type == nullptr || !is_type_poly_proc(e->type)) {
+ if (e->type == nullptr) {
add_dependency_to_set(c, e);
}
} else if (e->kind == Entity_Procedure && e->Procedure.is_export) {
@@ -3141,6 +3141,7 @@ void check_proc_info(Checker *c, ProcedureInfo pi) {
CheckerContext ctx = make_checker_context(c);
defer (destroy_checker_context(&ctx));
add_curr_ast_file(&ctx, pi.file);
+ ctx.decl = pi.decl;
TypeProc *pt = &pi.type->Proc;
String name = pi.token.string;
@@ -3148,7 +3149,6 @@ void check_proc_info(Checker *c, ProcedureInfo pi) {
GB_ASSERT_MSG(pt->is_poly_specialized, "%.*s", LIT(name));
}
-
bool bounds_check = (pi.tags & ProcTag_bounds_check) != 0;
bool no_bounds_check = (pi.tags & ProcTag_no_bounds_check) != 0;
diff --git a/src/ir.cpp b/src/ir.cpp
index 74b4a5908..aec5a5e36 100644
--- a/src/ir.cpp
+++ b/src/ir.cpp
@@ -3592,7 +3592,6 @@ gb_global i32 ir_global_type_info_member_names_index = 0;
gb_global i32 ir_global_type_info_member_offsets_index = 0;
gb_global i32 ir_global_type_info_member_usings_index = 0;
-#if 1
isize ir_type_info_count(CheckerInfo *info) {
return info->minimum_dependency_type_info_set.entries.count+1;
}
@@ -3610,16 +3609,6 @@ isize ir_type_info_index(CheckerInfo *info, Type *type, bool err_on_not_found=tr
}
return -1;
}
-#else
-isize ir_type_info_count(CheckerInfo *info) {
- return info->type_info_types.count;
-}
-
-isize ir_type_info_index(CheckerInfo *info, Type *type) {
- isize index = type_info_index(info, type);
- return index;
-}
-#endif
irValue *ir_type_info(irProcedure *proc, Type *type) {
CheckerInfo *info = proc->module->info;
@@ -6205,7 +6194,7 @@ void ir_build_constant_value_decl(irProcedure *proc, AstNodeValueDecl *vd) {
if (e->kind == Entity_TypeName) {
bool polymorphic_struct = false;
if (e->type != nullptr && e->kind == Entity_TypeName) {
- Type *bt = base_type(e->type);
+ Type *bt = base_type(e->type);
if (bt->kind == Type_Struct) {
polymorphic_struct = bt->Struct.is_polymorphic;
}