changeset 36 | 1bfd09c6b3d8 |
parent 33 | 9c1e160e9688 |
child 37 | be8c2dd09dff |
35:0bb85506f02a | 36:1bfd09c6b3d8 |
---|---|
187 !IRBuilderTest methodsFor:'testing'! |
187 !IRBuilderTest methodsFor:'testing'! |
188 |
188 |
189 error |
189 error |
190 "Redefinition for testing the #send:toSuperOf:" |
190 "Redefinition for testing the #send:toSuperOf:" |
191 |
191 |
192 "Created: / 15-02-2010 / 16:20:57 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
192 "Created: / 11-06-2008 / 16:08:52 / Jan Vrany <vranyj1@fel.cvut.cz>" |
193 "Created: / 15-11-2011 / 22:27:59 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
193 ! |
194 ! |
194 |
195 |
195 isThisEverCalled |
196 isThisEverCalled |
196 "Redefinition for testing the #send:toSuperOf:" |
197 "Redefinition for testing the #send:toSuperOf:" |
197 ! |
198 ! |
206 pushDup; |
207 pushDup; |
207 send:#'='; |
208 send:#'='; |
208 returnTop; |
209 returnTop; |
209 ir. |
210 ir. |
210 aCompiledMethod := iRMethod compiledCode. |
211 aCompiledMethod := iRMethod compiledCode. |
211 self assert:(aCompiledMethod isKindOf:Method). |
212 self assert:(aCompiledMethod isKindOf:CompiledMethod). |
212 self |
213 self |
213 assert:((aCompiledMethod valueWithReceiver:nil arguments:#()) = true). |
214 assert:((aCompiledMethod valueWithReceiver:nil arguments:#()) = true). |
214 ! |
215 ! |
215 |
216 |
216 testInstVar |
217 testInstVar |
223 pushInstVar:2; |
224 pushInstVar:2; |
224 send:#'+'; |
225 send:#'+'; |
225 returnTop; |
226 returnTop; |
226 ir. |
227 ir. |
227 aCompiledMethod := irBuilder compiledCode. |
228 aCompiledMethod := irBuilder compiledCode. |
228 self assert:(aCompiledMethod isKindOf:Method). |
229 self assert:(aCompiledMethod isKindOf:CompiledMethod). |
229 self |
230 self |
230 assert:((aCompiledMethod valueWithReceiver:(3 @ 4) arguments:#()) = 7). |
231 assert:((aCompiledMethod valueWithReceiver:(3 @ 4) arguments:#()) = 7). |
231 |
232 |
232 "Modified: / 11-06-2008 / 13:16:41 / Jan Vrany <vranyj1@fel.cvut.cz>" |
233 "Modified: / 11-06-2008 / 13:16:41 / Jan Vrany <vranyj1@fel.cvut.cz>" |
233 ! |
234 ! |
243 pushLiteral:3; |
244 pushLiteral:3; |
244 jumpAheadTarget:#end; |
245 jumpAheadTarget:#end; |
245 returnTop; |
246 returnTop; |
246 ir. |
247 ir. |
247 aCompiledMethod := iRMethod compiledCode. |
248 aCompiledMethod := iRMethod compiledCode. |
248 self assert:(aCompiledMethod isKindOf:Method). |
249 self assert:(aCompiledMethod isKindOf:CompiledMethod). |
249 self assert:((aCompiledMethod valueWithReceiver:nil arguments:#()) = nil). |
250 self assert:((aCompiledMethod valueWithReceiver:nil arguments:#()) = nil). |
250 ! |
251 ! |
251 |
252 |
252 testJumpAheadToIf |
253 testJumpAheadToIf |
253 |iRMethod aCompiledMethod| |
254 |iRMethod aCompiledMethod| |
261 pushLiteral:3; |
262 pushLiteral:3; |
262 jumpAheadTarget:#end; |
263 jumpAheadTarget:#end; |
263 returnTop; |
264 returnTop; |
264 ir. |
265 ir. |
265 aCompiledMethod := iRMethod compiledCode. |
266 aCompiledMethod := iRMethod compiledCode. |
266 self assert:(aCompiledMethod isKindOf:Method). |
267 self assert:(aCompiledMethod isKindOf:CompiledMethod). |
267 self assert:((aCompiledMethod valueWithReceiver:nil arguments:#()) = nil). |
268 self assert:((aCompiledMethod valueWithReceiver:nil arguments:#()) = nil). |
268 ! |
269 ! |
269 |
270 |
270 testJumpBackTo |
271 testJumpBackTo |
271 |iRMethod aCompiledMethod| |
272 |iRMethod aCompiledMethod| |
281 jumpBackTo:#begin; |
282 jumpBackTo:#begin; |
282 jumpAheadTarget:#end; |
283 jumpAheadTarget:#end; |
283 returnTop; |
284 returnTop; |
284 ir. |
285 ir. |
285 aCompiledMethod := iRMethod compiledCode. |
286 aCompiledMethod := iRMethod compiledCode. |
286 self assert:(aCompiledMethod isKindOf:Method). |
287 self assert:(aCompiledMethod isKindOf:CompiledMethod). |
287 self assert:((aCompiledMethod valueWithReceiver:nil arguments:#()) = nil). |
288 self assert:((aCompiledMethod valueWithReceiver:nil arguments:#()) = nil). |
288 ! |
289 ! |
289 |
290 |
290 testLine1 |
291 testLine1 |
291 |iRMethod aCompiledMethod| |
292 |iRMethod aCompiledMethod| |
296 line:5; |
297 line:5; |
297 pushLiteral:true; |
298 pushLiteral:true; |
298 returnTop; |
299 returnTop; |
299 ir. |
300 ir. |
300 aCompiledMethod := iRMethod compiledCode. |
301 aCompiledMethod := iRMethod compiledCode. |
301 self assert:(aCompiledMethod isKindOf:Method). |
302 self assert:(aCompiledMethod isKindOf:CompiledMethod). |
302 self |
303 self |
303 assert:((aCompiledMethod valueWithReceiver:nil arguments:#()) = true). |
304 assert:((aCompiledMethod valueWithReceiver:nil arguments:#()) = true). |
304 |
305 |
305 "Created: / 02-12-2008 / 09:11:06 / Jan Vrany <vranyj1@fel.cvut.cz>" |
306 "Created: / 02-12-2008 / 09:11:06 / Jan Vrany <vranyj1@fel.cvut.cz>" |
306 ! |
307 ! |
316 pushLiteral:false; |
317 pushLiteral:false; |
317 send:#'&'; |
318 send:#'&'; |
318 returnTop; |
319 returnTop; |
319 ir. |
320 ir. |
320 aCompiledMethod := iRMethod compiledCode. |
321 aCompiledMethod := iRMethod compiledCode. |
321 self assert:(aCompiledMethod isKindOf:Method). |
322 self assert:(aCompiledMethod isKindOf:CompiledMethod). |
322 self |
323 self |
323 assert:((aCompiledMethod valueWithReceiver:nil arguments:#()) = false). |
324 assert:((aCompiledMethod valueWithReceiver:nil arguments:#()) = false). |
324 |
325 |
325 "Created: / 02-12-2008 / 09:11:42 / Jan Vrany <vranyj1@fel.cvut.cz>" |
326 "Created: / 02-12-2008 / 09:11:42 / Jan Vrany <vranyj1@fel.cvut.cz>" |
326 ! |
327 ! |
333 addTemps:#( #self ); |
334 addTemps:#( #self ); |
334 pushLiteral:#( #test 4 #you ); |
335 pushLiteral:#( #test 4 #you ); |
335 returnTop; |
336 returnTop; |
336 ir. |
337 ir. |
337 aCompiledMethod := iRMethod compiledCode. |
338 aCompiledMethod := iRMethod compiledCode. |
338 self assert:(aCompiledMethod isKindOf:Method). |
339 self assert:(aCompiledMethod isKindOf:CompiledMethod). |
339 self assert:((aCompiledMethod valueWithReceiver:nil arguments:#()) |
340 self assert:((aCompiledMethod valueWithReceiver:nil arguments:#()) |
340 = #( #test 4 #you )). |
341 = #( #test 4 #you )). |
341 ! |
342 ! |
342 |
343 |
343 testLiteralBoolean |
344 testLiteralBoolean |
348 addTemps:#( #self ); |
349 addTemps:#( #self ); |
349 pushLiteral:true; |
350 pushLiteral:true; |
350 returnTop; |
351 returnTop; |
351 ir. |
352 ir. |
352 aCompiledMethod := iRMethod compiledCode. |
353 aCompiledMethod := iRMethod compiledCode. |
353 self assert:(aCompiledMethod isKindOf:Method). |
354 self assert:(aCompiledMethod isKindOf:CompiledMethod). |
354 self |
355 self |
355 assert:((aCompiledMethod valueWithReceiver:nil arguments:#()) = true). |
356 assert:((aCompiledMethod valueWithReceiver:nil arguments:#()) = true). |
356 ! |
357 ! |
357 |
358 |
358 testLiteralCharacter |
359 testLiteralCharacter |
363 addTemps:#( #self ); |
364 addTemps:#( #self ); |
364 pushLiteral:$e; |
365 pushLiteral:$e; |
365 returnTop; |
366 returnTop; |
366 ir. |
367 ir. |
367 aCompiledMethod := iRMethod compiledCode. |
368 aCompiledMethod := iRMethod compiledCode. |
368 self assert:(aCompiledMethod isKindOf:Method). |
369 self assert:(aCompiledMethod isKindOf:CompiledMethod). |
369 self assert:((aCompiledMethod valueWithReceiver:nil arguments:#()) = $e). |
370 self assert:((aCompiledMethod valueWithReceiver:nil arguments:#()) = $e). |
370 ! |
371 ! |
371 |
372 |
372 testLiteralFloat |
373 testLiteralFloat |
373 |iRMethod aCompiledMethod| |
374 |iRMethod aCompiledMethod| |
377 addTemps:#( #self ); |
378 addTemps:#( #self ); |
378 pushLiteral:2.0; |
379 pushLiteral:2.0; |
379 returnTop; |
380 returnTop; |
380 ir. |
381 ir. |
381 aCompiledMethod := iRMethod compiledCode. |
382 aCompiledMethod := iRMethod compiledCode. |
382 self assert:(aCompiledMethod isKindOf:Method). |
383 self assert:(aCompiledMethod isKindOf:CompiledMethod). |
383 self assert:((aCompiledMethod valueWithReceiver:nil arguments:#()) = 2.0). |
384 self assert:((aCompiledMethod valueWithReceiver:nil arguments:#()) = 2.0). |
384 |
385 |
385 "Modified: / 03-11-2008 / 08:39:52 / Jan Vrany <vranyj1@fel.cvut.cz>" |
386 "Modified: / 03-11-2008 / 08:39:52 / Jan Vrany <vranyj1@fel.cvut.cz>" |
386 ! |
387 ! |
387 |
388 |
393 addTemps:#( #self ); |
394 addTemps:#( #self ); |
394 pushLiteral:2; |
395 pushLiteral:2; |
395 returnTop; |
396 returnTop; |
396 ir. |
397 ir. |
397 aCompiledMethod := iRMethod compiledCode. |
398 aCompiledMethod := iRMethod compiledCode. |
398 self assert:(aCompiledMethod isKindOf:Method). |
399 self assert:(aCompiledMethod isKindOf:CompiledMethod). |
399 self assert:((aCompiledMethod valueWithReceiver:nil arguments:#()) = 2). |
400 self assert:((aCompiledMethod valueWithReceiver:nil arguments:#()) = 2). |
400 ! |
401 ! |
401 |
402 |
402 testLiteralNil |
403 testLiteralNil |
403 |iRMethod aCompiledMethod| |
404 |iRMethod aCompiledMethod| |
407 addTemps:#( #self ); |
408 addTemps:#( #self ); |
408 pushLiteral:nil; |
409 pushLiteral:nil; |
409 returnTop; |
410 returnTop; |
410 ir. |
411 ir. |
411 aCompiledMethod := iRMethod compiledCode. |
412 aCompiledMethod := iRMethod compiledCode. |
412 self assert:(aCompiledMethod isKindOf:Method). |
413 self assert:(aCompiledMethod isKindOf:CompiledMethod). |
413 self assert:((aCompiledMethod valueWithReceiver:4 arguments:#()) = nil). |
414 self assert:((aCompiledMethod valueWithReceiver:4 arguments:#()) = nil). |
414 ! |
415 ! |
415 |
416 |
416 testLiteralString |
417 testLiteralString |
417 |iRMethod aCompiledMethod| |
418 |iRMethod aCompiledMethod| |
421 addTemps:#( #self ); |
422 addTemps:#( #self ); |
422 pushLiteral:'hello'; |
423 pushLiteral:'hello'; |
423 returnTop; |
424 returnTop; |
424 ir. |
425 ir. |
425 aCompiledMethod := iRMethod compiledCode. |
426 aCompiledMethod := iRMethod compiledCode. |
426 self assert:(aCompiledMethod isKindOf:Method). |
427 self assert:(aCompiledMethod isKindOf:CompiledMethod). |
427 self |
428 self |
428 assert:((aCompiledMethod valueWithReceiver:nil arguments:#()) = 'hello'). |
429 assert:((aCompiledMethod valueWithReceiver:nil arguments:#()) = 'hello'). |
429 ! |
430 ! |
430 |
431 |
431 testLiteralSymbole |
432 testLiteralSymbole |
436 addTemps:#( #self ); |
437 addTemps:#( #self ); |
437 pushLiteral:#you; |
438 pushLiteral:#you; |
438 returnTop; |
439 returnTop; |
439 ir. |
440 ir. |
440 aCompiledMethod := iRMethod compiledCode. |
441 aCompiledMethod := iRMethod compiledCode. |
441 self assert:(aCompiledMethod isKindOf:Method). |
442 self assert:(aCompiledMethod isKindOf:CompiledMethod). |
442 self |
443 self |
443 assert:((aCompiledMethod valueWithReceiver:nil arguments:#()) = #you). |
444 assert:((aCompiledMethod valueWithReceiver:nil arguments:#()) = #you). |
444 ! |
445 ! |
445 |
446 |
446 testLiteralVariableClass |
447 testLiteralVariableClass |
451 addTemps:#( #self ); |
452 addTemps:#( #self ); |
452 pushLiteralVariable:Object binding; |
453 pushLiteralVariable:Object binding; |
453 returnTop; |
454 returnTop; |
454 ir. |
455 ir. |
455 aCompiledMethod := iRMethod compiledCode. |
456 aCompiledMethod := iRMethod compiledCode. |
456 self assert:(aCompiledMethod isKindOf:Method). |
457 self assert:(aCompiledMethod isKindOf:CompiledMethod). |
457 self |
458 self |
458 assert:((aCompiledMethod valueWithReceiver:nil arguments:#()) = Object). |
459 assert:((aCompiledMethod valueWithReceiver:nil arguments:#()) = Object). |
459 ! |
460 ! |
460 |
461 |
461 testLiteralVariableClassVariable |
462 testLiteralVariableClassVariable |
462 |iRMethod aCompiledMethod| |
463 |iRMethod aCompiledMethod| |
463 |
464 |
464 iRMethod := (IRBuilder new) |
465 iRMethod := (IRBuilder new) |
465 numRargs:1; |
466 numRargs:1; |
466 addTemps:#( #self ); |
467 addTemps:#( #self ); |
467 pushLiteralVariable:(ArithmeticValue bindingOf:#ArithmeticSignal); |
468 pushLiteralVariable:#ArithmeticError; |
468 returnTop; |
469 returnTop; |
469 ir. |
470 ir. |
470 aCompiledMethod := iRMethod compiledCode. |
471 aCompiledMethod := iRMethod compiledCode. |
471 self assert:(aCompiledMethod isKindOf:Method). |
472 self assert:(aCompiledMethod isKindOf:CompiledMethod). |
472 self assert:((aCompiledMethod valueWithReceiver:nil arguments:#()) |
473 self assert:((aCompiledMethod valueWithReceiver:nil arguments:#()) |
473 = ArithmeticValue arithmeticSignal). |
474 = ArithmeticValue arithmeticSignal). |
474 |
475 |
475 "Modified: / 11-06-2008 / 11:31:32 / Jan Vrany <vranyj1@fel.cvut.cz>" |
476 "Modified: / 11-06-2008 / 11:31:32 / Jan Vrany <vranyj1@fel.cvut.cz>" |
477 "Modified: / 15-11-2011 / 22:25:06 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
476 ! |
478 ! |
477 |
479 |
478 testLiteralVariableGlobale |
480 testLiteralVariableGlobale |
479 |iRMethod aCompiledMethod| |
481 |iRMethod aCompiledMethod| |
480 |
482 |
483 addTemps:#( #self ); |
485 addTemps:#( #self ); |
484 pushLiteralVariable:Smalltalk binding; |
486 pushLiteralVariable:Smalltalk binding; |
485 returnTop; |
487 returnTop; |
486 ir. |
488 ir. |
487 aCompiledMethod := iRMethod compiledCode. |
489 aCompiledMethod := iRMethod compiledCode. |
488 self assert:(aCompiledMethod isKindOf:Method). |
490 self assert:(aCompiledMethod isKindOf:CompiledMethod). |
489 self |
491 self |
490 assert:((aCompiledMethod valueWithReceiver:nil arguments:#()) = Smalltalk). |
492 assert:((aCompiledMethod valueWithReceiver:nil arguments:#()) = Smalltalk). |
491 |
493 |
492 "Modified: / 11-06-2008 / 11:32:07 / Jan Vrany <vranyj1@fel.cvut.cz>" |
494 "Modified: / 11-06-2008 / 11:32:07 / Jan Vrany <vranyj1@fel.cvut.cz>" |
493 ! |
495 ! |
502 pushLiteral:false; |
504 pushLiteral:false; |
503 popTop; |
505 popTop; |
504 returnTop; |
506 returnTop; |
505 ir. |
507 ir. |
506 aCompiledMethod := iRMethod compiledCode. |
508 aCompiledMethod := iRMethod compiledCode. |
507 self assert:(aCompiledMethod isKindOf:Method). |
509 self assert:(aCompiledMethod isKindOf:CompiledMethod). |
508 self |
510 self |
509 assert:((aCompiledMethod valueWithReceiver:nil arguments:#()) = true). |
511 assert:((aCompiledMethod valueWithReceiver:nil arguments:#()) = true). |
510 |
512 |
511 "Modified: / 11-06-2008 / 13:22:11 / Jan Vrany <vranyj1@fel.cvut.cz>" |
513 "Modified: / 11-06-2008 / 13:22:11 / Jan Vrany <vranyj1@fel.cvut.cz>" |
512 ! |
514 ! |
520 pushReceiver; |
522 pushReceiver; |
521 returnTop; |
523 returnTop; |
522 ir. |
524 ir. |
523 aCompiledMethod := iRMethod compiledCode. |
525 aCompiledMethod := iRMethod compiledCode. |
524 receiver := (5 @ 8). |
526 receiver := (5 @ 8). |
525 self assert:(aCompiledMethod isKindOf:Method). |
527 self assert:(aCompiledMethod isKindOf:CompiledMethod). |
526 self assert:((aCompiledMethod valueWithReceiver:receiver arguments:#()) |
528 self assert:((aCompiledMethod valueWithReceiver:receiver arguments:#()) |
527 == receiver). |
529 == receiver). |
528 ! |
530 ! |
529 |
531 |
530 testPushTempArgument |
532 testPushTempArgument |
537 pushTemp:#b; |
539 pushTemp:#b; |
538 send:#'+'; |
540 send:#'+'; |
539 returnTop; |
541 returnTop; |
540 ir. |
542 ir. |
541 aCompiledMethod := iRMethod compiledCode. |
543 aCompiledMethod := iRMethod compiledCode. |
542 self assert:(aCompiledMethod isKindOf:Method). |
544 self assert:(aCompiledMethod isKindOf:CompiledMethod). |
543 self |
545 self |
544 assert:((aCompiledMethod valueWithReceiver:nil arguments:#( 2 8 )) = 10). |
546 assert:((aCompiledMethod valueWithReceiver:nil arguments:#( 2 8 )) = 10). |
545 ! |
547 ! |
546 |
548 |
547 testPushTempSelf |
549 testPushTempSelf |
553 pushTemp:#self; |
555 pushTemp:#self; |
554 send:#class; |
556 send:#class; |
555 returnTop; |
557 returnTop; |
556 ir. |
558 ir. |
557 aCompiledMethod := iRMethod compiledCode. |
559 aCompiledMethod := iRMethod compiledCode. |
558 self assert:(aCompiledMethod isKindOf:Method). |
560 self assert:(aCompiledMethod isKindOf:CompiledMethod). |
559 self assert:((aCompiledMethod valueWithReceiver:nil arguments:#()) |
561 self assert:((aCompiledMethod valueWithReceiver:nil arguments:#()) |
560 == UndefinedObject). |
562 == UndefinedObject). |
561 ! |
563 ! |
562 |
564 |
563 testPushTempTemp |
565 testPushTempTemp |
568 addTemps:#( #self #a ); |
570 addTemps:#( #self #a ); |
569 pushTemp:#a; |
571 pushTemp:#a; |
570 returnTop; |
572 returnTop; |
571 ir. |
573 ir. |
572 aCompiledMethod := iRMethod compiledCode. |
574 aCompiledMethod := iRMethod compiledCode. |
573 self assert:(aCompiledMethod isKindOf:Method). |
575 self assert:(aCompiledMethod isKindOf:CompiledMethod). |
574 self assert:((aCompiledMethod valueWithReceiver:5 arguments:#()) = nil). |
576 self assert:((aCompiledMethod valueWithReceiver:5 arguments:#()) = nil). |
575 ! |
577 ! |
576 |
578 |
577 testPushThisContext |
579 testPushThisContext |
578 |iRMethod aCompiledMethod| |
580 |iRMethod aCompiledMethod| |
583 pushThisContext; |
585 pushThisContext; |
584 send:#receiver; |
586 send:#receiver; |
585 returnTop; |
587 returnTop; |
586 ir. |
588 ir. |
587 aCompiledMethod := iRMethod compiledCode. |
589 aCompiledMethod := iRMethod compiledCode. |
588 self assert:(aCompiledMethod isKindOf:Method). |
590 self assert:(aCompiledMethod isKindOf:CompiledMethod). |
589 self assert:((aCompiledMethod valueWithReceiver:5 arguments:#()) = 5). |
591 self assert:((aCompiledMethod valueWithReceiver:5 arguments:#()) = 5). |
590 ! |
592 ! |
591 |
593 |
592 testPushThisEnv |
594 testPushThisEnv |
593 |iRMethod aCompiledMethod receiver| |
595 |iRMethod aCompiledMethod receiver| |
605 pushThisEnv; |
607 pushThisEnv; |
606 returnTop; |
608 returnTop; |
607 ir. |
609 ir. |
608 aCompiledMethod := iRMethod compiledCode. |
610 aCompiledMethod := iRMethod compiledCode. |
609 receiver := Object new. |
611 receiver := Object new. |
610 self assert:(aCompiledMethod isKindOf:Method). |
612 self assert:(aCompiledMethod isKindOf:CompiledMethod). |
611 self assert:((aCompiledMethod valueWithReceiver:receiver arguments:#()) |
613 self assert:((aCompiledMethod valueWithReceiver:receiver arguments:#()) |
612 isKindOf:ClosureEnvironment) |
614 isKindOf:ClosureEnvironment) |
613 ! |
615 ! |
614 |
616 |
615 testSendNumArgs1 |
617 testSendNumArgs1 |
625 returnTop; |
627 returnTop; |
626 ir. |
628 ir. |
627 aCompiledMethod := iRMethod compiledCode. |
629 aCompiledMethod := iRMethod compiledCode. |
628 self class basicAddSelector:#mock1 |
630 self class basicAddSelector:#mock1 |
629 withMethod:(self class >> #mock1:with:). |
631 withMethod:(self class >> #mock1:with:). |
630 self assert:(aCompiledMethod isKindOf:Method). |
632 self assert:(aCompiledMethod isKindOf:CompiledMethod). |
631 self |
633 self |
632 assert:(aCompiledMethod valueWithReceiver:(IRBuilderTest new) |
634 assert:(aCompiledMethod valueWithReceiver:(IRBuilderTest new) |
633 arguments:#()) = 3. |
635 arguments:#()) = 3. |
634 self class basicRemoveSelector:#mock1. |
636 self class basicRemoveSelector:#mock1. |
635 |
637 |
648 returnTop; |
650 returnTop; |
649 ir. |
651 ir. |
650 aCompiledMethod := iRMethod compiledCode. |
652 aCompiledMethod := iRMethod compiledCode. |
651 self class basicAddSelector:#mock1 |
653 self class basicAddSelector:#mock1 |
652 withMethod:(self class >> #mock1:with:). |
654 withMethod:(self class >> #mock1:with:). |
653 self assert:(aCompiledMethod isKindOf:Method). |
655 self assert:(aCompiledMethod isKindOf:CompiledMethod). |
654 self should: |
656 self |
655 [ (aCompiledMethod valueWithReceiver:(IRBuilderTest new) arguments:#()) ] |
657 should:[ |
658 (aCompiledMethod valueWithReceiver:(IRBuilderTest new) arguments:#()) |
|
659 ] |
|
656 raise:Error. |
660 raise:Error. |
657 self class basicRemoveSelector:#mock1. |
661 self class basicRemoveSelector:#mock1. |
658 |
662 |
659 "Created: / 01-12-2008 / 19:59:02 / Jan Vrany <vranyj1@fel.cvut.cz>" |
663 "Created: / 01-12-2008 / 19:59:02 / Jan Vrany <vranyj1@fel.cvut.cz>" |
660 ! |
664 ! |
668 pushReceiver; |
672 pushReceiver; |
669 send:#error toSuperOf:IRBuilderTest; |
673 send:#error toSuperOf:IRBuilderTest; |
670 returnTop; |
674 returnTop; |
671 ir. |
675 ir. |
672 aCompiledMethod := iRMethod compiledCode. |
676 aCompiledMethod := iRMethod compiledCode. |
673 self assert:(aCompiledMethod isKindOf:Method). |
677 self assert:(aCompiledMethod isKindOf:CompiledMethod). |
674 self should: |
678 self |
675 [ (aCompiledMethod valueWithReceiver:(IRBuilderTest new) arguments:#()) ] |
679 should:[ |
680 (aCompiledMethod valueWithReceiver:(IRBuilderTest new) arguments:#()) |
|
681 ] |
|
676 raise:Error. |
682 raise:Error. |
677 |
683 |
678 "Modified: / 11-06-2008 / 16:09:12 / Jan Vrany <vranyj1@fel.cvut.cz>" |
684 "Modified: / 11-06-2008 / 16:09:12 / Jan Vrany <vranyj1@fel.cvut.cz>" |
679 "Modified: / 15-02-2010 / 16:20:44 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
685 "Modified: / 15-11-2011 / 22:25:36 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
680 ! |
686 ! |
681 |
687 |
682 testStorIntoVariable |
688 testStorIntoVariable |
683 |iRMethod aCompiledMethod| |
689 |iRMethod aCompiledMethod| |
684 |
690 |
685 iRMethod := (IRBuilder new) |
691 iRMethod := (IRBuilder new) |
686 numRargs:1; |
692 numRargs:1; |
687 addTemps:#( #self ); |
693 addTemps:#( #self ); |
688 pushLiteral:4; |
694 pushLiteral:4; |
689 storeIntoLiteralVariable:(IRBuilderTest bindingOf:#TestToPush); |
695 storeIntoLiteralVariable:(#'IRBuilderTest:TestToPush'); |
690 returnTop; |
696 returnTop; |
691 ir. |
697 ir. |
692 aCompiledMethod := iRMethod compiledCode. |
698 aCompiledMethod := iRMethod compiledCode. |
693 self assert:(aCompiledMethod isKindOf:Method). |
699 self assert:(aCompiledMethod isKindOf:CompiledMethod). |
694 aCompiledMethod valueWithReceiver:nil arguments:#(). |
700 aCompiledMethod valueWithReceiver:nil arguments:#(). |
695 self assert:(IRBuilderTest testToPush = 4). |
701 self assert:(IRBuilderTest testToPush = 4). |
696 IRBuilderTest testToPush:nil. |
702 IRBuilderTest testToPush:nil. |
703 |
|
704 "Modified: / 15-11-2011 / 22:27:39 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
697 ! |
705 ! |
698 |
706 |
699 testStoreTemp |
707 testStoreTemp |
700 |iRMethod aCompiledMethod| |
708 |iRMethod aCompiledMethod| |
701 |
709 |
706 storeTemp:#a; |
714 storeTemp:#a; |
707 pushTemp:#a; |
715 pushTemp:#a; |
708 returnTop; |
716 returnTop; |
709 ir. |
717 ir. |
710 aCompiledMethod := iRMethod compiledCode. |
718 aCompiledMethod := iRMethod compiledCode. |
711 self assert:(aCompiledMethod isKindOf:Method). |
719 self assert:(aCompiledMethod isKindOf:CompiledMethod). |
712 self assert:((aCompiledMethod valueWithReceiver:nil arguments:#()) = 34). |
720 self assert:((aCompiledMethod valueWithReceiver:nil arguments:#()) = 34). |
713 |
721 |
714 "Modified: / 11-06-2008 / 16:24:43 / Jan Vrany <vranyj1@fel.cvut.cz>" |
722 "Modified: / 11-06-2008 / 16:24:43 / Jan Vrany <vranyj1@fel.cvut.cz>" |
715 ! |
723 ! |
716 |
724 |
729 pushLiteral:5; |
737 pushLiteral:5; |
730 send:#privGetInstVar:; |
738 send:#privGetInstVar:; |
731 returnTop; |
739 returnTop; |
732 ir. |
740 ir. |
733 aCompiledMethod := iRMethod compiledCode. |
741 aCompiledMethod := iRMethod compiledCode. |
734 self assert:(aCompiledMethod isKindOf:Method). |
742 self assert:(aCompiledMethod isKindOf:CompiledMethod). |
735 self assert:((aCompiledMethod valueWithReceiver:nil arguments:#()) |
743 self assert:((aCompiledMethod valueWithReceiver:nil arguments:#()) |
736 isKindOf:ClosureEnvironment). |
744 isKindOf:ClosureEnvironment). |
737 |
745 |
738 "Modified: / 11-06-2008 / 14:47:51 / Jan Vrany <vranyj1@fel.cvut.cz>" |
746 "Modified: / 11-06-2008 / 14:47:51 / Jan Vrany <vranyj1@fel.cvut.cz>" |
739 ! |
747 ! |
752 pushLiteral:3; |
760 pushLiteral:3; |
753 jumpAheadTarget:#end; |
761 jumpAheadTarget:#end; |
754 returnTop; |
762 returnTop; |
755 ir. |
763 ir. |
756 aCompiledMethod := iRMethod compiledCode. |
764 aCompiledMethod := iRMethod compiledCode. |
757 self assert:(aCompiledMethod isKindOf:Method). |
765 self assert:(aCompiledMethod isKindOf:CompiledMethod). |
758 self assert:((aCompiledMethod valueWithReceiver:nil arguments:#()) = nil). |
766 self assert:((aCompiledMethod valueWithReceiver:nil arguments:#()) = nil). |
759 |
767 |
760 "Created: / 03-11-2008 / 13:34:50 / Jan Vrany <vranyj1@fel.cvut.cz>" |
768 "Created: / 03-11-2008 / 13:34:50 / Jan Vrany <vranyj1@fel.cvut.cz>" |
761 ! ! |
769 ! ! |
762 |
770 |
766 |aCompiledMethod irBuilder| |
774 |aCompiledMethod irBuilder| |
767 |
775 |
768 irBuilder := (IRBuilder new) |
776 irBuilder := (IRBuilder new) |
769 numRargs:1; |
777 numRargs:1; |
770 addTemps:#( #self ); |
778 addTemps:#( #self ); |
771 pushBlockUsingBuilder: |
779 pushBlockUsingBuilder:[:builder | |
772 [:builder | |
|
773 builder |
780 builder |
774 numRargs:1; |
781 numRargs:1; |
775 addTemps:#( #barg1 ); |
782 addTemps:#( #barg1 ); |
776 pushBlockUsingBuilder: |
783 pushBlockUsingBuilder:[:builder| |
777 [:builder | |
784 builder |
778 builder |
785 numRargs: 1; |
779 numRargs:1; |
786 addTemps: #( #barg2 ); |
780 addTemps:#( #barg2 ); |
787 pushTemp: #barg2; |
781 pushTemp:#barg2; |
788 returnTop |
782 returnTop ]; |
789 ]; |
783 pushTemp:#barg1; |
790 pushTemp: #barg1; |
784 send:#value:; |
791 send: #value:; |
785 returnTop ]; |
792 returnTop |
786 pushLiteral:22; |
793 ]; |
787 send:#value:; |
794 pushLiteral: 22; |
788 returnTop; |
795 send:#value; |
789 ir. |
796 returnTop; |
790 " |
797 ir. |
791 irBuilder ir |
798 " |
792 " |
799 irBuilder ir |
800 " |
|
801 |
|
793 aCompiledMethod := irBuilder compiledCode. |
802 aCompiledMethod := irBuilder compiledCode. |
794 self assert:(aCompiledMethod isKindOf:Method). |
803 self assert:(aCompiledMethod isKindOf:CompiledMethod). |
795 self assert:((aCompiledMethod valueWithReceiver:1 arguments:#()) = 22). |
804 self assert:((aCompiledMethod valueWithReceiver:1 arguments:#()) = 22). |
796 |
805 |
797 "Created: / 11-05-2009 / 23:04:13 / Jan Vrany <vranyj1@fel.cvut.cz>" |
806 "Created: / 11-05-2009 / 23:04:13 / Jan Vrany <vranyj1@fel.cvut.cz>" |
798 "Modified: / 23-03-2010 / 21:47:41 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
799 ! |
|
800 |
|
801 testBlock_blockNesting_2 |
|
802 |aCompiledMethod irBuilder| |
|
803 |
|
804 irBuilder := (IRBuilder new) |
|
805 numRargs:1; |
|
806 addTemps:#( #self ); |
|
807 pushBlockUsingBuilder: |
|
808 [:builder | |
|
809 builder |
|
810 numRargs:1; |
|
811 addTemps:#( #barg1 ); |
|
812 pushBlockUsingBuilder: |
|
813 [:builder | |
|
814 builder |
|
815 numRargs:1; |
|
816 addTemps:#( #barg2 ); |
|
817 pushTemp:#barg2; |
|
818 returnTop ]; |
|
819 pushTemp:#barg1; |
|
820 send:#value:; |
|
821 pushBlockUsingBuilder: |
|
822 [:builder | |
|
823 builder |
|
824 numRargs:1; |
|
825 addTemps:#( #barg2 ); |
|
826 pushLiteral:-1; |
|
827 returnTop ]; |
|
828 pushTemp:#barg1; |
|
829 send:#value:; |
|
830 returnTop ]; |
|
831 pushLiteral:22; |
|
832 send:#value:; |
|
833 returnTop; |
|
834 ir. |
|
835 " |
|
836 irBuilder ir |
|
837 " |
|
838 aCompiledMethod := irBuilder compiledCode. |
|
839 self assert:(aCompiledMethod isKindOf:Method). |
|
840 self assert:((aCompiledMethod valueWithReceiver:1 arguments:#()) = -1). |
|
841 |
|
842 "Created: / 23-03-2010 / 21:43:49 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
843 ! |
807 ! |
844 |
808 |
845 testBlock_blockTempArg |
809 testBlock_blockTempArg |
846 |aCompiledMethod irBuilder| |
810 |aCompiledMethod irBuilder| |
847 |
811 |
848 irBuilder := (IRBuilder new) |
812 irBuilder := (IRBuilder new) |
849 numRargs:1; |
813 numRargs:1; |
850 addTemps:#( #self ); |
814 addTemps:#( #self ); |
851 pushBlockUsingBuilder: |
815 pushBlockUsingBuilder:[:builder | |
852 [:builder | |
|
853 builder |
816 builder |
854 numRargs:1; |
817 numRargs:1; |
855 addTemps:#( #barg1 ); |
818 addTemps:#( #barg1 ); |
856 pushTemp:#barg1; |
819 pushTemp:#barg1; |
857 returnTop ]; |
820 returnTop |
821 ]; |
|
858 pushLiteral:22; |
822 pushLiteral:22; |
859 send:#value:; |
823 send:#value:; |
860 returnTop; |
824 returnTop; |
861 ir. |
825 ir. |
862 " |
826 " |
863 irBuilder ir |
827 irBuilder ir |
864 " |
828 " |
829 |
|
865 aCompiledMethod := irBuilder compiledCode. |
830 aCompiledMethod := irBuilder compiledCode. |
866 self assert:(aCompiledMethod isKindOf:Method). |
831 self assert:(aCompiledMethod isKindOf:CompiledMethod). |
867 self assert:((aCompiledMethod valueWithReceiver:1 arguments:#()) = 22). |
832 self assert:((aCompiledMethod valueWithReceiver:1 arguments:#()) = 22). |
868 |
833 |
869 "Created: / 30-03-2009 / 14:26:18 / Jan Vrany <vranyj1@fel.cvut.cz>" |
834 "Created: / 30-03-2009 / 14:26:18 / Jan Vrany <vranyj1@fel.cvut.cz>" |
870 "Modified: / 30-03-2009 / 19:16:25 / Jan Vrany <vranyj1@fel.cvut.cz>" |
835 "Modified: / 30-03-2009 / 19:16:25 / Jan Vrany <vranyj1@fel.cvut.cz>" |
871 ! |
836 ! |
874 |aCompiledMethod irBuilder| |
839 |aCompiledMethod irBuilder| |
875 |
840 |
876 irBuilder := (IRBuilder new) |
841 irBuilder := (IRBuilder new) |
877 numRargs:1; |
842 numRargs:1; |
878 addTemps:#( #self ); |
843 addTemps:#( #self ); |
879 pushBlockUsingBuilder: |
844 pushBlockUsingBuilder:[:builder | |
880 [:builder | |
|
881 builder |
845 builder |
882 numRargs:0; |
846 numRargs:0; |
883 addTemps:#( #bvar1 ); |
847 addTemps:#( #bvar1 ); |
884 pushLiteral:22; |
848 pushLiteral: 22; |
885 storeTemp:#bvar1; |
849 storeTemp:#bvar1; |
886 pushTemp:#bvar1; |
850 pushTemp: #bvar1; |
887 returnTop ]; |
851 returnTop |
852 ]; |
|
888 send:#value; |
853 send:#value; |
889 returnTop; |
854 returnTop; |
890 ir. |
855 ir. |
891 " |
856 " |
892 irBuilder ir |
857 irBuilder ir |
893 " |
858 " |
859 |
|
894 aCompiledMethod := irBuilder compiledCode. |
860 aCompiledMethod := irBuilder compiledCode. |
895 self assert:(aCompiledMethod isKindOf:Method). |
861 self assert:(aCompiledMethod isKindOf:CompiledMethod). |
896 self assert:((aCompiledMethod valueWithReceiver:1 arguments:#()) = 22). |
862 self assert:((aCompiledMethod valueWithReceiver:1 arguments:#()) = 22). |
897 |
863 |
898 "Created: / 30-03-2009 / 23:03:48 / Jan Vrany <vranyj1@fel.cvut.cz>" |
864 "Created: / 30-03-2009 / 23:03:48 / Jan Vrany <vranyj1@fel.cvut.cz>" |
899 ! |
865 ! |
900 |
866 |
902 |aCompiledMethod irBuilder| |
868 |aCompiledMethod irBuilder| |
903 |
869 |
904 irBuilder := (IRBuilder new) |
870 irBuilder := (IRBuilder new) |
905 numRargs:1; |
871 numRargs:1; |
906 addTemps:#( #self ); |
872 addTemps:#( #self ); |
907 pushLiteral:false; |
873 pushLiteral: false; |
908 pushLiteral:true; |
874 pushLiteral: true; |
909 jumpAheadTo:#end if:false; |
875 jumpAheadTo: #end if: false; |
910 pushBlockUsingBuilder: |
876 pushBlockUsingBuilder:[:builder | |
911 [:builder | |
877 builder |
878 numRargs: 0; |
|
879 pushLiteral: true; |
|
880 returnTop |
|
881 ]; |
|
882 send: #value; |
|
883 jumpAheadTarget: #end; |
|
884 returnTop; |
|
885 ir. |
|
886 " |
|
887 irBuilder ir |
|
888 " |
|
889 |
|
890 aCompiledMethod := irBuilder compiledCode. |
|
891 self assert:(aCompiledMethod isKindOf:CompiledMethod). |
|
892 self assert:((aCompiledMethod valueWithReceiver:1 arguments:#()) = true). |
|
893 |
|
894 "Created: / 13-05-2009 / 11:24:48 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
895 ! |
|
896 |
|
897 testBlock_exceptionHandler |
|
898 |aCompiledMethod irBuilder| |
|
899 |
|
900 irBuilder := (IRBuilder new) |
|
901 numRargs:1; |
|
902 addTemps:#( #self); |
|
903 pushBlockUsingBuilder:[:builder | |
|
904 builder |
|
905 numRargs:0; |
|
906 pushLiteral: 1; |
|
907 pushLiteral: 0; |
|
908 send: #/; |
|
909 pushLiteral: false; |
|
910 remoteReturn |
|
911 ]; |
|
912 pushLiteralVariable: #Error; |
|
913 pushBlockUsingBuilder:[:builder| |
|
914 builder |
|
915 numRargs:0; |
|
916 pushLiteral: true; |
|
917 remoteReturn]; |
|
918 send: #on:do:; |
|
919 pushLiteral: false; |
|
920 returnTop; |
|
921 ir. |
|
922 " |
|
923 irBuilder ir |
|
924 " |
|
925 |
|
926 aCompiledMethod := irBuilder compiledCode. |
|
927 self assert:(aCompiledMethod isKindOf:CompiledMethod). |
|
928 self assert:((aCompiledMethod valueWithReceiver:1 arguments:#()) = true). |
|
929 |
|
930 "Created: / 11-05-2009 / 21:53:19 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
931 ! |
|
932 |
|
933 testBlock_exceptionHandler_noRemoteReturn |
|
934 |aCompiledMethod irBuilder| |
|
935 |
|
936 irBuilder := (IRBuilder new) |
|
937 numRargs:1; |
|
938 addTemps:#( #self); |
|
939 pushBlockUsingBuilder:[:builder | |
|
940 builder |
|
941 numRargs:0; |
|
942 pushLiteral: 1; |
|
943 pushLiteral: 0; |
|
944 send: #/; |
|
945 pushLiteral: false; |
|
946 returnTop |
|
947 ]; |
|
948 pushLiteralVariable: #Error; |
|
949 pushBlockUsingBuilder:[:builder| |
|
950 builder |
|
951 numRargs:0; |
|
952 pushLiteral: true; |
|
953 returnTop]; |
|
954 send: #on:do:; |
|
955 returnTop; |
|
956 ir. |
|
957 " |
|
958 irBuilder ir |
|
959 " |
|
960 |
|
961 aCompiledMethod := irBuilder compiledCode. |
|
962 self assert:(aCompiledMethod isKindOf:CompiledMethod). |
|
963 self assert:((aCompiledMethod valueWithReceiver:1 arguments:#()) = true). |
|
964 |
|
965 "Created: / 11-05-2009 / 21:53:25 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
966 ! |
|
967 |
|
968 testBlock_invalid_instruction_ordering_bug_1 |
|
969 |aCompiledMethod irBuilder| |
|
970 |
|
971 irBuilder := (IRBuilder new) |
|
972 numRargs: 1; |
|
973 addTemps: #(self i); |
|
974 pushTemp: #i; |
|
975 pushLiteral: 3; |
|
976 pushReceiver; |
|
977 |
|
978 pushBlockUsingBuilder: [ :builder | |
|
979 builder |
|
980 numRargs: 0; |
|
981 addTemps: #(); |
|
982 pushTemp: #i; |
|
983 returnTop. |
|
984 ]; |
|
985 returnTop; |
|
986 ir. |
|
987 " |
|
988 irBuilder ir |
|
989 " |
|
990 |
|
991 aCompiledMethod := irBuilder compiledCode. |
|
992 self assert:(aCompiledMethod isKindOf:CompiledMethod). |
|
993 self assert:((aCompiledMethod valueWithReceiver:1 arguments:#()) isKindOf: Block). |
|
994 |
|
995 "Created: / 11-05-2009 / 21:55:30 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
996 ! |
|
997 |
|
998 testBlock_methodTempVar |
|
999 |aCompiledMethod irBuilder| |
|
1000 |
|
1001 irBuilder := (IRBuilder new) |
|
1002 numRargs:1; |
|
1003 addTemps:#( #self #a); |
|
1004 pushLiteral: 22; |
|
1005 storeTemp: #a; |
|
1006 pushBlockUsingBuilder:[:builder | |
|
912 builder |
1007 builder |
913 numRargs:0; |
1008 numRargs:0; |
914 pushLiteral:true; |
1009 pushTemp: #a; |
915 returnTop ]; |
1010 returnTop |
1011 ]; |
|
916 send:#value; |
1012 send:#value; |
917 jumpAheadTarget:#end; |
1013 returnTop; |
918 returnTop; |
1014 ir. |
919 ir. |
1015 " |
920 " |
1016 irBuilder ir |
921 irBuilder ir |
1017 " |
922 " |
1018 |
923 aCompiledMethod := irBuilder compiledCode. |
1019 aCompiledMethod := irBuilder compiledCode. |
924 self assert:(aCompiledMethod isKindOf:Method). |
1020 self assert:(aCompiledMethod isKindOf:CompiledMethod). |
925 self assert:((aCompiledMethod valueWithReceiver:1 arguments:#()) = true). |
|
926 |
|
927 "Created: / 13-05-2009 / 11:24:48 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
928 ! |
|
929 |
|
930 testBlock_exceptionHandler |
|
931 |aCompiledMethod irBuilder| |
|
932 |
|
933 irBuilder := (IRBuilder new) |
|
934 numRargs:1; |
|
935 addTemps:#( #self ); |
|
936 pushBlockUsingBuilder: |
|
937 [:builder | |
|
938 builder |
|
939 numRargs:0; |
|
940 pushLiteral:1; |
|
941 pushLiteral:0; |
|
942 send:#'/'; |
|
943 pushLiteral:false; |
|
944 remoteReturn ]; |
|
945 pushLiteralVariable:#Error; |
|
946 pushBlockUsingBuilder: |
|
947 [:builder | |
|
948 builder |
|
949 numRargs:0; |
|
950 pushLiteral:true; |
|
951 remoteReturn ]; |
|
952 send:#on:do:; |
|
953 pushLiteral:false; |
|
954 returnTop; |
|
955 ir. |
|
956 " |
|
957 irBuilder ir |
|
958 " |
|
959 aCompiledMethod := irBuilder compiledCode. |
|
960 self assert:(aCompiledMethod isKindOf:Method). |
|
961 self assert:((aCompiledMethod valueWithReceiver:1 arguments:#()) = true). |
|
962 |
|
963 "Created: / 11-05-2009 / 21:53:19 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
964 ! |
|
965 |
|
966 testBlock_exceptionHandler_noRemoteReturn |
|
967 |aCompiledMethod irBuilder| |
|
968 |
|
969 irBuilder := (IRBuilder new) |
|
970 numRargs:1; |
|
971 addTemps:#( #self ); |
|
972 pushBlockUsingBuilder: |
|
973 [:builder | |
|
974 builder |
|
975 numRargs:0; |
|
976 pushLiteral:1; |
|
977 pushLiteral:0; |
|
978 send:#'/'; |
|
979 pushLiteral:false; |
|
980 returnTop ]; |
|
981 pushLiteralVariable:#Error; |
|
982 pushBlockUsingBuilder: |
|
983 [:builder | |
|
984 builder |
|
985 numRargs:0; |
|
986 pushLiteral:true; |
|
987 returnTop ]; |
|
988 send:#on:do:; |
|
989 returnTop; |
|
990 ir. |
|
991 " |
|
992 irBuilder ir |
|
993 " |
|
994 aCompiledMethod := irBuilder compiledCode. |
|
995 self assert:(aCompiledMethod isKindOf:Method). |
|
996 self assert:((aCompiledMethod valueWithReceiver:1 arguments:#()) = true). |
|
997 |
|
998 "Created: / 11-05-2009 / 21:53:25 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
999 ! |
|
1000 |
|
1001 testBlock_invalid_instruction_ordering_bug_1 |
|
1002 |aCompiledMethod irBuilder| |
|
1003 |
|
1004 irBuilder := (IRBuilder new) |
|
1005 numRargs:1; |
|
1006 addTemps:#( #self #i ); |
|
1007 pushTemp:#i; |
|
1008 pushLiteral:3; |
|
1009 pushReceiver; |
|
1010 pushBlockUsingBuilder: |
|
1011 [:builder | |
|
1012 builder |
|
1013 numRargs:0; |
|
1014 addTemps:#(); |
|
1015 pushTemp:#i; |
|
1016 returnTop. ]; |
|
1017 returnTop; |
|
1018 ir. |
|
1019 " |
|
1020 irBuilder ir |
|
1021 " |
|
1022 aCompiledMethod := irBuilder compiledCode. |
|
1023 self assert:(aCompiledMethod isKindOf:Method). |
|
1024 self assert:((aCompiledMethod valueWithReceiver:1 arguments:#()) |
|
1025 isKindOf:Block). |
|
1026 |
|
1027 "Created: / 11-05-2009 / 21:55:30 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
1028 ! |
|
1029 |
|
1030 testBlock_methodTempVar |
|
1031 |aCompiledMethod irBuilder| |
|
1032 |
|
1033 irBuilder := (IRBuilder new) |
|
1034 numRargs:1; |
|
1035 addTemps:#( #self #a ); |
|
1036 pushLiteral:22; |
|
1037 storeTemp:#a; |
|
1038 pushBlockUsingBuilder: |
|
1039 [:builder | |
|
1040 builder |
|
1041 numRargs:0; |
|
1042 pushTemp:#a; |
|
1043 returnTop ]; |
|
1044 send:#value; |
|
1045 returnTop; |
|
1046 ir. |
|
1047 " |
|
1048 irBuilder ir |
|
1049 " |
|
1050 aCompiledMethod := irBuilder compiledCode. |
|
1051 self assert:(aCompiledMethod isKindOf:Method). |
|
1052 self assert:((aCompiledMethod valueWithReceiver:1 arguments:#()) = 22). |
1021 self assert:((aCompiledMethod valueWithReceiver:1 arguments:#()) = 22). |
1053 |
1022 |
1054 "Created: / 30-03-2009 / 23:05:00 / Jan Vrany <vranyj1@fel.cvut.cz>" |
1023 "Created: / 30-03-2009 / 23:05:00 / Jan Vrany <vranyj1@fel.cvut.cz>" |
1055 "Modified: / 01-04-2009 / 19:43:52 / Jan Vrany <vranyj1@fel.cvut.cz>" |
1024 "Modified: / 01-04-2009 / 19:43:52 / Jan Vrany <vranyj1@fel.cvut.cz>" |
1056 ! ! |
1025 ! ! |
1057 |
1026 |
1058 !IRBuilderTest class methodsFor:'documentation'! |
1027 !IRBuilderTest class methodsFor:'documentation'! |
1059 |
1028 |
1060 version |
1029 version |
1061 ^ '$Header: /cvs/stx/cvut/stx/goodies/newcompiler/IRBuilderTest.st,v 1.3 2009/10/08 12:03:51 fm Exp $' |
1030 ^ '$Id$' |
1062 ! |
1031 ! |
1063 |
1032 |
1064 version_CVS |
1033 version_CVS |
1065 ^ '$Header: /cvs/stx/cvut/stx/goodies/newcompiler/IRBuilderTest.st,v 1.3 2009/10/08 12:03:51 fm Exp $' |
1034 ^ '§Header: /cvs/stx/cvut/stx/goodies/newcompiler/IRBuilderTest.st,v 1.3 2009/10/08 12:03:51 fm Exp §' |
1066 ! |
1035 ! |
1067 |
1036 |
1068 version_SVN |
1037 version_SVN |
1069 ^ '$Id$' |
1038 ^ '$Id$' |
1070 ! ! |
1039 ! ! |