diff -r c8afb8e4c3cc -r 840c68a91cdd IRBuilderTest.st --- a/IRBuilderTest.st Thu Oct 30 22:23:12 2014 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1031 +0,0 @@ -"{ Package: 'ctu:ircompiler' }" - -TestCase subclass:#IRBuilderTest - instanceVariableNames:'' - classVariableNames:'TestToPush' - poolDictionaries:'' - category:'IR Compiler-Tests' -! - - -!IRBuilderTest class methodsFor:'as yet unclassified'! - -testToPush - ^TestToPush -! - -testToPush: anObject - - TestToPush := anObject -! ! - -!IRBuilderTest methodsFor:'mock methods'! - -mock1: arg1 with: arg2 - - ^arg1 + arg2 - - "Created: / 02-12-2008 / 09:11:46 / Jan Vrany " -! - -mock2 - - ^[ testSelector ] - - " - decompiling IRBuilderTest>>mock2 - nA: 0 nV: 0 nT: 2 - - 1: 37 04 00 00 makeBlock 4 (7) nv=0 na=0 - 5: 5A pushInstVar1 - 6: 00 retTop - 7: 08 03 LINE[3] - 9: 00 retTop - " - - "Created: / 28-03-2009 / 18:47:17 / Jan Vrany " - "Modified: / 28-03-2009 / 20:16:08 / Jan Vrany " -! - -mock3 - | b | - b := 1. - ^[ b ] - - " - decompiling IRBuilderTest>>mock3 - nA: 0 nV: 1 nT: 2 - - 1: 79 push1 - 2: 64 storeMethodVar1 - 3: 37 04 00 00 makeBlock 4 (9) nv=0 na=0 - 7: 50 pushMethodVar1 - 8: 00 retTop - 9: 08 04 LINE[4] - 11:00 retTop - " - - "Created: / 28-03-2009 / 20:16:36 / Jan Vrany " -! - -mock4 - - ^[:arg| arg ] - - " - decompiling IRBuilderTest>>mock4 - nA: 0 nV: 0 nT: 2 - - 1: 37 04 00 01 makeBlock 4 (7) nv=0 na=1 - 5: 8C pushBlockArg1 - 6: 00 retTop - 7: 08 03 LINE[3] - 9: 00 retTop - - - - " - - "Created: / 28-03-2009 / 20:18:32 / Jan Vrany " -! - -mock5 - - ^[|temp| temp ] - - " - decompiling IRBuilderTest>>mock5 - nA: 0 nV: 0 nT: 2 - - 1: 37 04 01 00 makeBlock 4 (7) nv=1 na=0 - 5: E8 pushBlockVar1 - 6: 00 retTop - 7: 08 03 LINE[3] - 9: 00 retTop - " - - "Created: / 28-03-2009 / 20:19:17 / Jan Vrany " -! - -mock6 - - ^[|temp| [ temp ] ] - - " - decompiling IRBuilderTest>>mock6 - nA: 0 nV: 0 nT: 3 - - 1: 37 0B 01 00 makeBlock 11 (14) nv=1 na=0 - 5: 37 06 00 00 makeBlock 6 (13) nv=0 na=0 - 9: 80 01 01 pushOuterBlockVar 1 lvl: 1 - 12:00 retTop - 13:00 retTop - 14:08 03 LINE[3] - 16:00 retTop - - " - - "Created: / 28-03-2009 / 20:20:06 / Jan Vrany " -! - -mock7 - | b | - b := 1. - ^[ ^b ] - - " - decompiling IRBuilderTest>>mock7 - nA: 0 nV: 1 nT: 2 - - 1: 79 push1 - 2: 64 storeMethodVar1 - 3: 37 06 00 00 makeBlock 6 (11) nv=0 na=0 - 7: 50 pushMethodVar1 - 8: 08 04 LINE[4] - 10:07 homeRetTop - 11:08 04 LINE[4] - 13:00 retTop - - " - - "Created: / 28-03-2009 / 20:21:51 / Jan Vrany " -! - -mock8 - - ^([:arg| arg ] value: 22) - - "Created: / 30-03-2009 / 19:21:48 / Jan Vrany " -! - -mock9 - - ^[:barg1 | [:barg2 | barg2 ] value: barg1 ] - value: 22 - - " - decompiling IRBuilderTest>>mock9 - nA: 0 nV: 0 nT: 3 - - 1: 37 0C 00 01 makeBlock 12 (15) nv=0 na=1 - 5: 37 04 00 01 makeBlock 4 (11) nv=0 na=1 - 9: 8C pushBlockArg1 - 10: 00 retTop - 11: 8C pushBlockArg1 - 12: 98 03 send1 #value:[3] - 14: 00 retTop - 15: 10 16 pushNum 22 - 17: 98 04 send1 #value:[4] - 19: 08 03 LINE[3] - 21: 00 - - " - - "Created: / 11-05-2009 / 23:09:57 / Jan Vrany " -! ! - -!IRBuilderTest methodsFor:'testing'! - -halt - "Redefinition for testing the #send:toSuperOf:" - - "Created: / 11-06-2008 / 16:08:52 / Jan Vrany " -! - -isThisEverCalled - "Redefinition for testing the #send:toSuperOf:" -! - -testDup - |iRMethod aCompiledMethod| - - iRMethod := (IRBuilder new) - numRargs:1; - addTemps:#( #self ); - pushLiteral:3; - pushDup; - send:#'='; - returnTop; - ir. - aCompiledMethod := iRMethod compiledCode. - self assert:(aCompiledMethod isKindOf:CompiledMethod). - self - assert:((aCompiledMethod valueWithReceiver:nil arguments:#()) = true). -! - -testInstVar - |aCompiledMethod irBuilder| - - irBuilder := (IRBuilder new) - numRargs:1; - addTemps:#( #self ); - pushInstVar:1; - pushInstVar:2; - send:#'+'; - returnTop; - ir. - aCompiledMethod := irBuilder compiledCode. - self assert:(aCompiledMethod isKindOf:CompiledMethod). - self - assert:((aCompiledMethod valueWithReceiver:(3 @ 4) arguments:#()) = 7). - - "Modified: / 11-06-2008 / 13:16:41 / Jan Vrany " -! - -testJumpAheadTo - |iRMethod aCompiledMethod| - - iRMethod := (IRBuilder new) - numRargs:1; - addTemps:#( #self ); - pushTemp:#self; - jumpAheadTo:#end; - pushLiteral:3; - jumpAheadTarget:#end; - returnTop; - ir. - aCompiledMethod := iRMethod compiledCode. - self assert:(aCompiledMethod isKindOf:CompiledMethod). - self assert:((aCompiledMethod valueWithReceiver:nil arguments:#()) = nil). -! - -testJumpAheadToIf - |iRMethod aCompiledMethod| - - iRMethod := (IRBuilder new) - numRargs:1; - addTemps:#( #self ); - pushTemp:#self; - pushLiteral:true; - jumpAheadTo:#end if:true; - pushLiteral:3; - jumpAheadTarget:#end; - returnTop; - ir. - aCompiledMethod := iRMethod compiledCode. - self assert:(aCompiledMethod isKindOf:CompiledMethod). - self assert:((aCompiledMethod valueWithReceiver:nil arguments:#()) = nil). -! - -testJumpBackTo - |iRMethod aCompiledMethod| - - iRMethod := (IRBuilder new) - numRargs:1; - addTemps:#( #self ); - pushTemp:#self; - pushLiteral:false; - jumpBackTarget:#begin; - jumpAheadTo:#end if:true; - pushLiteral:true; - jumpBackTo:#begin; - jumpAheadTarget:#end; - returnTop; - ir. - aCompiledMethod := iRMethod compiledCode. - self assert:(aCompiledMethod isKindOf:CompiledMethod). - self assert:((aCompiledMethod valueWithReceiver:nil arguments:#()) = nil). -! - -testLine1 - |iRMethod aCompiledMethod| - - iRMethod := (IRBuilder new) - numRargs:1; - addTemps:#( #self ); - line:5; - pushLiteral:true; - returnTop; - ir. - aCompiledMethod := iRMethod compiledCode. - self assert:(aCompiledMethod isKindOf:CompiledMethod). - self - assert:((aCompiledMethod valueWithReceiver:nil arguments:#()) = true). - - "Created: / 02-12-2008 / 09:11:06 / Jan Vrany " -! - -testLine2 - |iRMethod aCompiledMethod| - - iRMethod := (IRBuilder new) - numRargs:1; - addTemps:#( #self ); - line:5; - pushLiteral:true; - pushLiteral:false; - send:#'&'; - returnTop; - ir. - aCompiledMethod := iRMethod compiledCode. - self assert:(aCompiledMethod isKindOf:CompiledMethod). - self - assert:((aCompiledMethod valueWithReceiver:nil arguments:#()) = false). - - "Created: / 02-12-2008 / 09:11:42 / Jan Vrany " -! - -testLiteralArray - |iRMethod aCompiledMethod| - - iRMethod := (IRBuilder new) - numRargs:1; - addTemps:#( #self ); - pushLiteral:#( #test 4 #you ); - returnTop; - ir. - aCompiledMethod := iRMethod compiledCode. - self assert:(aCompiledMethod isKindOf:CompiledMethod). - self assert:((aCompiledMethod valueWithReceiver:nil arguments:#()) - = #( #test 4 #you )). -! - -testLiteralBoolean - |iRMethod aCompiledMethod| - - iRMethod := (IRBuilder new) - numRargs:1; - addTemps:#( #self ); - pushLiteral:true; - returnTop; - ir. - aCompiledMethod := iRMethod compiledCode. - self assert:(aCompiledMethod isKindOf:CompiledMethod). - self - assert:((aCompiledMethod valueWithReceiver:nil arguments:#()) = true). -! - -testLiteralCharacter - |iRMethod aCompiledMethod| - - iRMethod := (IRBuilder new) - numRargs:1; - addTemps:#( #self ); - pushLiteral:$e; - returnTop; - ir. - aCompiledMethod := iRMethod compiledCode. - self assert:(aCompiledMethod isKindOf:CompiledMethod). - self assert:((aCompiledMethod valueWithReceiver:nil arguments:#()) = $e). -! - -testLiteralFloat - |iRMethod aCompiledMethod| - - iRMethod := (IRBuilder new) - numRargs:1; - addTemps:#( #self ); - pushLiteral:2.0; - returnTop; - ir. - aCompiledMethod := iRMethod compiledCode. - self assert:(aCompiledMethod isKindOf:CompiledMethod). - self assert:((aCompiledMethod valueWithReceiver:nil arguments:#()) = 2.0). - - "Modified: / 03-11-2008 / 08:39:52 / Jan Vrany " -! - -testLiteralInteger - |iRMethod aCompiledMethod| - - iRMethod := (IRBuilder new) - numRargs:1; - addTemps:#( #self ); - pushLiteral:2; - returnTop; - ir. - aCompiledMethod := iRMethod compiledCode. - self assert:(aCompiledMethod isKindOf:CompiledMethod). - self assert:((aCompiledMethod valueWithReceiver:nil arguments:#()) = 2). -! - -testLiteralNil - |iRMethod aCompiledMethod| - - iRMethod := (IRBuilder new) - numRargs:1; - addTemps:#( #self ); - pushLiteral:nil; - returnTop; - ir. - aCompiledMethod := iRMethod compiledCode. - self assert:(aCompiledMethod isKindOf:CompiledMethod). - self assert:((aCompiledMethod valueWithReceiver:4 arguments:#()) = nil). -! - -testLiteralString - |iRMethod aCompiledMethod| - - iRMethod := (IRBuilder new) - numRargs:1; - addTemps:#( #self ); - pushLiteral:'hello'; - returnTop; - ir. - aCompiledMethod := iRMethod compiledCode. - self assert:(aCompiledMethod isKindOf:CompiledMethod). - self - assert:((aCompiledMethod valueWithReceiver:nil arguments:#()) = 'hello'). -! - -testLiteralSymbole - |iRMethod aCompiledMethod| - - iRMethod := (IRBuilder new) - numRargs:1; - addTemps:#( #self ); - pushLiteral:#you; - returnTop; - ir. - aCompiledMethod := iRMethod compiledCode. - self assert:(aCompiledMethod isKindOf:CompiledMethod). - self - assert:((aCompiledMethod valueWithReceiver:nil arguments:#()) = #you). -! - -testLiteralVariableClass - |iRMethod aCompiledMethod| - - iRMethod := (IRBuilder new) - numRargs:1; - addTemps:#( #self ); - pushLiteralVariable:Object binding; - returnTop; - ir. - aCompiledMethod := iRMethod compiledCode. - self assert:(aCompiledMethod isKindOf:CompiledMethod). - self - assert:((aCompiledMethod valueWithReceiver:nil arguments:#()) = Object). -! - -testLiteralVariableClassVariable - |iRMethod aCompiledMethod| - - iRMethod := (IRBuilder new) - numRargs:1; - addTemps:#( #self ); - pushLiteralVariable:(ArithmeticValue bindingOf:#ArithmeticSignal); - returnTop; - ir. - aCompiledMethod := iRMethod compiledCode. - self assert:(aCompiledMethod isKindOf:CompiledMethod). - self assert:((aCompiledMethod valueWithReceiver:nil arguments:#()) - = ArithmeticValue arithmeticSignal). - - "Modified: / 11-06-2008 / 11:31:32 / Jan Vrany " -! - -testLiteralVariableGlobale - |iRMethod aCompiledMethod| - - iRMethod := (IRBuilder new) - numRargs:1; - addTemps:#( #self ); - pushLiteralVariable:Smalltalk binding; - returnTop; - ir. - aCompiledMethod := iRMethod compiledCode. - self assert:(aCompiledMethod isKindOf:CompiledMethod). - self - assert:((aCompiledMethod valueWithReceiver:nil arguments:#()) = Smalltalk). - - "Modified: / 11-06-2008 / 11:32:07 / Jan Vrany " -! - -testPopTop - |iRMethod aCompiledMethod| - - iRMethod := (IRBuilder new) - numRargs:1; - addTemps:#( #self ); - pushLiteral:true; - pushLiteral:false; - popTop; - returnTop; - ir. - aCompiledMethod := iRMethod compiledCode. - self assert:(aCompiledMethod isKindOf:CompiledMethod). - self - assert:((aCompiledMethod valueWithReceiver:nil arguments:#()) = true). - - "Modified: / 11-06-2008 / 13:22:11 / Jan Vrany " -! - -testPushReceiver - |iRMethod aCompiledMethod receiver| - - iRMethod := (IRBuilder new) - numRargs:1; - addTemps:#( #self ); - pushReceiver; - returnTop; - ir. - aCompiledMethod := iRMethod compiledCode. - receiver := (5 @ 8). - self assert:(aCompiledMethod isKindOf:CompiledMethod). - self assert:((aCompiledMethod valueWithReceiver:receiver arguments:#()) - == receiver). -! - -testPushTempArgument - |iRMethod aCompiledMethod| - - iRMethod := (IRBuilder new) - numRargs:3; - addTemps:#( #self #a #b ); - pushTemp:#a; - pushTemp:#b; - send:#'+'; - returnTop; - ir. - aCompiledMethod := iRMethod compiledCode. - self assert:(aCompiledMethod isKindOf:CompiledMethod). - self - assert:((aCompiledMethod valueWithReceiver:nil arguments:#( 2 8 )) = 10). -! - -testPushTempSelf - |iRMethod aCompiledMethod| - - iRMethod := (IRBuilder new) - numRargs:1; - addTemps:#( #self ); - pushTemp:#self; - send:#class; - returnTop; - ir. - aCompiledMethod := iRMethod compiledCode. - self assert:(aCompiledMethod isKindOf:CompiledMethod). - self assert:((aCompiledMethod valueWithReceiver:nil arguments:#()) - == UndefinedObject). -! - -testPushTempTemp - |iRMethod aCompiledMethod| - - iRMethod := (IRBuilder new) - numRargs:1; - addTemps:#( #self #a ); - pushTemp:#a; - returnTop; - ir. - aCompiledMethod := iRMethod compiledCode. - self assert:(aCompiledMethod isKindOf:CompiledMethod). - self assert:((aCompiledMethod valueWithReceiver:5 arguments:#()) = nil). -! - -testPushThisContext - |iRMethod aCompiledMethod| - - iRMethod := (IRBuilder new) - numRargs:1; - addTemps:#( #self #a ); - pushThisContext; - send:#receiver; - returnTop; - ir. - aCompiledMethod := iRMethod compiledCode. - self assert:(aCompiledMethod isKindOf:CompiledMethod). - self assert:((aCompiledMethod valueWithReceiver:5 arguments:#()) = 5). -! - -testPushThisEnv - |iRMethod aCompiledMethod receiver| - - ^ self. - iRMethod := (IRBuilder new) - numRargs:1; - addTemps:#( #self ); - pushThisContext; - pushLiteral:5; - pushLiteral:ClosureEnvironment; - pushLiteral:1; - send:#new:; - send:#privSetInstVar:put:; - pushThisEnv; - returnTop; - ir. - aCompiledMethod := iRMethod compiledCode. - receiver := Object new. - self assert:(aCompiledMethod isKindOf:CompiledMethod). - self assert:((aCompiledMethod valueWithReceiver:receiver arguments:#()) - isKindOf:ClosureEnvironment) -! - -testSendNumArgs1 - |iRMethod aCompiledMethod| - - iRMethod := (IRBuilder new) - numRargs:1; - addTemps:#( #self ); - pushReceiver; - pushLiteral:1; - pushLiteral:2; - send:#mock1 numArgs:2; - returnTop; - ir. - aCompiledMethod := iRMethod compiledCode. - self class basicAddSelector:#mock1 - withMethod:(self class >> #mock1:with:). - self assert:(aCompiledMethod isKindOf:CompiledMethod). - self - assert:(aCompiledMethod valueWithReceiver:(IRBuilderTest new) - arguments:#()) = 3. - self class basicRemoveSelector:#mock1. - - "Created: / 01-12-2008 / 19:58:18 / Jan Vrany " -! - -testSendNumArgs2 - |iRMethod aCompiledMethod| - - iRMethod := (IRBuilder new) - numRargs:1; - addTemps:#( #self ); - pushReceiver; - pushLiteral:1; - send:#mock1 numArgs:1; - returnTop; - ir. - aCompiledMethod := iRMethod compiledCode. - self class basicAddSelector:#mock1 - withMethod:(self class >> #mock1:with:). - self assert:(aCompiledMethod isKindOf:CompiledMethod). - self - should:[ - (aCompiledMethod valueWithReceiver:(IRBuilderTest new) arguments:#()) - ] - raise:Error. - self class basicRemoveSelector:#mock1. - - "Created: / 01-12-2008 / 19:59:02 / Jan Vrany " -! - -testSendSuper - |iRMethod aCompiledMethod| - - iRMethod := (IRBuilder new) - numRargs:1; - addTemps:#( #self ); - pushReceiver; - send:#halt toSuperOf:IRBuilderTest; - returnTop; - ir. - aCompiledMethod := iRMethod compiledCode. - self assert:(aCompiledMethod isKindOf:CompiledMethod). - self - should:[ - (aCompiledMethod valueWithReceiver:(IRBuilderTest new) arguments:#()) - ] - raise:Error. - - "Modified: / 11-06-2008 / 16:09:12 / Jan Vrany " -! - -testStorIntoVariable - |iRMethod aCompiledMethod| - - iRMethod := (IRBuilder new) - numRargs:1; - addTemps:#( #self ); - pushLiteral:4; - storeIntoLiteralVariable:(IRBuilderTest bindingOf:#TestToPush); - returnTop; - ir. - aCompiledMethod := iRMethod compiledCode. - self assert:(aCompiledMethod isKindOf:CompiledMethod). - aCompiledMethod valueWithReceiver:nil arguments:#(). - self assert:(IRBuilderTest testToPush = 4). - IRBuilderTest testToPush:nil. -! - -testStoreTemp - |iRMethod aCompiledMethod| - - iRMethod := (IRBuilder new) - numRargs:1; - addTemps:#( #self #a ); - pushLiteral:34; - storeTemp:#a; - pushTemp:#a; - returnTop; - ir. - aCompiledMethod := iRMethod compiledCode. - self assert:(aCompiledMethod isKindOf:CompiledMethod). - self assert:((aCompiledMethod valueWithReceiver:nil arguments:#()) = 34). - - "Modified: / 11-06-2008 / 16:24:43 / Jan Vrany " -! - -testStoreThisEnv - |iRMethod aCompiledMethod| - - ^ self. - iRMethod := (IRBuilder new) - numRargs:1; - addTemps:#( #self #a ); - pushLiteral:ClosureEnvironment; - pushLiteral:1; - send:#new:; - storeThisEnv; - pushThisContext; - pushLiteral:5; - send:#privGetInstVar:; - returnTop; - ir. - aCompiledMethod := iRMethod compiledCode. - self assert:(aCompiledMethod isKindOf:CompiledMethod). - self assert:((aCompiledMethod valueWithReceiver:nil arguments:#()) - isKindOf:ClosureEnvironment). - - "Modified: / 11-06-2008 / 14:47:51 / Jan Vrany " -! - -testTwoJumpAheadToIfsToSameTarget - |iRMethod aCompiledMethod| - - iRMethod := (IRBuilder new) - numRargs:1; - addTemps:#( #self ); - pushTemp:#self; - pushLiteral:false; - jumpAheadTo:#end if:true; - pushLiteral:true; - jumpAheadTo:#end if:true; - pushLiteral:3; - jumpAheadTarget:#end; - returnTop; - ir. - aCompiledMethod := iRMethod compiledCode. - self assert:(aCompiledMethod isKindOf:CompiledMethod). - self assert:((aCompiledMethod valueWithReceiver:nil arguments:#()) = nil). - - "Created: / 03-11-2008 / 13:34:50 / Jan Vrany " -! ! - -!IRBuilderTest methodsFor:'testing - blocks'! - -testBlock_blockNesting_1 - |aCompiledMethod irBuilder| - - irBuilder := (IRBuilder new) - numRargs:1; - addTemps:#( #self ); - pushBlockUsingBuilder:[:builder | - builder - numRargs:1; - addTemps:#( #barg1 ); - pushBlockUsingBuilder:[:builder| - builder - numRargs: 1; - addTemps: #( #barg2 ); - pushTemp: #barg2; - returnTop - ]; - pushTemp: #barg1; - send: #value:; - returnTop - ]; - pushLiteral: 22; - send:#value; - returnTop; - ir. - " - irBuilder ir - " - - aCompiledMethod := irBuilder compiledCode. - self assert:(aCompiledMethod isKindOf:CompiledMethod). - self assert:((aCompiledMethod valueWithReceiver:1 arguments:#()) = 22). - - "Created: / 11-05-2009 / 23:04:13 / Jan Vrany " -! - -testBlock_blockTempArg - |aCompiledMethod irBuilder| - - irBuilder := (IRBuilder new) - numRargs:1; - addTemps:#( #self ); - pushBlockUsingBuilder:[:builder | - builder - numRargs:1; - addTemps:#( #barg1 ); - pushTemp:#barg1; - returnTop - ]; - pushLiteral:22; - send:#value:; - returnTop; - ir. - " - irBuilder ir - " - - aCompiledMethod := irBuilder compiledCode. - self assert:(aCompiledMethod isKindOf:CompiledMethod). - self assert:((aCompiledMethod valueWithReceiver:1 arguments:#()) = 22). - - "Created: / 30-03-2009 / 14:26:18 / Jan Vrany " - "Modified: / 30-03-2009 / 19:16:25 / Jan Vrany " -! - -testBlock_blockTempVar - |aCompiledMethod irBuilder| - - irBuilder := (IRBuilder new) - numRargs:1; - addTemps:#( #self ); - pushBlockUsingBuilder:[:builder | - builder - numRargs:0; - addTemps:#( #bvar1 ); - pushLiteral: 22; - storeTemp:#bvar1; - pushTemp: #bvar1; - returnTop - ]; - send:#value; - returnTop; - ir. - " - irBuilder ir - " - - aCompiledMethod := irBuilder compiledCode. - self assert:(aCompiledMethod isKindOf:CompiledMethod). - self assert:((aCompiledMethod valueWithReceiver:1 arguments:#()) = 22). - - "Created: / 30-03-2009 / 23:03:48 / Jan Vrany " -! - -testBlock_block_in_another_basic_block - |aCompiledMethod irBuilder| - - irBuilder := (IRBuilder new) - numRargs:1; - addTemps:#( #self ); - pushLiteral: false; - pushLiteral: true; - jumpAheadTo: #end if: false; - pushBlockUsingBuilder:[:builder | - builder - numRargs: 0; - pushLiteral: true; - returnTop - ]; - send: #value; - jumpAheadTarget: #end; - returnTop; - ir. - " - irBuilder ir - " - - aCompiledMethod := irBuilder compiledCode. - self assert:(aCompiledMethod isKindOf:CompiledMethod). - self assert:((aCompiledMethod valueWithReceiver:1 arguments:#()) = true). - - "Created: / 13-05-2009 / 11:24:48 / Jan Vrany " -! - -testBlock_exceptionHandler - |aCompiledMethod irBuilder| - - irBuilder := (IRBuilder new) - numRargs:1; - addTemps:#( #self); - pushBlockUsingBuilder:[:builder | - builder - numRargs:0; - pushLiteral: 1; - pushLiteral: 0; - send: #/; - pushLiteral: false; - remoteReturn - ]; - pushLiteralVariable: #Error; - pushBlockUsingBuilder:[:builder| - builder - numRargs:0; - pushLiteral: true; - remoteReturn]; - send: #on:do:; - pushLiteral: false; - returnTop; - ir. - " - irBuilder ir - " - - aCompiledMethod := irBuilder compiledCode. - self assert:(aCompiledMethod isKindOf:CompiledMethod). - self assert:((aCompiledMethod valueWithReceiver:1 arguments:#()) = true). - - "Created: / 11-05-2009 / 21:53:19 / Jan Vrany " -! - -testBlock_exceptionHandler_noRemoteReturn - |aCompiledMethod irBuilder| - - irBuilder := (IRBuilder new) - numRargs:1; - addTemps:#( #self); - pushBlockUsingBuilder:[:builder | - builder - numRargs:0; - pushLiteral: 1; - pushLiteral: 0; - send: #/; - pushLiteral: false; - returnTop - ]; - pushLiteralVariable: #Error; - pushBlockUsingBuilder:[:builder| - builder - numRargs:0; - pushLiteral: true; - returnTop]; - send: #on:do:; - returnTop; - ir. - " - irBuilder ir - " - - aCompiledMethod := irBuilder compiledCode. - self assert:(aCompiledMethod isKindOf:CompiledMethod). - self assert:((aCompiledMethod valueWithReceiver:1 arguments:#()) = true). - - "Created: / 11-05-2009 / 21:53:25 / Jan Vrany " -! - -testBlock_invalid_instruction_ordering_bug_1 - |aCompiledMethod irBuilder| - - irBuilder := (IRBuilder new) - numRargs: 1; - addTemps: #(self i); - pushTemp: #i; - pushLiteral: 3; - pushReceiver; - - pushBlockUsingBuilder: [ :builder | - builder - numRargs: 0; - addTemps: #(); - pushTemp: #i; - returnTop. - ]; - returnTop; - ir. - " - irBuilder ir - " - - aCompiledMethod := irBuilder compiledCode. - self assert:(aCompiledMethod isKindOf:CompiledMethod). - self assert:((aCompiledMethod valueWithReceiver:1 arguments:#()) isKindOf: Block). - - "Created: / 11-05-2009 / 21:55:30 / Jan Vrany " -! - -testBlock_methodTempVar - |aCompiledMethod irBuilder| - - irBuilder := (IRBuilder new) - numRargs:1; - addTemps:#( #self #a); - pushLiteral: 22; - storeTemp: #a; - pushBlockUsingBuilder:[:builder | - builder - numRargs:0; - pushTemp: #a; - returnTop - ]; - send:#value; - returnTop; - ir. - " - irBuilder ir - " - - aCompiledMethod := irBuilder compiledCode. - self assert:(aCompiledMethod isKindOf:CompiledMethod). - self assert:((aCompiledMethod valueWithReceiver:1 arguments:#()) = 22). - - "Created: / 30-03-2009 / 23:05:00 / Jan Vrany " - "Modified: / 01-04-2009 / 19:43:52 / Jan Vrany " -! ! - -!IRBuilderTest class methodsFor:'documentation'! - -version_CVS - ^ 'Header: /cvs/stx/cvut/stx/goodies/newcompiler/IRBuilderTest.st,v 1.3 2009/10/08 12:03:51 fm Exp ' -! - -version_SVN - ^ '$Id:: $' -! ! -