This commit is contained in:
gingerBill
2021-04-27 13:09:37 +01:00
parent 94fd59e6f0
commit e7e1866e50
6 changed files with 36 additions and 32 deletions

View File

@@ -1908,17 +1908,6 @@ fmt_value :: proc(fi: ^Info, v: any, verb: rune) {
}
}
handle_relative_pointer :: proc(ptr: ^$T) -> rawptr where intrinsics.type_is_integer(T) {
if ptr^ == 0 {
return nil;
}
when intrinsics.type_is_unsigned(T) {
return rawptr(uintptr(ptr) + uintptr(ptr^));
} else {
return rawptr(uintptr(ptr) + uintptr(i64(ptr^)));
}
}
}
fmt_complex :: proc(fi: ^Info, c: complex128, bits: int, verb: rune) {

View File

@@ -352,16 +352,17 @@ void override_entity_in_scope(Entity *original_entity, Entity *new_entity) {
string_map_set(&found_scope->elements, original_name, new_entity);
original_entity->flags |= EntityFlag_Overridden;
original_entity->type = new_entity->type;
original_entity->aliased_of = new_entity;
if (original_entity->identifier == nullptr) {
original_entity->identifier = new_entity->identifier;
}
if (original_entity->identifier != nullptr &&
original_entity->identifier->kind == Ast_Ident) {
original_entity->identifier->Ident.entity = nullptr;
original_entity->identifier->Ident.entity = new_entity;
}
original_entity->flags |= EntityFlag_Overridden;
// IMPORTANT NOTE(bill, 2021-04-10): copy only the variants
// This is most likely NEVER required, but it does not at all hurt to keep

View File

@@ -1141,6 +1141,9 @@ Entity *check_ident(CheckerContext *c, Operand *o, Ast *n, Type *named_type, Typ
}
return nullptr;
}
GB_ASSERT((e->flags & EntityFlag_Overridden) == 0);
if (e->parent_proc_decl != nullptr &&
e->parent_proc_decl != c->curr_proc_decl) {
if (e->kind == Entity_Variable) {
@@ -1195,8 +1198,6 @@ Entity *check_ident(CheckerContext *c, Operand *o, Ast *n, Type *named_type, Typ
if (e->state == EntityState_Unresolved) {
check_entity_decl(c, e, nullptr, named_type);
}
if (e->type == nullptr) {
// TODO(bill): Which is correct? return or compiler_error?
// compiler_error("How did this happen? type: %s; identifier: %.*s\n", type_to_string(e->type), LIT(name));

View File

@@ -960,7 +960,11 @@ Entity *entity_of_node(Ast *expr) {
expr = unparen_expr(expr);
switch (expr->kind) {
case_ast_node(ident, Ident, expr);
return ident->entity;
Entity *e = ident->entity;
if (e && e->flags & EntityFlag_Overridden) {
// GB_PANIC("use of an overriden entity: %.*s", LIT(e->token.string));
}
return e;
case_end;
case_ast_node(se, SelectorExpr, expr);
Ast *s = unselector_expr(se->selector);
@@ -973,7 +977,6 @@ Entity *entity_of_node(Ast *expr) {
return nullptr;
}
DeclInfo *decl_info_of_entity(Entity *e) {
if (e != nullptr) {
return e->decl_info;

View File

@@ -126,6 +126,8 @@ struct Entity {
Entity * using_parent;
Ast * using_expr;
Entity * aliased_of;
lbModule * code_gen_module;
lbProcedure *code_gen_procedure;

View File

@@ -3544,16 +3544,14 @@ void lb_build_constant_value_decl(lbProcedure *p, AstValueDecl *vd) {
Ast *ident = vd->names[i];
GB_ASSERT(ident->kind == Ast_Ident);
Entity *e = entity_of_node(ident);
if (e == nullptr) {
continue;
}
GB_ASSERT(e != nullptr);
if (e->kind != Entity_TypeName) {
continue;
}
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;
}
@@ -3575,12 +3573,16 @@ void lb_build_constant_value_decl(lbProcedure *p, AstValueDecl *vd) {
Ast *ident = vd->names[i];
GB_ASSERT(ident->kind == Ast_Ident);
Entity *e = entity_of_node(ident);
if (e == nullptr) {
continue;
}
GB_ASSERT(e != nullptr);
if (e->kind != Entity_Procedure) {
continue;
}
GB_ASSERT (vd->values[i] != nullptr);
Ast *value = unparen_expr(vd->values[i]);
if (value->kind != Ast_ProcLit) {
continue; // It's an alias
}
CheckerInfo *info = p->module->info;
DeclInfo *decl = decl_info_of_entity(e);
@@ -11436,7 +11438,13 @@ lbValue lb_get_using_variable(lbProcedure *p, Entity *e) {
GB_ASSERT(v.value != nullptr);
GB_ASSERT_MSG(parent->type == type_deref(v.type), "%s %s", type_to_string(parent->type), type_to_string(v.type));
lbValue ptr = lb_emit_deep_field_gep(p, v, sel);
lb_add_debug_local_variable(p, ptr.value, e->type, e->token);
if (parent->scope) {
if ((parent->scope->flags & (ScopeFlag_File|ScopeFlag_Pkg)) == 0) {
lb_add_debug_local_variable(p, ptr.value, e->type, e->token);
}
} else {
lb_add_debug_local_variable(p, ptr.value, e->type, e->token);
}
return ptr;
}
@@ -13778,13 +13786,13 @@ void lb_generate_code(lbGenerator *gen) {
}
gbString producer = gb_string_make(heap_allocator(), "odin");
producer = gb_string_append_fmt(producer, " version %.*s", LIT(ODIN_VERSION));
#ifdef NIGHTLY
producer = gb_string_appendc(producer, "-nightly");
#endif
#ifdef GIT_SHA
producer = gb_string_append_fmt(producer, "-%s", GIT_SHA);
#endif
// producer = gb_string_append_fmt(producer, " version %.*s", LIT(ODIN_VERSION));
// #ifdef NIGHTLY
// producer = gb_string_appendc(producer, "-nightly");
// #endif
// #ifdef GIT_SHA
// producer = gb_string_append_fmt(producer, "-%s", GIT_SHA);
// #endif
gbString split_name = gb_string_make(heap_allocator(), "");