Browse Source

Typer updated

Overloading for functions now handled.

cf TODO files :
* Functions => ref6.cpp
* Classes
Phyks (Lucas Verney) 5 years ago
parent
commit
b77f541c14
25 changed files with 42733 additions and 40550 deletions
  1. 2
    1
      TODO
  2. BIN
      compiler.cmi
  3. BIN
      compiler.cmo
  4. 12
    1
      hello.cpp
  5. 99
    50
      hello.s
  6. BIN
      main.cmi
  7. BIN
      main.cmo
  8. BIN
      minic++
  9. 36776
    36776
      parser.annot
  10. 36
    36
      parser.ml
  11. 4
    3
      tests/exec/address2.s
  12. 6
    4
      tests/exec/address3.s
  13. 8
    6
      tests/exec/bresenham.s
  14. 5
    4
      tests/exec/fact_loop.s
  15. 8
    6
      tests/exec/fact_rec.s
  16. 85
    54
      tests/exec/mandelbrot.s
  17. 4
    3
      tests/exec/passing.s
  18. 4
    3
      tests/exec/ref2.s
  19. 8
    5
      tests/exec/ref3.s
  20. 6
    4
      tests/exec/ref4.s
  21. 12
    7
      tests/exec/ref5.s
  22. 5546
    3558
      typer.annot
  23. BIN
      typer.cmi
  24. BIN
      typer.cmo
  25. 112
    29
      typer.ml

+ 2
- 1
TODO View File

@@ -5,8 +5,9 @@
5 5
     * bad/overload1
6 6
     * good/subtype2, 3
7 7
 * Fonctions
8
-    * Surcharge
8
+    * ref6.cpp
9 9
 * Classes
10
+    * Constructeurs => easy
10 11
     * Méthodes
11 12
     * Héritage
12 13
     * Héritage multiple

BIN
compiler.cmi View File


BIN
compiler.cmo View File


+ 12
- 1
hello.cpp View File

@@ -21,9 +21,17 @@ int fonction_args(int x, int y) {
21 21
 
22 22
 class A { public: int x; int y;};
23 23
 
24
+void surcharge() {
25
+    std::cout << 42 << "\n";
26
+}
27
+
28
+void surcharge (int x) {
29
+    std::cout << x << "\n";
30
+}
31
+
24 32
 int main() {
25 33
     A a;
26
-    A *a1 = new A();
34
+    // TODO A *a1 = new A();
27 35
     int x = 3;
28 36
     int y = 0;
29 37
 
@@ -99,5 +107,8 @@ int main() {
99 107
         }
100 108
     }
101 109
 
110
+    surcharge();
111
+    surcharge(43);
112
+
102 113
     return 2;
103 114
 }

+ 99
- 50
hello.s View File

@@ -1,6 +1,6 @@
1 1
 .text
2 2
 	b function_main
3
-function_fonction:
3
+function_fonction1:
4 4
 	add $sp, $sp, -12
5 5
 	sw $fp, 8($sp)
6 6
 	add $fp, $sp, 8
@@ -10,13 +10,13 @@ function_fonction:
10 10
 	la $a0, string_1
11 11
 	li $v0, 4
12 12
 	syscall
13
-end_function_fonction:
13
+end_function_fonction1:
14 14
 	lw $ra, 4($sp)
15 15
 	lw $fp, 8($sp)
16 16
 	add $sp, $sp, 12
17 17
 	move $v0, $a0
18 18
 	jr $ra
19
-function_fonction_args:
19
+function_fonction_args2:
20 20
 	add $sp, $sp, -12
21 21
 	sw $fp, 8($sp)
22 22
 	add $fp, $sp, 8
@@ -62,12 +62,46 @@ test_while_1:
62 62
 	la $a0, string_6
63 63
 	li $v0, 4
64 64
 	syscall
65
-end_function_fonction_args:
65
+end_function_fonction_args2:
66 66
 	lw $ra, 4($sp)
67 67
 	lw $fp, 8($sp)
68 68
 	add $sp, $sp, 12
69 69
 	move $v0, $a0
70 70
 	jr $ra
71
+function_surcharge3:
72
+	add $sp, $sp, -8
73
+	sw $fp, 4($sp)
74
+	add $fp, $sp, 4
75
+	sw $ra, 0($sp)
76
+	li $a0, 42
77
+	li $v0, 1
78
+	syscall
79
+	la $a0, string_7
80
+	li $v0, 4
81
+	syscall
82
+end_function_surcharge3:
83
+	lw $ra, 0($sp)
84
+	lw $fp, 4($sp)
85
+	add $sp, $sp, 8
86
+	move $v0, $a0
87
+	jr $ra
88
+function_surcharge4:
89
+	add $sp, $sp, -8
90
+	sw $fp, 4($sp)
91
+	add $fp, $sp, 4
92
+	sw $ra, 0($sp)
93
+	lw $a0, 4($fp)
94
+	li $v0, 1
95
+	syscall
96
+	la $a0, string_8
97
+	li $v0, 4
98
+	syscall
99
+end_function_surcharge4:
100
+	lw $ra, 0($sp)
101
+	lw $fp, 4($sp)
102
+	add $sp, $sp, 8
103
+	move $v0, $a0
104
+	jr $ra
71 105
 function_main:
72 106
 	add $sp, $sp, -36
73 107
 	sw $fp, 32($sp)
@@ -83,7 +117,7 @@ function_main:
83 117
 	lw $a0, -12($fp)
84 118
 	li $v0, 1
85 119
 	syscall
86
-	la $a0, string_7
120
+	la $a0, string_9
87 121
 	li $v0, 4
88 122
 	syscall
89 123
 	li $a0, 3
@@ -99,22 +133,22 @@ function_main:
99 133
 	lw $a0, var_test
100 134
 	li $v0, 1
101 135
 	syscall
102
-	la $a0, string_8
136
+	la $a0, string_10
103 137
 	li $v0, 4
104 138
 	syscall
105 139
 	lw $a0, -8($fp)
106 140
 	li $v0, 1
107 141
 	syscall
108
-	la $a0, string_9
142
+	la $a0, string_11
109 143
 	li $v0, 4
110 144
 	syscall
111
-	la $a0, string_10
145
+	la $a0, string_12
112 146
 	li $v0, 4
113 147
 	syscall
114 148
 	lw $a0, var_bidule
115 149
 	li $v0, 1
116 150
 	syscall
117
-	la $a0, string_11
151
+	la $a0, string_13
118 152
 	li $v0, 4
119 153
 	syscall
120 154
 	lw $a0, -8($fp)
@@ -128,7 +162,7 @@ function_main:
128 162
 	lw $a0, -8($fp)
129 163
 	li $v0, 1
130 164
 	syscall
131
-	la $a0, string_12
165
+	la $a0, string_14
132 166
 	li $v0, 4
133 167
 	syscall
134 168
 	lw $a0, -8($fp)
@@ -138,13 +172,13 @@ function_main:
138 172
 	lw $a0, -8($fp)
139 173
 	li $v0, 1
140 174
 	syscall
141
-	la $a0, string_13
175
+	la $a0, string_15
142 176
 	li $v0, 4
143 177
 	syscall
144 178
 	lw $a0, -12($fp)
145 179
 	li $v0, 1
146 180
 	syscall
147
-	la $a0, string_14
181
+	la $a0, string_16
148 182
 	li $v0, 4
149 183
 	syscall
150 184
 	li $a0, 41
@@ -183,19 +217,19 @@ function_main:
183 217
 	li $a0, 43
184 218
 	li $v0, 1
185 219
 	syscall
186
-	la $a0, string_15
220
+	la $a0, string_17
187 221
 	li $v0, 4
188 222
 	syscall
189
-	la $a0, string_16
223
+	la $a0, string_18
190 224
 	li $v0, 4
191 225
 	syscall
192
-	la $a0, string_17
226
+	la $a0, string_19
193 227
 	li $v0, 4
194 228
 	syscall
195
-	la $a0, string_18
229
+	la $a0, string_20
196 230
 	li $v0, 4
197 231
 	syscall
198
-	la $a0, string_19
232
+	la $a0, string_21
199 233
 	li $v0, 4
200 234
 	syscall
201 235
 	add $sp, $sp, 0
@@ -208,17 +242,17 @@ function_main:
208 242
 	seq $a0, $t1, $a0
209 243
 	beqz $a0, else_1
210 244
 	add $sp, $sp, 0
211
-	la $a0, string_20
245
+	la $a0, string_22
212 246
 	li $v0, 4
213 247
 	syscall
214
-	la $a0, string_21
248
+	la $a0, string_23
215 249
 	li $v0, 4
216 250
 	syscall
217 251
 	add $sp, $sp, 0
218 252
 	b end_if_1
219 253
 else_1:
220 254
 	add $sp, $sp, 0
221
-	la $a0, string_22
255
+	la $a0, string_24
222 256
 	li $v0, 4
223 257
 	syscall
224 258
 	add $sp, $sp, 0
@@ -235,7 +269,7 @@ end_if_1:
235 269
 	slt $a0, $t1, $a0
236 270
 	li $v0, 1
237 271
 	syscall
238
-	la $a0, string_23
272
+	la $a0, string_25
239 273
 	li $v0, 4
240 274
 	syscall
241 275
 	add $sp, $sp, 0
@@ -245,7 +279,7 @@ body_while_2:
245 279
 	lw $a0, -16($fp)
246 280
 	li $v0, 1
247 281
 	syscall
248
-	la $a0, string_24
282
+	la $a0, string_26
249 283
 	li $v0, 4
250 284
 	syscall
251 285
 	lw $a0, -16($fp)
@@ -273,7 +307,7 @@ body_for_1:
273 307
 	lw $a0, -20($fp)
274 308
 	li $v0, 1
275 309
 	syscall
276
-	la $a0, string_25
310
+	la $a0, string_27
277 311
 	li $v0, 4
278 312
 	syscall
279 313
 	add $sp, $sp, 0
@@ -290,13 +324,14 @@ test_for_1:
290 324
 	slt $a0, $t1, $a0
291 325
 	bnez $a0, body_for_1
292 326
 	add $sp, $sp, 0
293
-	jal function_fonction
327
+	jal function_fonction1
294 328
 	add $sp, $sp, 0
329
+	move $a0, $v0
295 330
 	sw $a0, -24($fp)
296 331
 	lw $a0, -24($fp)
297 332
 	li $v0, 1
298 333
 	syscall
299
-	la $a0, string_26
334
+	la $a0, string_28
300 335
 	li $v0, 4
301 336
 	syscall
