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

parser: change cur_line, tmp_line only in main pass

This commit is contained in:
d2verb
2019-07-19 03:21:23 +09:00
committed by Alexander Medvednikov
parent 38c58f9f1b
commit 67c2932f34
3 changed files with 29 additions and 17 deletions

View File

@@ -50,7 +50,7 @@ fn new_cgen(out_name_c string) *CGen {
}
fn (g mut CGen) genln(s string) {
if g.nogen || g.run == .decl {
if g.nogen || g.run != .main {
return
}
if g.is_tmp {
@@ -66,7 +66,7 @@ fn (g mut CGen) genln(s string) {
}
fn (g mut CGen) gen(s string) {
if g.nogen || g.run == .decl {
if g.nogen || g.run != .main {
return
}
if g.is_tmp {
@@ -77,6 +77,18 @@ fn (g mut CGen) gen(s string) {
}
}
fn (g mut CGen) resetln(s string) {
if g.nogen || g.run != .main {
return
}
if g.is_tmp {
g.tmp_line = s
}
else {
g.cur_line = s
}
}
fn (g mut CGen) save() {
s := g.lines.join('\n')
g.out.writeln(s)
@@ -109,7 +121,7 @@ fn (g mut CGen) add_placeholder() int {
}
fn (g mut CGen) set_placeholder(pos int, val string) {
if g.nogen {
if g.nogen || g.run != .main {
return
}
// g.lines.set(pos, val)
@@ -135,7 +147,7 @@ fn (g mut CGen) add_placeholder2() int {
}
fn (g mut CGen) set_placeholder2(pos int, val string) {
if g.nogen {
if g.nogen || g.run != .main {
return
}
if g.is_tmp {