cgen: cleaner comptime ifdefs .

pull/4572/head
Delyan Angelov 2020-04-24 08:42:26 +03:00
parent 25f2b171fc
commit 7a132e5c79
1 changed files with 3 additions and 5 deletions

View File

@ -2760,11 +2760,9 @@ fn (g Gen) is_importing_os() bool {
fn (mut g Gen) comp_if(it ast.CompIf) { fn (mut g Gen) comp_if(it ast.CompIf) {
ifdef := g.comp_if_to_ifdef(it.val, it.is_opt) ifdef := g.comp_if_to_ifdef(it.val, it.is_opt)
if it.is_not { if it.is_not {
g.writeln('\n#ifndef ' + ifdef) g.writeln('\n// \$if !${it.val} {\n#ifndef ' + ifdef)
g.writeln('// #if not $it.val')
} else { } else {
g.writeln('\n#ifdef ' + ifdef) g.writeln('\n// \$if ${it.val} {\n#ifdef ' + ifdef)
g.writeln('// #if $it.val')
} }
// NOTE: g.defer_ifdef is needed for defers called witin an ifdef // NOTE: g.defer_ifdef is needed for defers called witin an ifdef
// in v1 this code would be completely excluded // in v1 this code would be completely excluded
@ -2786,7 +2784,7 @@ fn (mut g Gen) comp_if(it ast.CompIf) {
g.stmts(it.else_stmts) g.stmts(it.else_stmts)
g.defer_ifdef = '' g.defer_ifdef = ''
} }
g.writeln('\n#endif') g.writeln('\n// } ${it.val}\n#endif\n')
} }
fn (mut g Gen) go_stmt(node ast.GoStmt) { fn (mut g Gen) go_stmt(node ast.GoStmt) {