Library names - Only link with used foreign libraries

This commit is contained in:
Ginger Bill
2017-01-26 20:00:16 +00:00
parent f47f25f942
commit e3e16f5d05
14 changed files with 341 additions and 251 deletions
+15
View File
@@ -12,6 +12,7 @@ typedef enum ImplicitValueId ImplicitValueId;
ENTITY_KIND(Procedure) \
ENTITY_KIND(Builtin) \
ENTITY_KIND(ImportName) \
ENTITY_KIND(LibraryName) \
ENTITY_KIND(Nil) \
ENTITY_KIND(ImplicitValue) \
ENTITY_KIND(Count)
@@ -72,6 +73,7 @@ struct Entity {
struct {
bool is_foreign;
String foreign_name;
Entity * foreign_library;
String link_name;
u64 tags;
OverloadKind overload_kind;
@@ -85,6 +87,11 @@ struct Entity {
Scope *scope;
bool used;
} ImportName;
struct {
String path;
String name;
bool used;
} LibraryName;
i32 Nil;
struct {
// TODO(bill): Should this be a user-level construct rather than compiler-level?
@@ -178,6 +185,14 @@ 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->LibraryName.path = path;
entity->LibraryName.name = name;
return entity;
}
Entity *make_entity_nil(gbAllocator a, String name, Type *type) {
Token token = make_token_ident(name);
Entity *entity = alloc_entity(a, Entity_Nil, NULL, token, type);