From 88835a0456337c4994d64e80e455d21385397aad Mon Sep 17 00:00:00 2001 From: joe-conigliaro Date: Tue, 1 Dec 2020 21:17:19 +1100 Subject: [PATCH] cgen: remove some nasty replacements --- vlib/v/gen/cgen.v | 5 +---- vlib/v/parser/parse_type.v | 6 +++++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/vlib/v/gen/cgen.v b/vlib/v/gen/cgen.v index 443952a9cd..168e2b8d8d 100644 --- a/vlib/v/gen/cgen.v +++ b/vlib/v/gen/cgen.v @@ -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 diff --git a/vlib/v/parser/parse_type.v b/vlib/v/parser/parse_type.v index 53a2c4e219..d71f12a1ed 100644 --- a/vlib/v/parser/parse_type.v +++ b/vlib/v/parser/parse_type.v @@ -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