@@ -36,9 +36,8 @@ fn (mut g Gen) const_decl(node ast.ConstDecl) {
3636 mut const_name := '_const_' + name
3737 if g.pref.translated && ! g.is_builtin_mod
3838 && ! util.module_is_builtin (field.name.all_before_last ('.' )) {
39- mut x := util.no_dots (field.name)
40- if x.starts_with ('main__' ) {
41- const_name = x['main__' .len..]
39+ if name.starts_with ('main__' ) {
40+ const_name = name.all_after_first ('main__' )
4241 }
4342 }
4443 if ! g.is_builtin_mod {
@@ -55,7 +54,8 @@ fn (mut g Gen) const_decl(node ast.ConstDecl) {
5554 && (! g.is_cc_msvc || field.expr.elem_type != ast.string_type) && elems_are_const {
5655 styp := g.styp (field.expr.typ)
5756 val := g.expr_string (field.expr)
58- g.global_const_defs[util.no_dots (field.name)] = GlobalConstDef{
57+ // eprintln('> const_name: ${const_name} | name: ${name} | styp: ${styp} | val: ${val}')
58+ g.global_const_defs[name] = GlobalConstDef{
5959 mod: field.mod
6060 def: '${g.static_non_parallel}${styp} ${const_name} = ${val} ; // fixed array const'
6161 dep_names: g.table.dependent_names_in_expr (field_expr)
@@ -72,7 +72,7 @@ fn (mut g Gen) const_decl(node ast.ConstDecl) {
7272 ast.StringLiteral {
7373 val := g.expr_string (field.expr)
7474 typ := if field.expr.language == .c { 'char*' } else { 'string' }
75- g.global_const_defs[util. no_dots (field. name) ] = GlobalConstDef{
75+ g.global_const_defs[name] = GlobalConstDef{
7676 mod: field.mod
7777 def: '${typ} ${const_name} ; // a string literal, inited later'
7878 init: '\t ${const_name} = ${val} ;'
@@ -121,7 +121,7 @@ fn (mut g Gen) const_decl(node ast.ConstDecl) {
121121 if field.expr.expr.is_fixed && g.pref.build_mode != .build_module {
122122 styp := g.styp (field.expr.typ)
123123 val := g.expr_string (field.expr.expr)
124- g.global_const_defs[util. no_dots (field. name) ] = GlobalConstDef{
124+ g.global_const_defs[name] = GlobalConstDef{
125125 mod: field.mod
126126 def: '${g.static_non_parallel}${styp} ${const_name} = ${val} ; // fixed array const'
127127 dep_names: g.table.dependent_names_in_expr (field_expr)
@@ -435,6 +435,7 @@ fn (mut g Gen) global_decl(node ast.GlobalDecl) {
435435 attributes + = '__attribute__ ((section ("${attr.arg} "))) '
436436 }
437437 for field in node.fields {
438+ name := c_name (field.name)
438439 if g.pref.skip_unused {
439440 if field.name ! in g.table.used_features.used_globals {
440441 $if trace_skip_unused_globals ? {
@@ -462,7 +463,7 @@ fn (mut g Gen) global_decl(node ast.GlobalDecl) {
462463 def_builder.write_string ('${extern}${visibility_kw}${modifier}${styp} ${attributes}${field.name} ' )
463464 if cextern {
464465 def_builder.writeln ('; // global 2' )
465- g.global_const_defs[util. no_dots (field. name) ] = GlobalConstDef{
466+ g.global_const_defs[name] = GlobalConstDef{
466467 mod: node.mod
467468 def: def_builder.str ()
468469 order: - 1
@@ -515,7 +516,7 @@ fn (mut g Gen) global_decl(node ast.GlobalDecl) {
515516 }
516517 }
517518 def_builder.writeln ('; // global 6' )
518- g.global_const_defs[util. no_dots (field. name) ] = GlobalConstDef{
519+ g.global_const_defs[name] = GlobalConstDef{
519520 mod: node.mod
520521 def: def_builder.str ()
521522 init: init
0 commit comments