Browse Source

Remove dead code

gingerBill 7 years ago
parent
commit
d7108416c9
5 changed files with 18 additions and 33 deletions
  1. 4 3
      src/check_decl.cpp
  2. 5 3
      src/checker.cpp
  3. 8 17
      src/entity.cpp
  4. 0 9
      src/exact_value.cpp
  5. 1 1
      src/ir.cpp

+ 4 - 3
src/check_decl.cpp

@@ -329,6 +329,7 @@ void check_const_decl(CheckerContext *ctx, Entity *e, AstNode *type_expr, AstNod
 		}
 		}
 
 
 		if (entity != nullptr) {
 		if (entity != nullptr) {
+			// TODO(bill): Clean up aliasing code
 			switch (entity->kind) {
 			switch (entity->kind) {
 			case Entity_Alias:
 			case Entity_Alias:
 				e->kind = Entity_Alias;
 				e->kind = Entity_Alias;
@@ -346,14 +347,14 @@ void check_const_decl(CheckerContext *ctx, Entity *e, AstNode *type_expr, AstNod
 				e->ImportName.path  = entity->ImportName.path;
 				e->ImportName.path  = entity->ImportName.path;
 				e->ImportName.name  = entity->ImportName.path;
 				e->ImportName.name  = entity->ImportName.path;
 				e->ImportName.scope = entity->ImportName.scope;
 				e->ImportName.scope = entity->ImportName.scope;
-				e->ImportName.used  = false;
+				e->flags &= ~EntityFlag_Used;
 				return;
 				return;
 			case Entity_LibraryName:
 			case Entity_LibraryName:
 				e->kind = Entity_LibraryName;
 				e->kind = Entity_LibraryName;
 				e->type = entity->type;
 				e->type = entity->type;
 				e->LibraryName.path  = entity->LibraryName.path;
 				e->LibraryName.path  = entity->LibraryName.path;
 				e->LibraryName.name  = entity->LibraryName.path;
 				e->LibraryName.name  = entity->LibraryName.path;
-				e->LibraryName.used  = false;
+				e->flags &= ~EntityFlag_Used;
 				return;
 				return;
 			}
 			}
 		}
 		}
@@ -468,7 +469,7 @@ void init_entity_foreign_library(CheckerContext *ctx, Entity *e) {
 		} else {
 		} else {
 			// TODO(bill): Extra stuff to do with library names?
 			// TODO(bill): Extra stuff to do with library names?
 			*foreign_library = found;
 			*foreign_library = found;
-			found->LibraryName.used = true;
+			found->flags |= EntityFlag_Used;
 			add_entity_use(ctx, ident, found);
 			add_entity_use(ctx, ident, found);
 		}
 		}
 	}
 	}

+ 5 - 3
src/checker.cpp

@@ -1287,7 +1287,7 @@ void add_dependency_to_set(Checker *c, Entity *entity) {
 			Entity *fl = e->Procedure.foreign_library;
 			Entity *fl = e->Procedure.foreign_library;
 			if (fl != nullptr) {
 			if (fl != nullptr) {
 				GB_ASSERT_MSG(fl->kind == Entity_LibraryName &&
 				GB_ASSERT_MSG(fl->kind == Entity_LibraryName &&
-				              fl->LibraryName.used,
+				              (fl->flags&EntityFlag_Used),
 				              "%.*s", LIT(name));
 				              "%.*s", LIT(name));
 				add_dependency_to_set(c, fl);
 				add_dependency_to_set(c, fl);
 			}
 			}
@@ -1296,7 +1296,7 @@ void add_dependency_to_set(Checker *c, Entity *entity) {
 			Entity *fl = e->Variable.foreign_library;
 			Entity *fl = e->Variable.foreign_library;
 			if (fl != nullptr) {
 			if (fl != nullptr) {
 				GB_ASSERT_MSG(fl->kind == Entity_LibraryName &&
 				GB_ASSERT_MSG(fl->kind == Entity_LibraryName &&
-				              fl->LibraryName.used,
+				              (fl->flags&EntityFlag_Used),
 				              "%.*s", LIT(name));
 				              "%.*s", LIT(name));
 				add_dependency_to_set(c, fl);
 				add_dependency_to_set(c, fl);
 			}
 			}
@@ -2339,7 +2339,9 @@ String path_to_entity_name(String name, String fullpath) {
 		}
 		}
 	}
 	}
 
 
