1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

parser: fix tmp is already started issue

This commit is contained in:
Danil-Lapirow 2019-10-28 22:50:58 +02:00 committed by Alexander Medvednikov
parent 6a609cb046
commit f161ff9db5

View File

@ -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
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
}