comparison 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
comparison
equal deleted inserted replaced
-1:000000000000 0:bfdcc3820b32
1 proc apply(proc f(x: integer));
2 begin
3 f(111)
4 end;
5
6 proc beta(y: integer);
7 proc f(x: integer);
8 begin
9 print_num(x);
10 newline();
11 end;
12
13 proc g(x:integer);
14 begin
15 print_num(y);
16 newline();
17 end;
18
19 begin
20 apply(f);
21 apply(g)
22 end;
23
24 begin
25 beta(222)
26 end.
27
28 (*<<
29 111
30 222
31 >>*)
32
33 (*[[
34 MODULE Main 0 0
35 IMPORT Lib 0
36 ENDHDR
37
38 PROC _apply 0 0 0
39 ! f(111)
40 CONST 111
41 LDLW 20
42 LDLW 16
43 PCALL 1
44 RETURN
45 END
46
47 PROC _beta 0 0 0
48 ! apply(f);
49 LOCAL 0
50 GLOBAL _f
51 CONST 0
52 GLOBAL _apply
53 PCALL 2
54 ! apply(g)
55 LOCAL 0
56 GLOBAL _g
57 CONST 0
58 GLOBAL _apply
59 PCALL 2
60 RETURN
61 END
62
63 PROC _f 0 0 0
64 ! print_num(x);
65 LDLW 16
66 CONST 0
67 GLOBAL lib.print_num
68 PCALL 1
69 ! newline();
70 CONST 0
71 GLOBAL lib.newline
72 PCALL 0
73 ! end;
74 RETURN
75 END
76
77 PROC _g 0 0 0
78 ! print_num(y);
79 LDLW 12
80 LDNW 16
81 CONST 0
82 GLOBAL lib.print_num
83 PCALL 1
84 ! newline();
85 CONST 0
86 GLOBAL lib.newline
87 PCALL 0
88 ! end;
89 RETURN
90 END
91
92 PROC MAIN 0 0 0
93 ! beta(222)
94 CONST 222
95 CONST 0
96 GLOBAL _beta
97 PCALL 1
98 RETURN
99 END
100
101 ! End
102 ]]*)