raz / test / run / KeptNil.raz

24 lines · 493 B · raw · history · last change 264716cb

1(* A parameter kept in rdi or rsi is shown when a signal stops the
2 procedure that keeps it. *)
3module KeptNil;
4import Out;
5import SYSTEM;
6
7type Rec = record x: INT; end;
8
9proc get(p: ^Rec; k: INT): INT;
10begin
11 return p^.x + k;
12end;
13
14(* called through a procedure value, so that get isn't made in place *)
15proc main*;
16var r: Rec; f: proc(p: ^Rec; k: INT): INT;
17begin
18 r.x := 1;
19 f := get;
20 Out.int(f(SYSTEM.ADR(r), 2)); Out.ln;
21 Out.int(f(nil, 5)); Out.ln;
22end;
23
24end KeptNil.