vfmt: prepare for using .source_name in type_to_str

pull/6502/head
Delyan Angelov 2020-10-08 08:02:04 +03:00
parent aea52af9ae
commit c3626bf2e6
4 changed files with 12 additions and 5 deletions

View File

@ -334,6 +334,7 @@ pub fn (mut p Parser) parse_generic_template_type(name string) table.Type {
idx = p.table.register_type_symbol(table.TypeSymbol{
name: name
source_name: name
mod: p.mod
kind: .any
is_public: true
})
@ -372,6 +373,7 @@ pub fn (mut p Parser) parse_generic_struct_inst_type(name string) table.Type {
kind: .generic_struct_inst
name: bs_name
source_name: bs_name
mod: p.mod
info: table.GenericStructInst{
parent_idx: p.table.type_idxs[name]
generic_types: generic_types

View File

@ -1544,12 +1544,12 @@ fn (mut p Parser) import_syms(mut parent ast.Import) {
idx := p.table.add_placeholder_type(name)
typ := table.new_type(idx)
prepend_mod_name := p.prepend_mod(alias)
p.table.register_type_symbol({
p.table.register_type_symbol(table.TypeSymbol{
kind: .alias
name: prepend_mod_name
source_name: prepend_mod_name
parent_idx: idx
mod: p.mod
parent_idx: idx
info: table.Alias{
parent_type: typ
language: table.Language.v
@ -1878,12 +1878,12 @@ fn (mut p Parser) type_decl() ast.TypeDecl {
table.Language.v
}
prepend_mod_name := p.prepend_mod(name)
p.table.register_type_symbol({
p.table.register_type_symbol(table.TypeSymbol{
kind: .alias
name: prepend_mod_name
source_name: prepend_mod_name
parent_idx: pid
mod: p.mod
parent_idx: pid
info: table.Alias{
parent_type: parent_type
language: language

View File

@ -228,6 +228,7 @@ fn (mut p Parser) struct_decl() ast.StructDecl {
kind: .struct_
name: name
source_name: name
mod: p.mod
info: table.Struct{
fields: fields
is_typedef: attrs.contains('typedef')
@ -235,7 +236,6 @@ fn (mut p Parser) struct_decl() ast.StructDecl {
is_ref_only: attrs.contains('ref_only')
generic_types: generic_types
}
mod: p.mod
is_public: is_pub
}
mut ret := 0

View File

@ -618,10 +618,15 @@ pub fn (mut t Table) find_or_register_fn_type(mod string, f Fn, is_anon, has_dec
}
pub fn (mut t Table) add_placeholder_type(name string) int {
mut modname := ''
if name.contains('.') {
modname = name.all_before_last('.')
}
ph_type := TypeSymbol{
kind: .placeholder
name: name
source_name: name
mod: modname
}
// println('added placeholder: $name - $ph_type.idx')
return t.register_type_symbol(ph_type)