eval: fix new_checker call

pull/4222/head
yuyi 2020-04-04 08:03:41 +08:00 committed by GitHub
parent f8b4a6f168
commit bb5ed66bb4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 5 deletions

View File

@ -7,6 +7,7 @@ import (
v.ast
v.checker
v.table
v.pref
)
pub type Object = int | string
@ -23,9 +24,10 @@ pub struct Var {
}
pub fn (e mut Eval) eval(file ast.File, table &table.Table) string {
vpref := &pref.Preferences{}
e.table = table
mut res := ''
e.checker = checker.new_checker(table)
e.checker = checker.new_checker(table, vpref)
for stmt in file.stmts {
res += e.stmt(stmt) + '\n'
}

View File

@ -37,6 +37,7 @@ fn test_eval() {
//
]
table := table.new_table()
vpref := &pref.Preferences{}
mut scope := &ast.Scope{
start_pos: 0
parent: 0
@ -49,7 +50,7 @@ fn test_eval() {
stmts: stmts
scope: scope
}
mut checker := checker.new_checker(table)
mut checker := checker.new_checker(table, vpref)
checker.check(file)
mut ev := eval.Eval{}
s := ev.eval(file, table)
@ -79,7 +80,7 @@ x := 10
table := &table.Table{}
vpref := &pref.Preferences{}
prog := parse_file(s, table, .skip_comments, vpref)
mut checker := checker.new_checker(table)
mut checker := checker.new_checker(table, vpref)
checker.check(prog)
res := gen.cgen([prog], table, vpref)
println(res)
@ -111,7 +112,7 @@ fn test_one() {
stmts: e
scope: scope
}
mut checker := checker.new_checker(table)
mut checker := checker.new_checker(table, vpref)
checker.check(program)
res := gen.cgen([program], table, vpref).replace('\n', '').trim_space().after('#endif')
println(res)
@ -196,7 +197,7 @@ fn test_parse_expr() {
mut e := []ast.Stmt
table := table.new_table()
vpref := &pref.Preferences{}
mut checker := checker.new_checker(table)
mut checker := checker.new_checker(table, vpref)
scope := &ast.Scope{
start_pos: 0
parent: 0