eval: small cleanup in the handling of `$if platform {`
parent
e0ed8f8278
commit
4538efd8f4
|
@ -117,7 +117,6 @@ pub fn (mut e Eval) register_symbols(mut files []&ast.File) {
|
|||
for mut file in files {
|
||||
file.idx = e.trace_file_paths.len
|
||||
e.trace_file_paths << file.path
|
||||
// eprintln('registering file: $file.path_base')
|
||||
mod := file.mod.name
|
||||
for mut stmt in file.stmts {
|
||||
if mut stmt is ast.FnDecl {
|
||||
|
@ -205,7 +204,7 @@ pub fn (mut e Eval) register_symbol(stmt ast.Stmt, mod string, file string) {
|
|||
}
|
||||
}
|
||||
else {
|
||||
eprintln('unsupported expression')
|
||||
e.error('unsupported expression')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -223,9 +222,10 @@ pub fn (mut e Eval) register_symbol(stmt ast.Stmt, mod string, file string) {
|
|||
|
||||
fn (e Eval) error(msg string) {
|
||||
eprintln('> V interpeter backtrace:')
|
||||
for idx, t in e.back_trace {
|
||||
eprintln(' ${e.trace_file_paths[t.file_idx]}:${t.line + 1}:${e.trace_function_names[t.fn_idx]}')
|
||||
// eprintln('${e.trace_file_paths[t.file_idx]}:${t.line + 1}:$t.fn_idx')
|
||||
for t in e.back_trace {
|
||||
file_path := e.trace_file_paths[t.file_idx] or { t.file_idx.str() }
|
||||
fn_name := e.trace_function_names[t.fn_idx] or { t.fn_idx.str() }
|
||||
eprintln(' $file_path:${t.line + 1}:$fn_name}')
|
||||
}
|
||||
util.verror('interpreter', msg)
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
module eval
|
||||
|
||||
import v.pref
|
||||
import v.ast
|
||||
import v.util
|
||||
import math
|
||||
|
@ -134,30 +135,16 @@ pub fn (mut e Eval) expr(expr ast.Expr, expecting ast.Type) Object {
|
|||
do_if = true
|
||||
} else {
|
||||
if branch.cond is ast.Ident {
|
||||
match branch.cond.name {
|
||||
'windows' {
|
||||
do_if = e.pref.os == .windows
|
||||
}
|
||||
'macos' {
|
||||
do_if = e.pref.os == .macos
|
||||
}
|
||||
'linux' {
|
||||
do_if = e.pref.os == .linux
|
||||
}
|
||||
'android' {
|
||||
do_if = e.pref.os == .android
|
||||
}
|
||||
'freebsd' {
|
||||
do_if = e.pref.os == .freebsd
|
||||
}
|
||||
'openbsd' {
|
||||
do_if = e.pref.os == .openbsd
|
||||
}
|
||||
'prealloc' {
|
||||
do_if = e.pref.prealloc
|
||||
}
|
||||
else {
|
||||
e.error('unknown compile time if: $branch.cond.name')
|
||||
if known_os := pref.os_from_string(branch.cond.name) {
|
||||
do_if = e.pref.os == known_os
|
||||
} else {
|
||||
match branch.cond.name {
|
||||
'prealloc' {
|
||||
do_if = e.pref.prealloc
|
||||
}
|
||||
else {
|
||||
e.error('unknown compile time if: $branch.cond.name')
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if branch.cond is ast.PostfixExpr {
|
||||
|
|
Loading…
Reference in New Issue