about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rwxr-xr-xapps/mubin359122 -> 360624 bytes
-rw-r--r--apps/mu.subx136
2 files changed, 125 insertions, 11 deletions
diff --git a/apps/mu b/apps/mu
index 1926795b..69d204ad 100755
--- a/apps/mu
+++ b/apps/mu
Binary files differdiff --git a/apps/mu.subx b/apps/mu.subx
index 9a024318..1da0be3b 100644
--- a/apps/mu.subx
+++ b/apps/mu.subx
@@ -1609,7 +1609,98 @@ test-convert-function-call-with-inout-with-incorrect-compound-type:
     # check output
     (check-stream-equal _test-output-stream  ""  "F - test-convert-function-call-with-inout-with-incorrect-compound-type: output should be empty")
     (check-next-stream-line-equal _test-error-stream  "fn f: call g: type for inout 'x' is not right"  "F - test-convert-function-call-with-inout-with-incorrect-compound-type: error message")
-    # don't bother checking the generated code; that's in the test 'test-local-clobbered-by-fn-output' below
+    # don't restore from ebp
+    81 0/subop/add %esp 8/imm32
+    # . epilogue
+    5d/pop-to-ebp
+    c3/return
+
+test-convert-function-call-with-inout-with-multiple-type-parameters:
+    # . prologue
+    55/push-ebp
+    89/<- %ebp 4/r32/esp
+    # setup
+    (clear-stream _test-input-stream)
+    (clear-stream $_test-input-buffered-file->buffer)
+    (clear-stream _test-output-stream)
+    (clear-stream $_test-output-buffered-file->buffer)
+    (clear-stream _test-error-stream)
+    (clear-stream $_test-error-buffered-file->buffer)
+    # var ed/edx: exit-descriptor = tailor-exit-descriptor(16)
+    68/push 0/imm32
+    68/push 0/imm32
+    89/<- %edx 4/r32/esp
+    (tailor-exit-descriptor %edx 0x10)
+    #
+    (write _test-input-stream "fn f {\n")
+    (write _test-input-stream "  var x: (addr int)\n")
+    (write _test-input-stream "  var y: (addr boolean)\n")
+    (write _test-input-stream "  g x, y\n")
+    (write _test-input-stream "}\n")
+    (write _test-input-stream "fn g a: (addr _), b: (addr _) {\n")
+    (write _test-input-stream "}\n")
+    # convert
+    (convert-mu _test-input-buffered-file _test-output-buffered-file _test-error-buffered-file %edx)
+    # registers except esp clobbered at this point
+    # restore ed
+    89/<- %edx 4/r32/esp
+    (flush _test-output-buffered-file)
+    (flush _test-error-buffered-file)
+#?     # dump _test-error-stream {{{
+#?     (write 2 "^")
+#?     (write-stream 2 _test-error-stream)
+#?     (write 2 "$\n")
+#?     (rewind-stream _test-error-stream)
+#?     # }}}
+    # no errors
+    (check-stream-equal _test-error-stream  ""  "F - test-convert-function-call-with-inout-with-multiple-type-parameters: error stream should be empty")
+    # don't bother checking the generated code
+    # don't restore from ebp
+    81 0/subop/add %esp 8/imm32
+    # . epilogue
+    5d/pop-to-ebp
+    c3/return
+
+test-convert-function-call-with-inout-with-incompatible-type-parameters:
+    # . prologue
+    55/push-ebp
+    89/<- %ebp 4/r32/esp
+    # setup
+    (clear-stream _test-input-stream)
+    (clear-stream $_test-input-buffered-file->buffer)
+    (clear-stream _test-output-stream)
+    (clear-stream $_test-output-buffered-file->buffer)
+    (clear-stream _test-error-stream)
+    (clear-stream $_test-error-buffered-file->buffer)
+    # var ed/edx: exit-descriptor = tailor-exit-descriptor(16)
+    68/push 0/imm32
+    68/push 0/imm32
+    89/<- %edx 4/r32/esp
+    (tailor-exit-descriptor %edx 0x10)
+    #
+    (write _test-input-stream "fn f {\n")
+    (write _test-input-stream "  var x: (addr int)\n")
+    (write _test-input-stream "  var y: (addr boolean)\n")
+    (write _test-input-stream "  g x, y\n")
+    (write _test-input-stream "}\n")
+    (write _test-input-stream "fn g a: (addr _T), b: (addr _T) {\n")
+    (write _test-input-stream "}\n")
+    # convert
+    (convert-mu _test-input-buffered-file _test-output-buffered-file _test-error-buffered-file %edx)
+    # registers except esp clobbered at this point
+    # restore ed
+    89/<- %edx 4/r32/esp
+    (flush _test-output-buffered-file)
+    (flush _test-error-buffered-file)
+#?     # dump _test-error-stream {{{
+#?     (write 2 "^")
+#?     (write-stream 2 _test-error-stream)
+#?     (write 2 "$\n")
+#?     (rewind-stream _test-error-stream)
+#?     # }}}
+    # check output
+    (check-stream-equal _test-output-stream  ""  "F - test-convert-function-call-with-inout-with-incompatible-type-parameters: output should be empty")
+    (check-next-stream-line-equal _test-error-stream  "fn f: call g: type for inout 'x' is not right"  "F - test-convert-function-call-with-inout-with-incompatible-type-parameters: error message")
     # don't restore from ebp
     81 0/subop/add %esp 8/imm32
     # . epilogue
