فهرست منبع

Add offset for nested things

gingerBill 6 ماه پیش
والد
کامیت
e168cea670
1فایلهای تغییر یافته به همراه10 افزوده شده و 11 حذف شده
  1. 10 11
      src/name_canonicalization.cpp

+ 10 - 11
src/name_canonicalization.cpp

@@ -366,11 +366,10 @@ gb_internal gbString string_canonical_entity_name(gbAllocator allocator, Entity
 
 
 
 
 
 
-gb_internal void write_canonical_parent_prefix(TypeWriter *w, Entity *e, bool ignore_final_dot=false) {
+gb_internal void write_canonical_parent_prefix(TypeWriter *w, Entity *e) {
 	GB_ASSERT(e != nullptr);
 	GB_ASSERT(e != nullptr);
-
-	if (e->kind == Entity_Procedure) {
-		if (e->Procedure.is_export || e->Procedure.is_foreign) {
+	if (e->kind == Entity_Procedure || e->kind == Entity_TypeName) {
+		if (e->kind == Entity_Procedure && (e->Procedure.is_export || e->Procedure.is_foreign)) {
 			// no prefix
 			// no prefix
 			return;
 			return;
 		}
 		}
@@ -396,7 +395,7 @@ gb_internal void write_canonical_parent_prefix(TypeWriter *w, Entity *e, bool ig
 			if (e->pkg->name == "llvm") {
 			if (e->pkg->name == "llvm") {
 				type_writer_appendc(w, "$");
 				type_writer_appendc(w, "$");
 			}
 			}
-			type_writer_appendc(w, gb_bprintf(CANONICAL_NAME_SEPARATOR "[%.*s]" CANONICAL_NAME_SEPARATOR, LIT(file_name)));
+			type_writer_append_fmt(w, CANONICAL_NAME_SEPARATOR "[%.*s]" CANONICAL_NAME_SEPARATOR, LIT(file_name));
 		}
 		}
 	} else if (e->kind == Entity_Procedure) {
 	} else if (e->kind == Entity_Procedure) {
 		if (e->Procedure.is_export || e->Procedure.is_foreign) {
 		if (e->Procedure.is_export || e->Procedure.is_foreign) {
@@ -405,10 +404,9 @@ gb_internal void write_canonical_parent_prefix(TypeWriter *w, Entity *e, bool ig
 		}
 		}
 		GB_PANIC("TODO(bill): handle entity kind: %d", e->kind);
 		GB_PANIC("TODO(bill): handle entity kind: %d", e->kind);
 	}
 	}
-
 	if (e->kind == Entity_Procedure && e->Procedure.is_anonymous) {
 	if (e->kind == Entity_Procedure && e->Procedure.is_anonymous) {
 		String file_name = filename_without_directory(e->file->fullpath);
 		String file_name = filename_without_directory(e->file->fullpath);
-		type_writer_appendc(w, gb_bprintf(CANONICAL_ANON_PREFIX "[%.*s:%d]", LIT(file_name), e->token.pos.offset));
+		type_writer_append_fmt(w, CANONICAL_ANON_PREFIX "[%.*s:%d]", LIT(file_name), e->token.pos.offset);
 	} else {
 	} else {
 		type_writer_append(w, e->token.string.text, e->token.string.len);
 		type_writer_append(w, e->token.string.text, e->token.string.len);
 	}
 	}
@@ -417,9 +415,7 @@ gb_internal void write_canonical_parent_prefix(TypeWriter *w, Entity *e, bool ig
 		type_writer_appendc(w, CANONICAL_TYPE_SEPARATOR);
 		type_writer_appendc(w, CANONICAL_TYPE_SEPARATOR);
 		write_type_to_canonical_string(w, e->type);
 		write_type_to_canonical_string(w, e->type);
 	}
 	}
-	if (!ignore_final_dot) {
-		type_writer_appendc(w, CANONICAL_NAME_SEPARATOR);
-	}
+	type_writer_appendc(w, CANONICAL_NAME_SEPARATOR);
 
 
 	return;
 	return;
 }
 }
@@ -461,7 +457,10 @@ gb_internal void write_canonical_entity_name(TypeWriter *w, Entity *e) {
 		}
 		}
 
 
 		if (s->decl_info != nullptr && s->decl_info->entity)  {
 		if (s->decl_info != nullptr && s->decl_info->entity)  {
-			write_canonical_parent_prefix(w, s->decl_info->entity);
+			Entity *parent = s->decl_info->entity;
+			write_canonical_parent_prefix(w, parent);
+			type_writer_append_fmt(w, CANONICAL_TYPE_SEPARATOR "[%d]", e->token.pos.offset);
+
 			goto write_base_name;
 			goto write_base_name;
 		} else if ((s->flags & ScopeFlag_File) && s->file != nullptr) {
 		} else if ((s->flags & ScopeFlag_File) && s->file != nullptr) {
 			String file_name = filename_without_directory(s->file->fullpath);
 			String file_name = filename_without_directory(s->file->fullpath);