annotate ppc/test/apply.p @ 0:bfdcc3820b32

Basis
author Mike Spivey <mike@cs.ox.ac.uk>
date Thu, 05 Oct 2017 08:04:15 +0100
parents
children
rev   line source
0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
1 proc apply(proc f(x: integer));
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
2 begin
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
3 f(111)
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
4 end;
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
5
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
6 proc beta(y: integer);
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
7 proc f(x: integer);
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
8 begin
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
9 print_num(x);
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
10 newline();
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
11 end;
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
12
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
13 proc g(x:integer);
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
14 begin
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
15 print_num(y);
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
16 newline();
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
17 end;
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
18
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
19 begin
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
20 apply(f);
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
21 apply(g)
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
22 end;
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
23
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
24 begin
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
25 beta(222)
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
26 end.
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
27
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
28 (*<<
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
29 111
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
30 222
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
31 >>*)
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
32
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
33 (*[[
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
34 MODULE Main 0 0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
35 IMPORT Lib 0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
36 ENDHDR
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
37
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
38 PROC _apply 0 0 0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
39 ! f(111)
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
40 CONST 111
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
41 LDLW 20
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
42 LDLW 16
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
43 PCALL 1
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
44 RETURN
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
45 END
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
46
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
47 PROC _beta 0 0 0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
48 ! apply(f);
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
49 LOCAL 0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
50 GLOBAL _f
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
51 CONST 0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
52 GLOBAL _apply
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
53 PCALL 2
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
54 ! apply(g)
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
55 LOCAL 0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
56 GLOBAL _g
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
57 CONST 0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
58 GLOBAL _apply
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
59 PCALL 2
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
60 RETURN
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
61 END
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
62
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
63 PROC _f 0 0 0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
64 ! print_num(x);
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
65 LDLW 16
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
66 CONST 0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
67 GLOBAL lib.print_num
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
68 PCALL 1
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
69 ! newline();
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
70 CONST 0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
71 GLOBAL lib.newline
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
72 PCALL 0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
73 ! end;
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
74 RETURN
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
75 END
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
76
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
77 PROC _g 0 0 0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
78 ! print_num(y);
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
79 LDLW 12
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
80 LDNW 16
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
81 CONST 0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
82 GLOBAL lib.print_num
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
83 PCALL 1
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
84 ! newline();
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
85 CONST 0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
86 GLOBAL lib.newline
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
87 PCALL 0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
88 ! end;
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
89 RETURN
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
90 END
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
91
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
92 PROC MAIN 0 0 0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
93 ! beta(222)
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
94 CONST 222
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
95 CONST 0
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
96 GLOBAL _beta
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
97 PCALL 1
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
98 RETURN
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
99 END
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
100
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
101 ! End
Mike Spivey <mike@cs.ox.ac.uk>
parents:
diff changeset
102 ]]*)