302 337
 	li $a0, 0
@@ -305,14 +340,14 @@ test_for_1:
305 340
 	lw $a0, 0($a0)
306 341
 	li $v0, 1
307 342
 	syscall
308
-	la $a0, string_27
343
+	la $a0, string_29
309 344
 	li $v0, 4
310 345
 	syscall
311 346
 	la $a0, object_a
312 347
 	lw $a0, 4($a0)
313 348
 	li $v0, 1
314 349
 	syscall
315
-	la $a0, string_28
350
+	la $a0, string_30
316 351
 	li $v0, 4
317 352
 	syscall
318 353
 	li $a0, 3
@@ -325,14 +360,14 @@ test_for_1:
325 360
 	lw $a0, 0($a0)
326 361
 	li $v0, 1
327 362
 	syscall
328
-	la $a0, string_29
363
+	la $a0, string_31
329 364
 	li $v0, 4
330 365
 	syscall
331 366
 	la $a0, object_a
332 367
 	lw $a0, 4($a0)
333 368
 	li $v0, 1
334 369
 	syscall
335
-	la $a0, string_30
370
+	la $a0, string_32
336 371
 	li $v0, 4
337 372
 	syscall
338 373
 	li $a0, 43
@@ -341,8 +376,9 @@ test_for_1:
341 376
 	li $a0, 42
342 377
 	sub $sp, $sp, 4
343 378
 	sw $a0, 0($sp)
344
-	jal function_fonction_args
379
+	jal function_fonction_args2
345 380
 	add $sp, $sp, 8
381
+	move $a0, $v0
346 382
 	li $a0, 0
347 383
 	sw $a0, -16($fp)
348 384
 	add $sp, $sp, 0
@@ -354,7 +390,7 @@ body_while_3:
354 390
 	sw $a0, -16($fp)
355 391
 	li $v0, 1
356 392
 	syscall
357
-	la $a0, string_31
393
+	la $a0, string_33
358 394
 	li $v0, 4
359 395
 	syscall
360 396
 	add $sp, $sp, 0
@@ -368,10 +404,10 @@ test_while_3:
368 404
 	slt $a0, $t1, $a0
369 405
 	bnez $a0, body_while_3
370 406
 	add $sp, $sp, 0
371
-	la $a0, string_32
407
+	la $a0, string_34
372 408
 	li $v0, 4
373 409
 	syscall
374
-	la $a0, string_33
410
+	la $a0, string_35
375 411
 	li $v0, 4
376 412
 	syscall
377 413
 	add $sp, $sp, 0
@@ -391,13 +427,13 @@ body_for_3:
391 427
 	lw $a0, -16($fp)
392 428
 	li $v0, 1
393 429
 	syscall
394
-	la $a0, string_34
430
+	la $a0, string_36
395 431
 	li $v0, 4
396 432
 	syscall
397 433
 	lw $a0, -32($fp)
398 434
 	li $v0, 1
399 435
 	syscall
400
-	la $a0, string_35
436
+	la $a0, string_37
401 437
 	li $v0, 4
402 438
 	syscall
403 439
 	add $sp, $sp, 0
@@ -428,6 +464,15 @@ test_for_2:
428 464
 	slt $a0, $t1, $a0
429 465
 	bnez $a0, body_for_2
430 466
 	add $sp, $sp, 0
467
+	jal function_surcharge3
468
+	add $sp, $sp, 0
469
+	move $a0, $v0
470
+	li $a0, 43
471
+	sub $sp, $sp, 4
472
+	sw $a0, 0($sp)
473
+	jal function_surcharge4
474
+	add $sp, $sp, 4
475
+	move $a0, $v0
431 476
 	li $a0, 2
432 477
 	move $v0, $a0
433 478
 	li $v0, 17
@@ -459,21 +504,21 @@ string_5:
459 504
 	.asciiz "\n"
460 505
 string_6:
461 506
 	.asciiz "\n"
462
-object_a:
463
-	.word 0
464
-	.word 0
465 507
 string_7:
466 508
 	.asciiz "\n"
467 509
 string_8:
468 510
 	.asciiz "\n"
511
+object_a:
512
+	.word 0
513
+	.word 0
469 514
 string_9:
470 515
 	.asciiz "\n"
471 516
 string_10:
472
-	.asciiz "bidule"
517
+	.asciiz "\n"
473 518
 string_11:
474 519
 	.asciiz "\n"
475 520
 string_12:
476
-	.asciiz "\n"
521
+	.asciiz "bidule"
477 522
 string_13:
478 523
 	.asciiz "\n"
479 524
 string_14:
@@ -481,23 +526,23 @@ string_14:
481 526
 string_15:
482 527
 	.asciiz "\n"
483 528
 string_16:
484
-	.asciiz "test"
529
+	.asciiz "\n"
485 530
 string_17:
486
-	.asciiz "print "
531
+	.asciiz "\n"
487 532
 string_18:
488
-	.asciiz "plusieurs\n"
533
+	.asciiz "test"
489 534
 string_19:
490
-	.asciiz "chaines\n"
535
+	.asciiz "print "
491 536
 string_20:
492
-	.asciiz "if ok"
537
+	.asciiz "plusieurs\n"
493 538
 string_21:
494
-	.asciiz "\n"
539
+	.asciiz "chaines\n"
495 540
 string_22:
496
-	.asciiz "else ok \n"
541
+	.asciiz "if ok"
497 542
 string_23:
498 543
 	.asciiz "\n"
499 544
 string_24:
500
-	.asciiz "\n"
545
+	.asciiz "else ok \n"
501 546
 string_25:
502 547
 	.asciiz "\n"
503 548
 string_26:
@@ -513,10 +558,14 @@ string_30:
513 558
 string_31:
514 559
 	.asciiz "\n"
515 560
 string_32:
516
-	.asciiz "test for imbriques"
561
+	.asciiz "\n"
517 562
 string_33:
518 563
 	.asciiz "\n"
519 564
 string_34:
520
-	.asciiz ", "
565
+	.asciiz "test for imbriques"
521 566
 string_35:
522 567
 	.asciiz "\n"
568
+string_36:
569
+	.asciiz ", "
570
+string_37:
571
+	.asciiz "\n"

BIN
main.cmi View File


BIN
main.cmo View File


BIN
minic++ View File


+ 36776
- 36776
parser.annot
File diff suppressed because it is too large
View File


+ 36
- 36
parser.ml View File

@@ -199,13 +199,13 @@ let rec _menhir_goto_nonempty_list_preceded_IN_expr_str__ : _menhir_env -> 'ttv_
199 199
         let _v : 'tv_nonempty_list_preceded_IN_expr_str__ = let x =
200 200
           let x = x0 in
201 201
           
202
-# 86 "/tmp/test/pkg/ocaml-menhir/usr/share/menhir/standard.mly"
202
+# 86 "/usr/share/menhir/standard.mly"
203 203
     ( x )
204 204
 # 205 "parser.ml"
205 205
           
206 206
         in
207 207
         
208
-# 126 "/tmp/test/pkg/ocaml-menhir/usr/share/menhir/standard.mly"
208
+# 126 "/usr/share/menhir/standard.mly"
209 209
     ( x :: xs )
210 210
 # 211 "parser.ml"
211 211
          in
@@ -273,7 +273,7 @@ and _menhir_goto_loption_separated_nonempty_list_COMMA_expr__ : _menhir_env -> '
273 273
             let _v : 'tv_paren_separated_list_COMMA_expr__ = let x =
274 274
               let xs = xs0 in
275 275
               
276
-# 135 "/tmp/test/pkg/ocaml-menhir/usr/share/menhir/standard.mly"
276
+# 135 "/usr/share/menhir/standard.mly"
277 277
     ( xs )
278 278
 # 279 "parser.ml"
279 279
               
@@ -509,13 +509,13 @@ and _menhir_goto_expr_str : _menhir_env -> 'ttv_tail -> _menhir_state -> 'tv_exp
509 509
         let _v : 'tv_nonempty_list_preceded_IN_expr_str__ = let x =
510 510
           let x = x0 in
511 511
           
512
-# 86 "/tmp/test/pkg/ocaml-menhir/usr/share/menhir/standard.mly"
512
+# 86 "/usr/share/menhir/standard.mly"
513 513
     ( x )
514 514
 # 515 "parser.ml"
515 515
           
516 516
         in
517 517
         
518
-# 124 "/tmp/test/pkg/ocaml-menhir/usr/share/menhir/standard.mly"
518
+# 124 "/usr/share/menhir/standard.mly"
519 519
     ( [ x ] )
520 520
 # 521 "parser.ml"
521 521
          in
@@ -643,7 +643,7 @@ and _menhir_goto_separated_nonempty_list_COMMA_expr_ : _menhir_env -> 'ttv_tail
643 643
         let (_menhir_stack : 'freshtv927 * _menhir_state * 'tv_separated_nonempty_list_COMMA_expr_) = Obj.magic _menhir_stack in
