annotate ppc/test/apply.p @ 1:b5139af1a420 tip basis

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