blob: 32c08e5453770cd39acfd20711d82038939ddeb3 (
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
|
import ::= fn(x :: []char) &Package {
p ::= pkg x;
p_ptr ::= new(Package);
*p_ptr = p;
p_ptr
};
puts :: fn(&char) i32 = #foreign "puts", "libc.so.6";
dprintf :: fn(i32, &char, f64) i32 = #foreign "dprintf", "libc.so.6";
hw ::= fn() i32 {
s := "Hello, world!\0";
puts(&s[0])
};
sqrt :: fn(f64) f64 = #foreign "sqrt", "libm.so.6";
foo ::= fn() i32 {
x := sqrt(2.0);
s := "sqrt(2) = %f\n\0";
dprintf(2, &s[0], x)
};
main ::= fn() {
// io ::= import("std/io");
// io.puts("Hello, world!");
// hw();
x ::= hw();
y ::= foo();
sqrt2 ::= sqrt(2.0);
// y ::= abort_1();
};
|