cgen: remove some nasty replacements
parent
9b583f51f1
commit
88835a0456
|
@ -531,8 +531,6 @@ fn (g &Gen) cc_type2(t table.Type) string {
|
||||||
sgtyps += '_$gts.name'
|
sgtyps += '_$gts.name'
|
||||||
}
|
}
|
||||||
styp += sgtyps
|
styp += sgtyps
|
||||||
} else if styp.contains('<') {
|
|
||||||
styp = styp.replace_each(['<', '_T_', '>', '', ',', '_'])
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return styp
|
return styp
|
||||||
|
@ -4531,8 +4529,7 @@ fn (mut g Gen) write_types(types []table.TypeSymbol) {
|
||||||
if typ.info.generic_types.len > 0 {
|
if typ.info.generic_types.len > 0 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if name.contains('<') {
|
if name.contains('_T_') {
|
||||||
name = name.replace_each(['<', '_T_', '>', '', ',', '_'])
|
|
||||||
g.typedefs.writeln('typedef struct $name $name;')
|
g.typedefs.writeln('typedef struct $name $name;')
|
||||||
}
|
}
|
||||||
// TODO avoid buffer manip
|
// TODO avoid buffer manip
|
||||||
|
|
|
@ -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 {
|
pub fn (mut p Parser) parse_generic_struct_inst_type(name string) table.Type {
|
||||||
mut bs_name := name
|
mut bs_name := name
|
||||||
|
mut bs_cname := name
|
||||||
p.next()
|
p.next()
|
||||||
p.in_generic_params = true
|
p.in_generic_params = true
|
||||||
bs_name += '<'
|
bs_name += '<'
|
||||||
|
bs_cname += '_T_'
|
||||||
mut generic_types := []table.Type{}
|
mut generic_types := []table.Type{}
|
||||||
mut is_instance := false
|
mut is_instance := false
|
||||||
for {
|
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)
|
gts := p.table.get_type_symbol(gt)
|
||||||
bs_name += gts.name
|
bs_name += gts.name
|
||||||
|
bs_cname += gts.name
|
||||||
generic_types << gt
|
generic_types << gt
|
||||||
if p.tok.kind != .comma {
|
if p.tok.kind != .comma {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
p.next()
|
p.next()
|
||||||
bs_name += ','
|
bs_name += ','
|
||||||
|
bs_cname += '_'
|
||||||
}
|
}
|
||||||
p.check(.gt)
|
p.check(.gt)
|
||||||
p.in_generic_params = false
|
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
|
kind: .generic_struct_inst
|
||||||
name: bs_name
|
name: bs_name
|
||||||
source_name: bs_name
|
source_name: bs_name
|
||||||
cname: util.no_dots(bs_name)
|
cname: util.no_dots(bs_cname)
|
||||||
mod: p.mod
|
mod: p.mod
|
||||||
info: table.GenericStructInst{
|
info: table.GenericStructInst{
|
||||||
parent_idx: parent_idx
|
parent_idx: parent_idx
|
||||||
|
|
Loading…
Reference in New Issue