comparison testc.rhope @ 184:c6ba9fe45910

Strip _c from filenames of current compiler
author Mike Pavone <pavone@retrodev.com>
date Wed, 27 Jul 2011 21:28:43 -0700
parents testc_c.rhope@5a08705f7610
children
comparison
equal deleted inserted replaced
183:24c6f8767190 184:c6ba9fe45910
1 Import cbackend.rhope 1 Import cbackend.rhope
2 Import number.rhope
3 Import boolean.rhope
4
5 //Dummy versions of nworker methods so the code in number_c.rhope will compile
6 Register Worker[prog,name,convention,inputs,outputs:out]
7 {
8 out <- prog
9 }
10
11 Bind Worker[prog,name,worker:out]
12 {
13 out <- prog
14 }
15
16 Blueprint NWorker
17 {
18 Inputs
19 Input Types
20 Outputs
21 Output Types
22 Builtin?
23 }
24
25 NWorker[convention:out]
26 {
27 out <- convention
28 }
2 29
3 Main[] 30 Main[]
4 { 31 {
5 prog <- C Program[] 32 prog <- [[C Program[]]Generate Number Methods]Generate Boolean Methods
6 base <- [[[[[[[prog]Create Function["Fib",("n"),("out"),""] 33 base <- [[[[[[[[[prog]Create Function["Fib",("n"),("out"),"rhope"]
7 ]Allocate Var["work1", "Any Type"] 34 ]Allocate Var["work1", Type Instance["Any Type"]]
8 ]Allocate Var["work2", "Any Type"] 35 ]Allocate Var["work2", Type Instance["Any Type"]]
9 ]Null["out"] 36 ]Register Constant["const_1", 1]
37 ]Register Constant["const_2", 2]
38 ]Set Null["out"]
10 ]Method Call["<", [[()]Append[AddRef["n"]]]Append[AddRef[Constant["const_2"]]]] 39 ]Method Call["<", [[()]Append[AddRef["n"]]]Append[AddRef[Constant["const_2"]]]]
11 ]Move[Result[0], "work1"] 40 ]Move[Result[0], "work1"]
12 ]Method Call["If", [()]Append["work1"]] 41 ]Method Call["If", [()]Append["work1"]]
13 {Print["base done"] } 42 {Print["base done"] }
14 43
15 stream1 <- [[[base]Instruction Stream 44 stream1 <- [[[base]Instruction Stream
16 ]Release[Result[0]] 45 ]Release[Result[0]]
17 ]Move[AddRef[Constant["const_1"]], "out"] 46 ]Move[AddRef[Constant["const_1"]], "out"]
18 {Print["stream1 done"]} 47 {Print["stream1 done"]}
19 48
20 stream3 <- [[[base]Instruction Stream 49
21 ]Release["n"]
22 ]Tail Method Call["+", ("work1","work2")]
23 50
24 stream2 <- [[[[[[[[[[[base]Instruction Stream 51 [[[[[[[[[[base]Instruction Stream
25 ]Release[Result[0]] 52 ]Release[Result[0]]
26 ]Method Call["-", [[()]Append[AddRef["n"]]]Append[AddRef[Constant["const_1"]]]] 53 ]Method Call["-", [[()]Append[AddRef["n"]]]Append[AddRef[Constant["const_1"]]]]
27 ]Move[Result[0], "work1"] 54 ]Move[Result[0], "work1"]
28 ]Method Call["-", [[()]Append[AddRef["n"]]]Append[AddRef[Constant["const_2"]]]] 55 ]Method Call["-", [[()]Append[AddRef["n"]]]Append[AddRef[Constant["const_2"]]]]
29 ]Move[Result[0], "work2"] 56 ]Move[Result[0], "work2"]
30 ]Call["Fib", ("work1")] 57 ]Call["Fib", ("work1")]
31 ]Move[Result[0], "work1"] 58 ]Move[Result[0], "work1"]
32 ]Call["Fib", ("work2")] 59 ]Call["Fib", ("work2")]
33 ]Move[Result[0], "work2"] 60 ]Move[Result[0], "work2"]
34 ]Do If[NotCond["out"], stream3] 61 {
35 {Print["stream2 done"]} 62 stream3 <- [[[~]Instruction Stream
63 ]Release["n"]
64 ]Method Call["+", ("work1","work2")]
65 stream2 <- [~]Do If[NotCond["out"], stream3]
66 {Print["stream2 done"]}
67 }
68
36 69
37 func <- [[[base 70 func <- [[[base
38 ]Do If[Result[0], stream1] 71 ]Do If[Result[0], stream1]
39 ]Do If[Result[1], stream2] 72 ]Do If[Result[1], stream2]
40 ]Release["n"] 73 ]Release["n"]
41 {Print["func done"] } 74 {Print["func done"] }
42 75
43 Print[[[prog]Store Function[func]]Text] 76 main <- [[[[prog]Create Function["Main", (), ("out"), "rhope"]
44 77 ]Register Constant["const_30", 30]
78 ]Call["Fib", [()]Append[Constant["const_30"]]]
79 ]Move[Result[0], "out"]
80
81 text <- [[[prog]Store Function[func]
82 ]Store Function[main]
83 ]Text
84 Print[[text]Length]
85 { Print[text] }
45 } 86 }
46 87