mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-07 16:18:52 +00:00
Update the comments
This commit is contained in:
@@ -3,19 +3,19 @@
|
|||||||
|
|
||||||
* No spaces between any values
|
* No spaces between any values
|
||||||
|
|
||||||
* normal declarations - pkg.name
|
* normal declarations - pkg::name
|
||||||
* builtin names - just their normal name e.g. `i32` or `string`
|
* builtin names - just their normal name e.g. `i32` or `string`
|
||||||
* nested - pkg.parent1.parent2.name
|
* nested - pkg::parent1::parent2::name
|
||||||
* file private - pkg.[file_name].name
|
* file private - pkg::[file_name]::name
|
||||||
* Example: `pkg.[file.odin].Type`
|
* Example: `pkg::[file.odin]::Type`
|
||||||
* polymorphic procedure/type - pkg.foo::TYPE
|
* polymorphic procedure/type - pkg::foo:TYPE
|
||||||
* naming convention for parameters
|
* naming convention for parameters
|
||||||
* type
|
* type
|
||||||
* $typeid_based_name
|
* $typeid_based_name
|
||||||
* $$constant_parameter
|
* $$constant_parameter
|
||||||
* Example: `foo.to_thing::proc(u64)->([]u8)`
|
* Example: `foo::to_thing:proc(u64)->([]u8)`
|
||||||
* nested decl in polymorphic procedure - pkg.foo::TYPE.name
|
* nested decl in polymorphic procedure - pkg::foo:TYPE::name
|
||||||
* anonymous procedures - pkg.foo.$anon[file.odin:123]
|
* anonymous procedures - pkg::foo::$anon[file.odin:123]
|
||||||
* 123 is the file offset in bytes
|
* 123 is the file offset in bytes
|
||||||
|
|
||||||
|
|
||||||
@@ -280,7 +280,11 @@ void type_writer_make_hasher(TypeWriter *w, u64 *hash) {
|
|||||||
|
|
||||||
gb_internal void write_canonical_params(TypeWriter *w, Type *params) {
|
gb_internal void write_canonical_params(TypeWriter *w, Type *params) {
|
||||||
type_writer_appendc(w, "(");
|
type_writer_appendc(w, "(");
|
||||||
if (params) {
|
defer (type_writer_appendc(w, ")"));
|
||||||
|
|
||||||
|
if (params == nullptr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
GB_ASSERT(params->kind == Type_Tuple);
|
GB_ASSERT(params->kind == Type_Tuple);
|
||||||
for_array(i, params->Tuple.variables) {
|
for_array(i, params->Tuple.variables) {
|
||||||
Entity *v = params->Tuple.variables[i];
|
Entity *v = params->Tuple.variables[i];
|
||||||
@@ -290,7 +294,8 @@ gb_internal void write_canonical_params(TypeWriter *w, Type *params) {
|
|||||||
type_writer_append(w, v->token.string.text, v->token.string.len);
|
type_writer_append(w, v->token.string.text, v->token.string.len);
|
||||||
type_writer_appendc(w, CANONICAL_TYPE_SEPARATOR);
|
type_writer_appendc(w, CANONICAL_TYPE_SEPARATOR);
|
||||||
|
|
||||||
if (v->kind == Entity_Variable) {
|
switch (v->kind) {
|
||||||
|
case Entity_Variable:
|
||||||
if (v->flags&EntityFlag_CVarArg) {
|
if (v->flags&EntityFlag_CVarArg) {
|
||||||
type_writer_appendc(w, CANONICAL_PARAM_C_VARARG);
|
type_writer_appendc(w, CANONICAL_PARAM_C_VARARG);
|
||||||
}
|
}
|
||||||
@@ -302,20 +307,24 @@ gb_internal void write_canonical_params(TypeWriter *w, Type *params) {
|
|||||||
} else {
|
} else {
|
||||||
write_type_to_canonical_string(w, v->type);
|
write_type_to_canonical_string(w, v->type);
|
||||||
}
|
}
|
||||||
} else if (v->kind == Entity_TypeName) {
|
break;
|
||||||
|
case Entity_TypeName:
|
||||||
type_writer_appendc(w, CANONICAL_PARAM_TYPEID);
|
type_writer_appendc(w, CANONICAL_PARAM_TYPEID);
|
||||||
write_type_to_canonical_string(w, v->type);
|
write_type_to_canonical_string(w, v->type);
|
||||||
} else if (v->kind == Entity_Constant) {
|
break;
|
||||||
|
case Entity_Constant:
|
||||||
|
{
|
||||||
type_writer_appendc(w, CANONICAL_PARAM_CONST);
|
type_writer_appendc(w, CANONICAL_PARAM_CONST);
|
||||||
gbString s = exact_value_to_string(v->Constant.value, 1<<16);
|
gbString s = exact_value_to_string(v->Constant.value, 1<<16);
|
||||||
type_writer_append(w, s, gb_string_length(s));
|
type_writer_append(w, s, gb_string_length(s));
|
||||||
gb_string_free(s);
|
gb_string_free(s);
|
||||||
} else {
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
GB_PANIC("TODO(bill): handle non type/const parapoly parameter values");
|
GB_PANIC("TODO(bill): handle non type/const parapoly parameter values");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
type_writer_appendc(w, ")");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -348,19 +357,6 @@ gb_internal gbString temp_canonical_string(Type *type) {
|
|||||||
return cast(gbString)w.user_data;
|
return cast(gbString)w.user_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
gb_internal void print_scope_flags(Scope *s) {
|
|
||||||
if (s->flags & ScopeFlag_Pkg) gb_printf_err("Pkg ");
|
|
||||||
if (s->flags & ScopeFlag_Builtin) gb_printf_err("Builtin ");
|
|
||||||
if (s->flags & ScopeFlag_Global) gb_printf_err("Global ");
|
|
||||||
if (s->flags & ScopeFlag_File) gb_printf_err("File ");
|
|
||||||
if (s->flags & ScopeFlag_Init) gb_printf_err("Init ");
|
|
||||||
if (s->flags & ScopeFlag_Proc) gb_printf_err("Proc ");
|
|
||||||
if (s->flags & ScopeFlag_Type) gb_printf_err("Type ");
|
|
||||||
if (s->flags & ScopeFlag_HasBeenImported) gb_printf_err("HasBeenImported ");
|
|
||||||
if (s->flags & ScopeFlag_ContextDefined) gb_printf_err("ContextDefined ");
|
|
||||||
gb_printf_err("\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
gb_internal gbString string_canonical_entity_name(gbAllocator allocator, Entity *e) {
|
gb_internal gbString string_canonical_entity_name(gbAllocator allocator, Entity *e) {
|
||||||
TypeWriter w = {};
|
TypeWriter w = {};
|
||||||
type_writer_make_string(&w, allocator);
|
type_writer_make_string(&w, allocator);
|
||||||
@@ -477,6 +473,20 @@ gb_internal void write_canonical_entity_name(TypeWriter *w, Entity *e) {
|
|||||||
goto write_base_name;
|
goto write_base_name;
|
||||||
}
|
}
|
||||||
gb_printf_err("%s WEIRD ENTITY TYPE %s %u %p\n", token_pos_to_string(e->token.pos), type_to_string(e->type), s->flags, s->decl_info);
|
gb_printf_err("%s WEIRD ENTITY TYPE %s %u %p\n", token_pos_to_string(e->token.pos), type_to_string(e->type), s->flags, s->decl_info);
|
||||||
|
|
||||||
|
auto const print_scope_flags = [](Scope *s) {
|
||||||
|
if (s->flags & ScopeFlag_Pkg) gb_printf_err("Pkg ");
|
||||||
|
if (s->flags & ScopeFlag_Builtin) gb_printf_err("Builtin ");
|
||||||
|
if (s->flags & ScopeFlag_Global) gb_printf_err("Global ");
|
||||||
|
if (s->flags & ScopeFlag_File) gb_printf_err("File ");
|
||||||
|
if (s->flags & ScopeFlag_Init) gb_printf_err("Init ");
|
||||||
|
if (s->flags & ScopeFlag_Proc) gb_printf_err("Proc ");
|
||||||
|
if (s->flags & ScopeFlag_Type) gb_printf_err("Type ");
|
||||||
|
if (s->flags & ScopeFlag_HasBeenImported) gb_printf_err("HasBeenImported ");
|
||||||
|
if (s->flags & ScopeFlag_ContextDefined) gb_printf_err("ContextDefined ");
|
||||||
|
gb_printf_err("\n");
|
||||||
|
};
|
||||||
|
|
||||||
print_scope_flags(s);
|
print_scope_flags(s);
|
||||||
GB_PANIC("weird entity");
|
GB_PANIC("weird entity");
|
||||||
}
|
}
|
||||||
@@ -499,10 +509,7 @@ write_base_name:
|
|||||||
} 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);
|
||||||
}
|
}
|
||||||
gb_unused(parent);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
// Handle parapoly stuff here?
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case Entity_Procedure:
|
case Entity_Procedure:
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
|
|
||||||
#define CANONICAL_TYPE_SEPARATOR ":"
|
#define CANONICAL_TYPE_SEPARATOR ":"
|
||||||
#define CANONICAL_NAME_SEPARATOR "::"
|
#define CANONICAL_NAME_SEPARATOR "::"
|
||||||
|
// #define CANONICAL_NAME_SEPARATOR "·"
|
||||||
|
|
||||||
#define CANONICAL_BIT_FIELD_SEPARATOR "|"
|
#define CANONICAL_BIT_FIELD_SEPARATOR "|"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user