cgen: remove some nasty replacements

pull/7038/head^2
joe-conigliaro 2020-12-01 21:17:19 +11:00
parent 9b583f51f1
commit 88835a0456
No known key found for this signature in database
GPG Key ID: C12F7136C08206F1
2 changed files with 6 additions and 5 deletions

View File

@ -531,8 +531,6 @@ fn (g &Gen) cc_type2(t table.Type) string {
sgtyps += '_$gts.name'
}
styp += sgtyps
} else if styp.contains('<') {
styp = styp.replace_each(['<', '_T_', '>', '', ',', '_'])
}
}
return styp
@ -4531,8 +4529,7 @@ fn (mut g Gen) write_types(types []table.TypeSymbol) {
if typ.info.generic_types.len > 0 {
continue
}
if name.contains('<') {
name = name.replace_each(['<', '_T_', '>', '', ',', '_'])
if name.contains('_T_') {
g.typedefs.writeln('typedef struct $name $name;')
}
// TODO avoid buffer manip

View File

@ -343,9 +343,11 @@ pub fn (mut p Parser) parse_generic_template_type(name string) table.Type {
pub fn (mut p Parser) parse_generic_struct_inst_type(name string) table.Type {
mut bs_name := name
mut bs_cname := name
p.next()
p.in_generic_params = true
bs_name += '<'
bs_cname += '_T_'
mut generic_types := []table.Type{}
mut is_instance := false
for {
@ -355,12 +357,14 @@ pub fn (mut p Parser) parse_generic_struct_inst_type(name string) table.Type {
}
gts := p.table.get_type_symbol(gt)
bs_name += gts.name
bs_cname += gts.name
generic_types << gt
if p.tok.kind != .comma {
break
}
p.next()
bs_name += ','
bs_cname += '_'
}
p.check(.gt)
p.in_generic_params = false
@ -379,7 +383,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
cname: util.no_dots(bs_name)
cname: util.no_dots(bs_cname)
mod: p.mod
info: table.GenericStructInst{
parent_idx: parent_idx