@@ -12177,6 +12268,15 @@ check-mu-call:  # stmt: (addr stmt), callee: (addr function), fn: (addr function
     # . prologue
     55/push-ebp
     89/<- %ebp 4/r32/esp
+    # var type-parameters: (addr table (handle array byte) (addr type-tree) 8)
+    68/push 0/imm32
+    # var type-parameters-storage: (table (handle array byte) (addr type-tree) 8)
+    81 5/subop/subtract %esp 0x60/imm32
+    68/push 0x60/imm32/size
+    68/push 0/imm32/read
+    68/push 0/imm32/write
+    # save a pointer to type-parameters-storage at type-parameters
+    89/<- *(ebp-4) 4/r32/esp
     # . save registers
     50/push-eax
     51/push-ecx
@@ -12225,7 +12325,7 @@ $check-mu-call:check-inout-type:
       # var t2/eax: (addr type-tree) = lookup(v2->type)
       (lookup *(eax+8) *(eax+0xc))  # Var-type Var-type => eax
       # if (t != t2) error
-      (type-match? %eax %ebx)  # => eax
+      (type-match? %eax %ebx *(ebp-4))  # => eax
       3d/compare-eax-and 0/imm32/false
       {
         0f 85/jump-if-!= break/disp32
@@ -12324,7 +12424,7 @@ $check-mu-call:check-output-type:
       # var t2/eax: (addr type-tree) = lookup(v2->type)
       (lookup *(eax+8) *(eax+0xc))  # Var-type Var-type => eax
       # if (t != t2) error
-      (type-match? %eax %ebx)  # => eax
+      (type-match? %eax %ebx *(ebp-4))  # => eax
       3d/compare-eax-and 0/imm32/false
       {
         0f 85/jump-if-!= break/disp32
@@ -12428,13 +12528,15 @@ $check-mu-call:end:
     5a/pop-to-edx
     59/pop-to-ecx
     58/pop-to-eax
+    # . reclaim locals exclusively on the stack
+    81 0/subop/add %esp 0x70/imm32
     # . epilogue
     89/<- %esp 5/r32/ebp
     5d/pop-to-ebp
     c3/return
 
 # like type-equal? but takes literals into account
-type-match?:  # def: (addr type-tree), call: (addr type-tree) -> result/eax: boolean
+type-match?:  # def: (addr type-tree), call: (addr type-tree), type-parameters: (addr table (handle array byte) (addr type-tree)) -> result/eax: boolean
     # . prologue
     55/push-ebp
     89/<- %ebp 4/r32/esp
@@ -12443,17 +12545,16 @@ type-match?:  # def: (addr type-tree), call: (addr type-tree) -> result/eax: boo
     3d/compare-eax-and 0/imm32/false
     b8/copy-to-eax 1/imm32/true
     75/jump-if-!= $type-match?:end/disp8
-    # TODO: if (def == '_') return false  # wildcard alone is illegal
 $type-match?:baseline:
     # otherwise fall back
-    (type-component-match? *(ebp+8) *(ebp+0xc))  # => eax
+    (type-component-match? *(ebp+8) *(ebp+0xc) *(ebp+0x10))  # => eax
 $type-match?:end:
     # . epilogue
     89/<- %esp 5/r32/ebp
     5d/pop-to-ebp
     c3/return
 
-type-component-match?:  # def: (addr type-tree), call: (addr type-tree) -> result/eax: boolean
+type-component-match?:  # def: (addr type-tree), call: (addr type-tree), type-parameters: (addr table (handle array byte) (addr type-tree)) -> result/eax: boolean
     # . prologue
     55/push-ebp
     89/<- %ebp 4/r32/esp
@@ -12479,8 +12580,8 @@ $type-component-match?:check-type-parameter:
       81 7/subop/compare *(ecx+4) 0xa/imm32/type-parameter  # Type-tree-value
       75/jump-if-!= break/disp8
 $type-component-match?:type-parameter:
-      b8/copy-to-eax 1/imm32/true
-      0f 84/jump-if-= $type-component-match?:end/disp32
+      (type-parameter-match? *(ecx+8) *(ecx+0xc)  %edx  *(ebp+0x10))  # => eax
+      e9/jump $type-component-match?:end/disp32
     }
 $type-component-match?:compare-atom-state:
     # if (def->is-atom? != call->is-atom?) return false
@@ -12505,7 +12606,7 @@ $type-component-match?:check-left:
     (lookup *(ecx+4) *(ecx+8))  # Type-tree-left Type-tree-left => eax
     89/<- %ebx 0/r32/eax
     (lookup *(edx+4) *(edx+8))  # Type-tree-left Type-tree-left => eax
-    (type-component-match? %ebx %eax)  # => eax
+    (type-component-match? %ebx %eax *(ebp+0x10))  # => eax
     3d/compare-eax-and 0/imm32/false
     74/jump-if-= $type-component-match?:end/disp8
 $type-component-match?:check-right:
@@ -12513,7 +12614,7 @@ $type-component-match?:check-right:
     (lookup *(ecx+0xc) *(ecx+0x10))  # Type-tree-right Type-tree-right => eax
     89/<- %ebx 0/r32/eax
     (lookup *(edx+0xc) *(edx+0x10))  # Type-tree-right Type-tree-right => eax
-    (type-component-match? %ebx %eax)  # => eax
+    (type-component-match? %ebx %eax *(ebp+0x10))  # => eax
 $type-component-match?:end:
     # . restore registers
     5b/pop-to-ebx
@@ -12524,6 +12625,19 @@ $type-component-match?:end:
     5d/pop-to-ebp
     c3/return
 
+type-parameter-match?:  # type-parameter-name: (handle array byte), type: (addr type-tree), type-parameters: (addr table (handle array byte) (addr type-tree)) -> result/eax: boolean
+    # . prologue
+    55/push-ebp
+    89/<- %ebp 4/r32/esp
+    # . save registers
+$type-parameter-match?:end:
+    b8/copy-to-eax 1/imm32/true
+    # . restore registers
+    # . epilogue
+    89/<- %esp 5/r32/ebp
+    5d/pop-to-ebp
+    c3/return
+
 size-of:  # v: (addr var) -> result/eax: int
     # . prologue
     55/push-ebp
; 2010-01-31 14:33:33 +0100 committer rumpf_a@web.de <> 2010-01-31 14:33:33 +0100 parseutils added' href='/ahoang/Nim/commit/lib/pure/parseutils.nim?h=devel&id=e22c73fd893447cc59dd854e9680626ed7da01b2'>e22c73fd8 ^
e80be6173 ^
6ca563dd2 ^
e80be6173 ^
6ca563dd2 ^
e80be6173 ^



6ca563dd2 ^

e80be6173 ^



6ca563dd2 ^








e22c73fd8 ^



a97684e27 ^
e22c73fd8 ^
a97684e27 ^
3e9dcc8be ^
e22c73fd8 ^

9acfc4311 ^
8d3966923 ^
9acfc4311 ^

dbcca9b3b ^
a97684e27 ^
dbcca9b3b ^
a97684e27 ^
9acfc4311 ^
dbcca9b3b ^
e22c73fd8 ^
d1b766cec ^
e22c73fd8 ^

8d3966923 ^
d1b766cec ^

e22c73fd8 ^
a97684e27 ^
e22c73fd8 ^
3e9dcc8be ^
e22c73fd8 ^



a97684e27 ^
e22c73fd8 ^
ae5074455 ^
d81935014 ^

a97684e27 ^


e22c73fd8 ^
8d3966923 ^
e22c73fd8 ^
d81935014 ^
a97684e27 ^
e22c73fd8 ^
ae5074455 ^
8d3966923 ^
ae5074455 ^
d81935014 ^

ae5074455 ^
a97684e27 ^
ae5074455 ^
d81935014 ^



a97684e27 ^
d81935014 ^
ae5074455 ^


a97684e27 ^
e22c73fd8 ^
d1b766cec ^



8d3966923 ^
d1b766cec ^
d81935014 ^










d1b766cec ^
3e9dcc8be ^
d1b766cec ^
b357e8083 ^




856dc4c5c ^


b357e8083 ^










d1b766cec ^



8d3966923 ^
d1b766cec ^
a97684e27 ^
d1b766cec ^
3e9dcc8be ^
d1b766cec ^
92a793350 ^
657dca5c3 ^
c24dc7944 ^
92a793350 ^
264de4537 ^


e22c73fd8 ^

92b8fac94 ^
e22c73fd8 ^


a97684e27 ^





e22c73fd8 ^
a97684e27 ^
e22c73fd8 ^

a97684e27 ^
e22c73fd8 ^



92b8fac94 ^
8098e2a42 ^
e22c73fd8 ^


92b8fac94 ^
ccd58fba2 ^
8d3966923 ^
ccd58fba2 ^

e22c73fd8 ^
8098e2a42 ^

e22c73fd8 ^


92b8fac94 ^
e22c73fd8 ^


2f43fdb83 ^
b2d188995 ^
e22c73fd8 ^

55cdaaef6 ^











a97684e27 ^

55cdaaef6 ^
a97684e27 ^
55cdaaef6 ^





a97684e27 ^
55cdaaef6 ^

ac9c2126e ^

9aa845c6b ^
ac9c2126e ^

9aa845c6b ^
a97684e27 ^

9aa845c6b ^
a97684e27 ^
9aa845c6b ^
ac9c2126e ^
9aa845c6b ^


a97684e27 ^
9aa845c6b ^


ac9c2126e ^
9aa845c6b ^
c55ff72ea ^



ac9c2126e ^
9aa845c6b ^




9aa845c6b ^

c55ff72ea ^



ac9c2126e ^
9aa845c6b ^
ac9c2126e ^



9aa845c6b ^

7b480ea2b ^




e22c73fd8 ^
8098e2a42 ^

eca05d2a3 ^
c95f6f117 ^
eca05d2a3 ^
92b8fac94 ^
e22c73fd8 ^
b2d188995 ^

8d3966923 ^
dbcca9b3b ^
11b695875 ^
14968fba4 ^
7c3435785 ^


14968fba4 ^

9fb36bd20 ^
11b695875 ^
9fb36bd20 ^




4523b29d7 ^
9fb36bd20 ^




4523b29d7 ^
9fb36bd20 ^



7c3435785 ^
9fb36bd20 ^
14968fba4 ^
11b695875 ^
9fb36bd20 ^

a97684e27 ^

14968fba4 ^

a97684e27 ^












14968fba4 ^

a97684e27 ^
14968fba4 ^
a97684e27 ^
14968fba4 ^

a97684e27 ^
7c3435785 ^


dbcca9b3b ^
8d3966923 ^
8f587e2ea ^
14968fba4 ^
7c3435785 ^
14968fba4 ^

9fb36bd20 ^




14968fba4 ^

22db40e5e ^



55cdaaef6 ^
32109a786 ^
67cea2b9b ^

55cdaaef6 ^
67cea2b9b ^
55cdaaef6 ^
67cea2b9b ^

55cdaaef6 ^
9acfc4311 ^
55cdaaef6 ^


























dbcca9b3b ^
e22c73fd8 ^
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
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493