diff --git a/vlib/compiler/cgen.v b/vlib/compiler/cgen.v index d99d90fa9c..bc62dde7f0 100644 --- a/vlib/compiler/cgen.v +++ b/vlib/compiler/cgen.v @@ -25,6 +25,7 @@ mut: consts_init []string pass Pass nogen bool + prev_tmps []string tmp_line string cur_line string prev_line string @@ -105,9 +106,7 @@ fn (g mut CGen) save() { fn (g mut CGen) start_tmp() { if g.is_tmp { - println(g.tmp_line) - println('start_tmp() already started. cur_line="$g.cur_line"') - exit(1) + g.prev_tmps << g.tmp_line } // kg.tmp_lines_pos++ g.tmp_line = '' @@ -115,9 +114,14 @@ fn (g mut CGen) start_tmp() { } fn (g mut CGen) end_tmp() string { - g.is_tmp = false res := g.tmp_line - g.tmp_line = '' + if g.prev_tmps.len > 0 { + g.tmp_line = g.prev_tmps.last() + g.prev_tmps = g.prev_tmps[0..g.prev_tmps.len-1] + } else { + g.tmp_line = '' + g.is_tmp = false + } return res }