about summary refs log tree commit diff stats
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rwxr-xr-xapps/mubin154329 -> 154340 bytes
-rw-r--r--apps/mu.subx38
2 files changed, 25 insertions, 13 deletions
diff --git a/apps/mu b/apps/mu
index 95d1501a..3a1fbac1 100755
--- a/apps/mu
+++ b/apps/mu
Binary files differdiff --git a/apps/mu.subx b/apps/mu.subx
index 6aa2333c..c2b752ed 100644
--- a/apps/mu.subx
+++ b/apps/mu.subx
@@ -240,7 +240,10 @@
 
 == data
 
-Program:  # (handle function)
+Program:
+_Program-functions:  # (handle function)
+  0/imm32
+_Program-types:  # (handle typeinfo)
   0/imm32
 
 Function-name:
@@ -1955,7 +1958,8 @@ test-convert-index-into-array:
 
 parse-mu:  # in: (addr buffered-file)
     # pseudocode
-    #   var curr-function: (addr (handle function)) = Program
+    #   var curr-function: (addr (handle function)) = Program->functions
+    #   var curr-type: (addr (handle typeinfo)) = Program->types
     #   var line: (stream byte 512)
     #   var word-slice: slice
     #   while true                                  # line loop
@@ -1967,7 +1971,7 @@ parse-mu:  # in: (addr buffered-file)
     #       continue
     #     else if slice-starts-with?(word-slice, "#")  # comment
     #       continue                                # end of line
-    #     else if slice-equal(word-slice, "fn")
+    #     else if slice-equal?(word-slice, "fn")
     #       var new-function: (handle function) = allocate(function)
     #       var vars: (stack (addr var) 256)
     #       populate-mu-function-header(in, new-function, vars)
@@ -1986,6 +1990,7 @@ parse-mu:  # in: (addr buffered-file)
     51/push-ecx
     52/push-edx
     53/push-ebx
+    56/push-esi
     57/push-edi
     # var line/ecx: (stream byte 512)
     81 5/subop/subtract %esp 0x200/imm32
@@ -1997,8 +2002,10 @@ parse-mu:  # in: (addr buffered-file)
     68/push 0/imm32/end
     68/push 0/imm32/start
     89/<- %edx 4/r32/esp
-    # var curr-function/edi: (addr (handle function)) = Program
-    bf/copy-to-edi Program/imm32
+    # var curr-function/edi: (addr (handle function))
+    bf/copy-to-edi _Program-functions/imm32
+    # var curr-type/esi: (addr (handle typeinfo))
+    be/copy-to-esi _Program-types/imm32
     # var vars/ebx: (stack (addr var) 256)
     81 5/subop/subtract %esp 0x400/imm32
     68/push 0x400/imm32/length
@@ -2036,7 +2043,7 @@ $parse-mu:fn:
         (slice-equal? %edx "fn")
         3d/compare-eax-and 0/imm32/false
         0f 84/jump-if-= break/disp32
-        # var new-function/eax: (handle function) = populate-mu-function(in, new-function, vars)
+        # var new-function/eax: (handle function) = populate-mu-function(line, in, vars)
         (allocate Heap *Function-size)  # => eax
         (zero-out %eax *Function-size)
         (clear-stack %ebx)
@@ -2056,6 +2063,7 @@ $parse-mu:end:
     81 0/subop/add %esp 0x630/imm32
     # . restore registers
     5f/pop-to-edi
+    5e/pop-to-esi
     5b/pop-to-ebx
     5a/pop-to-edx
     59/pop-to-ecx
@@ -2199,8 +2207,10 @@ $populate-mu-function-header:check-for-inout:
       01/add %edx 0/r32/eax
       # v->block-depth is implicitly 0
       #
+      # out->inouts = append(out->inouts, v)
       (append-list Heap %ebx *(edi+8))  # Function-inouts => eax
       89/<- *(edi+8) 0/r32/eax  # Function-inouts
+      # push(vars, v)
       (push *(ebp+0x10) %ebx)
       #
       e9/jump loop/disp32
@@ -4054,6 +4064,7 @@ $add-operation-and-inputs-to-stmt:inout-is-deref:
         ba/copy-to-edx 1/imm32/true
       }
       (lookup-var-or-literal %ecx *(ebp+0x10))  # => eax
+$add-operation-and-inputs-to-stmt:save-var:
       (append-stmt-var Heap %eax *(edi+8) %edx)  # Stmt1-inouts or Regvardef-inouts => eax
       89/<- *(edi+8) 0/r32/eax  # Stmt1-inouts or Regvardef-inouts
       e9/jump loop/disp32
@@ -4844,8 +4855,8 @@ emit-subx:  # out: (addr buffered-file)
     57/push-edi
     # edi = out
     8b/-> *(ebp+8) 7/r32/edi
-    # var curr/ecx: (handle function) = *Program
-    8b/-> *Program 1/r32/ecx
+    # var curr/ecx: (handle function) = *Program->functions
+    8b/-> *_Program-functions 1/r32/ecx
     {
       # if (curr == null) break
       81 7/subop/compare %ecx 0/imm32
@@ -5046,7 +5057,7 @@ $emit-subx-stmt-list:conditional-branch-with-target:
           # }}}
         }
 $emit-subx-stmt-list:1-to-1:
-        (emit-subx-stmt *(ebp+8) %ecx Primitives *Program)
+        (emit-subx-stmt *(ebp+8) %ecx Primitives *_Program-functions)
       }
       {
 $emit-subx-stmt-list:check-for-var-def:
@@ -5078,7 +5089,7 @@ $emit-subx-stmt-list:reg-var-def:
         # register variable definition
         (push *(ebp+0x10) %eax)
         # emit the instruction as usual
-        (emit-subx-stmt *(ebp+8) %ecx Primitives *Program)
+        (emit-subx-stmt *(ebp+8) %ecx Primitives *_Program-functions)
         # var-seen? = true
         ba/copy-to-edx 1/imm32/true
       }
@@ -5553,7 +5564,7 @@ $emit-subx-stmt-list:array-length:
       e9/jump $emit-subx-stmt:end/disp32
     }
     # }}}
-    # array index {{{
+    # index into array {{{
     # TODO: support literal index
     {
       # if (!string-equal?(var->operation, "index")) break
@@ -5571,8 +5582,9 @@ $emit-subx-stmt-list:index:
       (write-buffered *(ebp+8) " + ")
       # inouts[1]->register
       8b/-> *(ecx+8) 0/r32/eax  # Stmt1-inouts
-      8b/-> *(eax+4) 0/r32/eax  # List-next
-      8b/-> *eax 0/r32/eax  # List-value
+      8b/-> *(eax+4) 0/r32/eax  # Stmt-var-next
+      8b/-> *eax 0/r32/eax  # Stmt-var-value
+      # TODO: handle Stmt-var-is-deref
       (write-buffered *(ebp+8) *(eax+0x10))  # Var-register => eax
       #
       (write-buffered *(ebp+8) "<<2 + 4) ")
am.subx.html?h=hlt&id=3de4d557d5e4686e5be589a8c61b4246f6bab549'>^
3350c34a ^
7b109ab6 ^










3350c34a ^
7b109ab6 ^














3350c34a ^




4254408a ^



















3350c34a ^
4254408a ^










3350c34a ^
4254408a ^














3350c34a ^




4254408a ^
























































7b109ab6 ^



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275