ast: minor cleanup of register_type_symbol (#12213)
parent
29f068997b
commit
a006090b08
|
@ -732,29 +732,29 @@ fn (mut t Table) check_for_already_registered_symbol(typ TypeSymbol, existing_id
|
||||||
}
|
}
|
||||||
|
|
||||||
[inline]
|
[inline]
|
||||||
pub fn (mut t Table) register_type_symbol(typ TypeSymbol) int {
|
pub fn (mut t Table) register_type_symbol(sym TypeSymbol) int {
|
||||||
mut typ_idx := -2
|
mut idx := -2
|
||||||
mut existing_idx := t.type_idxs[typ.name]
|
mut existing_idx := t.type_idxs[sym.name]
|
||||||
if existing_idx > 0 {
|
if existing_idx > 0 {
|
||||||
typ_idx = t.check_for_already_registered_symbol(typ, existing_idx)
|
idx = t.check_for_already_registered_symbol(sym, existing_idx)
|
||||||
if typ_idx != -2 {
|
if idx != -2 {
|
||||||
return typ_idx
|
return idx
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if typ.mod == 'main' {
|
if sym.mod == 'main' {
|
||||||
existing_idx = t.type_idxs[typ.name.trim_prefix('main.')]
|
existing_idx = t.type_idxs[sym.name.trim_prefix('main.')]
|
||||||
if existing_idx > 0 {
|
if existing_idx > 0 {
|
||||||
typ_idx = t.check_for_already_registered_symbol(typ, existing_idx)
|
idx = t.check_for_already_registered_symbol(sym, existing_idx)
|
||||||
if typ_idx != -2 {
|
if idx != -2 {
|
||||||
return typ_idx
|
return idx
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
typ_idx = t.type_symbols.len
|
idx = t.type_symbols.len
|
||||||
t.type_symbols << typ
|
t.type_symbols << sym
|
||||||
t.type_symbols[typ_idx].idx = typ_idx
|
t.type_symbols[idx].idx = idx
|
||||||
t.type_idxs[typ.name] = typ_idx
|
t.type_idxs[sym.name] = idx
|
||||||
return typ_idx
|
return idx
|
||||||
}
|
}
|
||||||
|
|
||||||
[inline]
|
[inline]
|
||||||
|
|
Loading…
Reference in New Issue