mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-05 23:28:48 +00:00
Number fields within procedures with a depth-first numbering system
This commit is contained in:
@@ -358,6 +358,10 @@ gb_internal void check_open_scope(CheckerContext *c, Ast *node) {
|
|||||||
scope->flags |= ScopeFlag_Type;
|
scope->flags |= ScopeFlag_Type;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (c->decl && c->decl->proc_lit) {
|
||||||
|
// Number the scopes within a procedure body depth-first
|
||||||
|
scope->index = c->decl->scope_index++;
|
||||||
|
}
|
||||||
c->scope = scope;
|
c->scope = scope;
|
||||||
c->state_flags |= StateFlag_bounds_check;
|
c->state_flags |= StateFlag_bounds_check;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -229,6 +229,8 @@ struct DeclInfo {
|
|||||||
|
|
||||||
Array<BlockLabel> labels;
|
Array<BlockLabel> labels;
|
||||||
|
|
||||||
|
i32 scope_index;
|
||||||
|
|
||||||
Array<VariadicReuseData> variadic_reuses;
|
Array<VariadicReuseData> variadic_reuses;
|
||||||
i64 variadic_reuse_max_bytes;
|
i64 variadic_reuse_max_bytes;
|
||||||
i64 variadic_reuse_max_align;
|
i64 variadic_reuse_max_align;
|
||||||
@@ -273,6 +275,8 @@ struct Scope {
|
|||||||
std::atomic<Scope *> next;
|
std::atomic<Scope *> next;
|
||||||
std::atomic<Scope *> head_child;
|
std::atomic<Scope *> head_child;
|
||||||
|
|
||||||
|
i32 index; // within a procedure
|
||||||
|
|
||||||
RwMutex mutex;
|
RwMutex mutex;
|
||||||
StringMap<Entity *> elements;
|
StringMap<Entity *> elements;
|
||||||
PtrSet<Scope *> imported;
|
PtrSet<Scope *> imported;
|
||||||
|
|||||||
@@ -464,7 +464,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) {
|
||||||
Entity *parent = s->decl_info->entity;
|
Entity *parent = s->decl_info->entity;
|
||||||
write_canonical_parent_prefix(w, parent);
|
write_canonical_parent_prefix(w, parent);
|
||||||
type_writer_append_fmt(w, CANONICAL_TYPE_SEPARATOR "[%d]", e->token.pos.offset);
|
if (e->scope->index > 0) {
|
||||||
|
type_writer_append_fmt(w, CANONICAL_TYPE_SEPARATOR "[%d]", e->scope->index);
|
||||||
|
}
|
||||||
|
// 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) {
|
||||||
|
|||||||
Reference in New Issue
Block a user