diff options
| author | gingerBill <bill@gingerbill.org> | 2018-03-23 20:48:30 +0000 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2018-03-23 20:48:30 +0000 |
| commit | 30f5a3bb9358ded6a48e8d8ba6f5eb0b3743a807 (patch) | |
| tree | ebec105ee45307ef11491c3bbb8ec31f2f61df0e /src/entity.cpp | |
| parent | 2e1e1e6034152fa83a05b7fb47e75eefe758ca62 (diff) | |
Move cycle checking to much earlier on in the semantic stage
Diffstat (limited to 'src/entity.cpp')
| -rw-r--r-- | src/entity.cpp | 76 |
1 files changed, 38 insertions, 38 deletions
diff --git a/src/entity.cpp b/src/entity.cpp index 5dcb3ff7b..182df8c05 100644 --- a/src/entity.cpp +++ b/src/entity.cpp @@ -177,7 +177,8 @@ bool is_entity_exported(Entity *e) { gb_global u64 global_entity_id = 0; -Entity *alloc_entity(gbAllocator a, EntityKind kind, Scope *scope, Token token, Type *type) { +Entity *alloc_entity(EntityKind kind, Scope *scope, Token token, Type *type) { + gbAllocator a = heap_allocator(); Entity *entity = gb_alloc_item(a, Entity); entity->kind = kind; entity->state = EntityState_Unresolved; @@ -188,17 +189,17 @@ Entity *alloc_entity(gbAllocator a, EntityKind kind, Scope *scope, Token token, return entity; } -Entity *make_entity_variable(gbAllocator a, Scope *scope, Token token, Type *type, bool is_immutable, EntityState state = EntityState_Unresolved) { - Entity *entity = alloc_entity(a, Entity_Variable, scope, token, type); +Entity *alloc_entity_variable(Scope *scope, Token token, Type *type, bool is_immutable, EntityState state = EntityState_Unresolved) { + Entity *entity = alloc_entity(Entity_Variable, scope, token, type); entity->Variable.is_immutable = is_immutable; entity->state = state; return entity; } -Entity *make_entity_using_variable(gbAllocator a, Entity *parent, Token token, Type *type) { +Entity *alloc_entity_using_variable(Entity *parent, Token token, Type *type) { GB_ASSERT(parent != nullptr); token.pos = parent->token.pos; - Entity *entity = alloc_entity(a, Entity_Variable, parent->scope, token, type); + Entity *entity = alloc_entity(Entity_Variable, parent->scope, token, type); entity->using_parent = parent; entity->parent_proc_decl = parent->parent_proc_decl; entity->flags |= EntityFlag_Using; @@ -208,21 +209,21 @@ Entity *make_entity_using_variable(gbAllocator a, Entity *parent, Token token, T } -Entity *make_entity_constant(gbAllocator a, Scope *scope, Token token, Type *type, ExactValue value) { - Entity *entity = alloc_entity(a, Entity_Constant, scope, token, type); +Entity *alloc_entity_constant(Scope *scope, Token token, Type *type, ExactValue value) { + Entity *entity = alloc_entity(Entity_Constant, scope, token, type); entity->Constant.value = value; return entity; } -Entity *make_entity_type_name(gbAllocator a, Scope *scope, Token token, Type *type, EntityState state = EntityState_Unresolved) { - Entity *entity = alloc_entity(a, Entity_TypeName, scope, token, type); +Entity *alloc_entity_type_name(Scope *scope, Token token, Type *type, EntityState state = EntityState_Unresolved) { + Entity *entity = alloc_entity(Entity_TypeName, scope, token, type); entity->state = state; return entity; } -Entity *make_entity_param(gbAllocator a, Scope *scope, Token token, Type *type, bool is_using, bool is_value) { +Entity *alloc_entity_param(Scope *scope, Token token, Type *type, bool is_using, bool is_value) { bool is_immutable = false; - Entity *entity = make_entity_variable(a, scope, token, type, is_immutable); + Entity *entity = alloc_entity_variable(scope, token, type, is_immutable); entity->flags |= EntityFlag_Used; entity->flags |= EntityFlag_Param; entity->state = EntityState_Resolved; @@ -232,8 +233,8 @@ Entity *make_entity_param(gbAllocator a, Scope *scope, Token token, Type *type, } -Entity *make_entity_const_param(gbAllocator a, Scope *scope, Token token, Type *type, ExactValue value, bool poly_const) { - Entity *entity = make_entity_constant(a, scope, token, type, value); +Entity *alloc_entity_const_param(Scope *scope, Token token, Type *type, ExactValue value, bool poly_const) { + Entity *entity = alloc_entity_constant(scope, token, type, value); entity->flags |= EntityFlag_Used; if (poly_const) entity->flags |= EntityFlag_PolyConst; entity->flags |= EntityFlag_Param; @@ -241,8 +242,8 @@ Entity *make_entity_const_param(gbAllocator a, Scope *scope, Token token, Type * } -Entity *make_entity_field(gbAllocator a, Scope *scope, Token token, Type *type, bool is_using, i32 field_src_index, EntityState state = EntityState_Unresolved) { - Entity *entity = make_entity_variable(a, scope, token, type, false); +Entity *alloc_entity_field(Scope *scope, Token token, Type *type, bool is_using, i32 field_src_index, EntityState state = EntityState_Unresolved) { + Entity *entity = alloc_entity_variable(scope, token, type, false); entity->Variable.field_src_index = field_src_index; entity->Variable.field_index = field_src_index; if (is_using) entity->flags |= EntityFlag_Using; @@ -251,8 +252,8 @@ Entity *make_entity_field(gbAllocator a, Scope *scope, Token token, Type *type, return entity; } -Entity *make_entity_array_elem(gbAllocator a, Scope *scope, Token token, Type *type, i32 field_src_index) { - Entity *entity = make_entity_variable(a, scope, token, type, false); +Entity *alloc_entity_array_elem(Scope *scope, Token token, Type *type, i32 field_src_index) { + Entity *entity = alloc_entity_variable(scope, token, type, false); entity->Variable.field_src_index = field_src_index; entity->Variable.field_index = field_src_index; entity->flags |= EntityFlag_Field; @@ -261,34 +262,34 @@ Entity *make_entity_array_elem(gbAllocator a, Scope *scope, Token token, Type *t return entity; } -Entity *make_entity_procedure(gbAllocator a, Scope *scope, Token token, Type *signature_type, u64 tags) { - Entity *entity = alloc_entity(a, Entity_Procedure, scope, token, signature_type); +Entity *alloc_entity_procedure(Scope *scope, Token token, Type *signature_type, u64 tags) { + Entity *entity = alloc_entity(Entity_Procedure, scope, token, signature_type); entity->Procedure.tags = tags; return entity; } -Entity *make_entity_proc_group(gbAllocator a, Scope *scope, Token token, Type *type) { - Entity *entity = alloc_entity(a, Entity_ProcGroup, scope, token, type); +Entity *alloc_entity_proc_group(Scope *scope, Token token, Type *type) { + Entity *entity = alloc_entity(Entity_ProcGroup, scope, token, type); return entity; } -Entity *make_entity_builtin(gbAllocator a, Scope *scope, Token token, Type *type, i32 id) { - Entity *entity = alloc_entity(a, Entity_Builtin, scope, token, type); +Entity *alloc_entity_builtin(Scope *scope, Token token, Type *type, i32 id) { + Entity *entity = alloc_entity(Entity_Builtin, scope, token, type); entity->Builtin.id = id; entity->state = EntityState_Resolved; return entity; } -Entity *make_entity_alias(gbAllocator a, Scope *scope, Token token, Type *type, Entity *base) { - Entity *entity = alloc_entity(a, Entity_Alias, scope, token, type); +Entity *alloc_entity_alias(Scope *scope, Token token, Type *type, Entity *base) { + Entity *entity = alloc_entity(Entity_Alias, scope, token, type); entity->Alias.base = base; return entity; } -Entity *make_entity_import_name(gbAllocator a, Scope *scope, Token token, Type *type, - String path, String name, Scope *import_scope) { - Entity *entity = alloc_entity(a, Entity_ImportName, scope, token, type); +Entity *alloc_entity_import_name(Scope *scope, Token token, Type *type, + String path, String name, Scope *import_scope) { + Entity *entity = alloc_entity(Entity_ImportName, scope, token, type); entity->ImportName.path = path; entity->ImportName.name = name; entity->ImportName.scope = import_scope; @@ -296,9 +297,9 @@ Entity *make_entity_import_name(gbAllocator a, Scope *scope, Token token, Type * return entity; } -Entity *make_entity_library_name(gbAllocator a, Scope *scope, Token token, Type *type, - String path, String name) { - Entity *entity = alloc_entity(a, Entity_LibraryName, scope, token, type); +Entity *alloc_entity_library_name(Scope *scope, Token token, Type *type, + String path, String name) { + Entity *entity = alloc_entity(Entity_LibraryName, scope, token, type); entity->LibraryName.path = path; entity->LibraryName.name = name; entity->state = EntityState_Resolved; // TODO(bill): Is this correct? @@ -309,21 +310,20 @@ Entity *make_entity_library_name(gbAllocator a, Scope *scope, Token token, Type -Entity *make_entity_nil(gbAllocator a, String name, Type *type) { - Entity *entity = alloc_entity(a, Entity_Nil, nullptr, make_token_ident(name), type); +Entity *alloc_entity_nil(String name, Type *type) { + Entity *entity = alloc_entity(Entity_Nil, nullptr, make_token_ident(name), type); return entity; } -Entity *make_entity_label(gbAllocator a, Scope *scope, Token token, Type *type, - AstNode *node) { - Entity *entity = alloc_entity(a, Entity_Label, scope, token, type); +Entity *alloc_entity_label(Scope *scope, Token token, Type *type, AstNode *node) { + Entity *entity = alloc_entity(Entity_Label, scope, token, type); entity->Label.node = node; entity->state = EntityState_Resolved; return entity; } -Entity *make_entity_dummy_variable(gbAllocator a, Scope *scope, Token token) { +Entity *alloc_entity_dummy_variable(Scope *scope, Token token) { token.string = str_lit("_"); - return make_entity_variable(a, scope, token, nullptr, false); + return alloc_entity_variable(scope, token, nullptr, false); } |