Mercurial > repos > rhope
comparison testc.rhope @ 14:69dfca29565f
C backend close to being useable
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Tue, 26 May 2009 23:52:32 +0000 |
parents | |
children | ea991f95ae1f |
comparison
equal
deleted
inserted
replaced
12:31f8182f3433 | 14:69dfca29565f |
---|---|
1 Import cbackend.rhope | |
2 | |
3 Main[] | |
4 { | |
5 base <- [[[[[[C Function["Fib",("n"),("out"),""] | |
6 ]Allocate Var["work1", "Any Type"] | |
7 ]Allocate Var["work2", "Any Type"] | |
8 ]Null["out"] | |
9 ]Method Call["<", [[()]Append[AddRef["n"]]]Append[AddRef[Constant["const_2"]]]] | |
10 ]Move[Result[0], "work1"] | |
11 ]Method Call["If", [()]Append["work1"]] | |
12 {Print["base done"] } | |
13 | |
14 stream1 <- [[[base]Instruction Stream | |
15 ]Release[Result[0]] | |
16 ]Move[AddRef[Constant["const_1"]], "out"] | |
17 {Print["stream1 done"]} | |
18 | |
19 stream2 <- [[[[[[base]Instruction Stream | |
20 ]Release[Result[0]] | |
21 ]Method Call["-", [[()]Append[AddRef["n"]]]Append[AddRef[Constant["const_1"]]]] | |
22 ]Move[Result[0], "work1"] | |
23 ]Method Call["-", [[()]Append[AddRef["n"]]]Append[AddRef[Constant["const_2"]]]] | |
24 ]Move[Result[0], "work2"] | |
25 {Print["stream2 done"]} | |
26 | |
27 func <- [[base | |
28 ]Do If[Result[0], stream1] | |
29 ]Do If[Result[1], stream2] | |
30 {Print["func done"] } | |
31 | |
32 Print[[func]Definitions] | |
33 { | |
34 Print[[func]Text] } | |
35 } | |
36 | |
37 Foo[] | |
38 { | |
39 } | |
40 |