diff options
| author | 2026-10-12 08:46:23 +0330 | |
|---|---|---|
| committer | 2026-10-12 08:46:23 +0330 | |
| commit | ecc350ca5c2eb50be8309c5f14f8bf0d87db9a02 (patch) | |
| tree | 70e0af76a1b13affff7c6cc8aac7b3e6ef960478 /tests/programs/zc0plain.zc | |
a
Diffstat (limited to 'tests/programs/zc0plain.zc')
| -rw-r--r-- | tests/programs/zc0plain.zc | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/programs/zc0plain.zc b/tests/programs/zc0plain.zc new file mode 100644 index 0000000..1092f76 --- /dev/null +++ b/tests/programs/zc0plain.zc @@ -0,0 +1,23 @@ +// the stage 0 compiler (src/tools/zc0.c) has no types. it reads them and throws +// them away, so a typed program and the same program without the types come +// out as the same image. tests/programs/zc0typed.zc is this file with the types on. +let total; +let table[8]; +let names; +const LIMIT = 10; + +fn add(a, b) { return a + b; } +.u grow(v, n) { return v; } +fn keep(.d x, .m y) { return x != y; } +fn apply(f, p, q) { return f(*p); } +fn sq(x) { return x * x; } + +fn start() { + let i = 0, sum = 0; + let a[4]; + let p = a; + for (let j = 0; j < LIMIT; j++) sum = add(sum, sq(j)); + while (i < 4) { a[i] = i; i++; } + total = sum + a[3] + table[2]; + return total; +} |