644 644
         ((let (_menhir_stack, _menhir_s, x) = _menhir_stack in
645 645
         let _v : 'tv_loption_separated_nonempty_list_COMMA_expr__ = 
646
-# 59 "/tmp/test/pkg/ocaml-menhir/usr/share/menhir/standard.mly"
646
+# 59 "/usr/share/menhir/standard.mly"
647 647
     ( x )
648 648
 # 649 "parser.ml"
649 649
          in
@@ -655,7 +655,7 @@ and _menhir_goto_separated_nonempty_list_COMMA_expr_ : _menhir_env -> 'ttv_tail
655 655
         let (_menhir_stack : (('freshtv931 * _menhir_state * 'tv_expr * Lexing.position) * _menhir_state) * _menhir_state * 'tv_separated_nonempty_list_COMMA_expr_) = Obj.magic _menhir_stack in
656 656
         ((let (((_menhir_stack, _menhir_s, x, _startpos_x_), _), _, xs) = _menhir_stack in
657 657
         let _v : 'tv_separated_nonempty_list_COMMA_expr_ = 
658
-# 146 "/tmp/test/pkg/ocaml-menhir/usr/share/menhir/standard.mly"
658
+# 146 "/usr/share/menhir/standard.mly"
659 659
     ( x :: xs )
660 660
 # 661 "parser.ml"
661 661
          in
@@ -727,7 +727,7 @@ and _menhir_goto_separated_nonempty_list_COMMA_expr_ : _menhir_env -> 'ttv_tail
727 727
                 let _v : 'tv_instruction = let z =
728 728
                   let x = x0 in
729 729
                   
730
-# 86 "/tmp/test/pkg/ocaml-menhir/usr/share/menhir/standard.mly"
730
+# 86 "/usr/share/menhir/standard.mly"
731 731
     ( x )
732 732
 # 733 "parser.ml"
733 733
                   
@@ -1600,7 +1600,7 @@ and _menhir_goto_list_instruction_ : _menhir_env -> 'ttv_tail -> _menhir_state -
1600 1600
         let (_menhir_stack : ('freshtv875 * _menhir_state * 'tv_instruction * Lexing.position) * _menhir_state * 'tv_list_instruction_) = Obj.magic _menhir_stack in
1601 1601
         ((let ((_menhir_stack, _menhir_s, x, _endpos_x_), _, xs) = _menhir_stack in
1602 1602
         let _v : 'tv_list_instruction_ = 
1603
-# 116 "/tmp/test/pkg/ocaml-menhir/usr/share/menhir/standard.mly"
1603
+# 116 "/usr/share/menhir/standard.mly"
1604 1604
     ( x :: xs )
1605 1605
 # 1606 "parser.ml"
1606 1606
          in
@@ -1611,7 +1611,7 @@ and _menhir_goto_list_instruction_ : _menhir_env -> 'ttv_tail -> _menhir_state -
1611 1611
 and _menhir_reduce76 : _menhir_env -> 'ttv_tail -> _menhir_state -> 'ttv_return =
1612 1612
   fun _menhir_env _menhir_stack _menhir_s ->
1613 1613
     let _v : 'tv_option_expr_ = 
1614
-# 29 "/tmp/test/pkg/ocaml-menhir/usr/share/menhir/standard.mly"
1614
+# 29 "/usr/share/menhir/standard.mly"
1615 1615
     ( None )
1616 1616
 # 1617 "parser.ml"
1617 1617
      in
@@ -1667,7 +1667,7 @@ and _menhir_run67 : _menhir_env -> 'ttv_tail -> _menhir_state -> Lexing.position
1667 1667
 and _menhir_reduce69 : _menhir_env -> 'ttv_tail -> _menhir_state -> 'ttv_return =
1668 1668
   fun _menhir_env _menhir_stack _menhir_s ->
1669 1669
     let _v : 'tv_loption_separated_nonempty_list_COMMA_expr__ = 
1670
-# 57 "/tmp/test/pkg/ocaml-menhir/usr/share/menhir/standard.mly"
1670
+# 57 "/usr/share/menhir/standard.mly"
1671 1671
     ( [] )
1672 1672
 # 1673 "parser.ml"
1673 1673
      in
@@ -1990,7 +1990,7 @@ and _menhir_goto_expr : _menhir_env -> 'ttv_tail -> _menhir_state -> 'tv_expr ->
1990 1990
             let (_menhir_stack : 'freshtv685 * _menhir_state * 'tv_expr * Lexing.position) = Obj.magic _menhir_stack in
1991 1991
             ((let (_menhir_stack, _menhir_s, x, _startpos_x_) = _menhir_stack in
1992 1992
             let _v : 'tv_separated_nonempty_list_COMMA_expr_ = 
1993
-# 144 "/tmp/test/pkg/ocaml-menhir/usr/share/menhir/standard.mly"
1993
+# 144 "/usr/share/menhir/standard.mly"
1994 1994
     ( [ x ] )
1995 1995
 # 1996 "parser.ml"
1996 1996
              in
@@ -3090,7 +3090,7 @@ and _menhir_goto_expr : _menhir_env -> 'ttv_tail -> _menhir_state -> 'tv_expr ->
3090 3090
             let (_menhir_stack : 'freshtv815 * _menhir_state * 'tv_expr * Lexing.position) = Obj.magic _menhir_stack in
3091 3091
             ((let (_menhir_stack, _menhir_s, x, _startpos_x_) = _menhir_stack in
3092 3092
             let _v : 'tv_option_expr_ = 
3093
-# 31 "/tmp/test/pkg/ocaml-menhir/usr/share/menhir/standard.mly"
3093
+# 31 "/usr/share/menhir/standard.mly"
3094 3094
     ( Some x )
3095 3095
 # 3096 "parser.ml"
3096 3096
              in
@@ -3223,7 +3223,7 @@ and _menhir_goto_expr : _menhir_env -> 'ttv_tail -> _menhir_state -> 'tv_expr ->
3223 3223
             let _v : 'tv_instruction = let z =
3224 3224
               let x = x0 in
3225 3225
               
3226
-# 86 "/tmp/test/pkg/ocaml-menhir/usr/share/menhir/standard.mly"
3226
+# 86 "/usr/share/menhir/standard.mly"
3227 3227
     ( x )
3228 3228
 # 3229 "parser.ml"
3229 3229
               
@@ -3376,7 +3376,7 @@ and _menhir_goto_instruction : _menhir_env -> 'ttv_tail -> _menhir_state -> 'tv_
3376 3376
         let _v : 'tv_instruction = let z =
3377 3377
           let xs = xs1 in
3378 3378
           
3379
-# 135 "/tmp/test/pkg/ocaml-menhir/usr/share/menhir/standard.mly"
3379
+# 135 "/usr/share/menhir/standard.mly"
3380 3380
     ( xs )
3381 3381
 # 3382 "parser.ml"
3382 3382
           
@@ -3384,7 +3384,7 @@ and _menhir_goto_instruction : _menhir_env -> 'ttv_tail -> _menhir_state -> 'tv_
3384 3384
         let x =
3385 3385
           let xs = xs0 in
3386 3386
           
3387
-# 135 "/tmp/test/pkg/ocaml-menhir/usr/share/menhir/standard.mly"
3387
+# 135 "/usr/share/menhir/standard.mly"
3388 3388
     ( xs )
3389 3389
 # 3390 "parser.ml"
3390 3390
           
@@ -3592,7 +3592,7 @@ and _menhir_goto_separated_nonempty_list_COMMA_var_ : _menhir_env -> 'ttv_tail -
3592 3592
         let (_menhir_stack : ('freshtv593 * _menhir_state * 'tv_var) * _menhir_state * 'tv_separated_nonempty_list_COMMA_var_) = Obj.magic _menhir_stack in
3593 3593
         ((let ((_menhir_stack, _menhir_s, x), _, xs) = _menhir_stack in
3594 3594
         let _v : 'tv_separated_nonempty_list_COMMA_var_ = 
3595
-# 146 "/tmp/test/pkg/ocaml-menhir/usr/share/menhir/standard.mly"
3595
+# 146 "/usr/share/menhir/standard.mly"
3596 3596
     ( x :: xs )
3597 3597
 # 3598 "parser.ml"
3598 3598
          in
@@ -3684,7 +3684,7 @@ and _menhir_goto_separated_nonempty_list_COMMA_argument_ : _menhir_env -> 'ttv_t
3684 3684
         let (_menhir_s : _menhir_state) = _menhir_s in
3685 3685
         let (x : 'tv_separated_nonempty_list_COMMA_argument_) = _v in
3686 3686
         ((let _v : 'tv_loption_separated_nonempty_list_COMMA_argument__ = 
3687
-# 59 "/tmp/test/pkg/ocaml-menhir/usr/share/menhir/standard.mly"
3687
+# 59 "/usr/share/menhir/standard.mly"
3688 3688
     ( x )
3689 3689
 # 3690 "parser.ml"
3690 3690
          in
@@ -3700,7 +3700,7 @@ and _menhir_goto_separated_nonempty_list_COMMA_argument_ : _menhir_env -> 'ttv_t
3700 3700
         let (xs : 'tv_separated_nonempty_list_COMMA_argument_) = _v in
3701 3701
         ((let (_menhir_stack, _menhir_s, x) = _menhir_stack in
3702 3702
         let _v : 'tv_separated_nonempty_list_COMMA_argument_ = 
3703
-# 146 "/tmp/test/pkg/ocaml-menhir/usr/share/menhir/standard.mly"
3703
+# 146 "/usr/share/menhir/standard.mly"
3704 3704
     ( x :: xs )
3705 3705
 # 3706 "parser.ml"
3706 3706
          in
@@ -3711,7 +3711,7 @@ and _menhir_goto_separated_nonempty_list_COMMA_argument_ : _menhir_env -> 'ttv_t
3711 3711
 and _menhir_reduce63 : _menhir_env -> 'ttv_tail -> _menhir_state -> 'ttv_return =
3712 3712
   fun _menhir_env _menhir_stack _menhir_s ->
3713 3713
     let _v : 'tv_list_instruction_ = 
3714
-# 114 "/tmp/test/pkg/ocaml-menhir/usr/share/menhir/standard.mly"
3714
+# 114 "/usr/share/menhir/standard.mly"
3715 3715
     ( [] )
3716 3716
 # 3717 "parser.ml"
3717 3717
      in
@@ -4523,7 +4523,7 @@ and _menhir_goto_var : _menhir_env -> 'ttv_tail -> _menhir_state -> 'tv_var -> '
4523 4523
             let (_menhir_stack : 'freshtv471 * _menhir_state * 'tv_argument) = Obj.magic _menhir_stack in
4524 4524
             ((let (_menhir_stack, _menhir_s, x) = _menhir_stack in
4525 4525
             let _v : 'tv_separated_nonempty_list_COMMA_argument_ = 
4526
-# 144 "/tmp/test/pkg/ocaml-menhir/usr/share/menhir/standard.mly"
4526
+# 144 "/usr/share/menhir/standard.mly"
4527 4527
     ( [ x ] )
4528 4528
 # 4529 "parser.ml"
4529 4529
              in
@@ -4567,7 +4567,7 @@ and _menhir_goto_var : _menhir_env -> 'ttv_tail -> _menhir_state -> 'tv_var -> '
4567 4567
             let (_menhir_stack : 'freshtv489 * _menhir_state * 'tv_var) = Obj.magic _menhir_stack in
4568 4568
             ((let (_menhir_stack, _menhir_s, x) = _menhir_stack in
4569 4569
             let _v : 'tv_separated_nonempty_list_COMMA_var_ = 
4570
-# 144 "/tmp/test/pkg/ocaml-menhir/usr/share/menhir/standard.mly"
4570
+# 144 "/usr/share/menhir/standard.mly"
4571 4571
     ( [ x ] )
4572 4572
 # 4573 "parser.ml"
4573 4573
              in
@@ -5075,7 +5075,7 @@ and _menhir_goto_list_member_ : _menhir_env -> 'ttv_tail -> _menhir_state -> 'tv
5075 5075
         let (_menhir_stack : ('freshtv385 * _menhir_state * 'tv_member) * _menhir_state * 'tv_list_member_) = Obj.magic _menhir_stack in
5076 5076
         ((let ((_menhir_stack, _menhir_s, x), _, xs) = _menhir_stack in
5077 5077
         let _v : 'tv_list_member_ = 
5078
-# 116 "/tmp/test/pkg/ocaml-menhir/usr/share/menhir/standard.mly"
5078
+# 116 "/usr/share/menhir/standard.mly"
5079 5079
     ( x :: xs )
5080 5080
 # 5081 "parser.ml"
5081 5081
          in
@@ -5387,7 +5387,7 @@ and _menhir_goto_loption_separated_nonempty_list_COMMA_argument__ : _menhir_env
5387 5387
         let _v : 'tv_paren_separated_list_COMMA_argument__ = let x =
5388 5388
           let xs = xs0 in
5389 5389
           
5390
-# 135 "/tmp/test/pkg/ocaml-menhir/usr/share/menhir/standard.mly"
5390
+# 135 "/usr/share/menhir/standard.mly"
5391 5391
     ( xs )
5392 5392
 # 5393 "parser.ml"
5393 5393
           
@@ -5528,7 +5528,7 @@ and _menhir_run8 : _menhir_env -> 'ttv_tail -> _menhir_state -> (
5528 5528
 and _menhir_reduce65 : _menhir_env -> 'ttv_tail -> _menhir_state -> 'ttv_return =
5529 5529
   fun _menhir_env _menhir_stack _menhir_s ->
5530 5530
     let _v : 'tv_list_member_ = 
5531
-# 114 "/tmp/test/pkg/ocaml-menhir/usr/share/menhir/standard.mly"
5531
+# 114 "/usr/share/menhir/standard.mly"
5532 5532
     ( [] )
5533 5533
 # 5534 "parser.ml"
5534 5534
      in
@@ -5577,13 +5577,13 @@ and _menhir_goto_separated_nonempty_list_COMMA_preceded_PUBLIC_TIDENT__ : _menhi
5577 5577
         let _v : 'tv_separated_nonempty_list_COMMA_preceded_PUBLIC_TIDENT__ = let x =
5578 5578
           let x = x0 in
5579 5579
           
5580
-# 86 "/tmp/test/pkg/ocaml-menhir/usr/share/menhir/standard.mly"
5580
+# 86 "/usr/share/menhir/standard.mly"
5581 5581
     ( x )
5582 5582
 # 5583 "parser.ml"
5583 5583
           
5584 5584
         in
5585 5585
         
5586
-# 146 "/tmp/test/pkg/ocaml-menhir/usr/share/menhir/standard.mly"
5586
+# 146 "/usr/share/menhir/standard.mly"
5587 5587
     ( x :: xs )
5588 5588
 # 5589 "parser.ml"
5589 5589
          in
@@ -5612,7 +5612,7 @@ and _menhir_goto_separated_nonempty_list_COMMA_preceded_PUBLIC_TIDENT__ : _menhi
5612 5612
         let (_menhir_stack : 'freshtv329) = Obj.magic _menhir_stack in
5613 5613
         let (x : 'tv_supers) = _v in
5614 5614
         ((let _v : 'tv_option_supers_ = 
5615
-# 31 "/tmp/test/pkg/ocaml-menhir/usr/share/menhir/standard.mly"
5615
+# 31 "/usr/share/menhir/standard.mly"
5616 5616
     ( Some x )
5617 5617
 # 5618 "parser.ml"
5618 5618
          in
@@ -5694,7 +5694,7 @@ and _menhir_goto_list_decl_ : _menhir_env -> 'ttv_tail -> _menhir_state -> 'tv_l
5694 5694
         let (_menhir_stack : ('freshtv321 * _menhir_state * 'tv_decl) * _menhir_state * 'tv_list_decl_) = Obj.magic _menhir_stack in
5695 5695
         ((let ((_menhir_stack, _menhir_s, x), _, xs) = _menhir_stack in
5696 5696
         let _v : 'tv_list_decl_ = 
5697
-# 116 "/tmp/test/pkg/ocaml-menhir/usr/share/menhir/standard.mly"
5697
+# 116 "/usr/share/menhir/standard.mly"
5698 5698
     ( x :: xs )
5699 5699
 # 5700 "parser.ml"
5700 5700
          in
@@ -5823,7 +5823,7 @@ and _menhir_run7 : _menhir_env -> 'ttv_tail -> _menhir_state -> Lexing.position
5823 5823
         let (_menhir_stack : 'freshtv285) = Obj.magic _menhir_stack in
5824 5824
         let (_menhir_s : _menhir_state) = MenhirState7 in
5825 5825
         ((let _v : 'tv_loption_separated_nonempty_list_COMMA_argument__ = 
5826
-# 57 "/tmp/test/pkg/ocaml-menhir/usr/share/menhir/standard.mly"
5826
+# 57 "/usr/share/menhir/standard.mly"
5827 5827
     ( [] )
5828 5828
 # 5829 "parser.ml"
5829 5829
          in
@@ -5995,13 +5995,13 @@ and _menhir_run30 : _menhir_env -> 'ttv_tail -> _menhir_state -> 'ttv_return =
5995 5995
             let _v : 'tv_separated_nonempty_list_COMMA_preceded_PUBLIC_TIDENT__ = let x =
5996 5996
               let x = x0 in
5997 5997
               
5998
-# 86 "/tmp/test/pkg/ocaml-menhir/usr/share/menhir/standard.mly"
5998
+# 86 "/usr/share/menhir/standard.mly"
5999 5999
     ( x )
6000 6000
 # 6001 "parser.ml"
6001 6001
               
6002 6002
             in
6003 6003
             
6004
-# 144 "/tmp/test/pkg/ocaml-menhir/usr/share/menhir/standard.mly"
6004
+# 144 "/usr/share/menhir/standard.mly"
6005 6005
     ( [ x ] )
6006 6006
 # 6007 "parser.ml"
6007 6007
              in
@@ -6514,7 +6514,7 @@ and _menhir_errorcase : _menhir_env -> 'ttv_tail -> _menhir_state -> 'ttv_return
6514 6514
 and _menhir_reduce61 : _menhir_env -> 'ttv_tail -> _menhir_state -> 'ttv_return =
6515 6515
   fun _menhir_env _menhir_stack _menhir_s ->
6516 6516
     let _v : 'tv_list_decl_ = 
6517
-# 114 "/tmp/test/pkg/ocaml-menhir/usr/share/menhir/standard.mly"
6517
+# 114 "/usr/share/menhir/standard.mly"
6518 6518
     ( [] )
6519 6519
 # 6520 "parser.ml"
6520 6520
      in
@@ -6709,7 +6709,7 @@ and _menhir_run27 : _menhir_env -> 'ttv_tail -> _menhir_state -> Lexing.position
6709 6709
             let (_menhir_env : _menhir_env) = _menhir_env in
6710 6710
             let (_menhir_stack : 'freshtv21) = Obj.magic _menhir_stack in
6711 6711
             ((let _v : 'tv_option_supers_ = 
6712
-# 29 "/tmp/test/pkg/ocaml-menhir/usr/share/menhir/standard.mly"
6712
+# 29 "/usr/share/menhir/standard.mly"
6713 6713
     ( None )
6714 6714
 # 6715 "parser.ml"
6715 6715
              in
@@ -6808,7 +6808,7 @@ and fichier : (Lexing.lexbuf -> token) -> Lexing.lexbuf -> (
6808 6808
         let (_startpos__1_ : Lexing.position) = _startpos in
6809 6809
         ((let _startpos = _startpos__1_ in
6810 6810
         let _v : 'tv_boption_INCLUDE_ = 
6811
-# 50 "/tmp/test/pkg/ocaml-menhir/usr/share/menhir/standard.mly"
6811
+# 50 "/usr/share/menhir/standard.mly"
6812 6812
     ( true )
6813 6813
 # 6814 "parser.ml"
6814 6814
          in
@@ -6818,7 +6818,7 @@ and fichier : (Lexing.lexbuf -> token) -> Lexing.lexbuf -> (
6818 6818
         let (_menhir_stack : 'freshtv5) = Obj.magic _menhir_stack in
6819 6819
         ((let _startpos = _menhir_env._menhir_startp in
6820 6820
         let _v : 'tv_boption_INCLUDE_ = 
6821
-# 48 "/tmp/test/pkg/ocaml-menhir/usr/share/menhir/standard.mly"
6821
+# 48 "/usr/share/menhir/standard.mly"
6822 6822
     ( false )
6823 6823
 # 6824 "parser.ml"
6824 6824
          in

+ 4
- 3
tests/exec/address2.s View File

@@ -1,6 +1,6 @@
1 1
 .text
2 2
 	b function_main
3
-function_f:
3
+function_f1:
4 4
 	add $sp, $sp, -8
5 5
 	sw $fp, 4($sp)
6 6
 	add $fp, $sp, 4
@@ -8,7 +8,7 @@ function_f:
8 8
 	li $a0, 42
9 9
 	lw $a1, 4($fp)
10 10
 	sw $a0, 0($a1)
11
-end_function_f:
11
+end_function_f1:
12 12
 	lw $ra, 0($sp)
13 13
 	lw $fp, 4($sp)
14 14
 	add $sp, $sp, 8
@@ -33,8 +33,9 @@ function_main:
33 33
 	la $a0, -8($fp)
34 34
 	sub $sp, $sp, 4
35 35
 	sw $a0, 0($sp)
36
-	jal function_f
36
+	jal function_f1
37 37
 	add $sp, $sp, 4
38
+	move $a0, $v0
38 39
 	la $a0, string_3
39 40
 	li $v0, 4
40 41
 	syscall

+ 6
- 4
tests/exec/address3.s View File

@@ -1,6 +1,6 @@
1 1
 .text
2 2
 	b function_main
3
-function_f:
3
+function_f1:
4 4
 	add $sp, $sp, -8
5 5
 	sw $fp, 4($sp)
6 6
 	add $fp, $sp, 4
@@ -15,7 +15,7 @@ function_f:
15 15
 	add $a0, $t1, $a0
16 16
 	lw $a1, 4($fp)
17 17
 	sw $a0, 0($a1)
18
-end_function_f:
18
+end_function_f1:
19 19
 	lw $ra, 0($sp)
20 20
 	lw $fp, 4($sp)
21 21
 	add $sp, $sp, 8
@@ -40,8 +40,9 @@ function_main:
40 40
 	la $a0, -8($fp)
41 41
 	sub $sp, $sp, 4
42 42
 	sw $a0, 0($sp)
43
-	jal function_f
43
+	jal function_f1
44 44
 	add $sp, $sp, 4
45
+	move $a0, $v0
45 46
 	la $a0, string_3
46 47
 	li $v0, 4
47 48
 	syscall
@@ -54,8 +55,9 @@ function_main:
54 55
 	la $a0, -8($fp)
55 56
 	sub $sp, $sp, 4
56 57
 	sw $a0, 0($sp)
57
-	jal function_f
58
+	jal function_f1
58 59
 	add $sp, $sp, 4
60
+	move $a0, $v0
59 61
 	la $a0, string_5
60 62
 	li $v0, 4
61 63
 	syscall

+ 8
- 6
tests/exec/bresenham.s View File

@@ -1,6 +1,6 @@
1 1
 .text
2 2
 	b function_main
3
-function_plot:
3
+function_plot1:
4 4
 	add $sp, $sp, -8
5 5
 	sw $fp, 4($sp)
6 6
 	add $fp, $sp, 4
@@ -26,13 +26,13 @@ test_while_1:
26 26
 	la $a0, string_2
27 27
 	li $v0, 4
28 28
 	syscall
29
-end_function_plot:
29
+end_function_plot1:
30 30
 	lw $ra, 0($sp)
31 31
 	lw $fp, 4($sp)
32 32
 	add $sp, $sp, 8
33 33
 	move $v0, $a0
34 34
 	jr $ra
35
-function_bresenham:
35
+function_bresenham2:
36 36
 	add $sp, $sp, -20
37 37
 	sw $fp, 16($sp)
38 38
 	add $fp, $sp, 16
@@ -64,8 +64,9 @@ body_for_1:
64 64
 	lw $a0, -12($fp)
65 65
 	sub $sp, $sp, 4
66 66
 	sw $a0, 0($sp)
67
-	jal function_plot
67
+	jal function_plot1
68 68
 	add $sp, $sp, 4
69
+	move $a0, $v0
69 70
 	add $sp, $sp, 0
70 71
 	lw $a0, -16($fp)
71 72
 	sub $sp, $sp, 4
@@ -132,7 +133,7 @@ test_for_1:
132 133
 	sle $a0, $t1, $a0
133 134
 	bnez $a0, body_for_1
134 135
 	add $sp, $sp, 0
135
-end_function_bresenham:
136
+end_function_bresenham2:
136 137
 	lw $ra, 12($sp)
137 138
 	lw $fp, 16($sp)
138 139
 	add $sp, $sp, 20
@@ -149,8 +150,9 @@ function_main:
149 150
 	li $a0, 10
150 151
 	sub $sp, $sp, 4
151 152
 	sw $a0, 0($sp)
152
-	jal function_bresenham
153
+	jal function_bresenham2
153 154
 	add $sp, $sp, 8
155
+	move $a0, $v0
154 156
 end_function_main:
155 157
 	lw $ra, 0($sp)
156 158
 	lw $fp, 4($sp)

+ 5
- 4
tests/exec/fact_loop.s View File

@@ -1,6 +1,6 @@
1 1
 .text
2 2
 	b function_main
3
-function_fact_loop:
3
+function_fact_loop1:
4 4
 	add $sp, $sp, -12
5 5
 	sw $fp, 8($sp)
6 6
 	add $fp, $sp, 8
@@ -34,8 +34,8 @@ test_while_1:
34 34
 	add $sp, $sp, 0
35 35
 	lw $a0, -8($fp)
36 36
 	move $v0, $a0
37
-	b end_function_fact_loop
38
-end_function_fact_loop:
37
+	b end_function_fact_loop1
38
+end_function_fact_loop1:
39 39
 	lw $ra, 4($sp)
40 40
 	lw $fp, 8($sp)
41 41
 	add $sp, $sp, 12
@@ -49,8 +49,9 @@ function_main:
49 49
 	li $a0, 5
50 50
 	sub $sp, $sp, 4
51 51
 	sw $a0, 0($sp)
52
-	jal function_fact_loop
52
+	jal function_fact_loop1
53 53
 	add $sp, $sp, 4
54
+	move $a0, $v0
54 55
 	li $v0, 1
55 56
 	syscall
56 57
 	la $a0, string_1

+ 8
- 6
tests/exec/fact_rec.s View File

@@ -1,6 +1,6 @@
1 1
 .text
2 2
 	b function_main
3
-function_fact_rec:
3
+function_fact_rec1:
4 4
 	add $sp, $sp, -8
5 5
 	sw $fp, 4($sp)
6 6
 	add $fp, $sp, 4
@@ -16,7 +16,7 @@ function_fact_rec:
16 16
 	beqz $a0, else_1
17 17
 	li $a0, 1
18 18
 	move $v0, $a0
19
-	b end_function_fact_rec
19
+	b end_function_fact_rec1
20 20
 	b end_if_1
21 21
 else_1:
22 22
 end_if_1:
@@ -33,14 +33,15 @@ end_if_1:
33 33
 	sub $a0, $t1, $a0
34 34
 	sub $sp, $sp, 4
35 35
 	sw $a0, 0($sp)
36
-	jal function_fact_rec
36
+	jal function_fact_rec1
37 37
 	add $sp, $sp, 4
38
+	move $a0, $v0
38 39
 	lw $t1, 0($sp)
39 40
 	add $sp, $sp, 4
40 41
 	mul $a0, $t1, $a0
41 42
 	move $v0, $a0
42
-	b end_function_fact_rec
43
-end_function_fact_rec:
43
+	b end_function_fact_rec1
44
+end_function_fact_rec1:
44 45
 	lw $ra, 0($sp)
45 46
 	lw $fp, 4($sp)
46 47
 	add $sp, $sp, 8
@@ -54,8 +55,9 @@ function_main:
54 55
 	li $a0, 5
55 56
 	sub $sp, $sp, 4
56 57
 	sw $a0, 0($sp)
57
-	jal function_fact_rec
58
+	jal function_fact_rec1
58 59
 	add $sp, $sp, 4
60
+	move $a0, $v0
59 61
 	li $v0, 1
60 62
 	syscall
61 63
 	la $a0, string_1

+ 85
- 54
tests/exec/mandelbrot.s View File

@@ -1,6 +1,6 @@
1 1
 .text
2 2
 	b function_main
3
-function_add:
3
+function_add1:
4 4
 	add $sp, $sp, -8
5 5
 	sw $fp, 4($sp)
6 6
 	add $fp, $sp, 4
@@ -13,14 +13,14 @@ function_add:
13 13
 	add $sp, $sp, 4
14 14
 	add $a0, $t1, $a0
15 15
 	move $v0, $a0
16
-	b end_function_add
17
-end_function_add:
16
+	b end_function_add1
17
+end_function_add1:
18 18
 	lw $ra, 0($sp)
19 19
 	lw $fp, 4($sp)
20 20
 	add $sp, $sp, 8
21 21
 	move $v0, $a0
22 22
 	jr $ra
23
-function_sub:
23
+function_sub2:
24 24
 	add $sp, $sp, -8
25 25
 	sw $fp, 4($sp)
26 26
 	add $fp, $sp, 4
@@ -33,14 +33,14 @@ function_sub:
33 33
 	add $sp, $sp, 4
34 34
 	sub $a0, $t1, $a0
35 35
 	move $v0, $a0
36
-	b end_function_sub
37
-end_function_sub:
36
+	b end_function_sub2
37
+end_function_sub2:
38 38
 	lw $ra, 0($sp)
39 39
 	lw $fp, 4($sp)
40 40
 	add $sp, $sp, 8
41 41
 	move $v0, $a0
42 42
 	jr $ra
43
-function_mul:
43
+function_mul3:
44 44
 	add $sp, $sp, -12
45 45
 	sw $fp, 8($sp)
46 46
 	add $fp, $sp, 8
@@ -73,14 +73,14 @@ function_mul:
73 73
 	add $sp, $sp, 4
74 74
 	div $a0, $t1, $a0
75 75
 	move $v0, $a0
76
-	b end_function_mul
77
-end_function_mul:
76
+	b end_function_mul3
77
+end_function_mul3:
78 78
 	lw $ra, 4($sp)
79 79
 	lw $fp, 8($sp)
80 80
 	add $sp, $sp, 12
81 81
 	move $v0, $a0
82 82
 	jr $ra
83
-function_div:
83
+function_div4:
84 84
 	add $sp, $sp, -12
85 85
 	sw $fp, 8($sp)
86 86
 	add $fp, $sp, 8
@@ -113,14 +113,14 @@ function_div:
113 113
 	add $sp, $sp, 4
114 114
 	div $a0, $t1, $a0
115 115
 	move $v0, $a0
116
-	b end_function_div
117
-end_function_div:
116
+	b end_function_div4
117
+end_function_div4:
118 118
 	lw $ra, 4($sp)
119 119
 	lw $fp, 8($sp)
120 120
 	add $sp, $sp, 12
121 121
 	move $v0, $a0
122 122
 	jr $ra
123
-function_of_int:
123
+function_of_int5:
124 124
 	add $sp, $sp, -8
125 125
 	sw $fp, 4($sp)
126 126
 	add $fp, $sp, 4
@@ -133,14 +133,14 @@ function_of_int:
133 133
 	add $sp, $sp, 4
134 134
 	mul $a0, $t1, $a0
135 135
 	move $v0, $a0
136
-	b end_function_of_int
137
-end_function_of_int:
136
+	b end_function_of_int5
137
+end_function_of_int5:
138 138
 	lw $ra, 0($sp)
139 139
 	lw $fp, 4($sp)
140 140
 	add $sp, $sp, 8
141 141
 	move $v0, $a0
142 142
 	jr $ra
143
-function_iter:
143
+function_iter6:
144 144
 	add $sp, $sp, -16
145 145
 	sw $fp, 12($sp)
146 146
 	add $fp, $sp, 12
@@ -156,7 +156,7 @@ function_iter:
156 156
 	beqz $a0, else_1
157 157
 	li $a0, 1
158 158
 	move $v0, $a0
159
-	b end_function_iter
159
+	b end_function_iter6
160 160
 	b end_if_1
161 161
 else_1:
162 162
 end_if_1:
@@ -167,8 +167,9 @@ end_if_1:
167 167
 	lw $a0, 16($fp)
168 168
 	sub $sp, $sp, 4
169 169
 	sw $a0, 0($sp)
170
-	jal function_mul
170
+	jal function_mul3
171 171
 	add $sp, $sp, 8
172
+	move $a0, $v0
172 173
 	sw $a0, -8($fp)
173 174
 	lw $a0, 20($fp)
174 175
 	sub $sp, $sp, 4
@@ -176,8 +177,9 @@ end_if_1:
176 177
 	lw $a0, 20($fp)
177 178
 	sub $sp, $sp, 4
178 179
 	sw $a0, 0($sp)
179
-	jal function_mul
180
+	jal function_mul3
180 181
 	add $sp, $sp, 8
182
+	move $a0, $v0
181 183
 	sw $a0, -12($fp)
182 184
 	add $sp, $sp, 0
183 185
 	lw $a0, -12($fp)
@@ -186,22 +188,24 @@ end_if_1:
186 188
 	lw $a0, -8($fp)
187 189
 	sub $sp, $sp, 4
188 190
 	sw $a0, 0($sp)
189
-	jal function_add
191
+	jal function_add1
190 192
 	add $sp, $sp, 8
193
+	move $a0, $v0
191 194
 	sub $sp, $sp, 4
192 195
 	sw $a0, 0($sp)
193 196
 	li $a0, 4
194 197
 	sub $sp, $sp, 4
195 198
 	sw $a0, 0($sp)
196
-	jal function_of_int
199
+	jal function_of_int5
197 200
 	add $sp, $sp, 4
201
+	move $a0, $v0
198 202
 	lw $t1, 0($sp)
199 203
 	add $sp, $sp, 4
200 204
 	sgt $a0, $t1, $a0
201 205
 	beqz $a0, else_2
202 206
 	li $a0, 0
203 207
 	move $v0, $a0
204
-	b end_function_iter
208
+	b end_function_iter6
205 209
 	b end_if_2
206 210
 else_2:
207 211
 end_if_2:
@@ -215,23 +219,27 @@ end_if_2:
215 219
 	lw $a0, 16($fp)
216 220
 	sub $sp, $sp, 4
217 221
 	sw $a0, 0($sp)
218
-	jal function_mul
222
+	jal function_mul3
219 223
 	add $sp, $sp, 8
224
+	move $a0, $v0
220 225
 	sub $sp, $sp, 4
221 226
 	sw $a0, 0($sp)
222 227
 	li $a0, 2
223 228
 	sub $sp, $sp, 4
224 229
 	sw $a0, 0($sp)
225
-	jal function_of_int
230
+	jal function_of_int5
226 231
 	add $sp, $sp, 4
232
+	move $a0, $v0
227 233
 	sub $sp, $sp, 4
228 234
 	sw $a0, 0($sp)
229
-	jal function_mul
235
+	jal function_mul3
230 236
 	add $sp, $sp, 8
237
+	move $a0, $v0
231 238
 	sub $sp, $sp, 4
232 239
 	sw $a0, 0($sp)
233
-	jal function_add
240
+	jal function_add1
234 241
 	add $sp, $sp, 8
242
+	move $a0, $v0
235 243
 	sub $sp, $sp, 4
236 244
 	sw $a0, 0($sp)
237 245
 	lw $a0, 8($fp)
@@ -243,12 +251,14 @@ end_if_2:
243 251
 	lw $a0, -8($fp)
244 252
 	sub $sp, $sp, 4
245 253
 	sw $a0, 0($sp)
246
-	jal function_sub
254
+	jal function_sub2
247 255
 	add $sp, $sp, 8
256
+	move $a0, $v0
248 257
 	sub $sp, $sp, 4
249 258
 	sw $a0, 0($sp)
250
-	jal function_add
259
+	jal function_add1
251 260
 	add $sp, $sp, 8
261
+	move $a0, $v0
252 262
 	sub $sp, $sp, 4
253 263
 	sw $a0, 0($sp)
254 264
 	lw $a0, 12($fp)
@@ -266,17 +276,18 @@ end_if_2:
266 276
 	add $a0, $t1, $a0
267 277
 	sub $sp, $sp, 4
268 278
 	sw $a0, 0($sp)
269
-	jal function_iter
279
+	jal function_iter6
270 280
 	add $sp, $sp, 20
281
+	move $a0, $v0
271 282
 	move $v0, $a0
272
-	b end_function_iter
273
-end_function_iter:
283
+	b end_function_iter6
284
+end_function_iter6:
274 285
 	lw $ra, 8($sp)
275 286
 	lw $fp, 12($sp)
276 287
 	add $sp, $sp, 16
277 288
 	move $v0, $a0
278 289
 	jr $ra
279
-function_inside:
290
+function_inside7:
280 291
 	add $sp, $sp, -8
281 292
 	sw $fp, 4($sp)
282 293
 	add $fp, $sp, 4
@@ -284,15 +295,17 @@ function_inside:
284 295
 	li $a0, 0
285 296
 	sub $sp, $sp, 4
286 297
 	sw $a0, 0($sp)
287
-	jal function_of_int
298
+	jal function_of_int5
288 299
 	add $sp, $sp, 4
300
+	move $a0, $v0
289 301
 	sub $sp, $sp, 4
290 302
 	sw $a0, 0($sp)
291 303
 	li $a0, 0
292 304
 	sub $sp, $sp, 4
293 305
 	sw $a0, 0($sp)
294
-	jal function_of_int
306
+	jal function_of_int5
295 307
 	add $sp, $sp, 4
308
+	move $a0, $v0
296 309
 	sub $sp, $sp, 4
297 310
 	sw $a0, 0($sp)
298 311
 	lw $a0, 8($fp)
@@ -304,11 +317,12 @@ function_inside:
304 317
 	li $a0, 0
305 318
 	sub $sp, $sp, 4
306 319
 	sw $a0, 0($sp)
307
-	jal function_iter
320
+	jal function_iter6
308 321
 	add $sp, $sp, 20
322
+	move $a0, $v0
309 323
 	move $v0, $a0
310
-	b end_function_inside
311
-end_function_inside:
324
+	b end_function_inside7
325
+end_function_inside7:
312 326
 	lw $ra, 0($sp)
313 327
 	lw $fp, 4($sp)
314 328
 	add $sp, $sp, 8
@@ -325,14 +339,16 @@ function_main:
325 339
 	neg $a0, $a0
326 340
 	sub $sp, $sp, 4
327 341
 	sw $a0, 0($sp)
328
-	jal function_of_int
342
+	jal function_of_int5
329 343
 	add $sp, $sp, 4
344
+	move $a0, $v0
330 345
 	sw $a0, -12($fp)
331 346
 	li $a0, 1
332 347
 	sub $sp, $sp, 4
333 348
 	sw $a0, 0($sp)
334
-	jal function_of_int
349
+	jal function_of_int5
335 350
 	add $sp, $sp, 4
351
+	move $a0, $v0
336 352
 	sw $a0, -16($fp)
337 353
 	li $a0, 2
338 354
 	sub $sp, $sp, 4
@@ -343,8 +359,9 @@ function_main:
343 359
 	mul $a0, $t1, $a0
344 360
 	sub $sp, $sp, 4
345 361
 	sw $a0, 0($sp)
346
-	jal function_of_int
362
+	jal function_of_int5
347 363
 	add $sp, $sp, 4
364
+	move $a0, $v0
348 365
 	sub $sp, $sp, 4
349 366
 	sw $a0, 0($sp)
350 367
 	lw $a0, -12($fp)
@@ -353,31 +370,36 @@ function_main:
353 370
 	lw $a0, -16($fp)
354 371
 	sub $sp, $sp, 4
355 372
 	sw $a0, 0($sp)
356
-	jal function_sub
373
+	jal function_sub2
357 374
 	add $sp, $sp, 8
375
+	move $a0, $v0
358 376
 	sub $sp, $sp, 4
359 377
 	sw $a0, 0($sp)
360
-	jal function_div
378
+	jal function_div4
361 379
 	add $sp, $sp, 8
380
+	move $a0, $v0
362 381
 	sw $a0, -20($fp)
363 382
 	li $a0, 1
364 383
 	neg $a0, $a0
365 384
 	sub $sp, $sp, 4
366 385
 	sw $a0, 0($sp)
367
-	jal function_of_int
386
+	jal function_of_int5
368 387
 	add $sp, $sp, 4
388
+	move $a0, $v0
369 389
 	sw $a0, -24($fp)
370 390
 	li $a0, 1
371 391
 	sub $sp, $sp, 4
372 392
 	sw $a0, 0($sp)
373
-	jal function_of_int
393
+	jal function_of_int5
374 394
 	add $sp, $sp, 4
395
+	move $a0, $v0
375 396
 	sw $a0, -28($fp)
376 397
 	lw $a0, -8($fp)
377 398
 	sub $sp, $sp, 4
378 399
 	sw $a0, 0($sp)
379
-	jal function_of_int
400
+	jal function_of_int5
380 401
 	add $sp, $sp, 4
402
+	move $a0, $v0
381 403
 	sub $sp, $sp, 4
382 404
 	sw $a0, 0($sp)
383 405
 	lw $a0, -24($fp)
@@ -386,12 +408,14 @@ function_main:
386 408
 	lw $a0, -28($fp)
387 409
 	sub $sp, $sp, 4
388 410
 	sw $a0, 0($sp)
389
-	jal function_sub
411
+	jal function_sub2
390 412
 	add $sp, $sp, 8
413
+	move $a0, $v0
391 414
 	sub $sp, $sp, 4
392 415
 	sw $a0, 0($sp)
393
-	jal function_div
416
+	jal function_div4
394 417
 	add $sp, $sp, 8
418
+	move $a0, $v0
395 419
 	sw $a0, -32($fp)
396 420
 	li $a0, 0
397 421
 	sw $a0, -36($fp)
@@ -407,19 +431,22 @@ body_for_1:
407 431
 	lw $a0, -36($fp)
408 432
 	sub $sp, $sp, 4
409 433
 	sw $a0, 0($sp)
410
-	jal function_of_int
434
+	jal function_of_int5
411 435
 	add $sp, $sp, 4
436
+	move $a0, $v0
412 437
 	sub $sp, $sp, 4
413 438
 	sw $a0, 0($sp)
414
-	jal function_mul
439
+	jal function_mul3
415 440
 	add $sp, $sp, 8
441
+	move $a0, $v0
416 442
 	sub $sp, $sp, 4
417 443
 	sw $a0, 0($sp)
418 444
 	lw $a0, -24($fp)
419 445
 	sub $sp, $sp, 4
420 446
 	sw $a0, 0($sp)
421
-	jal function_add
447
+	jal function_add1
422 448
 	add $sp, $sp, 8
449
+	move $a0, $v0
423 450
 	sw $a0, -40($fp)
424 451
 	li $a0, 0
425 452
 	sw $a0, -44($fp)
@@ -435,19 +462,22 @@ body_for_2:
435 462
 	lw $a0, -44($fp)
436 463
 	sub $sp, $sp, 4
437 464
 	sw $a0, 0($sp)
438
-	jal function_of_int
465
+	jal function_of_int5
439 466
 	add $sp, $sp, 4
467
+	move $a0, $v0
440 468
 	sub $sp, $sp, 4
441 469
 	sw $a0, 0($sp)
442
-	jal function_mul
470
+	jal function_mul3
443 471
 	add $sp, $sp, 8
472
+	move $a0, $v0
444 473
 	sub $sp, $sp, 4
445 474
 	sw $a0, 0($sp)
446 475
 	lw $a0, -12($fp)
447 476
 	sub $sp, $sp, 4
448 477
 	sw $a0, 0($sp)
449
-	jal function_add
478
+	jal function_add1
450 479
 	add $sp, $sp, 8
480
+	move $a0, $v0
451 481
 	sw $a0, -48($fp)
452 482
 	add $sp, $sp, 0
453 483
 	lw $a0, -40($fp)
@@ -456,8 +486,9 @@ body_for_2:
456 486
 	lw $a0, -48($fp)
457 487
 	sub $sp, $sp, 4
458 488
 	sw $a0, 0($sp)
459
-	jal function_inside
489
+	jal function_inside7
460 490
 	add $sp, $sp, 8
491
+	move $a0, $v0
461 492
 	beqz $a0, else_3
462 493
 	la $a0, string_1
463 494
 	li $v0, 4

+ 4
- 3
tests/exec/passing.s View File

@@ -1,6 +1,6 @@
1 1
 .text
2 2
 	b function_main
3
-function_incr:
3
+function_incr1:
4 4
 	add $sp, $sp, -8
5 5
 	sw $fp, 4($sp)
6 6
 	add $fp, $sp, 4
@@ -15,7 +15,7 @@ function_incr:
15 15
 	add $a0, $t1, $a0
16 16
 	lw $a1, 4($fp)
17 17
 	sw $a0, 0($a1)
18
-end_function_incr:
18
+end_function_incr1:
19 19
 	lw $ra, 0($sp)
20 20
 	lw $fp, 4($sp)
21 21
 	add $sp, $sp, 8
@@ -40,8 +40,9 @@ function_main:
40 40
 	la $a0, -8($fp)
41 41
 	sub $sp, $sp, 4
42 42
 	sw $a0, 0($sp)
43
-	jal function_incr
43
+	jal function_incr1
44 44
 	add $sp, $sp, 4
45
+	move $a0, $v0
45 46
 	la $a0, string_3
46 47
 	li $v0, 4
47 48
 	syscall

+ 4
- 3
tests/exec/ref2.s View File

@@ -1,6 +1,6 @@
1 1
 .text
2 2
 	b function_main
3
-function_f:
3
+function_f1:
4 4
 	add $sp, $sp, -8
5 5
 	sw $fp, 4($sp)
6 6
 	add $fp, $sp, 4
@@ -8,7 +8,7 @@ function_f:
8 8
 	li $a0, 42
9 9
 	lw $a1, 4($fp)
10 10
 	sw $a0, 0($a1)
11
-end_function_f:
11
+end_function_f1:
12 12
 	lw $ra, 0($sp)
13 13
 	lw $fp, 4($sp)
14 14
 	add $sp, $sp, 8
@@ -33,8 +33,9 @@ function_main:
33 33
 	la $a0, -8($fp)
34 34
 	sub $sp, $sp, 4
35 35
 	sw $a0, 0($sp)
36
-	jal function_f
36
+	jal function_f1
37 37
 	add $sp, $sp, 4
38
+	move $a0, $v0
38 39
 	la $a0, string_3
39 40
 	li $v0, 4
40 41
 	syscall

+ 8
- 5
tests/exec/ref3.s View File

@@ -1,6 +1,6 @@
1 1
 .text
2 2
 	b function_main
3
-function_f:
3
+function_f1:
4 4
 	add $sp, $sp, -8
5 5
 	sw $fp, 4($sp)
6 6
 	add $fp, $sp, 4
@@ -15,7 +15,7 @@ function_f:
15 15
 	add $a0, $t1, $a0
16 16
 	lw $a1, 4($fp)
17 17
 	sw $a0, 0($a1)
18
-end_function_f:
18
+end_function_f1:
19 19
 	lw $ra, 0($sp)
20 20
 	lw $fp, 4($sp)
21 21
 	add $sp, $sp, 8
@@ -40,8 +40,9 @@ function_main:
40 40
 	la $a0, -8($fp)
41 41
 	sub $sp, $sp, 4
42 42
 	sw $a0, 0($sp)
43
-	jal function_f
43
+	jal function_f1
44 44
 	add $sp, $sp, 4
45
+	move $a0, $v0
45 46
 	la $a0, string_3
46 47
 	li $v0, 4
47 48
 	syscall
@@ -54,8 +55,9 @@ function_main:
54 55
 	la $a0, -8($fp)
55 56
 	sub $sp, $sp, 4
56 57
 	sw $a0, 0($sp)
57
-	jal function_f
58
+	jal function_f1
58 59
 	add $sp, $sp, 4
60
+	move $a0, $v0
59 61
 	la $a0, string_5
60 62
 	li $v0, 4
61 63
 	syscall
@@ -79,8 +81,9 @@ function_main:
79 81
 	la $a0, -8($fp)
80 82
 	sub $sp, $sp, 4
81 83
 	sw $a0, 0($sp)
82
-	jal function_f
84
+	jal function_f1
83 85
 	add $sp, $sp, 4
86
+	move $a0, $v0
84 87
 	la $a0, string_9
85 88
 	li $v0, 4
86 89
 	syscall

+ 6
- 4
tests/exec/ref4.s View File

@@ -1,6 +1,6 @@
1 1
 .text
2 2
 	b function_main
3
-function_f:
3
+function_f1:
4 4
 	add $sp, $sp, -8
5 5
 	sw $fp, 4($sp)
6 6
 	add $fp, $sp, 4
@@ -15,7 +15,7 @@ function_f:
15 15
 	add $a0, $t1, $a0
16 16
 	lw $a1, 4($fp)
17 17
 	sw $a0, 0($a1)
18
-end_function_f:
18
+end_function_f1:
19 19
 	lw $ra, 0($sp)
20 20
 	lw $fp, 4($sp)
21 21
 	add $sp, $sp, 8
@@ -40,8 +40,9 @@ function_main:
40 40
 	la $a0, -8($fp)
41 41
 	sub $sp, $sp, 4
42 42
 	sw $a0, 0($sp)
43
-	jal function_f
43
+	jal function_f1
44 44
 	add $sp, $sp, 4
45
+	move $a0, $v0
45 46
 	la $a0, string_3
46 47
 	li $v0, 4
47 48
 	syscall
@@ -56,8 +57,9 @@ function_main:
56 57
 	la $a0, -8($fp)
57 58
 	sub $sp, $sp, 4
58 59
 	sw $a0, 0($sp)
59
-	jal function_f
60
+	jal function_f1
60 61
 	add $sp, $sp, 4
62
+	move $a0, $v0
61 63
 	la $a0, string_5
62 64
 	li $v0, 4
63 65
 	syscall

+ 12
- 7
tests/exec/ref5.s View File

@@ -1,6 +1,6 @@
1 1
 .text
2 2
 	b function_main
3
-function_f:
3
+function_f1:
4 4
 	add $sp, $sp, -8
5 5
 	sw $fp, 4($sp)
6 6
 	add $fp, $sp, 4
@@ -15,7 +15,7 @@ function_f:
15 15
 	add $a0, $t1, $a0
16 16
 	lw $a1, 4($fp)
17 17
 	sw $a0, 0($a1)
18
-end_function_f:
18
+end_function_f1:
19 19
 	lw $ra, 0($sp)
20 20
 	lw $fp, 4($sp)
21 21
 	add $sp, $sp, 8
@@ -40,8 +40,9 @@ function_main:
40 40
 	la $a0, -8($fp)
41 41
 	sub $sp, $sp, 4
42 42
 	sw $a0, 0($sp)
43
-	jal function_f
43
+	jal function_f1
44 44
 	add $sp, $sp, 4
45
+	move $a0, $v0
45 46
 	la $a0, string_3
46 47
 	li $v0, 4
47 48
 	syscall
@@ -56,8 +57,9 @@ function_main:
56 57
 	la $a0, -8($fp)
57 58
 	sub $sp, $sp, 4
58 59
 	sw $a0, 0($sp)
59
-	jal function_f
60
+	jal function_f1
60 61
 	add $sp, $sp, 4
62
+	move $a0, $v0
61 63
 	la $a0, string_5
62 64
 	li $v0, 4
63 65
 	syscall
@@ -81,8 +83,9 @@ function_main:
81 83
 	la $a0, -8($fp)
82 84
 	sub $sp, $sp, 4
83 85
 	sw $a0, 0($sp)
84
-	jal function_f
86
+	jal function_f1
85 87
 	add $sp, $sp, 4
88
+	move $a0, $v0
86 89
 	la $a0, string_9
87 90
 	li $v0, 4
88 91
 	syscall
@@ -113,8 +116,9 @@ function_main:
113 116
 	la $a0, -8($fp)
114 117
 	sub $sp, $sp, 4
115 118
 	sw $a0, 0($sp)
116
-	jal function_f
119
+	jal function_f1
117 120
 	add $sp, $sp, 4
121
+	move $a0, $v0
118 122
 	la $a0, string_15
119 123
 	li $v0, 4
120 124
 	syscall
@@ -145,8 +149,9 @@ function_main:
145 149
 	la $a0, -8($fp)
146 150
 	sub $sp, $sp, 4
147 151
 	sw $a0, 0($sp)
148
-	jal function_f
152
+	jal function_f1
149 153
 	add $sp, $sp, 4
154
+	move $a0, $v0
150 155
 	la $a0, string_21
151 156
 	li $v0, 4
152 157
 	syscall

+ 5546
- 3558
typer.annot
File diff suppressed because it is too large
View File


BIN
typer.cmi View File


BIN
typer.cmo View File


+ 112
- 29
typer.ml View File

@@ -7,6 +7,8 @@ exception Error of string*Lexing.position
7 7
 type field_offset = int
8 8
 type in_class = False | InClass of string
9 9
 type class_fields = { name: at_ident; fields: (at_var, (at_ast_type * field_offset)) Hashtbl.t }
10
+type decl_fonction_record = { ident_decl: at_ident; args_decl: ((at_var * at_ast_type) * bool) list}
11
+type function_matches = FunctionFalse | FunctionMatches of decl_fonction_record
10 12
 
11 13
 let includes = ref false
12 14
 let is_main_here = ref false
@@ -17,6 +19,7 @@ let decl_fonction = Hashtbl.create 17
17 19
 let objects = Hashtbl.create 17
18 20
 let refs = Hashtbl.create 17
19 21
 let current_function = ref ""
22
+let nb_decl_function = ref 0
20 23
 
21 24
 
22 25
 let is_left_value = function
@@ -221,34 +224,51 @@ let rec type_expr pos locals = function
221 224
                 raise (Error ("Undefined function "^id^".", pos))
222 225
             end;
223 226
 
224
-            let decl_fonction_tmp = Hashtbl.find decl_fonction id in
227
+            let decl_fonction_list = Hashtbl.find decl_fonction id in
225 228
             let i = ref (-1) in
226 229
 
227
-            let correct_argument a b =
228
-                let tmp = type_expr pos locals a in
229
-
230
-                if compatible_types (snd tmp) (snd (fst b)) then
231
-                    ()
232
-                else
233
-                    raise (Error ("Type mismatch for an argument in function call.", pos))
230
+            let test_function_match stop test_function =
231
+                match stop with
232
+                | FunctionFalse ->
233
+                    let correct_argument continue2 a b =
234
+                        if continue2 then begin
235
+                            let tmp = type_expr pos locals a in
236
+
237
+                            if compatible_types (snd tmp) (snd (fst b)) then
238
+                                true
239
+                            else
240
+                                false
241
+                        end
242
+                        else
243
+                            false
244
+                    in
245
+
246
+                    begin
247
+                        try
248
+                            if List.fold_left2 correct_argument true le test_function.args_decl then
249
+                                FunctionMatches test_function
250
+                            else
251
+                                FunctionFalse
252
+                        with
253
+                        | Invalid_argument _ -> FunctionFalse
254
+                    end;
255
+                | FunctionMatches _ as f -> f
234 256
             in
235 257
 
236
-            begin
237
-                try
238
-                    List.iter2 correct_argument le decl_fonction_tmp
239
-                with
240
-                | Invalid_argument _ -> raise (Error ("Wrong number of arguments for function "^id^".", pos))
241
-            end;
258
+            let decl_fonction_tmp = match List.fold_left test_function_match FunctionFalse decl_fonction_list with
259
+                | FunctionMatches f -> f
260
+                | FunctionFalse -> raise (Error ("Wrong arguments in function call.", pos))
261
+            in
242 262
 
243 263
             let type_expr_ref x =
244 264
                 i:=!i+1;
245 265
                 let tmp = type_expr pos locals x in
246
-                if snd(List.nth decl_fonction_tmp !i) then
266
+                if snd(List.nth decl_fonction_tmp.args_decl !i) then
247 267
                     ATUOp (ATEComm, fst tmp), true
248 268
                 else
249 269
                     fst tmp, false
250 270
             in
251
-            ATApply (id, List.map (type_expr_ref) le), snd tmp
271
+            ATApply (decl_fonction_tmp.ident_decl, List.map (type_expr_ref) le), snd tmp
252 272
         | _ -> raise (Error ("Expression cannot be used as a function.", pos))
253 273
     end
254 274
     | Dot (e, id) -> begin
@@ -288,17 +308,17 @@ let rec type_instruction locals x = match x.instruction_content with
288 308
     | Return some_expr -> begin
289 309
         let type_current_function = Hashtbl.find globals (ATVIdent !current_function) in
290 310
         match some_expr with
291
-            | None -> if type_current_function = ATVoid then ATReturn (None, !current_function) else raise (Error ("Returned value doesn't match with function type.", fst x.instruction_loc))
311
+            | None -> if type_current_function = ATVoid then ATReturn (None, if !current_function = "main" then "main" else (!current_function)^(string_of_int !nb_decl_function)) else raise (Error ("Returned value doesn't match with function type.", fst x.instruction_loc))
292 312
             | Some expr ->
293 313
                     let tmp = type_expr (fst x.instruction_loc) locals expr in
294 314
                     
295 315
                     if compatible_types (snd tmp) type_current_function then
296 316
                         if Hashtbl.mem refs (ATVIdent !current_function) then
297 317
                             match expr with
298
-                            | EQident _ -> ATReturn (Some (fst tmp), !current_function)
318
+                            | EQident _ -> ATReturn (Some (fst tmp), if !current_function = "main" then "main" else (!current_function)^(string_of_int !nb_decl_function))
299 319
                             | _ -> raise (Error ("Returned value doesn't match with function type..", fst x.instruction_loc))
300 320
                         else
301
-                            ATReturn (Some (fst tmp), !current_function)
321
+                            ATReturn (Some (fst tmp), if !current_function = "main" then "main" else (!current_function)^(string_of_int !nb_decl_function))
302 322
                     else
303 323
                         raise (Error ("Returned value doesn't match with function type..", fst x.instruction_loc))
304 324
     end
@@ -401,8 +421,10 @@ and type_bloc locals x =
401 421
 
402 422
 let type_proto_ident = function
403 423
     | Qvar (x, y) ->
424
+            nb_decl_function := !nb_decl_function + 1;
404 425
             ATQvar (types_ast_to_atast x, type_qvar y)
405 426
     | Type tid ->
427
+            nb_decl_function := !nb_decl_function + 1;
406 428
             ATType tid
407 429
     | _ -> assert false
408 430
     (* TODO *)
@@ -422,6 +444,7 @@ let type_args pos args x =
422 444
     tmp, reference
423 445
 
424 446
 let type_proto args x in_class virtualbool =
447
+    let typed_args = List.map (type_args (fst x.proto_loc) args) x.args in
425 448
     let () = 
426 449
         match x.ident with
427 450
         | Qvar (a, b) when a = Int && b = Qident (Ident "main") ->
@@ -452,8 +475,32 @@ let type_proto args x in_class virtualbool =
452 475
                 current_function := id;
453 476
 
454 477
                 if in_class = False then begin
455
-                    if Hashtbl.mem globals (ATVIdent id) then
456
-                        raise (Error ("Redeclaration of function "^id^"().", fst x.proto_loc));
478
+                    if Hashtbl.mem globals (ATVIdent id) then begin
479
+                        (* Vérifier qu'elle a le même type et des arguments différents *)
480
+                        let old_type = Hashtbl.find globals (ATVIdent id) in
481
+                        if old_type = (types_ast_to_atast a) then begin
482
+                            let old_decls = Hashtbl.find decl_fonction id in
483
+                            let old_args = List.map (fun x -> x.args_decl) old_decls in
484
+
485
+                            let check_duplicate x =
486
+                                (* x est une liste d'arguments, on cherche si x == typed_args *)
487
+                                let check_duplicate_arg x =
488
+                                    let ast_type = snd (fst x) in
489
+                                    let reference = snd x in
490
+
491
+                                    List.exists (fun y -> snd (fst y) = ast_type && snd y = reference && false) typed_args;
492
+                                in
493
+                                if List.length x != List.length typed_args then
494
+                                    false
495
+                                else
496
+                                    List.for_all check_duplicate_arg x
497
+                            in
498
+                            if List.exists check_duplicate old_args then
499
+                                raise (Error ("Redeclaration of function "^id^"().", fst x.proto_loc));
500
+                        end
501
+                        else
502
+                            raise (Error ("Redeclaration of function "^id^"().", fst x.proto_loc));
503
+                    end;
457 504
 
458 505
                     Hashtbl.add globals (ATVIdent id) (types_ast_to_atast a);
459 506
                 end
@@ -467,15 +514,51 @@ let type_proto args x in_class virtualbool =
467 514
         | _ -> assert false;
468 515
     in
469 516
 
470
-    let typed_args = List.map (type_args (fst x.proto_loc) args) x.args in
471
-
472
-    (* Sauve la déclaration dans une table pour pouvoir vérifier que l'appel est bon *)
473
-    Hashtbl.add decl_fonction !current_function typed_args;
517
+    if !current_function = "main" then begin
518
+        Hashtbl.add decl_fonction !current_function ({ ident_decl = !current_function; args_decl = typed_args } :: []);
474 519
 
475
-    {
476
-        at_ident_proto = type_proto_ident x.ident;
477
-        at_args = List.map fst typed_args;
478
-    }
520
+        {
521
+            at_ident_proto = type_proto_ident x.ident;
522
+            at_args = List.map fst typed_args;
523
+        }
524
+    end
525
+    else begin
526
+        let tmp_new_proto_ident = type_proto_ident x.ident in
527
+        let rec change_ident = function
528
+            | ATQident (ATIdent id) -> id^(string_of_int !nb_decl_function)
529
+            | ATQident _ -> assert false
530
+            | ATQUTimes var -> change_ident var
531
+            | ATQEComm var -> change_ident var
532
+        in
533
+        let new_ident = match tmp_new_proto_ident with
534
+        | ATType tid -> assert false; (* TODO *)
535
+        | ATQvar (x,y) -> change_ident y
536
+        | _ -> assert false (* TODO *)
537
+        in
538
+        let rec change_qvar_ident = function
539
+            | ATQident (ATIdent id) -> ATQident (ATIdent new_ident)
540
+            | ATQident _ -> assert false
541
+            | ATQUTimes var -> ATQUTimes (change_qvar_ident var)
542
+            | ATQEComm var -> ATQEComm (change_qvar_ident var)
543
+        in
544
+        let new_proto_ident = match tmp_new_proto_ident with
545
+        | ATType tid -> assert false; (* TODO *)
546
+        | ATQvar (x, y) -> ATQvar (x, change_qvar_ident y)
547
+        | _ -> assert false (* TODO *)
548
+        in
549
+
550
+        (* Sauve la déclaration dans une table pour pouvoir vérifier que l'appel est bon *)
551
+        if Hashtbl.mem decl_fonction !current_function then
552
+            let tmp = Hashtbl.find decl_fonction !current_function in
553
+            Hashtbl.replace decl_fonction !current_function ({ ident_decl = new_ident; args_decl = typed_args } :: tmp);
554
+        else
555
+            Hashtbl.add decl_fonction !current_function ({ ident_decl = new_ident; args_decl = typed_args } :: []);
556
+
557
+        {
558
+            at_ident_proto = new_proto_ident;
559
+            at_args = List.map fst typed_args;
560
+        }
561
+    end
479 562
 
480 563
 let type_fonction x =
481 564
     let locals = Hashtbl.create 17 in