From c067b90403ab8493daa0bf5867b2bd92319feea5 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Sat, 26 May 2018 23:12:55 +0100 Subject: Add basic package support (no IR support yet) --- src/entity.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/entity.cpp') diff --git a/src/entity.cpp b/src/entity.cpp index 182df8c05..d7f7dc2df 100644 --- a/src/entity.cpp +++ b/src/entity.cpp @@ -6,6 +6,7 @@ struct DeclInfo; #define ENTITY_KINDS \ ENTITY_KIND(Invalid) \ + ENTITY_KIND(Package) \ ENTITY_KIND(Constant) \ ENTITY_KIND(Variable) \ ENTITY_KIND(TypeName) \ @@ -85,6 +86,12 @@ struct Entity { String deprecated_message; union { + struct { + String fullpath; + String name; + Scope *scope; + // Array imports; // Entity_Package + } Package; struct { ExactValue value; } Constant; @@ -189,6 +196,15 @@ Entity *alloc_entity(EntityKind kind, Scope *scope, Token token, Type *type) { return entity; } +Entity *alloc_entity_package(Scope *scope, Type *type, String fullpath, String name) { + Token token = empty_token; + token.string = name; + Entity *entity = alloc_entity(Entity_Package, scope, token, type); + entity->Package.fullpath = fullpath; + entity->Package.name = name; + return entity; +} + 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; -- cgit v1.2.3