-	filename = substring(filename, 0, dot);
+	if (dot > 0) {
+		filename = substring(filename, 0, dot);
+	}
 
 
 	if (is_string_an_identifier(filename)) {
 	if (is_string_an_identifier(filename)) {
 		return filename;
 		return filename;

+ 8 - 17
src/entity.cpp

@@ -50,13 +50,6 @@ enum EntityFlag {
 	EntityFlag_CVarArg       = 1<<20,
 	EntityFlag_CVarArg       = 1<<20,
 };
 };
 
 
-// Zero value means the overloading process is not yet done
-enum OverloadKind {
-	Overload_Unknown = 0,
-	Overload_No      = 1,
-	Overload_Yes     = 2,
-};
-
 enum EntityState {
 enum EntityState {
 	EntityState_Unresolved = 0,
 	EntityState_Unresolved = 0,
 	EntityState_InProgress  = 1,
 	EntityState_InProgress  = 1,
@@ -93,17 +86,18 @@ struct Entity {
 			i32        field_index;
 			i32        field_index;
 			i32        field_src_index;
 			i32        field_src_index;
 			ExactValue default_value;
 			ExactValue default_value;
+			String     thread_local_model;
 			Entity *   foreign_library;
 			Entity *   foreign_library;
 			AstNode *  foreign_library_ident;
 			AstNode *  foreign_library_ident;
 			String     link_name;
 			String     link_name;
 			String     link_prefix;
 			String     link_prefix;
-			String     thread_local_model;
+			bool       is_foreign;
+			bool       is_export;
+
 			bool       default_is_nil;
 			bool       default_is_nil;
 			bool       default_is_undef;
 			bool       default_is_undef;
 			bool       default_is_location;
 			bool       default_is_location;
 			bool       is_immutable;
 			bool       is_immutable;
-			bool       is_foreign;
-			bool       is_export;
 		} Variable;
 		} Variable;
 		struct {
 		struct {
 			bool   is_type_alias;
 			bool   is_type_alias;
@@ -111,14 +105,13 @@ struct Entity {
 			String ir_mangled_name;
 			String ir_mangled_name;
 		} TypeName;
 		} TypeName;
 		struct {
 		struct {
-			OverloadKind overload_kind;
-			String       link_name;
-			String       link_prefix;
 			u64          tags;
 			u64          tags;
-			bool         is_export;
-			bool         is_foreign;
 			Entity *     foreign_library;
 			Entity *     foreign_library;
 			AstNode *    foreign_library_ident;
 			AstNode *    foreign_library_ident;
+			String       link_name;
+			String       link_prefix;
+			bool         is_foreign;
+			bool         is_export;
 		} Procedure;
 		} Procedure;
 		struct {
 		struct {
 			Array<Entity *> entities;
 			Array<Entity *> entities;
@@ -133,12 +126,10 @@ struct Entity {
 			String path;
 			String path;
 			String name;
 			String name;
 			Scope *scope;
 			Scope *scope;
-			bool   used;
 		} ImportName;
 		} ImportName;
 		struct {
 		struct {
 			String path;
 			String path;
 			String name;
 			String name;
-			bool   used;
 		} LibraryName;
 		} LibraryName;
 		i32 Nil;
 		i32 Nil;
 		struct {
 		struct {

+ 0 - 9
src/exact_value.cpp

@@ -24,7 +24,6 @@ enum ExactValueKind {
 	ExactValue_Pointer,
 	ExactValue_Pointer,
 	ExactValue_Compound,  // TODO(bill): Is this good enough?
 	ExactValue_Compound,  // TODO(bill): Is this good enough?
 	ExactValue_Procedure, // TODO(bill): Is this good enough?
 	ExactValue_Procedure, // TODO(bill): Is this good enough?
-	ExactValue_Entity,    // TODO(bill): Is this good enough?
 
 
 	ExactValue_Count,
 	ExactValue_Count,
 };
 };
@@ -68,8 +67,6 @@ HashKey hash_exact_value(ExactValue v) {
 		return hash_pointer(v.value_compound);
 		return hash_pointer(v.value_compound);
 	case ExactValue_Procedure:
 	case ExactValue_Procedure:
 		return hash_pointer(v.value_procedure);
 		return hash_pointer(v.value_procedure);
-	case ExactValue_Entity:
-		return hash_pointer(v.value_entity);
 	}
 	}
 	return hashing_proc(&v, gb_size_of(ExactValue));
 	return hashing_proc(&v, gb_size_of(ExactValue));
 
 
@@ -132,12 +129,6 @@ ExactValue exact_value_procedure(AstNode *node) {
 	return result;
 	return result;
 }
 }
 
 
-ExactValue exact_value_entity(Entity *entity) {
-	ExactValue result = {ExactValue_Entity};
-	result.value_entity = entity;
-	return result;
-}
-
 
 
 ExactValue exact_value_integer_from_string(String string) {
 ExactValue exact_value_integer_from_string(String string) {
 	u64 u = u64_from_string(string);
 	u64 u = u64_from_string(string);

+ 1 - 1
src/ir.cpp

@@ -1331,7 +1331,7 @@ void ir_add_foreign_library_path(irModule *m, Entity *e) {
 		return;
 		return;
 	}
 	}
 	GB_ASSERT(e->kind == Entity_LibraryName);
 	GB_ASSERT(e->kind == Entity_LibraryName);
-	GB_ASSERT(e->LibraryName.used);
+	GB_ASSERT(e->flags & EntityFlag_Used);
 
 
 	String library_path = e->LibraryName.path;
 	String library_path = e->LibraryName.path;
 	if (library_path.len == 0) {
 	if (library_path.len == 0) {