comparison cbackend.rhope @ 2:73e978d590c7

Adding WIP compiler code
author Mike Pavone <pavone@retrodev.com>
date Wed, 29 Apr 2009 02:58:03 -0400
parents
children 31f8182f3433
comparison
equal deleted inserted replaced
1:b3f71490858c 2:73e978d590c7
1
2 Blueprint Blueprint Def
3 {
4 Name
5 Fixed Size
6 Fields
7 Methods
8 }
9
10 Blueprint Def[name]
11 {
12 out <- [[[[Build["Blueprint Def"]]Name <<[name]]Fixed Size <<[0]]Fields <<[()]]Methods <<[New@Dictionary[]]
13 }
14
15 Blueprint C Function
16 {
17 Name
18 Inputs
19 Outputs
20 Convention
21 Variables
22 Statements
23 }
24
25 C Function[name,inputs,outputs,convention:out]
26 {
27 out <- [[[[[[Build["C Function"]
28 ]Name <<[name]
29 ]Inputs <<[inputs]
30 ]Outputs <<[outputs]
31 ]Convention <<[convention]
32 ]Variables <<[New@Dictionary[]]
33 ]Statements <<[()]
34 }
35
36 Allocate Var@C Function[func,name,type:out]
37 {
38 out <- [func]Variables <<[ [[func]Variables >>]Set[name,type] ]
39 }
40
41 Add Statement@C Function[func,statement:out]
42 {
43 out <- [func]Statements <<[ [[func]Statements >>]Append[[statement]Append[";"]] ]
44 }
45
46 Add Operator Statement@C Function[func,source1,source2,dest,op:out]
47 {
48 out <- [func]Add Statement[[[[[dest]Append[" = "]]Append[source1]]Append[op]]Append[source2]]
49 }
50
51 Add@C Function[func,source1,source2,dest:out]
52 {
53 out <- [func]Add Operator Statement[source1,source2,dest," + "]
54 }
55
56 Sub@C Function[func,source1,source2,dest:out]
57 {
58 out <- [func]Add Operator Statement[source1,source2,dest," - "]
59 }
60
61 Multiply@C Function[func,source1,source2,dest:out]
62 {
63 out <- [func]Add Operator Statement[source1,source2,dest," * "]
64 }
65
66 Divide@C Function[func,source1,source2,dest:out]
67 {
68 out <- [func]Add Operator Statement[source1,source2,dest," / "]
69 }
70
71 Move@C Function[func,source,dest:out]
72 {
73 out <- [func]Add Statement[[[dest]Append[" = "]]Append[source]]
74 }
75
76 Definitions@C Function[func:out]
77 {
78
79 }
80
81 Text@C Function[func:out]
82 {
83
84 }