Mercurial > repos > rhope
annotate cbackend_c.rhope @ 96:5a08705f7610
Semi-broken cleanup of Array implementation
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Mon, 02 Aug 2010 05:12:19 -0400 |
parents | e73a93fb5de1 |
children | f4fc0a98088a |
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 backendutils_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 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3 Blueprint C Method Registry |
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 Lookup |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
6 Next ID |
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 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
9 C Method Registry[:out] |
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 builtins <- [[[[[[[[[[[[[Dictionary[] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
12 ]Set["+", "METHOD_ADD"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
13 ]Set["-", "METHOD_SUB"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
14 ]Set["/", "METHOD_DIV"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
15 ]Set["*", "METHOD_MUL"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
16 ]Set["LShift", "METHOD_LSHIFT"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
17 ]Set["RShift", "METHOD_RSHIFT"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
18 ]Set["=", "METHOD_EQUALS"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
19 ]Set[">", "METHOD_GREATER"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
20 ]Set["<", "METHOD_LESS"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
21 ]Set["If", "METHOD_IF"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
22 ]Set["Set Missing Field", "METHOD_SETFIELDMISSING"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
23 ]Set["Get Missing Field", "METHOD_GETFIELDMISSING"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
24 ]Set["Missing Method", "METHOD_MISSING"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
25 out <- [[Build[C Method Registry()]]Lookup <<[builtins]]Next ID<<[0] |
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 } |
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 Register Method@C Method Registry[reg,method:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
30 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
31 [[reg]Lookup >>]Index[method] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
32 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
33 out <- reg |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
34 }{ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
35 method ID <- [reg]Next ID>> |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
36 new lookup <- [[reg]Lookup >>]Set[method, ["METHOD_FIRST_USER+"]Append[String[method ID]]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
37 out <- [[reg]Lookup <<[new lookup]]Next ID <<[[method ID]+[1]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
38 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
39 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
40 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
41 Method ID@C Method Registry[reg,method:out,notfound] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
42 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
43 out,notfound <- [[reg]Lookup >>]Index[method] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
44 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
45 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
46 Blueprint C Field Registry |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
47 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
48 Lookup |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
49 Next ID |
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 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
52 C Field Registry[:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
53 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
54 out <- [[Build[C Field Registry()]]Lookup <<[Dictionary[]]]Next ID<<[1] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
55 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
56 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
57 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
58 Register Field@C Field Registry[reg,field:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
59 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
60 [[reg]Lookup >>]Index[field] |
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 out <- reg |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
63 }{ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
64 field ID <- [reg]Next ID>> |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
65 new lookup <- [[reg]Lookup >>]Set[field, field ID] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
66 out <- [[reg]Lookup <<[new lookup]]Next ID <<[[field ID]+[1]] |
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 Field ID@C Field Registry[reg,field:out,notfound] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
71 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
72 out,notfound <- [[reg]Lookup >>]Index[field] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
73 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
74 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
75 Blueprint C Type |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
76 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
77 Name |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
78 Fields |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
79 Methods |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
80 Init |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
81 Copy |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
82 Cleanup |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
83 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
84 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
85 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
86 C Type[name:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
87 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
88 out <- [[[[[[Build[C Type()]]Name <<[name]]Fields <<[()]]Methods <<[()]]Init <<["NULL"]]Copy <<["NULL"]]Cleanup <<["NULL"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
89 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
90 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
91 Add Field@C Type[ctype,name,type:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
92 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
93 out <- [ctype]Fields <<[ [[ctype]Fields >>]Append[ [[()]Append[name]]Append[type] ] ] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
94 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
95 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
96 Add Method@C Type[ctype,name:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
97 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
98 out <- [ctype]Methods <<[ [[ctype]Methods >>]Append[name] ] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
99 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
100 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
101 Register Methods@C Type[ctype,method reg:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
102 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
103 out <- Fold[Register Method[?], method reg, [ctype]Methods >>] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
104 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
105 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
106 _Register Field C[reg,field:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
107 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
108 name <- [field]Index[0] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
109 out <- [reg]Register Field[name] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
110 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
111 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
112 Register Fields@C Type[ctype,field reg:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
113 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
114 out <- Fold[_Register Field C[?], field reg, [ctype]Fields >>] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
115 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
116 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
117 Rhope Type to C[type:out,array] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
118 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
119 If[[Blueprint Of[type]]=[Type Instance()]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
120 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
121 variant <- [type]Variant >> |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
122 If[[[type]Name >>] = ["Array"]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
123 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
124 [("Naked","Raw Pointer")]Find[=[variant,?]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
125 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
126 /* |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
127 //Below code assumes that paramaterized types are implemented |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
128 pre param <- [[type]Params >>]Index[0] {} |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
129 { pre param <- 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
|
130 [[type]Params >>]Index[1] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
131 { param,param <- [pre param]Set Variant[~] } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
132 { param <- Val[pre param] } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
133 child type <- Rhope Type to C[param] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
134 If[[variant] = ["Naked"]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
135 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
136 out <- Val[child type] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
137 array <- "[1]" |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
138 }{ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
139 out <- [child type]Append[" *"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
140 array <- "" |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
141 } */ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
142 out <- "void *" |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
143 array <- "" |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
144 }{ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
145 typename <- "Array" |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
146 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
147 primitive <- No |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
148 }{ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
149 ,regulartype <- [("Naked","Raw Pointer")]Find[=[variant,?]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
150 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
151 [("Int64","Int32","Int16","Int8")]Find[=[[type]Name >>,?]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
152 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
153 primitive <- Yes |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
154 [[type]Name >>]Slice[3] {} |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
155 { typename <- [["int"]Append[~]]Append["_t"] } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
156 }{ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
157 ,regulartype <- [("UInt64","UInt32","UInt16","UInt8")]Find[=[[type]Name >>,?]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
158 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
159 primitive <- Yes |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
160 [[type]Name >>]Slice[4] {} |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
161 { typename <- [["uint"]Append[~]]Append["_t"] } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
162 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
163 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
164 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
165 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
166 Val[regulartype] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
167 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
168 typename <- [type]Name >> |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
169 primitive <- No |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
170 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
171 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
172 }{ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
173 typename <- type |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
174 param <- "Any Type" |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
175 variant <- "boxed" |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
176 primitive <- No |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
177 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
178 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
179 Val[typename] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
180 { array <- "" } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
181 If[[typename] = ["Any Type"]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
182 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
183 out <- "struct object *" |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
184 }{ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
185 [("Naked","Raw Pointer")]Find[=[variant,?]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
186 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
187 If[primitive] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
188 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
189 prefix <- "" |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
190 }{ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
191 prefix <- "nt_" |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
192 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
193 }{ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
194 prefix <- "t_" |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
195 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
196 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
197 If[[variant]=["Naked"]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
198 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
199 postfix <- "" |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
200 }{ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
201 postfix <- " *" |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
202 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
203 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
204 If[primitive] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
205 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
206 escaped <- Val[typename] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
207 }{ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
208 escaped <- Escape Rhope Name[typename] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
209 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
210 out <- [[prefix]Append[escaped]]Append[postfix] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
211 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
212 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
213 _Type Def C Type[text,field:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
214 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
215 name <- [field]Index[0] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
216 ,postfix <- Rhope Type to C[[field]Index[1]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
217 { type <- ["\n\t"]Append[~] } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
218 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
219 out <- [[[[text]Append[type]]Append[" "]]Append[[Escape Rhope Name[name]]Append[postfix]]]Append[";"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
220 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
221 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
222 Type Def@C Type[ctype:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
223 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
224 If[[[[ctype]Fields >>]Length] = [1]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
225 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
226 out <- [[[[_Type Def C Type["typedef struct {\n\tobject _SP_header;\n\t", [[ctype]Fields >>]Index[0]]]Append["\n} t_"]]Append[Escape Rhope Name[[ctype]Name >>]]]Append[";"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
227 ]Append[ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
228 [[[["typedef " |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
229 ]Append[Rhope Type to C[ [[[ctype]Fields >>]Index[0]]Index[1] ]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
230 ]Append[" nt_"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
231 ]Append[Escape Rhope Name[[ctype]Name >>]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
232 ]Append[";"] ] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
233 }{ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
234 //HACK!!! |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
235 If[[[ctype]Name >>]=["Blueprint"]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
236 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
237 out <- "" |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
238 }{ |
96
5a08705f7610
Semi-broken cleanup of Array implementation
Mike Pavone <pavone@retrodev.com>
parents:
92
diff
changeset
|
239 [("Array","Boxed Array","Worker")]Find[=[[ctype]Name >>,?]] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
240 { oend <- "\nMObject(" } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
241 { oend <- "\nObject(" } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
242 out <- [Fold[_Type Def C Type[?], "OBegin", [ctype]Fields >>]]Append[ [[oend]Append[Escape Rhope Name[[ctype]Name >>]]]Append[")"] ] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
243 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
244 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
245 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
246 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
247 _Type Init C[type name,method reg,text,method:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
248 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
249 out <- [[text]Append[[["\n\tadd_method(bp, "]Append[ [method reg]Method ID[method] ]]Append[ [[", MethodName("]Append[Escape Rhope Name[method]]]Append[[","]Append[Escape Rhope Name[type name]]]]]]Append["));"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
250 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
251 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
252 _Type Init C Field[type name,field reg,text,field:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
253 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
254 fname <- [field]Index[0] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
255 out <- [[[[text]Append[[["\n\tadd_getter(bp, "]Append[ String[[field reg]Field ID[fname]] ]]Append[ [[", MethodName("]Append[Escape Rhope Name[[fname]Append[" >>"]]]]Append[[","]Append[Escape Rhope Name[type name]]]]]]Append["));"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
256 ]Append[[["\n\tadd_setter(bp, "]Append[ String[[field reg]Field ID[fname]] ]]Append[ [[", MethodName("]Append[Escape Rhope Name[[fname]Append[" <<"]]]]Append[[","]Append[Escape Rhope Name[type name]]]]]]Append["));"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
257 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
258 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
259 Type Init@C Type[ctype,id,method reg,field reg:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
260 { |
96
5a08705f7610
Semi-broken cleanup of Array implementation
Mike Pavone <pavone@retrodev.com>
parents:
92
diff
changeset
|
261 [("Array","Boxed Array", "Worker")]Find[=[[ctype]Name >>, ?]] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
262 { size <- "-1" } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
263 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
264 [("Int64","Int32","Int16","Int8")]Find[=[[ctype]Name >>, ?]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
265 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
266 [[ctype]Name >>]Slice[3] {} |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
267 { typename <- [["int"]Append[~]]Append["_t"] } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
268 }{ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
269 [("UInt64","UInt32","UInt16","UInt8")]Find[=[[ctype]Name >>, ?]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
270 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
271 [[ctype]Name >>]Slice[4] {} |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
272 { typename <- [["uint"]Append[~]]Append["_t"] } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
273 }{ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
274 If[[[ctype]Name >>]=["Blueprint"]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
275 { typename <- "blueprint *" } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
276 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
277 If[[[ctype]Name >>]=["Boolean"]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
278 { typename <- "int32_t" } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
279 { typename <- ["nt_"]Append[Escape Rhope Name[[ctype]Name >>]] } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
280 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
281 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
282 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
283 size <- [["sizeof("]Append[typename]]Append[")"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
284 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
285 start <- [["\tbp = register_type_byid(" |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
286 ]Append[id] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
287 ]Append[ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
288 [[", "]Append[size] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
289 ]Append[ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
290 [", (special_func)"]Append[ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
291 [ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
292 [[[[Escape Rhope Name[[ctype]Init >>] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
293 ]Append[", (special_func)"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
294 ]Append[Escape Rhope Name[[ctype]Copy >> ]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
295 ]Append[", (special_func)"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
296 ]Append[Escape Rhope Name[[ctype]Cleanup >>]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
297 ]Append[");"]]] ] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
298 out <- Val[start]//Fold[[["_Type Init C Field"]Set Input[0, [ctype]Name >>]]Set Input[1, field reg], Fold[[["_Type Init C"]Set Input[0, [ctype]Name >>]]Set Input[1, method reg], start, [ctype]Methods >>], [ctype]Fields >>] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
299 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
300 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
301 Blueprint C Type Registry |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
302 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
303 Lookup |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
304 Definitions |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
305 Next ID |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
306 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
307 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
308 C Type Registry[:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
309 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
310 out <- [[[Build[C Type Registry()]]Lookup << [ |
96
5a08705f7610
Semi-broken cleanup of Array implementation
Mike Pavone <pavone@retrodev.com>
parents:
92
diff
changeset
|
311 [[[[[[[[[[[[[[[[[[[Dictionary[] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
312 ]Set["UInt8", "TYPE_UINT8"] //1 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
313 ]Set["UInt16", "TYPE_UINT16"] //2 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
314 ]Set["UInt32", "TYPE_UINT32"] //3 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
315 ]Set["UInt64", "TYPE_UINT64"] //4 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
316 ]Set["Int8", "TYPE_INT8"] //5 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
317 ]Set["Int16", "TYPE_INT16"] //6 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
318 ]Set["Int32", "TYPE_INT32"] //7 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
319 ]Set["Int64", "TYPE_INT64"] //8 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
320 ]Set["Boolean", "TYPE_BOOLEAN"] //9 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
321 ]Set["Float32", "TYPE_FLOAT32"] //10 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
322 ]Set["Float64", "TYPE_FLOAT64"] //11 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
323 ]Set["Real Number", "TYPE_FLOAT64"] //12 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
324 ]Set["Blueprint", "TYPE_BLUEPRINT"] //13 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
325 ]Set["Array", "TYPE_ARRAY"] //14 |
96
5a08705f7610
Semi-broken cleanup of Array implementation
Mike Pavone <pavone@retrodev.com>
parents:
92
diff
changeset
|
326 ]Set["Boxed Array", "TYPE_BOXEDARRAY"]//15 |
5a08705f7610
Semi-broken cleanup of Array implementation
Mike Pavone <pavone@retrodev.com>
parents:
92
diff
changeset
|
327 ]Set["Worker", "TYPE_WORKER"] //16 |
5a08705f7610
Semi-broken cleanup of Array implementation
Mike Pavone <pavone@retrodev.com>
parents:
92
diff
changeset
|
328 ]Set["Method Missing Exception", "TYPE_METHODMISSINGEXCEPTION"] //17 |
5a08705f7610
Semi-broken cleanup of Array implementation
Mike Pavone <pavone@retrodev.com>
parents:
92
diff
changeset
|
329 ]Set["Field Missing Exception", "TYPE_FIELDMISSINGEXCEPTION"] //18 |
5a08705f7610
Semi-broken cleanup of Array implementation
Mike Pavone <pavone@retrodev.com>
parents:
92
diff
changeset
|
330 ]Set["Wrong Type Exception", "TYPE_WRONGTYPEEXCEPTION"]] //19 |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
331 ]Definitions << [Dictionary[]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
332 ]Next ID <<[0] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
333 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
334 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
335 _Type Defs C[text,def:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
336 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
337 out <- [[text]Append[[def]Type Def]]Append["\n\n"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
338 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
339 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
340 Type Defs@C Type Registry[reg:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
341 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
342 out <- Fold[_Type Defs C[?], "", [reg]Definitions >>] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
343 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
344 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
345 _Type Inits C[reg,method reg,field reg,text,def,name:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
346 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
347 out <- [[text]Append[ [def]Type Init[[reg]Type ID[name], method reg, field reg] ]]Append["\n\n"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
348 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
349 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
350 Type Inits@C Type Registry[reg,method reg,field reg:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
351 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
352 out <- Fold[_Type Inits C[reg, method reg, field reg, ?], "", [reg]Definitions >>] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
353 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
354 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
355 Register Type@C Type Registry[reg,def:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
356 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
357 name <- [def]Name >> |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
358 [[reg]Lookup >>]Index[name] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
359 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
360 [[reg]Definitions >>]Index[name] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
361 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
362 out <- reg |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
363 }{ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
364 out <- [reg]Definitions <<[[[reg]Definitions >>]Set[name, def]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
365 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
366 }{ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
367 out <- [[[reg]Lookup <<[ [[reg]Lookup >>]Set[name, ["TYPE_FIRST_USER+"]Append[String[[reg]Next ID >>]]] ] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
368 ]Definitions <<[ [[reg]Definitions >>]Set[name, def] ] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
369 ]Next ID <<[ [[reg]Next ID >>]+[1] ] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
370 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
371 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
372 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
373 Type ID@C Type Registry[reg,name:out,notfound] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
374 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
375 out <- [[reg]Lookup >>]Index[name] {} |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
376 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
377 ,notfound <- If[[name]=["Any Type"]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
378 { out <- "0" } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
379 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
380 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
381 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
382 Simple Type?@C Type Registry[reg,name:yep,nope,notfound] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
383 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
384 ,notfound <- [[reg]Definitions >>]Index[name] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
385 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
386 yep,nope <- If[[[[~]Fields >>]Length] = [1]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
387 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
388 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
389 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
390 Blueprint C Function |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
391 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
392 Name |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
393 Inputs |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
394 Outputs |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
395 Convention |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
396 Variables |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
397 Statements |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
398 Method Registry |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
399 Field Registry |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
400 Type Registry |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
401 Constants |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
402 Input Types |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
403 Output Types |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
404 Resume Index |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
405 Last NumParams |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
406 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
407 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
408 C Function[name,inputs,outputs,convention:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
409 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
410 out <- C Function With Registry[name,inputs,outputs,convention, C Method Registry[], C Field Registry[], C Type Registry[]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
411 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
412 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
413 C Function With Registry[name,inputs,outputs,convention,registry,field reg,type reg:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
414 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
415 out <- [[[[[[[[[[[[[[Build[C Function()] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
416 ]Name <<[name] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
417 ]Inputs <<[inputs] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
418 ]Outputs <<[outputs] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
419 ]Convention <<[convention] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
420 ]Variables <<[Dictionary[]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
421 ]Statements <<[()] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
422 ]Method Registry <<[registry] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
423 ]Field Registry <<[field reg] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
424 ]Type Registry <<[type reg] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
425 ]Constants <<[Dictionary[]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
426 ]Input Types <<[ Fold[Append[?, "Any Type"], (), inputs] ] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
427 ]Output Types <<[ Fold[Append[?, "Any Type"], (), outputs] ] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
428 ]Resume Index <<[1] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
429 ]Last NumParams <<[-1] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
430 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
431 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
432 Set Input Type@C Function[func,type,input num:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
433 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
434 out <- [func]Input Types <<[ [[func]Input Types >>]Set[input num, type] ] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
435 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
436 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
437 Set Output Type@C Function[func,type,output num:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
438 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
439 out <- [func]Output Types <<[ [[func]Output Types >>]Set[output num, type] ] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
440 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
441 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
442 Register Constant@C Function[func,name,constant:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
443 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
444 out <- [func]Constants <<[ [[func]Constants >>]Set[name, constant] ] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
445 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
446 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
447 Allocate Var@C Function[func,name,type:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
448 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
449 out <- [func]Variables <<[ [[func]Variables >>]Set[name,type] ] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
450 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
451 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
452 Add Statement@C Function[func,statement:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
453 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
454 out <- [func]Statements <<[ [[func]Statements >>]Append[["\t"]Append[[statement]Append[";\n"]]] ] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
455 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
456 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
457 Add Raw Line@C Function[func,line:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
458 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
459 out <- [func]Statements <<[ [[func]Statements >>]Append[["\t"]Append[[line]Append["\n"]]] ] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
460 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
461 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
462 Add Operator Statement@C Function[func,psource1,psource2,pdest,op:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
463 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
464 source1 <- [psource1]Make Op[func] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
465 source2 <- [psource2]Make Op[func] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
466 dest <- [pdest]Make Op[func] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
467 out <- [func]Add Statement[[[[[dest]Append[" = "]]Append[source1]]Append[op]]Append[source2]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
468 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
469 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
470 Add@C Function[func,source1,source2,dest:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
471 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
472 out <- [func]Add Operator Statement[source1,source2,dest," + "] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
473 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
474 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
475 Sub@C Function[func,source1,source2,dest:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
476 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
477 out <- [func]Add Operator Statement[source1,source2,dest," - "] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
478 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
479 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
480 Multiply@C Function[func,source1,source2,dest:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
481 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
482 out <- [func]Add Operator Statement[source1,source2,dest," * "] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
483 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
484 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
485 Divide@C Function[func,source1,source2,dest:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
486 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
487 out <- [func]Add Operator Statement[source1,source2,dest," / "] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
488 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
489 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
490 DoLShift@C Function[func,source1,source2,dest:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
491 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
492 out <- [func]Add Operator Statement[source1,source2,dest," << "] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
493 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
494 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
495 DoRShift@C Function[func,source1,source2,dest:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
496 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
497 out <- [func]Add Operator Statement[source1,source2,dest," >> "] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
498 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
499 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
500 CompLess@C Function[func,source1,source2,dest:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
501 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
502 out <- [func]Add Operator Statement[source1,source2,dest," < "] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
503 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
504 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
505 CompGreater@C Function[func,source1,source2,dest:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
506 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
507 out <- [func]Add Operator Statement[source1,source2,dest," > "] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
508 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
509 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
510 CompEqual@C Function[func,source1,source2,dest:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
511 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
512 out <- [func]Add Operator Statement[source1,source2,dest," == "] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
513 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
514 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
515 CompLessEqual@C Function[func,source1,source2,dest:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
516 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
517 out <- [func]Add Operator Statement[source1,source2,dest," <= "] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
518 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
519 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
520 CompGreaterEqual@C Function[func,source1,source2,dest:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
521 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
522 out <- [func]Add Operator Statement[source1,source2,dest," >= "] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
523 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
524 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
525 CompNotEqual@C Function[func,source1,source2,dest:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
526 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
527 out <- [func]Add Operator Statement[source1,source2,dest," != "] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
528 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
529 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
530 Move@C Function[func,psource,pdest:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
531 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
532 source <- [psource]Make Op[func] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
533 dest <- [pdest]Make Op[func] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
534 out <- [func]Add Statement[[[dest]Append[" = "]]Append[source]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
535 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
536 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
537 Do AddRef@C Function[func,psource,pdest:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
538 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
539 source <- [psource]Make Op[func] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
540 dest <- [pdest]Make Op[func] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
541 out <- [func]Add Statement[[[[dest]Append[" = add_ref((object *)"]]Append[source]]Append[")"]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
542 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
543 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
544 AddRef No Dest@C Function[func,psource:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
545 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
546 source <- [psource]Make Op[func] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
547 out <- [func]Add Statement[[["add_ref((object *)"]Append[source]]Append[")"]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
548 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
549 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
550 Release@C Function[func,psource:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
551 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
552 source <- [psource]Make Op[func] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
553 out <- [func]Add Statement[[["release_ref((object *)"]Append[source]]Append[")"]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
554 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
555 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
556 Set Null@C Function[func,pdest:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
557 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
558 dest <- [pdest]Make Op[func] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
559 out <- [func]Add Statement[[dest]Append[" = NULL"]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
560 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
561 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
562 Lookup Constant@C Function[func,const,doaddref:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
563 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
564 var <- ["_const_"]Append[Escape Rhope Name[const]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
565 If[doaddref] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
566 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
567 out <- [["add_ref("]Append[var]]Append[")"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
568 }{ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
569 out <- Val[var] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
570 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
571 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
572 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
573 Field Result@C Function[func,var,field:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
574 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
575 as op <- [var]Make Op[func] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
576 [(String(),String Cat(),String Slice())]Find[=[Blueprint Of[var],?]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
577 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
578 [[func]Inputs >>]Find[=[var,?]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
579 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
580 type <- [[func]Input Types >>]Index[~] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
581 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
582 }{ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
583 type <- [[func]Variables >>]Index[var] { Print["op refers to a var"] } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
584 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
585 [[func]Outputs >>]Find[=[var,?]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
586 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
587 type <- [[func]Output Types >>]Index[~] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
588 }{ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
589 //Does it make sense for us to do this? |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
590 type <- 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
|
591 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
592 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
593 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
594 }{ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
595 type <- 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
|
596 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
597 If[[[func]Convention >>] = ["rhope"]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
598 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
599 If[[type] = ["Any Type"]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
600 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
601 rvar <- Val[as op] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
602 }{ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
603 rvar <- [[[["(("]Append[ Rhope Type to C[type] ]]Append[")("]]Append[as op]]Append["))"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
604 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
605 }{ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
606 rvar <- Val[as op] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
607 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
608 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
609 [[func]Type Registry >>]Simple Type?[[type]Name >>] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
610 { access <- "->" } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
611 { access <- "->payload." } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
612 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
613 //TODO: Generate some kind of error/exception in this case |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
614 access <- "->" |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
615 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
616 out <- [[rvar]Append[access]]Append[Escape Rhope Name[field]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
617 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
618 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
619 Read Field@C Function[func,var,field:out,result op] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
620 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
621 out <- func |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
622 result op <- Field Ref[var,field] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
623 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
624 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
625 Write Field@C Function[func,var,field:out,result op] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
626 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
627 out <- func |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
628 result op <- Field Ref[var,field] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
629 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
630 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
631 Set Field Null@C Function[func,var,field:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
632 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
633 out <- [func]Add Statement[ [[func]Field Result[var,field]]Append[" = NULL"] ] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
634 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
635 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
636 Copy@C Function[func,pdest:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
637 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
638 dest <- [pdest]Make Op[func] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
639 out <- [func]Add Statement[ [dest]Append[[[" = copy_object("]Append[dest]]Append[")"]] ] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
640 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
641 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
642 Box@C Function[func,psource,pdest,type:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
643 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
644 dest <- [pdest]Make Op[func] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
645 source <- [psource]Make Op[func] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
646 out <- [func]Add Statement[ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
647 [[[[[dest |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
648 ]Append[" = naked_to_boxed("] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
649 ]Append[ [[func]Type Registry >>]Type ID[[type]Name >>] ] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
650 ]Append[", &"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
651 ]Append[source] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
652 ]Append[")"] ] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
653 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
654 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
655 Unbox@C Function[func,psource,pdest:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
656 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
657 dest <- [pdest]Make Op[func] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
658 source <- [psource]Make Op[func] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
659 out <- [func]Add Statement[ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
660 [[[["boxed_to_naked(" |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
661 ]Append[source] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
662 ]Append[", &"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
663 ]Append[dest] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
664 ]Append[")"] ] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
665 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
666 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
667 Get Raw Pointer@C Function[func,psource,pdest:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
668 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
669 dest <- [pdest]Make Op[func] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
670 source <- [psource]Make Op[func] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
671 out <- [func]Add Statement[ [[[dest]Append[" = (void*)("]]Append[source]]Append[" + 1)"] ] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
672 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
673 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
674 Array Raw Pointer@C Function[func,psource,pdest:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
675 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
676 dest <- [pdest]Make Op[func] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
677 source <- [psource]Make Op[func] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
678 out <- [func]Add Statement[ [[[dest]Append[" = ((char *)"]]Append[source]]Append[")+ sizeof(t_Array)"] ] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
679 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
680 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
681 _Function Arg C[func,val,inputnum:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
682 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
683 out <- [func]Add Raw Line[ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
684 [[[["SetParam(" |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
685 ]Append[String[inputnum]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
686 ]Append[", "] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
687 ]Append[val] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
688 ]Append[")"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
689 ] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
690 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
691 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
692 _Val Function Arg C[func,val,inputnum,worker:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
693 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
694 out <- [func]Add Raw Line[ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
695 [[[[[["VCSetParam(" |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
696 ]Append[worker] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
697 ]Append[", "] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
698 ]Append[String[inputnum]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
699 ]Append[", "] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
700 ]Append[val] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
701 ]Append[")"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
702 ] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
703 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
704 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
705 Method Call@C Function[func,method,args:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
706 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
707 out <- [func]Call[method,args] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
708 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
709 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
710 Val Call@C Function[func,to call,args:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
711 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
712 worker <- Make Op[Strip Addref[to call], func] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
713 rargs <- Map[args, Make Op[?, func]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
714 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
715 If[[[func]Last NumParams >>] = [-1]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
716 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
717 freed <- Val[func] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
718 }{ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
719 freed <- [func]Add Raw Line["FreeCall"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
720 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
721 prepped <- [[freed]Add Raw Line[ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
722 [[[["VCPrepCall(" |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
723 ]Append[worker] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
724 ]Append[", "] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
725 ]Append[String[[rargs]Length]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
726 ]Append[")"] ] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
727 ]Last NumParams <<[[rargs]Length] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
728 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
729 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
730 out <- [[[[Fold[_Val Function Arg C[?, ?, ?, worker], prepped, rargs] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
731 ]Add Raw Line[ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
732 [[[[[[[["ValCall(" |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
733 ]Append[worker] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
734 ]Append[", "] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
735 ]Append[String[[rargs]Length]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
736 ]Append[", "] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
737 ]Append[String[[func]Resume Index >>]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
738 ]Append[", "] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
739 ]Append[Escape Rhope Name[[func]Name >>]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
740 ]Append[")"]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
741 ]Add Raw Line["DISPATCH"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
742 ]Add Raw Line[ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
743 [[[["ValCallPostlude(" |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
744 ]Append[String[[func]Resume Index >>]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
745 ]Append[", "] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
746 ]Append[Escape Rhope Name[[func]Name >>]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
747 ]Append[")"]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
748 ]Resume Index <<[ [[func]Resume Index >>]+[1] ] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
749 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
750 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
751 Call@C Function[func,name,args:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
752 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
753 If[[name]=["Call@Worker"]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
754 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
755 //TODO: Handle case when user explicitly calls the fully qualified version, but the type of the first arg isn't Worker |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
756 out <- [func]Val Call[[args]Index[0], Tail[args,1]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
757 }{ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
758 If[[name]=["Call"]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
759 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
760 to call <- [args]Index[0] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
761 last numparams <- [func]Last NumParams >> |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
762 out <- [[[[[[func]Add Raw Line[[["if (get_blueprint("]Append[Make Op[Strip Addref[to call], func]]]Append[")->type_id == TYPE_WORKER) {"]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
763 ]Val Call[to call, Tail[args,1]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
764 ]Add Raw Line["} else {"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
765 ]Last NumParams <<[last numparams] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
766 ]Func Base["Call",args, "Call"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
767 ]Add Raw Line["}"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
768 }{ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
769 out <- [func]Func Base[Escape Rhope Name[name],args, "Call"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
770 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
771 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
772 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
773 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
774 Func Base@C Function[func,tocall,args,type:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
775 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
776 Print[ [[func]Name >>]Append[ [": Func Base("]Append[tocall] ] ] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
777 rargs <- Map[args, Make Op[?, func]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
778 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
779 If[[[rargs]Length] > [[func]Last NumParams >>]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
780 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
781 If[[[func]Last NumParams >>] = [-1]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
782 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
783 freed <- Val[func] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
784 }{ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
785 freed <- [func]Add Raw Line["FreeCall"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
786 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
787 prepped <- [[freed]Add Raw Line[ [["PrepCall("]Append[String[[rargs]Length]]]Append[")"] ] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
788 ]Last NumParams <<[[rargs]Length] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
789 }{ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
790 prepped <- Val[func] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
791 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
792 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
793 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
794 out <- [[Fold[_Function Arg C[?], prepped, rargs] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
795 ]Add Raw Line[ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
796 [[[[[[[[[type]Append["("] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
797 ]Append[tocall] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
798 ]Append[", "] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
799 ]Append[String[[rargs]Length]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
800 ]Append[", "] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
801 ]Append[String[[func]Resume Index >>]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
802 ]Append[", "] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
803 ]Append[Escape Rhope Name[[func]Name >>]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
804 ]Append[")"]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
805 ]Resume Index <<[ [[func]Resume Index >>]+[1] ] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
806 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
807 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
808 Call Foreign@C Function[func,name,language,args,store result:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
809 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
810 rargs <- Map[args, Make Op[?, func]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
811 //Assume language = "C" for now |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
812 base <- [[[name]Append["("]]Append[ Join[rargs, ", "] ]]Append[")"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
813 ,do store <- [(String(), String Slice(), String Cat())]Find[=[Blueprint Of[store result], ?]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
814 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
815 ,do store <- If[[store result]=[""]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
816 { stmt <- Val[base] } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
817 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
818 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
819 Val[do store] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
820 { stmt <- [[Make Op[store result, func]]Append[" = "]]Append[base] } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
821 out <- [func]Add Statement[stmt] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
822 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
823 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
824 Get Field Call@C Function[func,field,source:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
825 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
826 out <- [func]Func Base[Escape Rhope Name[[field]Append[" >>"]], [()]Append[source], "Call"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
827 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
828 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
829 Set Field Call@C Function[func,field,object,value:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
830 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
831 out <- [func]Func Base[Escape Rhope Name[[field]Append[" <<"]], [[()]Append[object]]Append[value], "Call"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
832 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
833 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
834 Tail Method Call@C Function[func,method,args:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
835 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
836 out <- [func]Func Base[[[func]Method Registry >>]Method ID[method],args, "TMCall"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
837 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
838 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
839 Tail Call@C Function[func,name,args:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
840 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
841 out <- [func]Func Base[Escape Rhope Name[name],args, "TCall"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
842 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
843 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
844 Resolve@C Function[func,op:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
845 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
846 If[[[func]Convention >>] = ["rhope"]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
847 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
848 [[func]Inputs >>]Find[=[op,?]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
849 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
850 out <- [["my_cdata->params["]Append[String[~]]]Append[" ]"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
851 }{ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
852 out <- [[["lv_"]Append[Escape Rhope Name[[func]Name >>]]]Append["->"]]Append[Escape Rhope Name[op]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
853 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
854 }{ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
855 out <- Escape Rhope Name[op] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
856 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
857 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
858 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
859 Resolve Output@C Function[func,name:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
860 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
861 If[[[func]Convention >>] = ["rhope"]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
862 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
863 out <- [[["lv_"]Append[Escape Rhope Name[[func]Name >>]]]Append["->"]]Append[Escape Rhope Name[name]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
864 }{ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
865 out <- Escape Rhope Name[name] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
866 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
867 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
868 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
869 Instruction Stream@C Function[func:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
870 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
871 out <- [func]Statements <<[()] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
872 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
873 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
874 _If C[func, statement:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
875 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
876 out <- [func]Statements <<[ [[func]Statements >>]Append[ ["\t"]Append[statement] ] ] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
877 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
878 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
879 Do If@C Function[func,condition,stream:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
880 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
881 cond <- [condition]Make Op[func] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
882 out <- [[Fold[_If C[?], [[func |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
883 ]Add Raw Line[ [["if("]Append[cond]]Append[")"] ] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
884 ]Add Raw Line["{"], [stream]Statements >>] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
885 ]Add Raw Line["}"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
886 ]Resume Index <<[[stream]Resume Index >>] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
887 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
888 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
889 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
890 Discard Outputs@C Function[func,first to discard:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
891 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
892 out <- [[[[[func |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
893 ]Add Raw Line[[["for(idx = "]Append[String[first to discard]]]Append["; idx < cdata->num_params; ++idx)"]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
894 ]Add Raw Line["{"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
895 ]Add Raw Line[" if (cdata->params[idx])"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
896 ]Add Raw Line[" release_ref(cdata->params[idx]);"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
897 ]Add Raw Line["}"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
898 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
899 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
900 Result Reference@C Function[func,output:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
901 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
902 out <- [["cdata->params["]Append[String[output]]]Append["]"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
903 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
904 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
905 Checked Result Reference@C Function[func,output:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
906 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
907 out <- [[[["("]Append[output]]Append[" < cdata->num_params ? cdata->params["]]Append[output]]Append["] : NULL)"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
908 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
909 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
910 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
911 If Null Else@C Function[func,left,right:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
912 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
913 check <- [[Make Condition[left]]Strip Addref]Make Op[func] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
914 l <- [left]Make Op[func] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
915 r <- [right]Make Op[func] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
916 out <- [[[[[["(" |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
917 ]Append[check] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
918 ]Append[" ? "] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
919 ]Append[l] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
920 ]Append[" : "] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
921 ]Append[r] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
922 ]Append[")"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
923 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
924 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
925 _Set Outputs C[string,inputname,inputnum,func:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
926 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
927 out <- [string]Append[[[ [ ["\tRet("]Append[String[inputnum]] ]Append[ [[", lv_"]Append[Escape Rhope Name[[func]Name >>]]]Append["->"]]]Append[Escape Rhope Name[inputname]]]Append[")\n"]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
928 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
929 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
930 Set Outputs@C Function[func:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
931 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
932 If[[[func]Convention >>] = ["rhope"]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
933 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
934 out <- [[[Fold[_Set Outputs C[?, ?, ?, func], "", [func]Outputs >>]]Append["\tNumRet("]]Append[String[[[func]Outputs >>]Length]]]Append[")\n"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
935 }{ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
936 [[func]Outputs >>]Index[0] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
937 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
938 out <- [["\treturn "]Append[Escape Rhope Name[~]]]Append[";\n"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
939 }{ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
940 out <- "" |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
941 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
942 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
943 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
944 _Output Defs C[string,varname,index,func:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
945 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
946 out <- [[[string]Append[ ["\t"]Append[Rhope Type to C[[[func]Output Types >>]Index[index]]] ]]Append[[" "]Append[Escape Rhope Name[varname]]]]Append[";\n"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
947 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
948 _Var Defs C[string,type,varname:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
949 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
950 Print[["Variable: "]Append[varname]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
951 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
952 out <- [[[string]Append[ ["\t"]Append[Rhope Type to C[type]] ]]Append[[" "]Append[Escape Rhope Name[varname]]]]Append[";\n"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
953 { Print["Produced Output"]} |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
954 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
955 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
956 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
957 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
958 Definitions@C Function[func:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
959 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
960 Print[["Definitions@C Function: "]Append[[func]Name >>]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
961 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
962 If[ [[[func]Convention >>] = ["rhope"]] And [[ [[[func]Variables >>]Length]+[[[func]Outputs >>]Length] ] > [0]] ] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
963 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
964 localtype <- [[[Fold[_Output Defs C[?, ?, ?, func], Fold[_Var Defs C[?],"typedef struct {\n", [func]Variables >>], [func]Outputs >>]]Append["} lt_"]]Append[Escape Rhope Name[[func]Name >>]]]Append[";\n"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
965 }{ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
966 localtype <- "" |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
967 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
968 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
969 If[ [[func]Convention >>] = ["rhope"] ] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
970 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
971 /* parts <- [[func]Name >>]Split["@"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
972 [parts]Index[1] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
973 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
974 proto <- [[[["MethodDef(" |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
975 ]Append[Escape Rhope Name[[parts]Index[0]]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
976 ]Append[", "] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
977 ]Append[Escape Rhope Name[~]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
978 ]Append[")\n"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
979 }{ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
980 proto <- [["FuncDef("]Append[Escape Rhope Name[[func]Name >>]]]Append[")\n"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
981 } */ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
982 out <- Val[localtype] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
983 }{ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
984 out <- [[func]Naked Proto]Append[";\n"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
985 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
986 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
987 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
988 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
989 _Proto Input[list,input,index,types:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
990 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
991 out <- [list]Append[ [[Rhope Type to C[[types]Index[index]]]Append[" "]]Append[Escape Rhope Name[input]] ] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
992 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
993 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
994 Naked Proto@C Function[func:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
995 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
996 [[func]Output Types >>]Index[0] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
997 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
998 outtype <- [Rhope Type to C[~]]Append[" "] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
999 }{ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1000 outtype <- "void " |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1001 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1002 out <- [[[[outtype |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1003 ]Append[ Escape Rhope Name[[func]Name >>]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1004 ]Append["("] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1005 ]Append[ [Fold[_Proto Input[?, ?, ?, [func]Input Types >>], (), [func]Inputs >>]]Join[", "] ] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1006 ]Append[")"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1007 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1008 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1009 Type Check@C Function[func,text,type,input num:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1010 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1011 If[[type] = ["Any Type"]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1012 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1013 out <- text |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1014 }{ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1015 out <- [text]Append[ [["\tParam("]Append[input num]]Append[ [[", "]Append[ [[func]Type Registry >>]Type ID[type] ]]Append[")"] ] ] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1016 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1017 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1018 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1019 Check Param Type C[text,type,input num,func:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1020 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1021 [(String(),String Cat(),String Slice())]Find[=[Blueprint Of[type],?]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1022 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1023 typename <- type |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1024 }{ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1025 typename <- [type]Name >> |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1026 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1027 If[[typename] = ["Any Type"]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1028 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1029 out <- text |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1030 }{ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1031 out <- [text]Append[[[["\tParam("]Append[String[input num]]]Append[ [","]Append[ [[func]Type Registry >>]Type ID[typename] ] ]]Append[")\n"]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1032 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1033 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1034 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1035 Text@C Function[func:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1036 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1037 Print[["Text@C Function: "]Append[[func]Name >>]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1038 If[ [[func]Convention >>] = ["rhope"] ] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1039 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1040 before <- [[func]Name >>]Partition["@"] {} {} |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1041 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1042 type <- "MethodImpl" |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1043 cname <- [[[[Escape Rhope Name[before] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1044 ]Append[", "] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1045 ]Append[Escape Rhope Name[~]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1046 ]Append[", "] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1047 ]Append[ [[func]Type Registry >>]Type ID[~] ] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1048 }{ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1049 type <- "Func" |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1050 cname <- Val[fname] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1051 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1052 fname <- Escape Rhope Name[[func]Name >>] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1053 param check <- Fold[Check Param Type C[?, ?, ?, func], "", [func]Input Types >>] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1054 If[ [ [[[func]Variables >>]Length]+[[[func]Outputs >>]Length] ] = [0] ] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1055 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1056 out <- [[[[[[[[ [type]Append["NoLocals("] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1057 ]Append[cname] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1058 ]Append[",\n\tNumParams "] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1059 ]Append[ String[[[func]Inputs >>]Length] ] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1060 ]Append[")\n\n"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1061 ]Append[param check] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1062 ]Append[ [[func]Statements >>]Join[""] ] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1063 ]Append["EndFuncNoLocals\n"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1064 ]Append["DISPATCH"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1065 }{ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1066 If[[[func]Last NumParams >>] = [-1]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1067 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1068 freecall <- "" |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1069 }{ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1070 freecall <- "\n\tFreeCall\n" |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1071 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1072 out <- [[[[[[[[[[ [type]Append["("] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1073 ]Append[cname] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1074 ]Append[",\n\tNumParams "] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1075 ]Append[ String[[[func]Inputs >>]Length] ] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1076 ]Append[")\n\n"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1077 ]Append[param check] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1078 ]Append[ [[func]Statements >>]Join[""] ] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1079 ]Append[freecall] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1080 ]Append[[func]Set Outputs] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1081 ]Append[[["EndFunc("]Append[fname]]Append[")\n"]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1082 ]Append["DISPATCH"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1083 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1084 }{ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1085 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1086 out <- [[[ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1087 Fold[_Output Defs C[?, ?, ?, func], |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1088 Fold[_Var Defs C[?], [[func]Naked Proto]Append["\n{"], [func]Variables >>], [func]Outputs >>] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1089 ]Append[[[func]Statements >>]Join[""]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1090 ]Append[[func]Set Outputs] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1091 ]Append["}"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1092 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1093 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1094 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1095 Blueprint C Program |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1096 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1097 Functions |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1098 Method Registry |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1099 Field Registry |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1100 Type Registry |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1101 Libraries |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1102 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1103 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1104 C Program[:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1105 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1106 out <- [[[[[Build[C Program()]]Functions <<[Dictionary[]]]Method Registry <<[C Method Registry[]]]Type Registry <<[C Type Registry[]]]Field Registry <<[C Field Registry[]]]Libraries <<[Dictionary[]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1107 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1108 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1109 Link@C Program[program,language,library:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1110 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1111 If[[library] = ["runtime"]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1112 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1113 out <- program |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1114 }{ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1115 langlibs <- [[program]Libraries >>]Index[language] {} |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1116 { langlibs <- Dictionary[] } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1117 out <- [program]Libraries <<[ [[program]Libraries >>]Set[language, [langlibs]Set[library, Yes]] ] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1118 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1119 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1120 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1121 Register Type@C Program[program,def:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1122 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1123 out <- [[[program]Type Registry <<[ [[program]Type Registry >>]Register Type[def] ] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1124 ]Method Registry <<[ [def]Register Methods[[program]Method Registry >>] ] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1125 ]Field Registry <<[ [def]Register Fields[[program]Field Registry >>] ] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1126 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1127 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1128 Create Type@C Program[program,name:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1129 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1130 out <- C Type[name] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1131 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1132 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1133 Create Function@C Program[program,name,inputs,outputs,convention:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1134 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1135 out <- C Function With Registry[name,inputs,outputs,convention, [program]Method Registry >>, [program]Field Registry >>, [program]Type Registry >>] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1136 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1137 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1138 Store Function@C Program[program,func:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1139 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1140 out <- [program]Functions <<[ [[program]Functions >>]Set[ [func]Name >>, func] ] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1141 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1142 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1143 Method?@C Program[program,funcname:is,isnot] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1144 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1145 is,isnot <- [[program]Method Registry >>]Method ID[funcname] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1146 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1147 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1148 _Defs C Program[text,func:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1149 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1150 def <- [func]Definitions |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1151 If[[def]=[""]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1152 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1153 out <- text |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1154 }{ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1155 out <- [text]Append[[def]Append["\n\n"]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1156 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1157 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1158 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1159 _Text C Program[text,func,type reg:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1160 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1161 out <- [text]Append[[[ [func]Type Registry <<[type reg] ]Text]Append["\n\n"]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1162 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1163 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1164 Combine Consts[consts,func:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1165 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1166 out <- Combine[[func]Constants >>, consts] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1167 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1168 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1169 _Consts C Program[text,value,name:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1170 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1171 out <- [text]Append[ [["object * _const_"]Append[Escape Rhope Name[name]]]Append[";\n"] ] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1172 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1173 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1174 Const Construct C[value,type reg:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1175 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1176 valtype <- Blueprint Of[value] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1177 [(Int8(),UInt8(),Int16(),UInt16(),Int32(),UInt32(),Int64(),UInt64())]Find[=[valtype,?]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1178 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1179 size <- [("8","16","32","64")]Index[[~]/[2]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1180 If[[~]Mod[2]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1181 { s <- "UI" } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1182 { s <- "I" } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1183 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1184 out <- [[[[[["make_" |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1185 ]Append[s] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1186 ]Append["nt"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1187 ]Append[size] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1188 ]Append["("] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1189 ]Append[String[value]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1190 ]Append[")"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1191 }{ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1192 If[[valtype] = [Type Instance()]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1193 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1194 //TODO: Support parametric types |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1195 typeid <- [type reg]Type ID[[value]Name >>] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1196 out <- [["make_Blueprint("]Append[typeid]]Append[")"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1197 }{ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1198 If[[valtype] = [Boolean()]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1199 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1200 If[value] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1201 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1202 out <- "make_Bool(1)" |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1203 }{ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1204 out <- "make_Bool(0)" |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1205 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1206 }{ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1207 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1208 [(String(),String Slice(),String Cat())]Find[=[valtype,?]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1209 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1210 out <- [["make_String(\""]Append[ [[[value]Replace["\\", "\\\\"]]Replace["\n", "\\n"]]Replace["\"", "\\\""] ]]Append["\")"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1211 }{ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1212 If[[valtype]=[Worker Literal()]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1213 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1214 //TODO: Figure out how to fully support these in nested cases |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1215 //or workaround the problem higher up in the food chain |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1216 [[value]Args >>]Last |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1217 { size <- String[[~]+[1]] } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1218 { size <- "0" } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1219 out <- [[[[[["make_Worker(FUNC_" |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1220 ]Append[Escape Rhope Name[[value]Name >>]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1221 ]Append[", "] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1222 ]Append[size] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1223 ]Append[", "] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1224 ]Append[String[Fold[+[1,?], 0, [value]Args >>]]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1225 ]Append[")"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1226 }{ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1227 out <- "UnhandledLiteralType" |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1228 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1229 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1230 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1231 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1232 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1233 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1234 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1235 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1236 _Set Worker Params C[text,param,num,type reg,name:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1237 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1238 out <- [text]Append[ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1239 [[[[[["\t((object **)(((t_Worker *)_const_" |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1240 ]Append[name] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1241 ]Append[")+1))["] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1242 ]Append[String[num]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1243 ]Append["] = "] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1244 ]Append[Const Construct C[param, type reg]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1245 ]Append[";\n"] ] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1246 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1247 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1248 _Set Consts C Program[text,value,name,type reg:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1249 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1250 valtype <- Blueprint Of[value] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1251 [(String(),String Cat(),String Slice(),Worker Literal(),List(),List Leaf())]Find[=[valtype,?]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1252 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1253 out <- text |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1254 }{ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1255 Const Construct C[value,type reg] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1256 { out <- [text]Append[ [[[["\t_const_"]Append[Escape Rhope Name[name]]]Append[" = "]]Append[~]]Append[";\n"] ] } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1257 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1258 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1259 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1260 _Set List Els[text,el,index,type reg:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1261 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1262 out <- [[text]Append[ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1263 [["\tinout[1] = " |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1264 ]Append[Const Construct C[index,type reg]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1265 ]Append[ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1266 [[";\n\tinout[2] = " |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1267 ]Append[Const Construct C[el, type reg]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1268 ]Append[";\n"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1269 ]]]Append["\trhope(FUNC_Set, inout, 3, 3);\n"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1270 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1271 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1272 _Set Late Consts C[text,value,name,type reg:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1273 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1274 valtype <- Blueprint Of[value] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1275 [(String(),String Cat(),String Slice(),Worker Literal(),List(),List Leaf())]Find[=[valtype,?]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1276 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1277 If[[~]>[3]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1278 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1279 out <- [Fold[_Set List Els[?, ?, ?, type reg], "\trhope(FUNC_List, inout, 0, 1);\n", value] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1280 ]Append[[["\t_const_"]Append[Escape Rhope Name[name]]]Append[" = inout[0];\n"]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1281 }{ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1282 Const Construct C[value,type reg] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1283 { init <- [text]Append[ [[[["\t_const_"]Append[Escape Rhope Name[name]]]Append[" = "]]Append[~]]Append[";\n"] ] } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1284 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1285 If[[valtype]=[Worker Literal()]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1286 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1287 out <- Fold[_Set Worker Params C[?, ?, ?, type reg, Escape Rhope Name[name]], init, [value]Args >>] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1288 }{ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1289 out <- Val[init] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1290 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1291 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1292 }{ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1293 out <- text |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1294 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1295 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1296 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1297 _Dispatch Switch Sub[text, num, name:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1298 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1299 out <- [[[[[text |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1300 ]Append["\tResumeEntry("] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1301 ]Append[String[num]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1302 ]Append[","] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1303 ]Append[name] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1304 ]Append[")\\\n"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1305 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1306 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1307 _Dispatch Switch[text,func,raw name:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1308 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1309 If[[[func]Convention >>] = ["rhope"]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1310 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1311 name <- Escape Rhope Name[raw name] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1312 out <- [[text]Append[ [["\tDispatchEntry("]Append[name]]Append[")\\\n"] ] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1313 ]Append[Fold[_Dispatch Switch Sub[?, ?, name], "", Range[1, [func]Resume Index >>]]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1314 }{ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1315 out <- text |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1316 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1317 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1318 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1319 _Dispatch Switch Methods[text,id,raw name:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1320 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1321 name <- Escape Rhope Name[raw name] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1322 out <- [text]Append[ [["\tDispatchEntry("]Append[name]]Append[")\\\n"] ] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1323 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1324 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1325 _Dispatch Enum Sub[text, num, name:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1326 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1327 out <- [[[[[text |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1328 ]Append["\tRES_"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1329 ]Append[String[num]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1330 ]Append["_"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1331 ]Append[name] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1332 ]Append[",\n"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1333 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1334 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1335 _Dispatch Enum[text,func,raw name:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1336 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1337 If[[[func]Convention >>] = ["rhope"]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1338 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1339 name <- Escape Rhope Name[raw name] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1340 out <- [[text]Append[ [["\tFUNC_"]Append[name]]Append[",\n"] ] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1341 ]Append[Fold[_Dispatch Enum Sub[?, ?, name], "", Range[1, [func]Resume Index >>]]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1342 }{ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1343 out <- text |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1344 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1345 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1346 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1347 _Dispatch Enum Methods[text,types,name:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1348 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1349 out <- [text]Append[ [["\tFUNC_"]Append[Escape Rhope Name[name]]]Append[",\n"] ] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1350 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1351 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1352 Dispatch@C Program[program,all methods:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1353 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1354 out <- [[[[["typedef enum {\n" |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1355 ]Append[Fold[_Dispatch Enum[?], |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1356 [Fold[_Dispatch Enum Methods[?], "", all methods]]Append["\tFUNC_Build,\n\tFUNC_BlueprintSP_Of,\n\tFUNC_ID,\n\tFUNC_BlueprintSP_FromSP_ID,\n"], |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1357 [program]Functions >>]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1358 ]Append["\tEND\n} funcids;\n\n"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1359 ]Append["#define DispatchEntries \\\n"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1360 ]Append[Fold[_Dispatch Switch[?], |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1361 [Fold[_Dispatch Switch Methods[?], "", all methods]]Append["\tDispatchEntry(Build)\\\n\tDispatchEntry(BlueprintSP_Of)\\\n\tDispatchEntry(ID)\\\n\tDispatchEntry(BlueprintSP_FromSP_ID)\\\n"], |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1362 [program]Functions >>]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1363 ]Append["\tEndEntry\n\n"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1364 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1365 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1366 Not Native[func:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1367 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1368 If[[[func]Convention >>] = ["rhope"]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1369 { out <- No } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1370 { out <- Yes } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1371 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1372 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1373 Native[func:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1374 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1375 out <- [[func]Convention >>] = ["rhope"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1376 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1377 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1378 Local Pointers[text,func:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1379 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1380 If[ [ [[[func]Variables >>]Length]+[[[func]Outputs >>]Length] ] = [0] ] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1381 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1382 out <- text |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1383 }{ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1384 out <- [text]Append[[["\tFuncDef("]Append[Escape Rhope Name[[func]Name >>]]]Append[")\n"]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1385 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1386 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1387 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1388 _Method to Types[dict,name,type:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1389 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1390 typelist <- [dict]Index[name] {} |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1391 { typelist <- () } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1392 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1393 out <- [dict]Set[name, [typelist]Append[[type]Name >>]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1394 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1395 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1396 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1397 _Field to Types[dict,field,type:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1398 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1399 name <- [field]Index[0] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1400 out <- _Method to Types[_Method to Types[dict, [name]Append[" >>"], type], [name]Append[" <<"], type] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1401 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1402 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1403 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1404 Method to Types[dict,type:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1405 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1406 out <- Fold[_Method to Types[?, ?, type], dict, [type]Methods >>] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1407 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1408 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1409 Field to Types[dict,type:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1410 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1411 out <- Fold[_Field to Types[?, ?, type], dict, [type]Fields >>] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1412 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1413 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1414 _Method Dispatch[text, type, method, reg: out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1415 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1416 out <- [[[[[[[text]Append["\tMethodDispatch("]]Append[ [reg]Type ID[type] ]]Append[","]]Append[Escape Rhope Name[method]]]Append[","]]Append[Escape Rhope Name[type]]]Append[")\n"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1417 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1418 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1419 Method Dispatch[text, types, method, reg: out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1420 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1421 out <- [[[Fold[_Method Dispatch[?, ?, method, reg], [[[text]Append["Method("]]Append[ Escape Rhope Name[method] ]]Append[")\n"], types] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1422 ]Append["EndMethod("] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1423 ]Append[Escape Rhope Name[method]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1424 ]Append[")\n\n"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1425 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1426 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1427 Text@C Program[program:out] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1428 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1429 type defs <- [[program]Type Registry >>]Definitions >> |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1430 constants <- Fold[Combine Consts[?], Dictionary[], [program]Functions >>] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1431 all methods <- Fold[Field to Types[?], Fold[Method to Types[?], Dictionary[], type defs], type defs] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1432 headers <- "#include <stdio.h> |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1433 #include <stdlib.h> |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1434 #include \"builtin.h\" |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1435 #include \"object.h\" |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1436 #include \"context.h\" |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1437 #include \"func.h\" |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1438 #include \"integer.h\" |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1439 #include \"blueprint.h\" |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1440 #include \"array.h\" |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1441 #include \"worker.h\" |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1442 #include \"bool.h\"\n\n" |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1443 out <- [[[[[[[[[[[[[[[headers |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1444 ]Append[[program]Dispatch[all methods]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1445 ]Append[[[program]Type Registry >>]Type Defs] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1446 ]Append[Fold[_Consts C Program[?], |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1447 Fold[_Defs C Program[?], "", [program]Functions >>], |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1448 constants]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1449 ]Append[Fold[_Text C Program[?, ?, [program]Type Registry >>], "", Filter[[program]Functions >>, Not Native[?]]]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1450 ]Append["\n |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1451 int32_t rhope(uint32_t func, object ** params, uint16_t numparams, uint16_t callspace) |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1452 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1453 uint16_t resume,idx, vcparam_offset, last_vcparam; |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1454 context * ct; |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1455 calldata * cdata, *temp_cdata, *my_cdata; |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1456 DispatchVar |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1457 FuncDef(Build) |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1458 FuncDef(BlueprintSP_Of) |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1459 FuncDef(ID) |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1460 FuncDef(BlueprintSP_FromSP_ID)\n"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1461 ]Append[Fold[Local Pointers[?], "", [program]Functions >>]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1462 ]Append[" |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1463 ct = new_context(); |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1464 cdata = alloc_cdata(ct, NULL, callspace); |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1465 cdata->num_params = numparams; |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1466 for(idx = 0; idx < numparams; ++idx) |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1467 cdata->params[idx] = params[idx]; |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1468 cdata->func = END; |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1469 DISPATCH\n"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1470 ]Append[Fold[Method Dispatch[?, ?, ?, [program]Type Registry >>], "", all methods]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1471 ]Append[" |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1472 Func(Build, |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1473 NumParams 1) |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1474 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1475 Param(0, TYPE_BLUEPRINT) |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1476 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1477 lv_Build->bp = ((t_Blueprint *)(cdata->params[0]))->bp; |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1478 release_ref(cdata->params[0]); |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1479 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1480 Ret(0, new_object_bp(lv_Build->bp)) |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1481 EndFunc(Build) |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1482 DISPATCH |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1483 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1484 Func(BlueprintSP_Of, |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1485 NumParams 1) |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1486 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1487 lv_BlueprintSP_Of->bp = get_blueprint(cdata->params[0]); |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1488 release_ref(cdata->params[0]); |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1489 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1490 Ret(0, new_object(TYPE_BLUEPRINT)) |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1491 ((t_Blueprint *)cdata->params[0])->bp = lv_BlueprintSP_Of->bp; |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1492 EndFunc(BlueprintSP_Of) |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1493 DISPATCH |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1494 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1495 Func(ID, NumParams 1) |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1496 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1497 Param(0, TYPE_BLUEPRINT) |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1498 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1499 lv_ID->id = new_object(TYPE_UINT32); |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1500 ((t_UInt32 *)lv_ID->id)->Num = ((t_Blueprint *)cdata->params[0])->bp->type_id; |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1501 release_ref(cdata->params[0]); |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1502 Ret(0, lv_ID->id) |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1503 EndFunc(ID) |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1504 DISPATCH |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1505 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1506 Func(BlueprintSP_FromSP_ID, NumParams 1) |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1507 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1508 Param(0, TYPE_UINT32) |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1509 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1510 lv_BlueprintSP_FromSP_ID->type = ((t_UInt32 *)cdata->params[0])->Num; |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1511 if (lv_BlueprintSP_FromSP_ID->type >= max_registered_type || !registered_types[lv_BlueprintSP_FromSP_ID->type]) { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1512 Ret(1, cdata->params[0]) |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1513 Ret(0, NULL) |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1514 } else { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1515 release_ref(cdata->params[0]); |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1516 Ret(0, new_object(TYPE_BLUEPRINT)) |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1517 ((t_Blueprint *)cdata->params[0])->bp = registered_types[lv_BlueprintSP_FromSP_ID->type]; |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1518 Ret(1, NULL) |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1519 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1520 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1521 EndFunc(BlueprintSP_FromSP_ID) |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1522 DISPATCH\n"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1523 ]Append[Fold[_Text C Program[?, ?, [program]Type Registry >>], "", Filter[[program]Functions >>, Native[?]]]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1524 ]Append[" |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1525 DO_END: |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1526 for(idx = 0; idx < cdata->num_params; ++idx) |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1527 params[idx] = cdata->params[idx]; |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1528 free_context(ct); |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1529 return cdata->num_params; |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1530 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1531 _exception: |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1532 puts(\"Exception! Trace follows:\"); |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1533 while(cdata && cdata->func != END) |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1534 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1535 printf(\"%d\\n\", cdata->func); |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1536 cdata = cdata->lastframe; |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1537 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1538 return -1; |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1539 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1540 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1541 #include \"builtin.c\" |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1542 #include \"array.c\" |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1543 #include \"worker.c\" |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1544 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1545 int main(int argc, char **argv) |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1546 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1547 blueprint * bp; |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1548 int numret; |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1549 int idx; |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1550 object * inout[2]; |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1551 register_builtin_types();\n\n"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1552 ]Append[ [[program]Type Registry >>]Type Inits[[program]Method Registry >>, [program]Field Registry >>] ] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1553 ]Append[Fold[_Set Consts C Program[?, ?, ?, [program]Type Registry >>], "", constants]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1554 ]Append[Fold[_Set Late Consts C[?, ?, ?, [program]Type Registry >>], "", constants]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1555 ]Append[" |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1556 rhope(FUNC_List, inout, 0, 1); |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1557 for (idx = 0; idx < argc; ++idx) |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1558 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1559 inout[1] = make_String(argv[idx]); |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1560 rhope(FUNC_Append, inout, 2, 2); |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1561 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1562 numret = rhope(FUNC_Main, inout, 1, 1); |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1563 if (!numret) |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1564 return 0; |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1565 if (numret < 0) |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1566 return numret; |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1567 if (get_blueprint(inout[0])->type_id == TYPE_INT32) |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1568 return ((t_Int32 *)inout[0])->Num; |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1569 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1570 rhope(FUNC_If, inout, 1, 2); |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1571 if (inout[0]) |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1572 return 0; |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1573 return 1; |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1574 }\n\n"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1575 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1576 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1577 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1578 |