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

parser: remove start_tmp() entirely

This commit is contained in:
Alexander Medvednikov
2019-11-11 05:22:34 +03:00
parent 91896af877
commit b3143bb559
4 changed files with 22 additions and 32 deletions

View File

@@ -105,25 +105,28 @@ fn (g mut CGen) save() {
g.out.close()
}
fn (g mut CGen) start_tmp() {
if g.is_tmp {
g.prev_tmps << g.tmp_line
// returns expression's type, and entire expression's string representation)
fn (p mut Parser) tmp_expr() (string, string) {
// former start_tmp()
if p.cgen.is_tmp {
p.cgen.prev_tmps << p.cgen.tmp_line
}
// kg.tmp_lines_pos++
g.tmp_line = ''
g.is_tmp = true
}
fn (g mut CGen) end_tmp() string {
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]
p.cgen.tmp_line = ''
p.cgen.is_tmp = true
//
typ := p.bool_expression()
res := p.cgen.tmp_line
if p.cgen.prev_tmps.len > 0 {
p.cgen.tmp_line = p.cgen.prev_tmps.last()
p.cgen.prev_tmps = p.cgen.prev_tmps[0..p.cgen.prev_tmps.len-1]
} else {
g.tmp_line = ''
g.is_tmp = false
p.cgen.tmp_line = ''
p.cgen.is_tmp = false
}
return res
return typ, res
}
fn (g &CGen) add_placeholder() int {