Mercurial > repos > rhope
annotate testc_c.rhope @ 110:336da6ce8174
Merge
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Wed, 06 Oct 2010 23:48:32 +0000 |
parents | 5a08705f7610 |
children |
rev | line source |
---|---|
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1 Import cbackend_c.rhope |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2 Import number_c.rhope |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3 Import boolean.rhope |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
4 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5 //Dummy versions of nworker methods so the code in number_c.rhope will compile |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
6 Register Worker[prog,name,convention,inputs,outputs:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
7 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
8 out <- prog |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
9 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
10 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
11 Bind Worker[prog,name,worker:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
12 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
13 out <- prog |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
14 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
15 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
16 Blueprint NWorker |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
17 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
18 Inputs |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
19 Input Types |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
20 Outputs |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
21 Output Types |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
22 Builtin? |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
23 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
24 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
25 NWorker[convention:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
26 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
27 out <- convention |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
28 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
29 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
30 Main[] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
31 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
32 prog <- [[C Program[]]Generate Number Methods]Generate Boolean Methods |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
33 base <- [[[[[[[[[prog]Create Function["Fib",("n"),("out"),"rhope"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
34 ]Allocate Var["work1", Type Instance["Any Type"]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
35 ]Allocate Var["work2", Type Instance["Any Type"]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
36 ]Register Constant["const_1", 1] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
37 ]Register Constant["const_2", 2] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
38 ]Set Null["out"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
39 ]Method Call["<", [[()]Append[AddRef["n"]]]Append[AddRef[Constant["const_2"]]]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
40 ]Move[Result[0], "work1"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
41 ]Method Call["If", [()]Append["work1"]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
42 {Print["base done"] } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
43 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
44 stream1 <- [[[base]Instruction Stream |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
45 ]Release[Result[0]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
46 ]Move[AddRef[Constant["const_1"]], "out"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
47 {Print["stream1 done"]} |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
48 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
49 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
50 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
51 [[[[[[[[[[base]Instruction Stream |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
52 ]Release[Result[0]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
53 ]Method Call["-", [[()]Append[AddRef["n"]]]Append[AddRef[Constant["const_1"]]]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
54 ]Move[Result[0], "work1"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
55 ]Method Call["-", [[()]Append[AddRef["n"]]]Append[AddRef[Constant["const_2"]]]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
56 ]Move[Result[0], "work2"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
57 ]Call["Fib", ("work1")] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
58 ]Move[Result[0], "work1"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
59 ]Call["Fib", ("work2")] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
60 ]Move[Result[0], "work2"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
61 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
62 stream3 <- [[[~]Instruction Stream |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
63 ]Release["n"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
64 ]Method Call["+", ("work1","work2")] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
65 stream2 <- [~]Do If[NotCond["out"], stream3] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
66 {Print["stream2 done"]} |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
67 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
68 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
69 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
70 func <- [[[base |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
71 ]Do If[Result[0], stream1] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
72 ]Do If[Result[1], stream2] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
73 ]Release["n"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
74 {Print["func done"] } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
75 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
76 main <- [[[[prog]Create Function["Main", (), ("out"), "rhope"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
77 ]Register Constant["const_30", 30] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
78 ]Call["Fib", [()]Append[Constant["const_30"]]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
79 ]Move[Result[0], "out"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
80 |
96
5a08705f7610
Semi-broken cleanup of Array implementation
Mike Pavone <pavone@retrodev.com>
parents:
92
diff
changeset
|
81 text <- [[[prog]Store Function[func] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
82 ]Store Function[main] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
83 ]Text |
96
5a08705f7610
Semi-broken cleanup of Array implementation
Mike Pavone <pavone@retrodev.com>
parents:
92
diff
changeset
|
84 Print[[text]Length] |
5a08705f7610
Semi-broken cleanup of Array implementation
Mike Pavone <pavone@retrodev.com>
parents:
92
diff
changeset
|
85 { Print[text] } |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
86 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
87 |