native: define println and exit builtins or verror()
parent
1eac6eee59
commit
a31a1eb9cb
|
@ -12,6 +12,7 @@ import v.pref
|
||||||
import v.util
|
import v.util
|
||||||
import v.errors
|
import v.errors
|
||||||
import v.pkgconfig
|
import v.pkgconfig
|
||||||
|
import v.gen.native
|
||||||
|
|
||||||
const int_min = int(0x80000000)
|
const int_min = int(0x80000000)
|
||||||
|
|
||||||
|
@ -2069,7 +2070,14 @@ pub fn (mut c Checker) fn_call(mut call_expr ast.CallExpr) ast.Type {
|
||||||
c.table.fns[fn_name].usages++
|
c.table.fns[fn_name].usages++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if c.pref.is_script && !found {
|
if !found && c.pref.backend == .native {
|
||||||
|
if fn_name in native.builtins {
|
||||||
|
found = true
|
||||||
|
c.table.fns[fn_name].usages++
|
||||||
|
return ast.string_type
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !found && c.pref.is_script && !found {
|
||||||
os_name := 'os.$fn_name'
|
os_name := 'os.$fn_name'
|
||||||
if f := c.table.find_fn(os_name) {
|
if f := c.table.find_fn(os_name) {
|
||||||
if f.generic_names.len == call_expr.concrete_types.len {
|
if f.generic_names.len == call_expr.concrete_types.len {
|
||||||
|
|
|
@ -11,6 +11,8 @@ import v.errors
|
||||||
import v.pref
|
import v.pref
|
||||||
import term
|
import term
|
||||||
|
|
||||||
|
pub const builtins = ['println', 'exit']
|
||||||
|
|
||||||
interface CodeGen {
|
interface CodeGen {
|
||||||
g Gen
|
g Gen
|
||||||
allocate_var(name string, size int, initial_val int)
|
allocate_var(name string, size int, initial_val int)
|
||||||
|
@ -70,8 +72,7 @@ pub fn gen(files []ast.File, table &ast.Table, out_name string, pref &pref.Prefe
|
||||||
eprintln('Warning: ${file.warnings[0]}')
|
eprintln('Warning: ${file.warnings[0]}')
|
||||||
}
|
}
|
||||||
if file.errors.len > 0 {
|
if file.errors.len > 0 {
|
||||||
eprintln('Error ${file.errors[0]}')
|
verror('Error ${file.errors[0]}')
|
||||||
// verror('Error ${file.errors[0]}')
|
|
||||||
}
|
}
|
||||||
g.stmts(file.stmts)
|
g.stmts(file.stmts)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue