Files
aji/tests/conformance/phase2/run/hello.air
T
dev d405d4ea50 Phase 2: I/O intrinsics, linear resources, deterministic profile (RFC 0007)
- air: resource types file<read|write|append>, listener, stream; io_error;
  intrinsic registry (19 intrinsics) synced with reference/intrinsics.md;
  fallible intrinsics as ok/err terminators; fs prefix narrowing;
  linear_aggregates gating
- verifier: intrinsic form, operand, result and capability-kind checks
  (E1001, E3201, E5002); intrinsic effects (E3101); resource linearity
  in the borrow walker with per-edge moves: E3002 leaks and join
  mismatches, E3001, E2001, E2002, E2101 for close while borrowed;
  resources as borrow roots
- interp: deterministic world (captured console, VFS, loopback TCP,
  instruction clock, pinned xoshiro256 PRNG), blocked outcome, run
  record with stdout/stderr/files
- CLI: --stdin, --vfs, --seed, --result-file, --profile (hosted: exit 3),
  exit code 7; runner: stdin/vfs/seed/stdout/stderr/file/blocked headers
- conformance: hello, file copy and TCP echo exit programs; 37 new tests;
  4000 mutants without a crash
2026-10-04 14:02:17 +03:00

84 lines
2.3 KiB
LLVM

; Hello world: the first Aji program that writes to stdout.
; expect: run
; grant: out=io.write
; result: null
; stdout: hello, aji\n
; phase: 2
; spec: docs/reference/intrinsics.md
module test.hello
air 0
lang 0.1
features [arrays, capabilities, effects, ownership, resources]
fn @main(%out: cap<io.write>) -> void
effects [io.write]
entry:
%msg = local.alloc array<u8, 11>
local.zero %msg
%msg_m = borrow.mut %msg
%msg_i0 = const.usize 0
%msg_c0 = const.u8 104
%msg_e0 = borrow.index %msg_m, %msg_i0
store %msg_e0, %msg_c0
borrow.end %msg_e0
%msg_i1 = const.usize 1
%msg_c1 = const.u8 101
%msg_e1 = borrow.index %msg_m, %msg_i1
store %msg_e1, %msg_c1
borrow.end %msg_e1
%msg_i2 = const.usize 2
%msg_c2 = const.u8 108
%msg_e2 = borrow.index %msg_m, %msg_i2
store %msg_e2, %msg_c2
borrow.end %msg_e2
%msg_i3 = const.usize 3
%msg_c3 = const.u8 108
%msg_e3 = borrow.index %msg_m, %msg_i3
store %msg_e3, %msg_c3
borrow.end %msg_e3
%msg_i4 = const.usize 4
%msg_c4 = const.u8 111
%msg_e4 = borrow.index %msg_m, %msg_i4
store %msg_e4, %msg_c4
borrow.end %msg_e4
%msg_i5 = const.usize 5
%msg_c5 = const.u8 44
%msg_e5 = borrow.index %msg_m, %msg_i5
store %msg_e5, %msg_c5
borrow.end %msg_e5
%msg_i6 = const.usize 6
%msg_c6 = const.u8 32
%msg_e6 = borrow.index %msg_m, %msg_i6
store %msg_e6, %msg_c6
borrow.end %msg_e6
%msg_i7 = const.usize 7
%msg_c7 = const.u8 97
%msg_e7 = borrow.index %msg_m, %msg_i7
store %msg_e7, %msg_c7
borrow.end %msg_e7
%msg_i8 = const.usize 8
%msg_c8 = const.u8 106
%msg_e8 = borrow.index %msg_m, %msg_i8
store %msg_e8, %msg_c8
borrow.end %msg_e8
%msg_i9 = const.usize 9
%msg_c9 = const.u8 105
%msg_e9 = borrow.index %msg_m, %msg_i9
store %msg_e9, %msg_c9
borrow.end %msg_e9
%msg_i10 = const.usize 10
%msg_c10 = const.u8 10
%msg_e10 = borrow.index %msg_m, %msg_i10
store %msg_e10, %msg_c10
borrow.end %msg_e10
borrow.end %msg_m
%msg_r = borrow.ref %msg
%msg_s = slice.make %msg_r
intrinsic io.stdout_write(%out, %msg_s), ok -> @done, err -> @failed
done:
borrow.end %msg_s
borrow.end %msg_r
ret
failed(%e: io_error):
trap