blob: a7be85380e37b4d0f77c09a3367220d5f5bcc424 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
module builtin
// called by the generated main/init
fn init() {
}
pub fn isnil(p voidptr) bool {
return p == 0
}
pub fn print(s string) {
sys_write(1, s.str, u64(s.len))
}
pub fn println(s string) {
print(s)
print('\n')
}
pub fn panic(s string) {
eprint('V panic: ')
eprintln(s)
sys_exit(1)
}
// replaces panic when -debug arg is passed
fn panic_debug(line_no int, file string, mod string, fn_name string, s string) {
eprintln('================ V panic ================')
eprint(' module: ')
eprintln('mod')
eprint(' function: ')
eprint(fn_name)
eprintln('()')
eprintln(' file: ')
eprintln(file)
// println(' line: ${line_no}')
eprint(' message: ')
eprintln(s)
eprintln('=========================================')
sys_exit(1)
}
pub fn eprint(s string) {
if isnil(s.str) {
panic('eprint(NIL)')
}
sys_write(2, s.str, u64(s.len))
}
pub fn eprint_ln(s string) {
eprint(s)
eprint('\n')
}
pub fn eprintln(s string) {
if isnil(s.str) {
panic('eprintln(NIL)')
}
eprint_ln(s)
}
|