Mercurial > repos > rhope
annotate cbackend.rhope @ 189:d0e3a13c1bd9 default tip
Remove old calculator example
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Fri, 07 Oct 2011 00:24:04 -0700 |
parents | ba35ab624ec2 |
children |
rev | line source |
---|---|
184
c6ba9fe45910
Strip _c from filenames of current compiler
Mike Pavone <pavone@retrodev.com>
parents:
176
diff
changeset
|
1 Import backendutils.rhope |
92
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 |
109
b7df624895b2
Hack to reduce overhead of Escape Rhope Name
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
117 Rhope Type to C[type,p:out,array] |
92
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 }{ |
142
7bbdc034e347
Fix some bugs. Get basic network code working (epoll listener + accept connections). Start porting webserver.
Mike Pavone <pavone@retrodev.com>
parents:
141
diff
changeset
|
157 [("UInt64","UInt32","UInt16","UInt8")]Find[=[[type]Name >>,?]] |
92
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"] } |
142
7bbdc034e347
Fix some bugs. Get basic network code working (epoll listener + accept connections). Start porting webserver.
Mike Pavone <pavone@retrodev.com>
parents:
141
diff
changeset
|
162 }{ |
7bbdc034e347
Fix some bugs. Get basic network code working (epoll listener + accept connections). Start porting webserver.
Mike Pavone <pavone@retrodev.com>
parents:
141
diff
changeset
|
163 ,regulartype <- If[[[type]Name >>]=["Context"]] |
7bbdc034e347
Fix some bugs. Get basic network code working (epoll listener + accept connections). Start porting webserver.
Mike Pavone <pavone@retrodev.com>
parents:
141
diff
changeset
|
164 { |
7bbdc034e347
Fix some bugs. Get basic network code working (epoll listener + accept connections). Start porting webserver.
Mike Pavone <pavone@retrodev.com>
parents:
141
diff
changeset
|
165 typename <- "context *" |
7bbdc034e347
Fix some bugs. Get basic network code working (epoll listener + accept connections). Start porting webserver.
Mike Pavone <pavone@retrodev.com>
parents:
141
diff
changeset
|
166 primitive <- Yes |
7bbdc034e347
Fix some bugs. Get basic network code working (epoll listener + accept connections). Start porting webserver.
Mike Pavone <pavone@retrodev.com>
parents:
141
diff
changeset
|
167 } |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
168 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
169 } |
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 Val[regulartype] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
173 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
174 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
|
175 primitive <- No |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
176 } |
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 typename <- type |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
180 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
|
181 variant <- "boxed" |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
182 primitive <- No |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
183 } |
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 Val[typename] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
186 { array <- "" } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
187 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
|
188 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
189 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
|
190 }{ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
191 [("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
|
192 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
193 If[primitive] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
194 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
195 prefix <- "" |
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 prefix <- "nt_" |
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 }{ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
200 prefix <- "t_" |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
201 } |
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 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
|
204 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
205 postfix <- "" |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
206 }{ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
207 postfix <- " *" |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
208 } |
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 If[primitive] |
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 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
|
213 }{ |
109
b7df624895b2
Hack to reduce overhead of Escape Rhope Name
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
214 escaped <- Escape Rhope Name[typename,p] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
215 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
216 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
|
217 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
218 |
109
b7df624895b2
Hack to reduce overhead of Escape Rhope Name
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
219 _Type Def C Type[text,field,p:out] |
92
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 name <- [field]Index[0] |
109
b7df624895b2
Hack to reduce overhead of Escape Rhope Name
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
222 ,postfix <- Rhope Type to C[[field]Index[1],p] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
223 { 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
|
224 |
109
b7df624895b2
Hack to reduce overhead of Escape Rhope Name
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
225 out <- [[[[text]Append[type]]Append[" "]]Append[[Escape Rhope Name[name,p]]Append[postfix]]]Append[";"] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
226 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
227 |
109
b7df624895b2
Hack to reduce overhead of Escape Rhope Name
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
228 Type Def@C Type[ctype,p:out] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
229 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
230 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
|
231 { |
109
b7df624895b2
Hack to reduce overhead of Escape Rhope Name
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
232 out <- [[[[_Type Def C Type["typedef struct {\n\tobject _SP_header;\n\t", [[ctype]Fields >>]Index[0], p]]Append["\n} t_"]]Append[Escape Rhope Name[[ctype]Name >>,p]]]Append[";"] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
233 ]Append[ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
234 [[[["typedef " |
109
b7df624895b2
Hack to reduce overhead of Escape Rhope Name
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
235 ]Append[Rhope Type to C[ [[[ctype]Fields >>]Index[0]]Index[1],p ]] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
236 ]Append[" nt_"] |
109
b7df624895b2
Hack to reduce overhead of Escape Rhope Name
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
237 ]Append[Escape Rhope Name[[ctype]Name >>,p]] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
238 ]Append[";"] ] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
239 }{ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
240 //HACK!!! |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
241 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
|
242 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
243 out <- "" |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
244 }{ |
96
5a08705f7610
Semi-broken cleanup of Array implementation
Mike Pavone <pavone@retrodev.com>
parents:
92
diff
changeset
|
245 [("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
|
246 { oend <- "\nMObject(" } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
247 { oend <- "\nObject(" } |
109
b7df624895b2
Hack to reduce overhead of Escape Rhope Name
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
248 out <- [Fold[_Type Def C Type[?,?,p], "OBegin", [ctype]Fields >>]]Append[ [[oend]Append[Escape Rhope Name[[ctype]Name >>,p]]]Append[")"] ] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
249 } |
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 |
139
a68e6828d896
Global stores and transactions are working. Definately leaks memory on retries. Probably a fair number of bugs to work out. However, a basic test program works.
Mike Pavone <pavone@retrodev.com>
parents:
136
diff
changeset
|
253 _Global Type Defs C[text,store,p:out] |
a68e6828d896
Global stores and transactions are working. Definately leaks memory on retries. Probably a fair number of bugs to work out. However, a basic test program works.
Mike Pavone <pavone@retrodev.com>
parents:
136
diff
changeset
|
254 { |
a68e6828d896
Global stores and transactions are working. Definately leaks memory on retries. Probably a fair number of bugs to work out. However, a basic test program works.
Mike Pavone <pavone@retrodev.com>
parents:
136
diff
changeset
|
255 estore <- Escape Rhope Name[[store]Name >>, p] |
a68e6828d896
Global stores and transactions are working. Definately leaks memory on retries. Probably a fair number of bugs to work out. However, a basic test program works.
Mike Pavone <pavone@retrodev.com>
parents:
136
diff
changeset
|
256 varnames <- Map[Keys[[store]Vars >>], Escape Rhope Name[?, p]] |
a68e6828d896
Global stores and transactions are working. Definately leaks memory on retries. Probably a fair number of bugs to work out. However, a basic test program works.
Mike Pavone <pavone@retrodev.com>
parents:
136
diff
changeset
|
257 out <- [text]Append[ |
a68e6828d896
Global stores and transactions are working. Definately leaks memory on retries. Probably a fair number of bugs to work out. However, a basic test program works.
Mike Pavone <pavone@retrodev.com>
parents:
136
diff
changeset
|
258 [[[[[[[[["typedef struct {\n\tobject header;\n\t" |
a68e6828d896
Global stores and transactions are working. Definately leaks memory on retries. Probably a fair number of bugs to work out. However, a basic test program works.
Mike Pavone <pavone@retrodev.com>
parents:
136
diff
changeset
|
259 ]Append[ [[ Map[varnames, ["object * gs_"]Append[?]] ]Join[";\n\t"] |
a68e6828d896
Global stores and transactions are working. Definately leaks memory on retries. Probably a fair number of bugs to work out. However, a basic test program works.
Mike Pavone <pavone@retrodev.com>
parents:
136
diff
changeset
|
260 ]Append[";\n} mutt_"]] |
a68e6828d896
Global stores and transactions are working. Definately leaks memory on retries. Probably a fair number of bugs to work out. However, a basic test program works.
Mike Pavone <pavone@retrodev.com>
parents:
136
diff
changeset
|
261 ]Append[estore] |
a68e6828d896
Global stores and transactions are working. Definately leaks memory on retries. Probably a fair number of bugs to work out. However, a basic test program works.
Mike Pavone <pavone@retrodev.com>
parents:
136
diff
changeset
|
262 ]Append[[[";\nmutable_object * gs_"]Append[estore]]Append[";\n\n"]] |
a68e6828d896
Global stores and transactions are working. Definately leaks memory on retries. Probably a fair number of bugs to work out. However, a basic test program works.
Mike Pavone <pavone@retrodev.com>
parents:
136
diff
changeset
|
263 ]Append[[["void gscopy_"]Append[estore]]Append[[["(object * obj)\n{\n\tmutt_"]Append[estore]]Append[[[" *mutt_obj = (mutt_"]Append[estore]]Append[" *)obj;\n\t"]]]] |
a68e6828d896
Global stores and transactions are working. Definately leaks memory on retries. Probably a fair number of bugs to work out. However, a basic test program works.
Mike Pavone <pavone@retrodev.com>
parents:
136
diff
changeset
|
264 ]Append[ [Map[varnames, ["add_ref(mutt_obj->gs_"]Append[?]]]Join[");\n\t"] ] |
a68e6828d896
Global stores and transactions are working. Definately leaks memory on retries. Probably a fair number of bugs to work out. However, a basic test program works.
Mike Pavone <pavone@retrodev.com>
parents:
136
diff
changeset
|
265 ]Append[");\n}\n\n"] |
a68e6828d896
Global stores and transactions are working. Definately leaks memory on retries. Probably a fair number of bugs to work out. However, a basic test program works.
Mike Pavone <pavone@retrodev.com>
parents:
136
diff
changeset
|
266 ]Append[[["void gscleanup_"]Append[estore]]Append[[["(object * obj)\n{\n\tmutt_"]Append[estore]]Append[[[" *mutt_obj = (mutt_"]Append[estore]]Append[" *)obj;\n\t"]]]] |
a68e6828d896
Global stores and transactions are working. Definately leaks memory on retries. Probably a fair number of bugs to work out. However, a basic test program works.
Mike Pavone <pavone@retrodev.com>
parents:
136
diff
changeset
|
267 ]Append[ [Map[varnames, ["release_ref(mutt_obj->gs_"]Append[?]]]Join[");\n\t"] ] |
a68e6828d896
Global stores and transactions are working. Definately leaks memory on retries. Probably a fair number of bugs to work out. However, a basic test program works.
Mike Pavone <pavone@retrodev.com>
parents:
136
diff
changeset
|
268 ]Append[");\n}\n\n"] ] |
a68e6828d896
Global stores and transactions are working. Definately leaks memory on retries. Probably a fair number of bugs to work out. However, a basic test program works.
Mike Pavone <pavone@retrodev.com>
parents:
136
diff
changeset
|
269 } |
a68e6828d896
Global stores and transactions are working. Definately leaks memory on retries. Probably a fair number of bugs to work out. However, a basic test program works.
Mike Pavone <pavone@retrodev.com>
parents:
136
diff
changeset
|
270 |
a68e6828d896
Global stores and transactions are working. Definately leaks memory on retries. Probably a fair number of bugs to work out. However, a basic test program works.
Mike Pavone <pavone@retrodev.com>
parents:
136
diff
changeset
|
271 _Global Type Inits C[text,store,p:out] |
a68e6828d896
Global stores and transactions are working. Definately leaks memory on retries. Probably a fair number of bugs to work out. However, a basic test program works.
Mike Pavone <pavone@retrodev.com>
parents:
136
diff
changeset
|
272 { |
a68e6828d896
Global stores and transactions are working. Definately leaks memory on retries. Probably a fair number of bugs to work out. However, a basic test program works.
Mike Pavone <pavone@retrodev.com>
parents:
136
diff
changeset
|
273 estore <- Escape Rhope Name[[store]Name >>, p] |
a68e6828d896
Global stores and transactions are working. Definately leaks memory on retries. Probably a fair number of bugs to work out. However, a basic test program works.
Mike Pavone <pavone@retrodev.com>
parents:
136
diff
changeset
|
274 out <- [text]Append[ [[[[[[[[["\tbp = register_type(sizeof(mutt_"]Append[estore]]Append[ [[[")-sizeof(object), NULL, gscopy_"]Append[estore]]Append[", gscleanup_"]]Append[estore] ]]Append[");\n\tgs_"]]Append[estore]]Append[" = (mutable_object *)new_object(TYPE_MUTABLEGLOBAL);\n\tgs_"]]Append[estore]]Append["->data = new_object_bp(bp);\n\tgs_"]]Append[estore]]Append["->version = 0;"] ] |
a68e6828d896
Global stores and transactions are working. Definately leaks memory on retries. Probably a fair number of bugs to work out. However, a basic test program works.
Mike Pavone <pavone@retrodev.com>
parents:
136
diff
changeset
|
275 } |
a68e6828d896
Global stores and transactions are working. Definately leaks memory on retries. Probably a fair number of bugs to work out. However, a basic test program works.
Mike Pavone <pavone@retrodev.com>
parents:
136
diff
changeset
|
276 |
109
b7df624895b2
Hack to reduce overhead of Escape Rhope Name
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
277 _Type Init C[type name,method reg,text,method,p:out] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
278 { |
109
b7df624895b2
Hack to reduce overhead of Escape Rhope Name
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
279 out <- [[text]Append[[["\n\tadd_method(bp, "]Append[ [method reg]Method ID[method] ]]Append[ [[", MethodName("]Append[Escape Rhope Name[method,p]]]Append[[","]Append[Escape Rhope Name[type name,p]]]]]]Append["));"] |
92
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 |
109
b7df624895b2
Hack to reduce overhead of Escape Rhope Name
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
282 _Type Init C Field[type name,field reg,text,field,p:out] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
283 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
284 fname <- [field]Index[0] |
109
b7df624895b2
Hack to reduce overhead of Escape Rhope Name
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
285 out <- [[[[text]Append[[["\n\tadd_getter(bp, "]Append[ String[[field reg]Field ID[fname]] ]]Append[ [[", MethodName("]Append[Escape Rhope Name[[fname]Append[" >>"],p]]]Append[[","]Append[Escape Rhope Name[type name,p]]]]]]Append["));"] |
b7df624895b2
Hack to reduce overhead of Escape Rhope Name
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
286 ]Append[[["\n\tadd_setter(bp, "]Append[ String[[field reg]Field ID[fname]] ]]Append[ [[", MethodName("]Append[Escape Rhope Name[[fname]Append[" <<"],p]]]Append[[","]Append[Escape Rhope Name[type name,p]]]]]]Append["));"] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
287 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
288 |
109
b7df624895b2
Hack to reduce overhead of Escape Rhope Name
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
289 Type Init@C Type[ctype,id,method reg,field reg,p:out] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
290 { |
96
5a08705f7610
Semi-broken cleanup of Array implementation
Mike Pavone <pavone@retrodev.com>
parents:
92
diff
changeset
|
291 [("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
|
292 { size <- "-1" } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
293 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
294 [("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
|
295 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
296 [[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
|
297 { 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
|
298 }{ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
299 [("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
|
300 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
301 [[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
|
302 { 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
|
303 }{ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
304 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
|
305 { typename <- "blueprint *" } |
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 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
|
308 { typename <- "int32_t" } |
109
b7df624895b2
Hack to reduce overhead of Escape Rhope Name
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
309 { typename <- ["nt_"]Append[Escape Rhope Name[[ctype]Name >>,p]] } |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
310 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
311 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
312 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
313 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
|
314 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
315 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
|
316 ]Append[id] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
317 ]Append[ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
318 [[", "]Append[size] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
319 ]Append[ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
320 [", (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
|
321 [ |
109
b7df624895b2
Hack to reduce overhead of Escape Rhope Name
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
322 [[[[Escape Rhope Name[[ctype]Init >>,p] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
323 ]Append[", (special_func)"] |
109
b7df624895b2
Hack to reduce overhead of Escape Rhope Name
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
324 ]Append[Escape Rhope Name[[ctype]Copy >> ,p]] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
325 ]Append[", (special_func)"] |
109
b7df624895b2
Hack to reduce overhead of Escape Rhope Name
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
326 ]Append[Escape Rhope Name[[ctype]Cleanup >>,p]] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
327 ]Append[");"]]] ] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
328 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
|
329 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
330 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
331 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
|
332 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
333 Lookup |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
334 Definitions |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
335 Next ID |
109
b7df624895b2
Hack to reduce overhead of Escape Rhope Name
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
336 Escape Pattern |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
337 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
338 |
109
b7df624895b2
Hack to reduce overhead of Escape Rhope Name
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
339 C Type Registry[p:out] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
340 { |
109
b7df624895b2
Hack to reduce overhead of Escape Rhope Name
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
341 out <- [[[[Build[C Type Registry()]]Lookup << [ |
96
5a08705f7610
Semi-broken cleanup of Array implementation
Mike Pavone <pavone@retrodev.com>
parents:
92
diff
changeset
|
342 [[[[[[[[[[[[[[[[[[[Dictionary[] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
343 ]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
|
344 ]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
|
345 ]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
|
346 ]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
|
347 ]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
|
348 ]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
|
349 ]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
|
350 ]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
|
351 ]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
|
352 ]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
|
353 ]Set["Float64", "TYPE_FLOAT64"] //11 |
118
b3f56e1d54a0
Merged changes from interpreted version of compiler to compiled version
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
354 ]Set["Real Number", "TYPE_FLOAT64"] |
b3f56e1d54a0
Merged changes from interpreted version of compiler to compiled version
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
355 ]Set["Blueprint", "TYPE_BLUEPRINT"] //12 |
b3f56e1d54a0
Merged changes from interpreted version of compiler to compiled version
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
356 ]Set["Array", "TYPE_ARRAY"] //13 |
b3f56e1d54a0
Merged changes from interpreted version of compiler to compiled version
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
357 ]Set["Boxed Array", "TYPE_BOXEDARRAY"]//14 |
135
18a4403fe576
Javascript backend can now produce broken output. Needs fixes plus port of standard lib
Mike Pavone <pavone@retrodev.com>
parents:
127
diff
changeset
|
358 ]Set["Worker", "TYPE_WORKER"] //15 |
118
b3f56e1d54a0
Merged changes from interpreted version of compiler to compiled version
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
359 ]Set["Method Missing Exception", "TYPE_METHODMISSINGEXCEPTION"] //16 |
b3f56e1d54a0
Merged changes from interpreted version of compiler to compiled version
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
360 ]Set["Field Missing Exception", "TYPE_FIELDMISSINGEXCEPTION"] //17 |
b3f56e1d54a0
Merged changes from interpreted version of compiler to compiled version
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
361 ]Set["Wrong Type Exception", "TYPE_WRONGTYPEEXCEPTION"]] //18 |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
362 ]Definitions << [Dictionary[]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
363 ]Next ID <<[0] |
109
b7df624895b2
Hack to reduce overhead of Escape Rhope Name
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
364 ]Escape Pattern <<[p] |
92
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 |
109
b7df624895b2
Hack to reduce overhead of Escape Rhope Name
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
367 _Type Defs C[text,def,p:out] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
368 { |
109
b7df624895b2
Hack to reduce overhead of Escape Rhope Name
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
369 out <- [[text]Append[[def]Type Def[p]]]Append["\n\n"] |
92
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 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
|
373 { |
109
b7df624895b2
Hack to reduce overhead of Escape Rhope Name
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
374 out <- Fold[_Type Defs C[?,?,[reg]Escape Pattern >>], "", [reg]Definitions >>] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
375 } |
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 _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
|
378 { |
109
b7df624895b2
Hack to reduce overhead of Escape Rhope Name
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
379 out <- [[text]Append[ [def]Type Init[[reg]Type ID[name], method reg, field reg,[reg]Escape Pattern >>] ]]Append["\n\n"] |
92
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 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
|
383 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
384 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
|
385 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
386 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
387 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
|
388 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
389 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
|
390 [[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
|
391 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
392 [[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
|
393 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
394 out <- reg |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
395 }{ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
396 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
|
397 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
398 }{ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
399 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
|
400 ]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
|
401 ]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
|
402 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
403 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
404 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
405 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
|
406 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
407 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
|
408 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
409 ,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
|
410 { out <- "0" } |
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 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
414 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
|
415 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
416 ,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
|
417 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
418 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
|
419 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
420 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
421 |
127
50406500334d
Port availability of type names at runtime to compiled compiler
Mike Pavone <pavone@retrodev.com>
parents:
123
diff
changeset
|
422 Defined?@C Type Registry[reg,name:yep,nope] |
50406500334d
Port availability of type names at runtime to compiled compiler
Mike Pavone <pavone@retrodev.com>
parents:
123
diff
changeset
|
423 { |
50406500334d
Port availability of type names at runtime to compiled compiler
Mike Pavone <pavone@retrodev.com>
parents:
123
diff
changeset
|
424 yep,nope <- [[reg]Definitions >>]Index[name] |
50406500334d
Port availability of type names at runtime to compiled compiler
Mike Pavone <pavone@retrodev.com>
parents:
123
diff
changeset
|
425 } |
50406500334d
Port availability of type names at runtime to compiled compiler
Mike Pavone <pavone@retrodev.com>
parents:
123
diff
changeset
|
426 |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
427 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
|
428 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
429 Name |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
430 Inputs |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
431 Outputs |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
432 Convention |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
433 Variables |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
434 Statements |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
435 Method Registry |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
436 Field Registry |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
437 Type Registry |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
438 Constants |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
439 Input Types |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
440 Output Types |
139
a68e6828d896
Global stores and transactions are working. Definately leaks memory on retries. Probably a fair number of bugs to work out. However, a basic test program works.
Mike Pavone <pavone@retrodev.com>
parents:
136
diff
changeset
|
441 Uses |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
442 Resume Index |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
443 Last NumParams |
109
b7df624895b2
Hack to reduce overhead of Escape Rhope Name
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
444 Escape Pattern |
92
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 |
109
b7df624895b2
Hack to reduce overhead of Escape Rhope Name
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
447 C Function[name,inputs,outputs,convention,p:out] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
448 { |
109
b7df624895b2
Hack to reduce overhead of Escape Rhope Name
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
449 out <- C Function With Registry[name,inputs,outputs,convention, C Method Registry[], C Field Registry[], C Type Registry[p],p] |
92
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 |
109
b7df624895b2
Hack to reduce overhead of Escape Rhope Name
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
452 C Function With Registry[name,inputs,outputs,convention,registry,field reg,type reg,p:out] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
453 { |
139
a68e6828d896
Global stores and transactions are working. Definately leaks memory on retries. Probably a fair number of bugs to work out. However, a basic test program works.
Mike Pavone <pavone@retrodev.com>
parents:
136
diff
changeset
|
454 out <- [[[[[[[[[[[[[[[[Build[C Function()] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
455 ]Name <<[name] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
456 ]Inputs <<[inputs] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
457 ]Outputs <<[outputs] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
458 ]Convention <<[convention] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
459 ]Variables <<[Dictionary[]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
460 ]Statements <<[()] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
461 ]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
|
462 ]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
|
463 ]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
|
464 ]Constants <<[Dictionary[]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
465 ]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
|
466 ]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
|
467 ]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
|
468 ]Last NumParams <<[-1] |
109
b7df624895b2
Hack to reduce overhead of Escape Rhope Name
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
469 ]Escape Pattern <<[p] |
139
a68e6828d896
Global stores and transactions are working. Definately leaks memory on retries. Probably a fair number of bugs to work out. However, a basic test program works.
Mike Pavone <pavone@retrodev.com>
parents:
136
diff
changeset
|
470 ]Uses <<[()] |
92
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 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
473 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
|
474 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
475 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
|
476 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
477 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
478 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
|
479 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
480 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
|
481 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
482 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
483 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
|
484 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
485 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
|
486 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
487 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
488 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
|
489 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
490 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
|
491 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
492 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
493 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
|
494 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
495 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
|
496 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
497 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
498 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
|
499 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
500 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
|
501 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
502 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
503 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
|
504 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
505 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
|
506 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
|
507 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
|
508 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
|
509 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
510 |
136
fc3815b7462f
Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
135
diff
changeset
|
511 Make AddRef Op@C Function[func,val:out] |
fc3815b7462f
Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
135
diff
changeset
|
512 { |
fc3815b7462f
Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
135
diff
changeset
|
513 out <- [["add_ref((object *)"]Append[ [val]Make Op[func] ]]Append[")"] |
fc3815b7462f
Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
135
diff
changeset
|
514 } |
fc3815b7462f
Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
135
diff
changeset
|
515 |
169
fd06fb07762a
Basic inlining of arithmetic and comparison operations on integer types
Mike Pavone <pavone@retrodev.com>
parents:
162
diff
changeset
|
516 Cast Value@C Function[func,op,type:out] |
fd06fb07762a
Basic inlining of arithmetic and comparison operations on integer types
Mike Pavone <pavone@retrodev.com>
parents:
162
diff
changeset
|
517 { |
fd06fb07762a
Basic inlining of arithmetic and comparison operations on integer types
Mike Pavone <pavone@retrodev.com>
parents:
162
diff
changeset
|
518 tname <- Rhope Type to C[type, [func]Escape Pattern >>] |
fd06fb07762a
Basic inlining of arithmetic and comparison operations on integer types
Mike Pavone <pavone@retrodev.com>
parents:
162
diff
changeset
|
519 out <- [[[["(("]Append[tname]]Append[")"]]Append[Make Op[op, func]]]Append[")"] |
fd06fb07762a
Basic inlining of arithmetic and comparison operations on integer types
Mike Pavone <pavone@retrodev.com>
parents:
162
diff
changeset
|
520 } |
fd06fb07762a
Basic inlining of arithmetic and comparison operations on integer types
Mike Pavone <pavone@retrodev.com>
parents:
162
diff
changeset
|
521 |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
522 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
|
523 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
524 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
|
525 } |
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 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
|
528 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
529 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
|
530 } |
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 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
|
533 { |
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 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
|
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 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
|
538 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
539 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
|
540 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
541 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
542 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
|
543 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
544 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
|
545 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
546 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
547 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
|
548 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
549 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
|
550 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
551 |
123 | 552 BitAnd@C Function[func,source1,source2,dest:out] |
553 { | |
554 out <- [func]Add Operator Statement[source1,source2,dest," & "] | |
555 } | |
556 | |
557 BitOr@C Function[func,source1,source2,dest:out] | |
558 { | |
559 out <- [func]Add Operator Statement[source1,source2,dest," | "] | |
560 } | |
561 | |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
562 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
|
563 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
564 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
|
565 } |
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 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
|
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 <- [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
|
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 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
|
573 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
574 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
|
575 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
576 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
577 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
|
578 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
579 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
|
580 } |
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 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
|
583 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
584 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
|
585 } |
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 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
|
588 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
589 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
|
590 } |
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 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
|
593 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
594 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
|
595 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
|
596 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
|
597 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
598 |
170
ac5c2d78663f
Inline calls to If@Boolean when static type info is present
Mike Pavone <pavone@retrodev.com>
parents:
169
diff
changeset
|
599 |
172
926b56a43f47
Fix some bugs related to inlining
Mike Pavone <pavone@retrodev.com>
parents:
171
diff
changeset
|
600 |
176 | 601 |
184
c6ba9fe45910
Strip _c from filenames of current compiler
Mike Pavone <pavone@retrodev.com>
parents:
176
diff
changeset
|
602 |
186
ba35ab624ec2
Add support for raw C function output from C backend as well as an option to use Boehm-GC instead of reference counting
Mike Pavone <pavone@retrodev.com>
parents:
184
diff
changeset
|
603 |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
604 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
|
605 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
606 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
|
607 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
|
608 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
|
609 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
610 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
611 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
|
612 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
613 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
|
614 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
|
615 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
616 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
617 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
|
618 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
619 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
|
620 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
|
621 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
622 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
623 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
|
624 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
625 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
|
626 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
|
627 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
628 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
629 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
|
630 { |
109
b7df624895b2
Hack to reduce overhead of Escape Rhope Name
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
631 var <- ["_const_"]Append[Escape Rhope Name[const,[func]Escape Pattern >>]] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
632 If[doaddref] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
633 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
634 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
|
635 }{ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
636 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
|
637 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
638 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
639 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
640 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
|
641 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
642 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
|
643 [(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
|
644 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
645 [[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
|
646 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
647 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
|
648 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
649 }{ |
171
a32afde77abb
Remove some debug Print calls from compiler
Mike Pavone <pavone@retrodev.com>
parents:
170
diff
changeset
|
650 type <- [[func]Variables >>]Index[var] {} |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
651 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
652 [[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
|
653 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
654 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
|
655 }{ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
656 //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
|
657 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
|
658 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
659 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
660 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
661 }{ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
662 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
|
663 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
664 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
|
665 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
666 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
|
667 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
668 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
|
669 }{ |
109
b7df624895b2
Hack to reduce overhead of Escape Rhope Name
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
670 rvar <- [[[["(("]Append[ Rhope Type to C[type,[func]Escape Pattern >>] ]]Append[")("]]Append[as op]]Append["))"] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
671 } |
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 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
|
674 } |
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 [[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
|
677 { access <- "->" } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
678 { access <- "->payload." } |
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 //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
|
681 access <- "->" |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
682 } |
109
b7df624895b2
Hack to reduce overhead of Escape Rhope Name
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
683 out <- [[rvar]Append[access]]Append[Escape Rhope Name[field,[func]Escape Pattern >>]] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
684 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
685 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
686 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
|
687 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
688 out <- func |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
689 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
|
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 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
|
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 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
695 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
|
696 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
697 |
139
a68e6828d896
Global stores and transactions are working. Definately leaks memory on retries. Probably a fair number of bugs to work out. However, a basic test program works.
Mike Pavone <pavone@retrodev.com>
parents:
136
diff
changeset
|
698 Global Reference@C Function[func,store,var:out] |
a68e6828d896
Global stores and transactions are working. Definately leaks memory on retries. Probably a fair number of bugs to work out. However, a basic test program works.
Mike Pavone <pavone@retrodev.com>
parents:
136
diff
changeset
|
699 { |
a68e6828d896
Global stores and transactions are working. Definately leaks memory on retries. Probably a fair number of bugs to work out. However, a basic test program works.
Mike Pavone <pavone@retrodev.com>
parents:
136
diff
changeset
|
700 |
a68e6828d896
Global stores and transactions are working. Definately leaks memory on retries. Probably a fair number of bugs to work out. However, a basic test program works.
Mike Pavone <pavone@retrodev.com>
parents:
136
diff
changeset
|
701 estore <- Escape Rhope Name[store,[func]Escape Pattern >>] |
186
ba35ab624ec2
Add support for raw C function output from C backend as well as an option to use Boehm-GC instead of reference counting
Mike Pavone <pavone@retrodev.com>
parents:
184
diff
changeset
|
702 out <- [[[[[ [["((mutt_"]Append[estore]]Append["*)lv("]]Append[Escape Rhope Name[[func]Name >>,[func]Escape Pattern >>]]]Append[", gs_"]]Append[estore]]Append[")->local_data)->gs_"]]Append[Escape Rhope Name[var,[func]Escape Pattern >>]] |
139
a68e6828d896
Global stores and transactions are working. Definately leaks memory on retries. Probably a fair number of bugs to work out. However, a basic test program works.
Mike Pavone <pavone@retrodev.com>
parents:
136
diff
changeset
|
703 } |
118
b3f56e1d54a0
Merged changes from interpreted version of compiler to compiled version
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
704 |
139
a68e6828d896
Global stores and transactions are working. Definately leaks memory on retries. Probably a fair number of bugs to work out. However, a basic test program works.
Mike Pavone <pavone@retrodev.com>
parents:
136
diff
changeset
|
705 Set Global@C Function[func,store,var,src:out] |
a68e6828d896
Global stores and transactions are working. Definately leaks memory on retries. Probably a fair number of bugs to work out. However, a basic test program works.
Mike Pavone <pavone@retrodev.com>
parents:
136
diff
changeset
|
706 { |
a68e6828d896
Global stores and transactions are working. Definately leaks memory on retries. Probably a fair number of bugs to work out. However, a basic test program works.
Mike Pavone <pavone@retrodev.com>
parents:
136
diff
changeset
|
707 estore <- Escape Rhope Name[store,[func]Escape Pattern >>] |
186
ba35ab624ec2
Add support for raw C function output from C backend as well as an option to use Boehm-GC instead of reference counting
Mike Pavone <pavone@retrodev.com>
parents:
184
diff
changeset
|
708 cell pointer <- [[[["lv("]Append[Escape Rhope Name[[func]Name >>,[func]Escape Pattern >>]]]Append[", gs_"]]Append[estore]]Append[")"] |
139
a68e6828d896
Global stores and transactions are working. Definately leaks memory on retries. Probably a fair number of bugs to work out. However, a basic test program works.
Mike Pavone <pavone@retrodev.com>
parents:
136
diff
changeset
|
709 out <- [[[[func]Add Statement[[["tmp = copy_object("]Append[[cell pointer]Append["->local_data"]]]Append[")"]] |
a68e6828d896
Global stores and transactions are working. Definately leaks memory on retries. Probably a fair number of bugs to work out. However, a basic test program works.
Mike Pavone <pavone@retrodev.com>
parents:
136
diff
changeset
|
710 ]Add Statement[ [[[["((mutt_"]Append[estore]]Append[" *)tmp)->gs_"]]Append[Escape Rhope Name[var, [func]Escape Pattern >>]]]Append[[" = "]Append[[src]Make Op[func]]] ] |
a68e6828d896
Global stores and transactions are working. Definately leaks memory on retries. Probably a fair number of bugs to work out. However, a basic test program works.
Mike Pavone <pavone@retrodev.com>
parents:
136
diff
changeset
|
711 ]Add Statement[[cell pointer]Append["->local_data = tmp"]] |
a68e6828d896
Global stores and transactions are working. Definately leaks memory on retries. Probably a fair number of bugs to work out. However, a basic test program works.
Mike Pavone <pavone@retrodev.com>
parents:
136
diff
changeset
|
712 ]Add Statement[[cell pointer]Append["->local_version++"]] |
a68e6828d896
Global stores and transactions are working. Definately leaks memory on retries. Probably a fair number of bugs to work out. However, a basic test program works.
Mike Pavone <pavone@retrodev.com>
parents:
136
diff
changeset
|
713 } |
123 | 714 |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
715 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
|
716 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
717 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
|
718 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
719 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
720 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
|
721 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
722 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
|
723 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
|
724 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
725 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
726 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
|
727 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
728 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
|
729 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
|
730 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
|
731 [[[[[dest |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
732 ]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
|
733 ]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
|
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[source] |
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 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
738 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
739 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
|
740 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
741 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
|
742 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
|
743 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
|
744 [[[["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
|
745 ]Append[source] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
746 ]Append[", &"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
747 ]Append[dest] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
748 ]Append[")"] ] |
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 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
|
752 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
753 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
|
754 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
|
755 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
|
756 } |
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 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
|
759 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
760 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
|
761 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
|
762 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
|
763 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
764 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
765 _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
|
766 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
767 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
|
768 [[[["SetParam(" |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
769 ]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
|
770 ]Append[", "] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
771 ]Append[val] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
772 ]Append[")"] |
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 } |
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 _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
|
777 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
778 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
|
779 [[[[[["VCSetParam(" |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
780 ]Append[worker] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
781 ]Append[", "] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
782 ]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
|
783 ]Append[", "] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
784 ]Append[val] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
785 ]Append[")"] |
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 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
788 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
789 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
|
790 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
791 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
|
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 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
|
795 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
796 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
|
797 rargs <- Map[args, Make Op[?, func]] |
142
7bbdc034e347
Fix some bugs. Get basic network code working (epoll listener + accept connections). Start porting webserver.
Mike Pavone <pavone@retrodev.com>
parents:
141
diff
changeset
|
798 |
7bbdc034e347
Fix some bugs. Get basic network code working (epoll listener + accept connections). Start porting webserver.
Mike Pavone <pavone@retrodev.com>
parents:
141
diff
changeset
|
799 If[[[[func]Variables >>]Length]+[[[func]Outputs >>]Length]] |
7bbdc034e347
Fix some bugs. Get basic network code working (epoll listener + accept connections). Start porting webserver.
Mike Pavone <pavone@retrodev.com>
parents:
141
diff
changeset
|
800 { |
7bbdc034e347
Fix some bugs. Get basic network code working (epoll listener + accept connections). Start porting webserver.
Mike Pavone <pavone@retrodev.com>
parents:
141
diff
changeset
|
801 valcall <- "ValCall(" |
7bbdc034e347
Fix some bugs. Get basic network code working (epoll listener + accept connections). Start porting webserver.
Mike Pavone <pavone@retrodev.com>
parents:
141
diff
changeset
|
802 postlude <- "ValCallPostlude(" |
7bbdc034e347
Fix some bugs. Get basic network code working (epoll listener + accept connections). Start porting webserver.
Mike Pavone <pavone@retrodev.com>
parents:
141
diff
changeset
|
803 }{ |
7bbdc034e347
Fix some bugs. Get basic network code working (epoll listener + accept connections). Start porting webserver.
Mike Pavone <pavone@retrodev.com>
parents:
141
diff
changeset
|
804 valcall <- "ValCallNoLocals(" |
7bbdc034e347
Fix some bugs. Get basic network code working (epoll listener + accept connections). Start porting webserver.
Mike Pavone <pavone@retrodev.com>
parents:
141
diff
changeset
|
805 postlude <- "ValCallNoLocalsPostlude(" |
7bbdc034e347
Fix some bugs. Get basic network code working (epoll listener + accept connections). Start porting webserver.
Mike Pavone <pavone@retrodev.com>
parents:
141
diff
changeset
|
806 } |
92
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 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
|
809 { |
118
b3f56e1d54a0
Merged changes from interpreted version of compiler to compiled version
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
810 prepped <- [[func]Add Raw Line[ |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
811 [[[["VCPrepCall(" |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
812 ]Append[worker] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
813 ]Append[", "] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
814 ]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
|
815 ]Append[")"] ] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
816 ]Last NumParams <<[[rargs]Length] |
118
b3f56e1d54a0
Merged changes from interpreted version of compiler to compiled version
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
817 }{ |
b3f56e1d54a0
Merged changes from interpreted version of compiler to compiled version
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
818 prepped <- [[func]Add Raw Line[ |
b3f56e1d54a0
Merged changes from interpreted version of compiler to compiled version
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
819 [[[[[["VCRePrepCall(" |
b3f56e1d54a0
Merged changes from interpreted version of compiler to compiled version
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
820 ]Append[worker] |
b3f56e1d54a0
Merged changes from interpreted version of compiler to compiled version
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
821 ]Append[", "] |
b3f56e1d54a0
Merged changes from interpreted version of compiler to compiled version
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
822 ]Append[String[[rargs]Length]] |
b3f56e1d54a0
Merged changes from interpreted version of compiler to compiled version
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
823 ]Append[", "] |
b3f56e1d54a0
Merged changes from interpreted version of compiler to compiled version
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
824 ]Append[String[[func]Last NumParams >>]] |
b3f56e1d54a0
Merged changes from interpreted version of compiler to compiled version
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
825 ]Append[")"] ] |
b3f56e1d54a0
Merged changes from interpreted version of compiler to compiled version
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
826 ]Last NumParams <<[[rargs]Length] |
b3f56e1d54a0
Merged changes from interpreted version of compiler to compiled version
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
827 } |
92
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 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
830 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
|
831 ]Add Raw Line[ |
142
7bbdc034e347
Fix some bugs. Get basic network code working (epoll listener + accept connections). Start porting webserver.
Mike Pavone <pavone@retrodev.com>
parents:
141
diff
changeset
|
832 [[[[[[[[valcall |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
833 ]Append[worker] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
834 ]Append[", "] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
835 ]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
|
836 ]Append[", "] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
837 ]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
|
838 ]Append[", "] |
109
b7df624895b2
Hack to reduce overhead of Escape Rhope Name
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
839 ]Append[Escape Rhope Name[[func]Name >>,[func]Escape Pattern >>]] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
840 ]Append[")"]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
841 ]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
|
842 ]Add Raw Line[ |
142
7bbdc034e347
Fix some bugs. Get basic network code working (epoll listener + accept connections). Start porting webserver.
Mike Pavone <pavone@retrodev.com>
parents:
141
diff
changeset
|
843 [[[[postlude |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
844 ]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
|
845 ]Append[", "] |
109
b7df624895b2
Hack to reduce overhead of Escape Rhope Name
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
846 ]Append[Escape Rhope Name[[func]Name >>,[func]Escape Pattern >>]] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
847 ]Append[")"]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
848 ]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
|
849 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
850 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
851 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
|
852 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
853 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
|
854 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
855 //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
|
856 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
|
857 }{ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
858 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
|
859 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
860 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
|
861 last numparams <- [func]Last NumParams >> |
159
d1e206ff75f9
Fix some bugs involving calling a worker object
Mike Pavone <pavone@retrodev.com>
parents:
154
diff
changeset
|
862 out <- [[[[[[[func]Add Raw Line[[["if (get_blueprint("]Append[Make Op[Strip Addref[to call], func]]]Append[")->type_id == TYPE_WORKER) {"]] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
863 ]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
|
864 ]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
|
865 ]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
|
866 ]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
|
867 ]Add Raw Line["}"] |
159
d1e206ff75f9
Fix some bugs involving calling a worker object
Mike Pavone <pavone@retrodev.com>
parents:
154
diff
changeset
|
868 ]Last NumParams <<[[Length[args]]-[1]] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
869 }{ |
109
b7df624895b2
Hack to reduce overhead of Escape Rhope Name
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
870 out <- [func]Func Base[Escape Rhope Name[name,[func]Escape Pattern >>],args, "Call"] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
871 } |
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 |
142
7bbdc034e347
Fix some bugs. Get basic network code working (epoll listener + accept connections). Start porting webserver.
Mike Pavone <pavone@retrodev.com>
parents:
141
diff
changeset
|
875 Func Base@C Function[func,tocall,args,rtype:out] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
876 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
877 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
|
878 rargs <- Map[args, Make Op[?, func]] |
142
7bbdc034e347
Fix some bugs. Get basic network code working (epoll listener + accept connections). Start porting webserver.
Mike Pavone <pavone@retrodev.com>
parents:
141
diff
changeset
|
879 |
7bbdc034e347
Fix some bugs. Get basic network code working (epoll listener + accept connections). Start porting webserver.
Mike Pavone <pavone@retrodev.com>
parents:
141
diff
changeset
|
880 If[[[[func]Variables >>]Length]+[[[func]Outputs >>]Length]] |
7bbdc034e347
Fix some bugs. Get basic network code working (epoll listener + accept connections). Start porting webserver.
Mike Pavone <pavone@retrodev.com>
parents:
141
diff
changeset
|
881 { type <- Val[rtype] } |
7bbdc034e347
Fix some bugs. Get basic network code working (epoll listener + accept connections). Start porting webserver.
Mike Pavone <pavone@retrodev.com>
parents:
141
diff
changeset
|
882 { type <- [rtype]Append["NoLocals"] } |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
883 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
884 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
|
885 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
886 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
|
887 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
888 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
|
889 }{ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
890 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
|
891 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
892 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
|
893 ]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
|
894 }{ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
895 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
|
896 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
897 |
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 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
|
900 ]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
|
901 [[[[[[[[[type]Append["("] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
902 ]Append[tocall] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
903 ]Append[", "] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
904 ]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
|
905 ]Append[", "] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
906 ]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
|
907 ]Append[", "] |
109
b7df624895b2
Hack to reduce overhead of Escape Rhope Name
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
908 ]Append[Escape Rhope Name[[func]Name >>,[func]Escape Pattern >>]] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
909 ]Append[")"]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
910 ]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
|
911 } |
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 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
|
914 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
915 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
|
916 //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
|
917 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
|
918 ,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
|
919 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
920 ,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
|
921 { 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
|
922 } |
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 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
|
925 { 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
|
926 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
|
927 } |
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 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
|
930 { |
109
b7df624895b2
Hack to reduce overhead of Escape Rhope Name
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
931 out <- [func]Func Base[Escape Rhope Name[[field]Append[" >>"],[func]Escape Pattern >>], [()]Append[source], "Call"] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
932 } |
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 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
|
935 { |
109
b7df624895b2
Hack to reduce overhead of Escape Rhope Name
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
936 out <- [func]Func Base[Escape Rhope Name[[field]Append[" <<"],[func]Escape Pattern >>], [[()]Append[object]]Append[value], "Call"] |
92
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 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
939 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
|
940 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
941 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
|
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 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
|
945 { |
109
b7df624895b2
Hack to reduce overhead of Escape Rhope Name
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
946 out <- [func]Func Base[Escape Rhope Name[name,[func]Escape Pattern >>],args, "TCall"] |
92
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 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
949 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
|
950 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
951 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
|
952 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
953 [[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
|
954 { |
186
ba35ab624ec2
Add support for raw C function output from C backend as well as an option to use Boehm-GC instead of reference counting
Mike Pavone <pavone@retrodev.com>
parents:
184
diff
changeset
|
955 out <- [["my_params("]Append[String[~]]]Append[")"] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
956 }{ |
186
ba35ab624ec2
Add support for raw C function output from C backend as well as an option to use Boehm-GC instead of reference counting
Mike Pavone <pavone@retrodev.com>
parents:
184
diff
changeset
|
957 out <- [[[["lv("]Append[Escape Rhope Name[[func]Name >>,[func]Escape Pattern >>]]]Append[", "]]Append[Escape Rhope Name[op,[func]Escape Pattern >>]]]Append[")"] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
958 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
959 }{ |
109
b7df624895b2
Hack to reduce overhead of Escape Rhope Name
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
960 out <- Escape Rhope Name[op,[func]Escape Pattern >>] |
92
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 } |
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 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
|
965 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
966 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
|
967 { |
186
ba35ab624ec2
Add support for raw C function output from C backend as well as an option to use Boehm-GC instead of reference counting
Mike Pavone <pavone@retrodev.com>
parents:
184
diff
changeset
|
968 out <- [[[["lv("]Append[Escape Rhope Name[[func]Name >>,[func]Escape Pattern >>]]]Append[", "]]Append[Escape Rhope Name[name,[func]Escape Pattern >>]]]Append[")"] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
969 }{ |
109
b7df624895b2
Hack to reduce overhead of Escape Rhope Name
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
970 out <- Escape Rhope Name[name,[func]Escape Pattern >>] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
971 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
972 } |
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 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
|
975 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
976 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
|
977 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
978 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
979 _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
|
980 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
981 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
|
982 } |
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 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
|
985 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
986 cond <- [condition]Make Op[func] |
170
ac5c2d78663f
Inline calls to If@Boolean when static type info is present
Mike Pavone <pavone@retrodev.com>
parents:
169
diff
changeset
|
987 after statements <- Fold[_If C[?], [[func |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
988 ]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
|
989 ]Add Raw Line["{"], [stream]Statements >>] |
170
ac5c2d78663f
Inline calls to If@Boolean when static type info is present
Mike Pavone <pavone@retrodev.com>
parents:
169
diff
changeset
|
990 |
ac5c2d78663f
Inline calls to If@Boolean when static type info is present
Mike Pavone <pavone@retrodev.com>
parents:
169
diff
changeset
|
991 |
ac5c2d78663f
Inline calls to If@Boolean when static type info is present
Mike Pavone <pavone@retrodev.com>
parents:
169
diff
changeset
|
992 If[[[[func]Last NumParams >>]=[-1]]And[[[stream]Last NumParams >>]>[-1]]] |
ac5c2d78663f
Inline calls to If@Boolean when static type info is present
Mike Pavone <pavone@retrodev.com>
parents:
169
diff
changeset
|
993 { |
ac5c2d78663f
Inline calls to If@Boolean when static type info is present
Mike Pavone <pavone@retrodev.com>
parents:
169
diff
changeset
|
994 after free <- [after statements]Add Raw Line["FreeCall"] |
ac5c2d78663f
Inline calls to If@Boolean when static type info is present
Mike Pavone <pavone@retrodev.com>
parents:
169
diff
changeset
|
995 }{ |
ac5c2d78663f
Inline calls to If@Boolean when static type info is present
Mike Pavone <pavone@retrodev.com>
parents:
169
diff
changeset
|
996 after free <- Val[after statements] |
ac5c2d78663f
Inline calls to If@Boolean when static type info is present
Mike Pavone <pavone@retrodev.com>
parents:
169
diff
changeset
|
997 } |
172
926b56a43f47
Fix some bugs related to inlining
Mike Pavone <pavone@retrodev.com>
parents:
171
diff
changeset
|
998 out <- [[[after free]Add Raw Line["}"] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
999 ]Resume Index <<[[stream]Resume Index >>] |
172
926b56a43f47
Fix some bugs related to inlining
Mike Pavone <pavone@retrodev.com>
parents:
171
diff
changeset
|
1000 ]Variables <<[ Combine[[after free]Variables >>, [stream]Variables >>]] |
92
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 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1003 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
|
1004 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1005 out <- [[[[[func |
186
ba35ab624ec2
Add support for raw C function output from C backend as well as an option to use Boehm-GC instead of reference counting
Mike Pavone <pavone@retrodev.com>
parents:
184
diff
changeset
|
1006 ]Add Raw Line[[["for(idx = "]Append[String[first to discard]]]Append["; idx < numresults; ++idx)"]] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1007 ]Add Raw Line["{"] |
186
ba35ab624ec2
Add support for raw C function output from C backend as well as an option to use Boehm-GC instead of reference counting
Mike Pavone <pavone@retrodev.com>
parents:
184
diff
changeset
|
1008 ]Add Raw Line[" if (result(idx))"] |
ba35ab624ec2
Add support for raw C function output from C backend as well as an option to use Boehm-GC instead of reference counting
Mike Pavone <pavone@retrodev.com>
parents:
184
diff
changeset
|
1009 ]Add Raw Line[" release_ref(result(idx));"] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1010 ]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
|
1011 } |
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 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
|
1014 { |
186
ba35ab624ec2
Add support for raw C function output from C backend as well as an option to use Boehm-GC instead of reference counting
Mike Pavone <pavone@retrodev.com>
parents:
184
diff
changeset
|
1015 out <- [["result("]Append[String[output]]]Append[")"] |
92
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 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
|
1019 { |
186
ba35ab624ec2
Add support for raw C function output from C backend as well as an option to use Boehm-GC instead of reference counting
Mike Pavone <pavone@retrodev.com>
parents:
184
diff
changeset
|
1020 out <- [[[["("]Append[String[output]]]Append[" < numresults ? result("]]Append[String[output]]]Append[") : NULL)"] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1021 } |
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 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1024 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
|
1025 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1026 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
|
1027 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
|
1028 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
|
1029 out <- [[[[[["(" |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1030 ]Append[check] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1031 ]Append[" ? "] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1032 ]Append[l] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1033 ]Append[" : "] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1034 ]Append[r] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1035 ]Append[")"] |
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 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1038 _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
|
1039 { |
186
ba35ab624ec2
Add support for raw C function output from C backend as well as an option to use Boehm-GC instead of reference counting
Mike Pavone <pavone@retrodev.com>
parents:
184
diff
changeset
|
1040 out <- [string]Append[[[ [ ["\tRet("]Append[String[inputnum]] ]Append[ [[", lv("]Append[Escape Rhope Name[[func]Name >>,[func]Escape Pattern >>]]]Append[", "]]]Append[Escape Rhope Name[inputname,[func]Escape Pattern >>]]]Append["))\n"]] |
92
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 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1043 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
|
1044 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1045 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
|
1046 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1047 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
|
1048 }{ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1049 [[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
|
1050 { |
109
b7df624895b2
Hack to reduce overhead of Escape Rhope Name
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
1051 out <- [["\treturn "]Append[Escape Rhope Name[~,[func]Escape Pattern >>]]]Append[";\n"] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1052 }{ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1053 out <- "" |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1054 } |
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 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1057 _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
|
1058 { |
186
ba35ab624ec2
Add support for raw C function output from C backend as well as an option to use Boehm-GC instead of reference counting
Mike Pavone <pavone@retrodev.com>
parents:
184
diff
changeset
|
1059 out <- [[[string]Append[ [" lvar("]Append[Rhope Type to C[[[func]Output Types >>]Index[index],[func]Escape Pattern >>]] ]]Append[[", "]Append[Escape Rhope Name[varname,[func]Escape Pattern >>]]]]Append[")"] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1060 } |
109
b7df624895b2
Hack to reduce overhead of Escape Rhope Name
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
1061 _Var Defs C[string,type,varname,p:out] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1062 { |
186
ba35ab624ec2
Add support for raw C function output from C backend as well as an option to use Boehm-GC instead of reference counting
Mike Pavone <pavone@retrodev.com>
parents:
184
diff
changeset
|
1063 out <- [[[string]Append[ [" lvar("]Append[Rhope Type to C[type,p]] ]]Append[[", "]Append[Escape Rhope Name[varname,p]]]]Append[")"] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1064 } |
139
a68e6828d896
Global stores and transactions are working. Definately leaks memory on retries. Probably a fair number of bugs to work out. However, a basic test program works.
Mike Pavone <pavone@retrodev.com>
parents:
136
diff
changeset
|
1065 _Global Cell Defs C[func,p,string,store:out] |
a68e6828d896
Global stores and transactions are working. Definately leaks memory on retries. Probably a fair number of bugs to work out. However, a basic test program works.
Mike Pavone <pavone@retrodev.com>
parents:
136
diff
changeset
|
1066 { |
186
ba35ab624ec2
Add support for raw C function output from C backend as well as an option to use Boehm-GC instead of reference counting
Mike Pavone <pavone@retrodev.com>
parents:
184
diff
changeset
|
1067 out <- [string]Append[ [[" lvar(trans_cell *, gs_"]Append[Escape Rhope Name[store,p]]]Append[")"] ] |
139
a68e6828d896
Global stores and transactions are working. Definately leaks memory on retries. Probably a fair number of bugs to work out. However, a basic test program works.
Mike Pavone <pavone@retrodev.com>
parents:
136
diff
changeset
|
1068 } |
92
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 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1071 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
|
1072 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1073 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
|
1074 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1075 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
|
1076 { |
186
ba35ab624ec2
Add support for raw C function output from C backend as well as an option to use Boehm-GC instead of reference counting
Mike Pavone <pavone@retrodev.com>
parents:
184
diff
changeset
|
1077 ename <- Escape Rhope Name[[func]Name >>,[func]Escape Pattern >>] |
ba35ab624ec2
Add support for raw C function output from C backend as well as an option to use Boehm-GC instead of reference counting
Mike Pavone <pavone@retrodev.com>
parents:
184
diff
changeset
|
1078 localtype <- [ |
ba35ab624ec2
Add support for raw C function output from C backend as well as an option to use Boehm-GC instead of reference counting
Mike Pavone <pavone@retrodev.com>
parents:
184
diff
changeset
|
1079 [ |
ba35ab624ec2
Add support for raw C function output from C backend as well as an option to use Boehm-GC instead of reference counting
Mike Pavone <pavone@retrodev.com>
parents:
184
diff
changeset
|
1080 [ |
ba35ab624ec2
Add support for raw C function output from C backend as well as an option to use Boehm-GC instead of reference counting
Mike Pavone <pavone@retrodev.com>
parents:
184
diff
changeset
|
1081 Fold[ |
ba35ab624ec2
Add support for raw C function output from C backend as well as an option to use Boehm-GC instead of reference counting
Mike Pavone <pavone@retrodev.com>
parents:
184
diff
changeset
|
1082 _Global Cell Defs C[func,[func]Escape Pattern >>,?], |
ba35ab624ec2
Add support for raw C function output from C backend as well as an option to use Boehm-GC instead of reference counting
Mike Pavone <pavone@retrodev.com>
parents:
184
diff
changeset
|
1083 Fold[ |
ba35ab624ec2
Add support for raw C function output from C backend as well as an option to use Boehm-GC instead of reference counting
Mike Pavone <pavone@retrodev.com>
parents:
184
diff
changeset
|
1084 _Output Defs C[?, ?, ?, func], |
ba35ab624ec2
Add support for raw C function output from C backend as well as an option to use Boehm-GC instead of reference counting
Mike Pavone <pavone@retrodev.com>
parents:
184
diff
changeset
|
1085 Fold[ |
ba35ab624ec2
Add support for raw C function output from C backend as well as an option to use Boehm-GC instead of reference counting
Mike Pavone <pavone@retrodev.com>
parents:
184
diff
changeset
|
1086 _Var Defs C[?,?,?,[func]Escape Pattern >>], |
ba35ab624ec2
Add support for raw C function output from C backend as well as an option to use Boehm-GC instead of reference counting
Mike Pavone <pavone@retrodev.com>
parents:
184
diff
changeset
|
1087 ["#define ldec_"]Append[ename], |
ba35ab624ec2
Add support for raw C function output from C backend as well as an option to use Boehm-GC instead of reference counting
Mike Pavone <pavone@retrodev.com>
parents:
184
diff
changeset
|
1088 [func]Variables >>], |
ba35ab624ec2
Add support for raw C function output from C backend as well as an option to use Boehm-GC instead of reference counting
Mike Pavone <pavone@retrodev.com>
parents:
184
diff
changeset
|
1089 [func]Outputs >>], |
ba35ab624ec2
Add support for raw C function output from C backend as well as an option to use Boehm-GC instead of reference counting
Mike Pavone <pavone@retrodev.com>
parents:
184
diff
changeset
|
1090 [func]Uses >>] |
ba35ab624ec2
Add support for raw C function output from C backend as well as an option to use Boehm-GC instead of reference counting
Mike Pavone <pavone@retrodev.com>
parents:
184
diff
changeset
|
1091 ]Append["\nLocalsType(ldec_"]]Append[ename] |
ba35ab624ec2
Add support for raw C function output from C backend as well as an option to use Boehm-GC instead of reference counting
Mike Pavone <pavone@retrodev.com>
parents:
184
diff
changeset
|
1092 ]Append[ [[", "]Append[ename]]Append[")\n"] ] |
92
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 localtype <- "" |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1095 } |
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 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
|
1098 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1099 /* 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
|
1100 [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
|
1101 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1102 proto <- [[[["MethodDef(" |
109
b7df624895b2
Hack to reduce overhead of Escape Rhope Name
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
1103 ]Append[Escape Rhope Name[[parts]Index[0],[func]Escape Pattern >>]] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1104 ]Append[", "] |
109
b7df624895b2
Hack to reduce overhead of Escape Rhope Name
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
1105 ]Append[Escape Rhope Name[~,[func]Escape Pattern >>]] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1106 ]Append[")\n"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1107 }{ |
109
b7df624895b2
Hack to reduce overhead of Escape Rhope Name
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
1108 proto <- [["FuncDef("]Append[Escape Rhope Name[[func]Name >>,[func]Escape Pattern >>]]]Append[")\n"] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1109 } */ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1110 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
|
1111 }{ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1112 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
|
1113 } |
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 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1116 |
109
b7df624895b2
Hack to reduce overhead of Escape Rhope Name
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
1117 _Proto Input[list,input,index,types,p:out] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1118 { |
109
b7df624895b2
Hack to reduce overhead of Escape Rhope Name
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
1119 out <- [list]Append[ [[Rhope Type to C[[types]Index[index],p]]Append[" "]]Append[Escape Rhope Name[input,p]] ] |
92
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 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1122 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
|
1123 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1124 [[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
|
1125 { |
109
b7df624895b2
Hack to reduce overhead of Escape Rhope Name
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
1126 outtype <- [Rhope Type to C[~,[func]Escape Pattern >>]]Append[" "] |
92
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 outtype <- "void " |
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 <- [[[[outtype |
109
b7df624895b2
Hack to reduce overhead of Escape Rhope Name
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
1131 ]Append[ Escape Rhope Name[[func]Name >>,[func]Escape Pattern >>]] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1132 ]Append["("] |
109
b7df624895b2
Hack to reduce overhead of Escape Rhope Name
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
1133 ]Append[ [Fold[_Proto Input[?, ?, ?, [func]Input Types >>,[func]Escape Pattern >>], (), [func]Inputs >>]]Join[", "] ] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1134 ]Append[")"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1135 } |
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 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
|
1138 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1139 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
|
1140 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1141 out <- text |
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 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
|
1144 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1145 } |
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 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
|
1148 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1149 [(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
|
1150 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1151 typename <- type |
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 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
|
1154 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1155 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
|
1156 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1157 out <- text |
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 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
|
1160 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1161 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1162 |
139
a68e6828d896
Global stores and transactions are working. Definately leaks memory on retries. Probably a fair number of bugs to work out. However, a basic test program works.
Mike Pavone <pavone@retrodev.com>
parents:
136
diff
changeset
|
1163 Find Trans Cell@C Function[func,text,store:out] |
a68e6828d896
Global stores and transactions are working. Definately leaks memory on retries. Probably a fair number of bugs to work out. However, a basic test program works.
Mike Pavone <pavone@retrodev.com>
parents:
136
diff
changeset
|
1164 { |
a68e6828d896
Global stores and transactions are working. Definately leaks memory on retries. Probably a fair number of bugs to work out. However, a basic test program works.
Mike Pavone <pavone@retrodev.com>
parents:
136
diff
changeset
|
1165 estore <- Escape Rhope Name[store,[func]Escape Pattern >>] |
186
ba35ab624ec2
Add support for raw C function output from C backend as well as an option to use Boehm-GC instead of reference counting
Mike Pavone <pavone@retrodev.com>
parents:
184
diff
changeset
|
1166 out <- [text]Append[ [[[["lv("]Append[Escape Rhope Name[[func]Name >>,[func]Escape Pattern >>]]]Append[", gs_"]]Append[estore]]Append[[[") = find_obj_cell(cur_transaction, gs_"]Append[estore]]Append[");\n"]] ] |
139
a68e6828d896
Global stores and transactions are working. Definately leaks memory on retries. Probably a fair number of bugs to work out. However, a basic test program works.
Mike Pavone <pavone@retrodev.com>
parents:
136
diff
changeset
|
1167 } |
a68e6828d896
Global stores and transactions are working. Definately leaks memory on retries. Probably a fair number of bugs to work out. However, a basic test program works.
Mike Pavone <pavone@retrodev.com>
parents:
136
diff
changeset
|
1168 |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1169 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
|
1170 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1171 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
|
1172 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
|
1173 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1174 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
|
1175 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1176 type <- "MethodImpl" |
109
b7df624895b2
Hack to reduce overhead of Escape Rhope Name
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
1177 cname <- [[[[Escape Rhope Name[before,[func]Escape Pattern >>] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1178 ]Append[", "] |
109
b7df624895b2
Hack to reduce overhead of Escape Rhope Name
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
1179 ]Append[Escape Rhope Name[~,[func]Escape Pattern >>]] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1180 ]Append[", "] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1181 ]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
|
1182 }{ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1183 type <- "Func" |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1184 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
|
1185 } |
109
b7df624895b2
Hack to reduce overhead of Escape Rhope Name
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
1186 fname <- Escape Rhope Name[[func]Name >>,[func]Escape Pattern >>] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1187 param check <- Fold[Check Param Type C[?, ?, ?, func], "", [func]Input Types >>] |
142
7bbdc034e347
Fix some bugs. Get basic network code working (epoll listener + accept connections). Start porting webserver.
Mike Pavone <pavone@retrodev.com>
parents:
141
diff
changeset
|
1188 If[[[func]Last NumParams >>] = [-1]] |
7bbdc034e347
Fix some bugs. Get basic network code working (epoll listener + accept connections). Start porting webserver.
Mike Pavone <pavone@retrodev.com>
parents:
141
diff
changeset
|
1189 { |
7bbdc034e347
Fix some bugs. Get basic network code working (epoll listener + accept connections). Start porting webserver.
Mike Pavone <pavone@retrodev.com>
parents:
141
diff
changeset
|
1190 freecall <- "" |
7bbdc034e347
Fix some bugs. Get basic network code working (epoll listener + accept connections). Start porting webserver.
Mike Pavone <pavone@retrodev.com>
parents:
141
diff
changeset
|
1191 }{ |
7bbdc034e347
Fix some bugs. Get basic network code working (epoll listener + accept connections). Start porting webserver.
Mike Pavone <pavone@retrodev.com>
parents:
141
diff
changeset
|
1192 freecall <- "\n\tFreeCall\n" |
7bbdc034e347
Fix some bugs. Get basic network code working (epoll listener + accept connections). Start porting webserver.
Mike Pavone <pavone@retrodev.com>
parents:
141
diff
changeset
|
1193 } |
139
a68e6828d896
Global stores and transactions are working. Definately leaks memory on retries. Probably a fair number of bugs to work out. However, a basic test program works.
Mike Pavone <pavone@retrodev.com>
parents:
136
diff
changeset
|
1194 If[ [ [[[[func]Variables >>]Length]+[[[func]Outputs >>]Length]]+[[[func]Uses >>]Length] ] = [0] ] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1195 { |
186
ba35ab624ec2
Add support for raw C function output from C backend as well as an option to use Boehm-GC instead of reference counting
Mike Pavone <pavone@retrodev.com>
parents:
184
diff
changeset
|
1196 out <- [[[[[[[[[[[ [type]Append["NoLocals("] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1197 ]Append[cname] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1198 ]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
|
1199 ]Append[ String[[[func]Inputs >>]Length] ] |
186
ba35ab624ec2
Add support for raw C function output from C backend as well as an option to use Boehm-GC instead of reference counting
Mike Pavone <pavone@retrodev.com>
parents:
184
diff
changeset
|
1200 ]Append[",\n\tNumOutputs "] |
ba35ab624ec2
Add support for raw C function output from C backend as well as an option to use Boehm-GC instead of reference counting
Mike Pavone <pavone@retrodev.com>
parents:
184
diff
changeset
|
1201 ]Append[ String[[[func]Outputs >>]Length] ] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1202 ]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
|
1203 ]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
|
1204 ]Append[ [[func]Statements >>]Join[""] ] |
142
7bbdc034e347
Fix some bugs. Get basic network code working (epoll listener + accept connections). Start porting webserver.
Mike Pavone <pavone@retrodev.com>
parents:
141
diff
changeset
|
1205 ]Append[freecall] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1206 ]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
|
1207 ]Append["DISPATCH"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1208 }{ |
139
a68e6828d896
Global stores and transactions are working. Definately leaks memory on retries. Probably a fair number of bugs to work out. However, a basic test program works.
Mike Pavone <pavone@retrodev.com>
parents:
136
diff
changeset
|
1209 If[[[func]Uses >>]Length] |
a68e6828d896
Global stores and transactions are working. Definately leaks memory on retries. Probably a fair number of bugs to work out. However, a basic test program works.
Mike Pavone <pavone@retrodev.com>
parents:
136
diff
changeset
|
1210 { |
a68e6828d896
Global stores and transactions are working. Definately leaks memory on retries. Probably a fair number of bugs to work out. However, a basic test program works.
Mike Pavone <pavone@retrodev.com>
parents:
136
diff
changeset
|
1211 begin trans <- [[[["\tbegin_transaction(ct, "]Append[ String[[[func]Uses >>]Length] ]]Append[", "]]Append[ [Map[Map[[func]Uses >>, Escape Rhope Name[?, [func]Escape Pattern >>]], ["gs_"]Append[?]]]Join[", "] ]]Append[");\n"] |
a68e6828d896
Global stores and transactions are working. Definately leaks memory on retries. Probably a fair number of bugs to work out. However, a basic test program works.
Mike Pavone <pavone@retrodev.com>
parents:
136
diff
changeset
|
1212 init trans <- [[Fold[Find Trans Cell[func,?], begin trans, [func]Uses >>] |
a68e6828d896
Global stores and transactions are working. Definately leaks memory on retries. Probably a fair number of bugs to work out. However, a basic test program works.
Mike Pavone <pavone@retrodev.com>
parents:
136
diff
changeset
|
1213 ]Append[[["transretry_"]Append[fname]]Append[":\n"]] |
186
ba35ab624ec2
Add support for raw C function output from C backend as well as an option to use Boehm-GC instead of reference counting
Mike Pavone <pavone@retrodev.com>
parents:
184
diff
changeset
|
1214 ]Append[ [["\tfor(idx = 0; idx < "]Append[String[[[func]Inputs >>]Length]]]Append["; ++idx) { add_ref(my_params(idx)); }\n"] ] |
139
a68e6828d896
Global stores and transactions are working. Definately leaks memory on retries. Probably a fair number of bugs to work out. However, a basic test program works.
Mike Pavone <pavone@retrodev.com>
parents:
136
diff
changeset
|
1215 //TODO: Figure out whether this is a readonly or write transaction |
a68e6828d896
Global stores and transactions are working. Definately leaks memory on retries. Probably a fair number of bugs to work out. However, a basic test program works.
Mike Pavone <pavone@retrodev.com>
parents:
136
diff
changeset
|
1216 commit trans <- [[["\tif(!commit_transaction(ct, 0)) { prep_retry(ct); goto transretry_"]Append[fname]]Append["; }\n"] |
186
ba35ab624ec2
Add support for raw C function output from C backend as well as an option to use Boehm-GC instead of reference counting
Mike Pavone <pavone@retrodev.com>
parents:
184
diff
changeset
|
1217 ]Append[ [["\tfor(idx = 0; idx < "]Append[String[[[func]Inputs >>]Length]]]Append["; ++idx) { release_ref(my_params(idx)); }\n"] ] |
139
a68e6828d896
Global stores and transactions are working. Definately leaks memory on retries. Probably a fair number of bugs to work out. However, a basic test program works.
Mike Pavone <pavone@retrodev.com>
parents:
136
diff
changeset
|
1218 }{ |
a68e6828d896
Global stores and transactions are working. Definately leaks memory on retries. Probably a fair number of bugs to work out. However, a basic test program works.
Mike Pavone <pavone@retrodev.com>
parents:
136
diff
changeset
|
1219 init trans <- "" |
a68e6828d896
Global stores and transactions are working. Definately leaks memory on retries. Probably a fair number of bugs to work out. However, a basic test program works.
Mike Pavone <pavone@retrodev.com>
parents:
136
diff
changeset
|
1220 commit trans <- "" |
a68e6828d896
Global stores and transactions are working. Definately leaks memory on retries. Probably a fair number of bugs to work out. However, a basic test program works.
Mike Pavone <pavone@retrodev.com>
parents:
136
diff
changeset
|
1221 } |
186
ba35ab624ec2
Add support for raw C function output from C backend as well as an option to use Boehm-GC instead of reference counting
Mike Pavone <pavone@retrodev.com>
parents:
184
diff
changeset
|
1222 out <- [[[[[[[[[[[[[[ [type]Append["("] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1223 ]Append[cname] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1224 ]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
|
1225 ]Append[ String[[[func]Inputs >>]Length] ] |
186
ba35ab624ec2
Add support for raw C function output from C backend as well as an option to use Boehm-GC instead of reference counting
Mike Pavone <pavone@retrodev.com>
parents:
184
diff
changeset
|
1226 ]Append[",\n\tNumOutputs "] |
ba35ab624ec2
Add support for raw C function output from C backend as well as an option to use Boehm-GC instead of reference counting
Mike Pavone <pavone@retrodev.com>
parents:
184
diff
changeset
|
1227 ]Append[ String[[[func]Outputs >>]Length] ] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1228 ]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
|
1229 ]Append[param check] |
139
a68e6828d896
Global stores and transactions are working. Definately leaks memory on retries. Probably a fair number of bugs to work out. However, a basic test program works.
Mike Pavone <pavone@retrodev.com>
parents:
136
diff
changeset
|
1230 ]Append[init trans] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1231 ]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
|
1232 ]Append[freecall] |
139
a68e6828d896
Global stores and transactions are working. Definately leaks memory on retries. Probably a fair number of bugs to work out. However, a basic test program works.
Mike Pavone <pavone@retrodev.com>
parents:
136
diff
changeset
|
1233 ]Append[commit trans] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1234 ]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
|
1235 ]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
|
1236 ]Append["DISPATCH"] |
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 }{ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1239 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1240 out <- [[[ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1241 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
|
1242 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
|
1243 ]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
|
1244 ]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
|
1245 ]Append["}"] |
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 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1249 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
|
1250 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1251 Functions |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1252 Method Registry |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1253 Field Registry |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1254 Type Registry |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1255 Libraries |
139
a68e6828d896
Global stores and transactions are working. Definately leaks memory on retries. Probably a fair number of bugs to work out. However, a basic test program works.
Mike Pavone <pavone@retrodev.com>
parents:
136
diff
changeset
|
1256 Global Stores |
109
b7df624895b2
Hack to reduce overhead of Escape Rhope Name
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
1257 Escape Pattern |
92
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 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
|
1261 { |
109
b7df624895b2
Hack to reduce overhead of Escape Rhope Name
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
1262 p <- Pattern[("_", "@", " ", ":", "?", "+", "-", "*", "/", "<", ">", "(", ")", "!", "=", "'", |
b7df624895b2
Hack to reduce overhead of Escape Rhope Name
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
1263 "\"", "\t", ",", ".", "\n", "{", "}", "[", "]", "#", "\\", "\r", ";", "&", "|", "%", "^", "`", "~")] |
139
a68e6828d896
Global stores and transactions are working. Definately leaks memory on retries. Probably a fair number of bugs to work out. However, a basic test program works.
Mike Pavone <pavone@retrodev.com>
parents:
136
diff
changeset
|
1264 out <- [[[[[[[Build[C Program()]]Functions <<[Dictionary[]]]Method Registry <<[C Method Registry[]]]Type Registry <<[C Type Registry[p]]]Field Registry <<[C Field Registry[]]]Libraries <<[Dictionary[]]]Escape Pattern <<[p]]Global Stores <<[Dictionary[]] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1265 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1266 |
136
fc3815b7462f
Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
135
diff
changeset
|
1267 Supported Number Types@C Program[program:out] |
135
18a4403fe576
Javascript backend can now produce broken output. Needs fixes plus port of standard lib
Mike Pavone <pavone@retrodev.com>
parents:
127
diff
changeset
|
1268 { |
18a4403fe576
Javascript backend can now produce broken output. Needs fixes plus port of standard lib
Mike Pavone <pavone@retrodev.com>
parents:
127
diff
changeset
|
1269 out <- ("Int8","Int16","Int32","Int64","UInt8","UInt16","UInt32","UInt64") |
18a4403fe576
Javascript backend can now produce broken output. Needs fixes plus port of standard lib
Mike Pavone <pavone@retrodev.com>
parents:
127
diff
changeset
|
1270 } |
18a4403fe576
Javascript backend can now produce broken output. Needs fixes plus port of standard lib
Mike Pavone <pavone@retrodev.com>
parents:
127
diff
changeset
|
1271 |
136
fc3815b7462f
Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
135
diff
changeset
|
1272 Needed Specials@C Program[program,typename,makespecial:out] |
135
18a4403fe576
Javascript backend can now produce broken output. Needs fixes plus port of standard lib
Mike Pavone <pavone@retrodev.com>
parents:
127
diff
changeset
|
1273 { |
18a4403fe576
Javascript backend can now produce broken output. Needs fixes plus port of standard lib
Mike Pavone <pavone@retrodev.com>
parents:
127
diff
changeset
|
1274 init name <- [" init "]Append[typename] |
18a4403fe576
Javascript backend can now produce broken output. Needs fixes plus port of standard lib
Mike Pavone <pavone@retrodev.com>
parents:
127
diff
changeset
|
1275 with init <- [()]Append[ [[()]Append[init name]]Append[[makespecial]Index["init"]] ] |
18a4403fe576
Javascript backend can now produce broken output. Needs fixes plus port of standard lib
Mike Pavone <pavone@retrodev.com>
parents:
127
diff
changeset
|
1276 [("Array","Boxed Array","Worker")]Find[=[?,typename]] |
18a4403fe576
Javascript backend can now produce broken output. Needs fixes plus port of standard lib
Mike Pavone <pavone@retrodev.com>
parents:
127
diff
changeset
|
1277 { |
18a4403fe576
Javascript backend can now produce broken output. Needs fixes plus port of standard lib
Mike Pavone <pavone@retrodev.com>
parents:
127
diff
changeset
|
1278 out <- Val[with init] |
18a4403fe576
Javascript backend can now produce broken output. Needs fixes plus port of standard lib
Mike Pavone <pavone@retrodev.com>
parents:
127
diff
changeset
|
1279 }{ |
18a4403fe576
Javascript backend can now produce broken output. Needs fixes plus port of standard lib
Mike Pavone <pavone@retrodev.com>
parents:
127
diff
changeset
|
1280 copy name <- [" copy "]Append[typename] |
18a4403fe576
Javascript backend can now produce broken output. Needs fixes plus port of standard lib
Mike Pavone <pavone@retrodev.com>
parents:
127
diff
changeset
|
1281 cleanup name <- [" cleanup "]Append[typename] |
18a4403fe576
Javascript backend can now produce broken output. Needs fixes plus port of standard lib
Mike Pavone <pavone@retrodev.com>
parents:
127
diff
changeset
|
1282 out <- [[with init]Append[ [[()]Append[copy name]]Append[[makespecial]Index["copy"]] ] |
18a4403fe576
Javascript backend can now produce broken output. Needs fixes plus port of standard lib
Mike Pavone <pavone@retrodev.com>
parents:
127
diff
changeset
|
1283 ]Append[ [[()]Append[cleanup name]]Append[[makespecial]Index["cleanup"]] ] |
18a4403fe576
Javascript backend can now produce broken output. Needs fixes plus port of standard lib
Mike Pavone <pavone@retrodev.com>
parents:
127
diff
changeset
|
1284 } |
18a4403fe576
Javascript backend can now produce broken output. Needs fixes plus port of standard lib
Mike Pavone <pavone@retrodev.com>
parents:
127
diff
changeset
|
1285 } |
18a4403fe576
Javascript backend can now produce broken output. Needs fixes plus port of standard lib
Mike Pavone <pavone@retrodev.com>
parents:
127
diff
changeset
|
1286 |
136
fc3815b7462f
Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
135
diff
changeset
|
1287 Set Stdlib Imports@C Program[program,parser:out] |
fc3815b7462f
Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
135
diff
changeset
|
1288 { |
fc3815b7462f
Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
135
diff
changeset
|
1289 out <- [parser]Imports <<[ [[parser]Imports >>]Set["kernel.rhope", Yes] ] |
fc3815b7462f
Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
135
diff
changeset
|
1290 } |
fc3815b7462f
Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
135
diff
changeset
|
1291 |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1292 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
|
1293 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1294 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
|
1295 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1296 out <- program |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1297 }{ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1298 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
|
1299 { langlibs <- Dictionary[] } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1300 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
|
1301 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1302 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1303 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1304 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
|
1305 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1306 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
|
1307 ]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
|
1308 ]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
|
1309 } |
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 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
|
1312 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1313 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
|
1314 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1315 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1316 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
|
1317 { |
109
b7df624895b2
Hack to reduce overhead of Escape Rhope Name
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
1318 out <- C Function With Registry[name,inputs,outputs,convention, [program]Method Registry >>, [program]Field Registry >>, [program]Type Registry >>, [program]Escape Pattern >>] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1319 } |
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 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
|
1322 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1323 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
|
1324 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1325 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1326 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
|
1327 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1328 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
|
1329 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1330 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1331 _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
|
1332 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1333 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
|
1334 If[[def]=[""]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1335 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1336 out <- text |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1337 }{ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1338 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
|
1339 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1340 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1341 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1342 _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
|
1343 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1344 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
|
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 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
|
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 <- 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
|
1350 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1351 |
109
b7df624895b2
Hack to reduce overhead of Escape Rhope Name
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
1352 _Consts C Program[text,value,name,p:out] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1353 { |
109
b7df624895b2
Hack to reduce overhead of Escape Rhope Name
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
1354 out <- [text]Append[ [["object * _const_"]Append[Escape Rhope Name[name,p]]]Append[";\n"] ] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1355 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1356 |
118
b3f56e1d54a0
Merged changes from interpreted version of compiler to compiled version
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
1357 _Consts C Release[text,value,name,p:out] |
b3f56e1d54a0
Merged changes from interpreted version of compiler to compiled version
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
1358 { |
b3f56e1d54a0
Merged changes from interpreted version of compiler to compiled version
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
1359 out <- [text]Append[ [["\trelease_ref(_const_"]Append[Escape Rhope Name[name,p]]]Append[");\n"] ] |
b3f56e1d54a0
Merged changes from interpreted version of compiler to compiled version
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
1360 } |
b3f56e1d54a0
Merged changes from interpreted version of compiler to compiled version
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
1361 |
b3f56e1d54a0
Merged changes from interpreted version of compiler to compiled version
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
1362 _List Literal El[text,val,index,type reg:out] |
b3f56e1d54a0
Merged changes from interpreted version of compiler to compiled version
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
1363 { |
b3f56e1d54a0
Merged changes from interpreted version of compiler to compiled version
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
1364 out <- [[[[text |
b3f56e1d54a0
Merged changes from interpreted version of compiler to compiled version
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
1365 ]Append[", "] |
b3f56e1d54a0
Merged changes from interpreted version of compiler to compiled version
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
1366 ]Append[index] |
b3f56e1d54a0
Merged changes from interpreted version of compiler to compiled version
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
1367 ]Append[", "] |
b3f56e1d54a0
Merged changes from interpreted version of compiler to compiled version
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
1368 ]Append[Const Construct C[val, type reg]] |
b3f56e1d54a0
Merged changes from interpreted version of compiler to compiled version
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
1369 } |
b3f56e1d54a0
Merged changes from interpreted version of compiler to compiled version
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
1370 |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1371 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
|
1372 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1373 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
|
1374 [(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
|
1375 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1376 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
|
1377 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
|
1378 { s <- "UI" } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1379 { s <- "I" } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1380 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1381 out <- [[[[[["make_" |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1382 ]Append[s] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1383 ]Append["nt"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1384 ]Append[size] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1385 ]Append["("] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1386 ]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
|
1387 ]Append[")"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1388 }{ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1389 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
|
1390 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1391 //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
|
1392 typeid <- [type reg]Type ID[[value]Name >>] |
118
b3f56e1d54a0
Merged changes from interpreted version of compiler to compiled version
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
1393 |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1394 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
|
1395 }{ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1396 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
|
1397 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1398 If[value] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1399 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1400 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
|
1401 }{ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1402 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
|
1403 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1404 }{ |
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 [(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
|
1407 { |
120
cd25171e1bb2
Use List for Subsets instead of a Dictionary for performance reasons. Fix issue with List literals. Compiled compiler is now self-hosting.
Mike Pavone <pavone@retrodev.com>
parents:
118
diff
changeset
|
1408 out <- [["make_String(\""]Append[ [[[[value]Replace["\\", "\\\\"]]Replace["\n", "\\n"]]Replace["\"", "\\\""]]Replace["\r", "\\r"] ]]Append["\")"] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1409 }{ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1410 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
|
1411 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1412 //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
|
1413 //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
|
1414 [[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
|
1415 { 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
|
1416 { size <- "0" } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1417 out <- [[[[[["make_Worker(FUNC_" |
109
b7df624895b2
Hack to reduce overhead of Escape Rhope Name
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
1418 ]Append[Escape Rhope Name[[value]Name >>,[type reg]Escape Pattern >>]] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1419 ]Append[", "] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1420 ]Append[size] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1421 ]Append[", "] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1422 ]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
|
1423 ]Append[")"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1424 }{ |
118
b3f56e1d54a0
Merged changes from interpreted version of compiler to compiled version
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
1425 [(List(), List Leaf())]Find[=[?,valtype]] |
b3f56e1d54a0
Merged changes from interpreted version of compiler to compiled version
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
1426 { |
b3f56e1d54a0
Merged changes from interpreted version of compiler to compiled version
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
1427 out <- [Fold[_List Literal El[?, ?, ?, type reg], ["make_List("]Append[String[[value]Length]], value]]Append[")"] |
b3f56e1d54a0
Merged changes from interpreted version of compiler to compiled version
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
1428 }{ |
b3f56e1d54a0
Merged changes from interpreted version of compiler to compiled version
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
1429 out <- "UnhandledLiteralType" |
b3f56e1d54a0
Merged changes from interpreted version of compiler to compiled version
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
1430 } |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1431 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1432 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1433 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1434 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1435 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1436 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1437 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1438 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1439 _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
|
1440 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1441 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
|
1442 [[[[[["\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
|
1443 ]Append[name] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1444 ]Append[")+1))["] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1445 ]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
|
1446 ]Append["] = "] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1447 ]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
|
1448 ]Append[";\n"] ] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1449 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1450 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1451 _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
|
1452 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1453 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
|
1454 [(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
|
1455 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1456 out <- text |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1457 }{ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1458 Const Construct C[value,type reg] |
109
b7df624895b2
Hack to reduce overhead of Escape Rhope Name
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
1459 { out <- [text]Append[ [[[["\t_const_"]Append[Escape Rhope Name[name,[type reg]Escape Pattern >>]]]Append[" = "]]Append[~]]Append[";\n"] ] } |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1460 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1461 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1462 |
147
f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
Mike Pavone <pavone@retrodev.com>
parents:
142
diff
changeset
|
1463 _Set List Els C[text,el,index,type reg:out] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1464 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1465 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
|
1466 [["\tinout[1] = " |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1467 ]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
|
1468 ]Append[ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1469 [[";\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
|
1470 ]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
|
1471 ]Append[";\n"] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1472 ]]]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
|
1473 } |
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 _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
|
1476 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1477 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
|
1478 [(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
|
1479 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1480 If[[~]>[3]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1481 { |
147
f3686f60985d
Sort of working port of framework. Transaction bug seems to be getting in the way. Going to work around, but want the old version in the repo so I can test later.
Mike Pavone <pavone@retrodev.com>
parents:
142
diff
changeset
|
1482 out <- [Fold[_Set List Els C[?, ?, ?, type reg], [text]Append["\trhope(FUNC_List, inout, 0, 1);\n"], value] |
109
b7df624895b2
Hack to reduce overhead of Escape Rhope Name
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
1483 ]Append[[["\t_const_"]Append[Escape Rhope Name[name,[type reg]Escape Pattern >>]]]Append[" = inout[0];\n"]] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1484 }{ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1485 Const Construct C[value,type reg] |
109
b7df624895b2
Hack to reduce overhead of Escape Rhope Name
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
1486 { init <- [text]Append[ [[[["\t_const_"]Append[Escape Rhope Name[name,[type reg]Escape Pattern >>]]]Append[" = "]]Append[~]]Append[";\n"] ] } |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1487 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1488 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
|
1489 { |
109
b7df624895b2
Hack to reduce overhead of Escape Rhope Name
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
1490 out <- Fold[_Set Worker Params C[?, ?, ?, type reg, Escape Rhope Name[name,[type reg]Escape Pattern >>]], init, [value]Args >>] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1491 }{ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1492 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
|
1493 } |
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 }{ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1496 out <- text |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1497 } |
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 |
139
a68e6828d896
Global stores and transactions are working. Definately leaks memory on retries. Probably a fair number of bugs to work out. However, a basic test program works.
Mike Pavone <pavone@retrodev.com>
parents:
136
diff
changeset
|
1500 _Global Var Init C[text,value,name,storevar,type reg:out] |
a68e6828d896
Global stores and transactions are working. Definately leaks memory on retries. Probably a fair number of bugs to work out. However, a basic test program works.
Mike Pavone <pavone@retrodev.com>
parents:
136
diff
changeset
|
1501 { |
a68e6828d896
Global stores and transactions are working. Definately leaks memory on retries. Probably a fair number of bugs to work out. However, a basic test program works.
Mike Pavone <pavone@retrodev.com>
parents:
136
diff
changeset
|
1502 out <- [[[[[text]Append[storevar]]Append[Escape Rhope Name[name, [type reg]Escape Pattern >>]]]Append[" = "]]Append[Const Construct C[value, type reg]]]Append[";\n"] |
a68e6828d896
Global stores and transactions are working. Definately leaks memory on retries. Probably a fair number of bugs to work out. However, a basic test program works.
Mike Pavone <pavone@retrodev.com>
parents:
136
diff
changeset
|
1503 } |
a68e6828d896
Global stores and transactions are working. Definately leaks memory on retries. Probably a fair number of bugs to work out. However, a basic test program works.
Mike Pavone <pavone@retrodev.com>
parents:
136
diff
changeset
|
1504 |
a68e6828d896
Global stores and transactions are working. Definately leaks memory on retries. Probably a fair number of bugs to work out. However, a basic test program works.
Mike Pavone <pavone@retrodev.com>
parents:
136
diff
changeset
|
1505 _Global Store Inits C[text,store,type reg:out] |
a68e6828d896
Global stores and transactions are working. Definately leaks memory on retries. Probably a fair number of bugs to work out. However, a basic test program works.
Mike Pavone <pavone@retrodev.com>
parents:
136
diff
changeset
|
1506 { |
a68e6828d896
Global stores and transactions are working. Definately leaks memory on retries. Probably a fair number of bugs to work out. However, a basic test program works.
Mike Pavone <pavone@retrodev.com>
parents:
136
diff
changeset
|
1507 estore <- Escape Rhope Name[[store]Name >>, [type reg]Escape Pattern >>] |
a68e6828d896
Global stores and transactions are working. Definately leaks memory on retries. Probably a fair number of bugs to work out. However, a basic test program works.
Mike Pavone <pavone@retrodev.com>
parents:
136
diff
changeset
|
1508 out <- Fold[_Global Var Init C[?,?,?, [[[["\t((mutt_"]Append[estore]]Append[" *)(gs_"]]Append[estore]]Append["->data))->gs_"], type reg], text, [store]Vars >>] |
a68e6828d896
Global stores and transactions are working. Definately leaks memory on retries. Probably a fair number of bugs to work out. However, a basic test program works.
Mike Pavone <pavone@retrodev.com>
parents:
136
diff
changeset
|
1509 } |
a68e6828d896
Global stores and transactions are working. Definately leaks memory on retries. Probably a fair number of bugs to work out. However, a basic test program works.
Mike Pavone <pavone@retrodev.com>
parents:
136
diff
changeset
|
1510 |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1511 _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
|
1512 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1513 out <- [[[[[text |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1514 ]Append["\tResumeEntry("] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1515 ]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
|
1516 ]Append[","] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1517 ]Append[name] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1518 ]Append[")\\\n"] |
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 _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
|
1522 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1523 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
|
1524 { |
109
b7df624895b2
Hack to reduce overhead of Escape Rhope Name
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
1525 name <- Escape Rhope Name[raw name,[func]Escape Pattern >>] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1526 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
|
1527 ]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
|
1528 }{ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1529 out <- text |
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 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1532 |
109
b7df624895b2
Hack to reduce overhead of Escape Rhope Name
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
1533 _Dispatch Switch Methods[p,text,id,raw name:out] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1534 { |
109
b7df624895b2
Hack to reduce overhead of Escape Rhope Name
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
1535 name <- Escape Rhope Name[raw name,p] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1536 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
|
1537 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1538 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1539 _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
|
1540 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1541 out <- [[[[[text |
186
ba35ab624ec2
Add support for raw C function output from C backend as well as an option to use Boehm-GC instead of reference counting
Mike Pavone <pavone@retrodev.com>
parents:
184
diff
changeset
|
1542 ]Append["\tResEnum("] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1543 ]Append[String[num]] |
186
ba35ab624ec2
Add support for raw C function output from C backend as well as an option to use Boehm-GC instead of reference counting
Mike Pavone <pavone@retrodev.com>
parents:
184
diff
changeset
|
1544 ]Append[", "] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1545 ]Append[name] |
186
ba35ab624ec2
Add support for raw C function output from C backend as well as an option to use Boehm-GC instead of reference counting
Mike Pavone <pavone@retrodev.com>
parents:
184
diff
changeset
|
1546 ]Append[")\n"] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1547 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1548 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1549 _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
|
1550 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1551 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
|
1552 { |
109
b7df624895b2
Hack to reduce overhead of Escape Rhope Name
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
1553 name <- Escape Rhope Name[raw name,[func]Escape Pattern >>] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1554 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
|
1555 ]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
|
1556 }{ |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1557 out <- text |
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 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1560 |
109
b7df624895b2
Hack to reduce overhead of Escape Rhope Name
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
1561 _Dispatch Enum Methods[p,text,types,name:out] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1562 { |
109
b7df624895b2
Hack to reduce overhead of Escape Rhope Name
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
1563 out <- [text]Append[ [["\tFUNC_"]Append[Escape Rhope Name[name,p]]]Append[",\n"] ] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1564 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1565 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1566 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
|
1567 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1568 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
|
1569 ]Append[Fold[_Dispatch Enum[?], |
186
ba35ab624ec2
Add support for raw C function output from C backend as well as an option to use Boehm-GC instead of reference counting
Mike Pavone <pavone@retrodev.com>
parents:
184
diff
changeset
|
1570 [Fold[_Dispatch Enum Methods[[program]Escape Pattern >>,?], "", all methods]]Append["\tFUNC_Build,\n\tFUNC_BlueprintSP_Of,\n\tFUNC_ID,\n\tFUNC_BlueprintSP_FromSP_ID,\n\tFUNC_Pause,\n\tResEnum(1, Pause)\n\tFUNC_Resume,\n\tFUNC_RunSP_Bytecode,\n\tResEnum(1, RunSP_Bytecode)\n"], |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1571 [program]Functions >>]] |
140
c14698c512f1
Untested addition of Pause/Resume
Mike Pavone <pavone@retrodev.com>
parents:
139
diff
changeset
|
1572 ]Append["\tEND,\n\tEND_THREAD\n} funcids;\n\n"] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1573 ]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
|
1574 ]Append[Fold[_Dispatch Switch[?], |
176 | 1575 [Fold[_Dispatch Switch Methods[[program]Escape Pattern >>,?], "", all methods]]Append["\tDispatchEntry(Build)\\\n\tDispatchEntry(BlueprintSP_Of)\\\n\tDispatchEntry(ID)\\\n\tDispatchEntry(BlueprintSP_FromSP_ID)\\\n\tDispatchEntry(Pause)\\\n\tResumeEntry(1,Pause)\\\n\tDispatchEntry(Resume)\\\n\tDispatchEntry(RunSP_Bytecode)\\\n\tResumeEntry(1,RunSP_Bytecode)\\\n"], |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1576 [program]Functions >>]] |
141
f2cb85c53ced
Fix Pause/Resume and rewrite Call Async in Rhope rather than C
Mike Pavone <pavone@retrodev.com>
parents:
140
diff
changeset
|
1577 ]Append["\tEndEntry\\\n\tEndThreadEntry\n\n"] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1578 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1579 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1580 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
|
1581 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1582 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
|
1583 { out <- No } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1584 { out <- Yes } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1585 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1586 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1587 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
|
1588 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1589 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
|
1590 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1591 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1592 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
|
1593 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1594 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
|
1595 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1596 out <- text |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1597 }{ |
186
ba35ab624ec2
Add support for raw C function output from C backend as well as an option to use Boehm-GC instead of reference counting
Mike Pavone <pavone@retrodev.com>
parents:
184
diff
changeset
|
1598 If[[[func]Name >>]Contains["@"]] |
ba35ab624ec2
Add support for raw C function output from C backend as well as an option to use Boehm-GC instead of reference counting
Mike Pavone <pavone@retrodev.com>
parents:
184
diff
changeset
|
1599 { |
ba35ab624ec2
Add support for raw C function output from C backend as well as an option to use Boehm-GC instead of reference counting
Mike Pavone <pavone@retrodev.com>
parents:
184
diff
changeset
|
1600 deftype <- "\tMethodDef(" |
ba35ab624ec2
Add support for raw C function output from C backend as well as an option to use Boehm-GC instead of reference counting
Mike Pavone <pavone@retrodev.com>
parents:
184
diff
changeset
|
1601 }{ |
ba35ab624ec2
Add support for raw C function output from C backend as well as an option to use Boehm-GC instead of reference counting
Mike Pavone <pavone@retrodev.com>
parents:
184
diff
changeset
|
1602 deftype <- "\tFuncDef(" |
ba35ab624ec2
Add support for raw C function output from C backend as well as an option to use Boehm-GC instead of reference counting
Mike Pavone <pavone@retrodev.com>
parents:
184
diff
changeset
|
1603 } |
ba35ab624ec2
Add support for raw C function output from C backend as well as an option to use Boehm-GC instead of reference counting
Mike Pavone <pavone@retrodev.com>
parents:
184
diff
changeset
|
1604 out <- [text]Append[[[deftype]Append[Escape Rhope Name[[func]Name >>,[func]Escape Pattern >>]]]Append[")\n"]] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1605 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1606 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1607 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1608 _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
|
1609 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1610 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
|
1611 { typelist <- () } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1612 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1613 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
|
1614 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1615 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1616 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1617 _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
|
1618 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1619 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
|
1620 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
|
1621 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1622 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1623 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1624 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
|
1625 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1626 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
|
1627 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1628 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1629 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
|
1630 { |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1631 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
|
1632 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1633 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1634 _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
|
1635 { |
109
b7df624895b2
Hack to reduce overhead of Escape Rhope Name
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
1636 out <- [[[[[[[text]Append["\tMethodDispatch("]]Append[ [reg]Type ID[type] ]]Append[","]]Append[Escape Rhope Name[method,[reg]Escape Pattern >>]]]Append[","]]Append[Escape Rhope Name[type,[reg]Escape Pattern >>]]]Append[")\n"] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1637 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1638 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1639 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
|
1640 { |
109
b7df624895b2
Hack to reduce overhead of Escape Rhope Name
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
1641 out <- [[[Fold[_Method Dispatch[?, ?, method, reg], [[[text]Append["Method("]]Append[ Escape Rhope Name[method,[reg]Escape Pattern >>] ]]Append[")\n"], types] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1642 ]Append["EndMethod("] |
109
b7df624895b2
Hack to reduce overhead of Escape Rhope Name
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
1643 ]Append[Escape Rhope Name[method,[reg]Escape Pattern >>]] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1644 ]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
|
1645 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1646 |
127
50406500334d
Port availability of type names at runtime to compiled compiler
Mike Pavone <pavone@retrodev.com>
parents:
123
diff
changeset
|
1647 Init Type Names[text,typeid,name,reg:out] |
50406500334d
Port availability of type names at runtime to compiled compiler
Mike Pavone <pavone@retrodev.com>
parents:
123
diff
changeset
|
1648 { |
50406500334d
Port availability of type names at runtime to compiled compiler
Mike Pavone <pavone@retrodev.com>
parents:
123
diff
changeset
|
1649 [reg]Defined?[name] |
50406500334d
Port availability of type names at runtime to compiled compiler
Mike Pavone <pavone@retrodev.com>
parents:
123
diff
changeset
|
1650 { out <- [text]Append[ [[[["\tregistered_types["]Append[typeid]]Append["]->name = "]]Append[Const Construct C[name, reg]]]Append[";\n"] ] } |
50406500334d
Port availability of type names at runtime to compiled compiler
Mike Pavone <pavone@retrodev.com>
parents:
123
diff
changeset
|
1651 { out <- text } |
50406500334d
Port availability of type names at runtime to compiled compiler
Mike Pavone <pavone@retrodev.com>
parents:
123
diff
changeset
|
1652 } |
50406500334d
Port availability of type names at runtime to compiled compiler
Mike Pavone <pavone@retrodev.com>
parents:
123
diff
changeset
|
1653 |
135
18a4403fe576
Javascript backend can now produce broken output. Needs fixes plus port of standard lib
Mike Pavone <pavone@retrodev.com>
parents:
127
diff
changeset
|
1654 Text Filename@C Program[program,source name:out] |
18a4403fe576
Javascript backend can now produce broken output. Needs fixes plus port of standard lib
Mike Pavone <pavone@retrodev.com>
parents:
127
diff
changeset
|
1655 { |
18a4403fe576
Javascript backend can now produce broken output. Needs fixes plus port of standard lib
Mike Pavone <pavone@retrodev.com>
parents:
127
diff
changeset
|
1656 out <- [source name]Append[".c"] |
18a4403fe576
Javascript backend can now produce broken output. Needs fixes plus port of standard lib
Mike Pavone <pavone@retrodev.com>
parents:
127
diff
changeset
|
1657 } |
18a4403fe576
Javascript backend can now produce broken output. Needs fixes plus port of standard lib
Mike Pavone <pavone@retrodev.com>
parents:
127
diff
changeset
|
1658 |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1659 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
|
1660 { |
109
b7df624895b2
Hack to reduce overhead of Escape Rhope Name
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
1661 p <- [program]Escape Pattern >> |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1662 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
|
1663 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
|
1664 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
|
1665 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
|
1666 #include <stdlib.h> |
141
f2cb85c53ced
Fix Pause/Resume and rewrite Call Async in Rhope rather than C
Mike Pavone <pavone@retrodev.com>
parents:
140
diff
changeset
|
1667 #include <string.h> |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1668 #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
|
1669 #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
|
1670 #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
|
1671 #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
|
1672 #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
|
1673 #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
|
1674 #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
|
1675 #include \"worker.h\" |
118
b3f56e1d54a0
Merged changes from interpreted version of compiler to compiled version
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
1676 #include \"bool.h\" |
b3f56e1d54a0
Merged changes from interpreted version of compiler to compiled version
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
1677 #include <sys/time.h>\n\n" |
139
a68e6828d896
Global stores and transactions are working. Definately leaks memory on retries. Probably a fair number of bugs to work out. However, a basic test program works.
Mike Pavone <pavone@retrodev.com>
parents:
136
diff
changeset
|
1678 out <- [[[[[[[[[[[[[[[[[[[[[headers |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1679 ]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
|
1680 ]Append[[[program]Type Registry >>]Type Defs] |
139
a68e6828d896
Global stores and transactions are working. Definately leaks memory on retries. Probably a fair number of bugs to work out. However, a basic test program works.
Mike Pavone <pavone@retrodev.com>
parents:
136
diff
changeset
|
1681 ]Append[Fold[_Global Type Defs C[?,?,p], "", [program]Global Stores >>]] |
109
b7df624895b2
Hack to reduce overhead of Escape Rhope Name
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
1682 ]Append[Fold[_Consts C Program[?,?,?,p], |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1683 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
|
1684 constants]] |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1685 ]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
|
1686 ]Append["\n |
162
bac2c74801f0
Move some C code out of cbackend_c.rhope into separate include files
Mike Pavone <pavone@retrodev.com>
parents:
159
diff
changeset
|
1687 #include \"rhopefuncs_prolog.c\"\n"] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1688 ]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
|
1689 ]Append[" |
162
bac2c74801f0
Move some C code out of cbackend_c.rhope into separate include files
Mike Pavone <pavone@retrodev.com>
parents:
159
diff
changeset
|
1690 #include \"localpointers_fragment.c\"\n"] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1691 ]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
|
1692 ]Append[" |
162
bac2c74801f0
Move some C code out of cbackend_c.rhope into separate include files
Mike Pavone <pavone@retrodev.com>
parents:
159
diff
changeset
|
1693 #include \"builtinworkers.c\"\n"] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1694 ]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
|
1695 ]Append[" |
162
bac2c74801f0
Move some C code out of cbackend_c.rhope into separate include files
Mike Pavone <pavone@retrodev.com>
parents:
159
diff
changeset
|
1696 #include \"rhopefuncs_epilog.c\" |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1697 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1698 #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
|
1699 #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
|
1700 #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
|
1701 |
186
ba35ab624ec2
Add support for raw C function output from C backend as well as an option to use Boehm-GC instead of reference counting
Mike Pavone <pavone@retrodev.com>
parents:
184
diff
changeset
|
1702 #include \"main_start.c\" \n\n"] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1703 ]Append[ [[program]Type Registry >>]Type Inits[[program]Method Registry >>, [program]Field Registry >>] ] |
139
a68e6828d896
Global stores and transactions are working. Definately leaks memory on retries. Probably a fair number of bugs to work out. However, a basic test program works.
Mike Pavone <pavone@retrodev.com>
parents:
136
diff
changeset
|
1704 ]Append[Fold[_Global Type Inits C[?, ?, p], "", [program]Global Stores >>]] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1705 ]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
|
1706 ]Append[Fold[_Set Late Consts C[?, ?, ?, [program]Type Registry >>], "", constants]] |
139
a68e6828d896
Global stores and transactions are working. Definately leaks memory on retries. Probably a fair number of bugs to work out. However, a basic test program works.
Mike Pavone <pavone@retrodev.com>
parents:
136
diff
changeset
|
1707 ]Append[Fold[_Global Store Inits C[?, ?, [program]Type Registry >>], "", [program]Global Stores >>]] |
127
50406500334d
Port availability of type names at runtime to compiled compiler
Mike Pavone <pavone@retrodev.com>
parents:
123
diff
changeset
|
1708 ]Append[Fold[Init Type Names[?, ?, ?, [program]Type Registry >>], "", [[program]Type Registry >>]Lookup >>]] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1709 ]Append[" |
186
ba35ab624ec2
Add support for raw C function output from C backend as well as an option to use Boehm-GC instead of reference counting
Mike Pavone <pavone@retrodev.com>
parents:
184
diff
changeset
|
1710 #include \"main_mid.c\" |
ba35ab624ec2
Add support for raw C function output from C backend as well as an option to use Boehm-GC instead of reference counting
Mike Pavone <pavone@retrodev.com>
parents:
184
diff
changeset
|
1711 |
ba35ab624ec2
Add support for raw C function output from C backend as well as an option to use Boehm-GC instead of reference counting
Mike Pavone <pavone@retrodev.com>
parents:
184
diff
changeset
|
1712 #ifdef ENABLE_LEAK_DETECTION\n\n"] |
118
b3f56e1d54a0
Merged changes from interpreted version of compiler to compiled version
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
1713 ]Append[Fold[_Consts C Release[?, ?, ?, p], "", constants]] |
b3f56e1d54a0
Merged changes from interpreted version of compiler to compiled version
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
1714 ]Append[ |
b3f56e1d54a0
Merged changes from interpreted version of compiler to compiled version
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
1715 " |
b3f56e1d54a0
Merged changes from interpreted version of compiler to compiled version
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
1716 print_mem_info(manager); |
b3f56e1d54a0
Merged changes from interpreted version of compiler to compiled version
Mike Pavone <pavone@retrodev.com>
parents:
109
diff
changeset
|
1717 print_live_object_types(manager); |
154
29b479a2ce48
Make memory leak detection controllable by a define
Mike Pavone <pavone@retrodev.com>
parents:
151
diff
changeset
|
1718 #endif //ENABLE_LEAK_DETECTION |
186
ba35ab624ec2
Add support for raw C function output from C backend as well as an option to use Boehm-GC instead of reference counting
Mike Pavone <pavone@retrodev.com>
parents:
184
diff
changeset
|
1719 #include \"main_end.c\"\n\n"] |
92
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1720 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1721 } |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1722 |
e73a93fb5de1
Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1723 |