Tests moved to separate subpackage to follow St/X conventions.
--- 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 <vranyj1@fel.cvut.cz>"
-!
-
-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 <vranyj1@fel.cvut.cz>"
- "Modified: / 28-03-2009 / 20:16:08 / Jan Vrany <vranyj1@fel.cvut.cz>"
-!
-
-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 <vranyj1@fel.cvut.cz>"
-!
-
-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 <vranyj1@fel.cvut.cz>"
-!
-
-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 <vranyj1@fel.cvut.cz>"
-!
-
-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 <vranyj1@fel.cvut.cz>"
-!
-
-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 <vranyj1@fel.cvut.cz>"
-!
-
-mock8
-
- ^([:arg| arg ] value: 22)
-
- "Created: / 30-03-2009 / 19:21:48 / Jan Vrany <vranyj1@fel.cvut.cz>"
-!
-
-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 <vranyj1@fel.cvut.cz>"
-! !
-
-!IRBuilderTest methodsFor:'testing'!
-
-halt
- "Redefinition for testing the #send:toSuperOf:"
-
- "Created: / 11-06-2008 / 16:08:52 / Jan Vrany <vranyj1@fel.cvut.cz>"
-!
-
-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 <vranyj1@fel.cvut.cz>"
-!
-
-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 <vranyj1@fel.cvut.cz>"
-!
-
-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 <vranyj1@fel.cvut.cz>"
-!
-
-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 <vranyj1@fel.cvut.cz>"
-!
-
-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 <vranyj1@fel.cvut.cz>"
-!
-
-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 <vranyj1@fel.cvut.cz>"
-!
-
-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 <vranyj1@fel.cvut.cz>"
-!
-
-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 <vranyj1@fel.cvut.cz>"
-!
-
-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 <vranyj1@fel.cvut.cz>"
-!
-
-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 <vranyj1@fel.cvut.cz>"
-!
-
-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 <vranyj1@fel.cvut.cz>"
-!
-
-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 <vranyj1@fel.cvut.cz>"
-!
-
-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 <vranyj1@fel.cvut.cz>"
-! !
-
-!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 <vranyj1@fel.cvut.cz>"
-!
-
-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 <vranyj1@fel.cvut.cz>"
- "Modified: / 30-03-2009 / 19:16:25 / Jan Vrany <vranyj1@fel.cvut.cz>"
-!
-
-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 <vranyj1@fel.cvut.cz>"
-!
-
-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 <vranyj1@fel.cvut.cz>"
-!
-
-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 <vranyj1@fel.cvut.cz>"
-!
-
-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 <vranyj1@fel.cvut.cz>"
-!
-
-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 <vranyj1@fel.cvut.cz>"
-!
-
-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 <vranyj1@fel.cvut.cz>"
- "Modified: / 01-04-2009 / 19:43:52 / Jan Vrany <vranyj1@fel.cvut.cz>"
-! !
-
-!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:: $'
-! !
-
--- a/IRTransformTest.st Thu Oct 30 22:23:12 2014 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,172 +0,0 @@
-"{ Package: 'ctu:ircompiler' }"
-
-TestCase subclass:#IRTransformTest
- instanceVariableNames:''
- classVariableNames:''
- poolDictionaries:''
- category:'IR Compiler-Tests'
-!
-
-
-!IRTransformTest methodsFor:'testing'!
-
-testAdd
- |iRMethod aCompiledMethod|
-
- iRMethod := (IRBuilder new)
- numRargs:1;
- addTemps:#( #self );
- pushLiteral:1;
- returnTop;
- ir.
- (iRMethod allSequences last) last delete.
- (iRMethod allSequences last) last delete.
- (iRMethod allSequences last) add:(IRInstruction pushLiteral:2).
- (iRMethod allSequences last) add:(IRInstruction returnTop).
- aCompiledMethod := iRMethod compiledCode.
- self should:[ (aCompiledMethod valueWithReceiver:nil arguments:#()) = 2 ].
-!
-
-testAddBefore
- |iRMethod aCompiledMethod ret|
-
- iRMethod := (IRBuilder new)
- numRargs:1;
- addTemps:#( #self );
- pushLiteral:1;
- returnTop;
- ir.
- (iRMethod allSequences last) last delete.
- (iRMethod allSequences last) last delete.
- ret := (IRInstruction returnTop).
- (iRMethod allSequences last) add:ret.
- (iRMethod allSequences last) add:(IRInstruction pushLiteral:2) before:ret.
- aCompiledMethod := iRMethod compiledCode.
- self should:[ (aCompiledMethod valueWithReceiver:nil arguments:#()) = 2 ].
-!
-
-testAddIntructions
-
- | iRMethod aCompiledMethod |
-
- iRMethod := IRBuilder new
- numRargs: 1;
- addTemps: #(self); "receiver and args declarations"
- pushLiteral: 1;
- returnTop;
- ir.
-
- (iRMethod allSequences last) last delete.
- (iRMethod allSequences last) last delete.
-
- (iRMethod allSequences last)
- addInstructions: {(IRInstruction pushLiteral: 2). (IRInstruction returnTop)}.
-
- aCompiledMethod := iRMethod compiledCode.
- self should: [(aCompiledMethod valueWithReceiver: nil arguments: #() ) = 2].
-
- "Modified: / 30-03-2009 / 19:40:10 / Jan Vrany <vranyj1@fel.cvut.cz>"
-!
-
-testAddIntructionsBefore
-
- | iRMethod aCompiledMethod push |
-
- iRMethod := IRBuilder new
- numRargs: 1;
- addTemps: #(self); "receiver and args declarations"
- pushLiteral: 1;
- returnTop;
- ir.
-
- push := (iRMethod allSequences last) at: (iRMethod allSequences size - 1) .
-
- (iRMethod allSequences last)
- addInstructions: {(IRInstruction pushLiteral: 2). (IRInstruction returnTop)} before: push.
-
- aCompiledMethod := iRMethod compiledCode.
- self should: [(aCompiledMethod valueWithReceiver: nil arguments: #() ) = 2].
-
- "Modified: / 30-03-2009 / 19:40:21 / Jan Vrany <vranyj1@fel.cvut.cz>"
-!
-
-testAddIntructionsBeforeFromLList
- |iRMethod aCompiledMethod push llist col|
-
- iRMethod := (IRBuilder new)
- numRargs:1;
- addTemps:#( #self );
- pushLiteral:1;
- returnTop;
- ir.
- push := (iRMethod allSequences last) at:(iRMethod allSequences size - 1).
- llist := LinkedList new.
- llist add:(IRInstruction pushLiteral:2).
- llist add:(IRInstruction returnTop).
- col := llist asOrderedCollection.
- (iRMethod allSequences last) addInstructions:col before:push.
- aCompiledMethod := iRMethod compiledCode.
- self should:[ (aCompiledMethod valueWithReceiver:nil arguments:#()) = 2 ].
-!
-
-testDelete
- |iRMethod aCompiledMethod|
-
- iRMethod := (IRBuilder new)
- numRargs:1;
- addTemps:#( #self );
- pushLiteral:1;
- pushLiteral:2;
- returnTop;
- ir.
- ((iRMethod allSequences last)
- detect:[:each | each isConstant:[:c | c == 2 ] ]) delete.
- aCompiledMethod := iRMethod compiledCode.
- self should:[ (aCompiledMethod valueWithReceiver:nil arguments:#()) = 1 ].
-!
-
-testReplace
- |iRMethod aCompiledMethod|
-
- iRMethod := (IRBuilder new)
- numRargs:1;
- addTemps:#( #self );
- pushLiteral:1;
- returnTop;
- ir.
- (iRMethod allSequences last at:1)
- replaceWith:(IRInstruction pushLiteral:2).
- aCompiledMethod := iRMethod compiledCode.
- self should:[ (aCompiledMethod valueWithReceiver:nil arguments:#()) = 2 ].
-!
-
-testReplaceInstr
-
- | iRMethod aCompiledMethod |
-
- iRMethod := IRBuilder new
- numRargs: 1;
- addTemps: #(self); "receiver and args declarations"
- pushLiteral: 1;
- returnTop;
- ir.
-
- (iRMethod allSequences last at: 1)
- replaceWithInstructions: {(IRInstruction pushLiteral: 2)}.
-
- aCompiledMethod := iRMethod compiledCode.
- self should: [(aCompiledMethod valueWithReceiver: nil arguments: #() ) = 2].
-
- "Modified: / 30-03-2009 / 19:40:30 / Jan Vrany <vranyj1@fel.cvut.cz>"
-! !
-
-!IRTransformTest class methodsFor:'documentation'!
-
-version_CVS
- ^ 'Header: /cvs/stx/cvut/stx/goodies/newcompiler/IRTransformTest.st,v 1.3 2009/10/08 11:56:52 fm Exp '
-!
-
-version_SVN
- ^ '$Id:: $'
-! !
-
--- a/Make.proto Thu Oct 30 22:23:12 2014 +0000
+++ b/Make.proto Thu Oct 30 22:27:09 2014 +0000
@@ -34,7 +34,7 @@
# add the path(es) here:,
# ********** OPTIONAL: MODIFY the next lines ***
# LOCALINCLUDES=-Ifoo -Ibar
-LOCALINCLUDES= -I$(INCLUDE_TOP)/stx/goodies/refactoryBrowser/parser -I$(INCLUDE_TOP)/stx/goodies/sunit -I$(INCLUDE_TOP)/stx/libbasic -I$(INCLUDE_TOP)/stx/libcomp -I$(INCLUDE_TOP)/stx/libcompat -I$(INCLUDE_TOP)/stx/libtool -I$(INCLUDE_TOP)/stx/libwidg
+LOCALINCLUDES= -I$(INCLUDE_TOP)/stx/goodies/refactoryBrowser/parser -I$(INCLUDE_TOP)/stx/libbasic -I$(INCLUDE_TOP)/stx/libcomp -I$(INCLUDE_TOP)/stx/libcompat -I$(INCLUDE_TOP)/stx/libtool -I$(INCLUDE_TOP)/stx/libwidg
# if you need any additional defines for embedded C code,
@@ -124,12 +124,7 @@
# build all mandatory prerequisite packages (containing superclasses) for this package
prereq:
cd $(TOP)/libbasic && $(MAKE) "CFLAGS_LOCAL=$(GLOBALDEFINES)"
- cd $(TOP)/libbasic2 && $(MAKE) "CFLAGS_LOCAL=$(GLOBALDEFINES)"
- cd $(TOP)/libbasic3 && $(MAKE) "CFLAGS_LOCAL=$(GLOBALDEFINES)"
cd $(TOP)/libcomp && $(MAKE) "CFLAGS_LOCAL=$(GLOBALDEFINES)"
- cd $(TOP)/libview && $(MAKE) "CFLAGS_LOCAL=$(GLOBALDEFINES)"
- cd $(TOP)/libview2 && $(MAKE) "CFLAGS_LOCAL=$(GLOBALDEFINES)"
- cd $(TOP)/goodies/sunit && $(MAKE) "CFLAGS_LOCAL=$(GLOBALDEFINES)"
--- a/abbrev.stc Thu Oct 30 22:23:12 2014 +0000
+++ b/abbrev.stc Thu Oct 30 22:27:09 2014 +0000
@@ -2,14 +2,12 @@
# this file is needed for stc to be able to compile modules independently.
# it provides information about a classes filename, category and especially namespace.
IRBuilder IRBuilder ctu:ircompiler 'IR Compiler-IR' 0
-IRBuilderTest IRBuilderTest ctu:ircompiler 'IR Compiler-Tests' 1
IRBytecodeGenerator IRBytecodeGenerator ctu:ircompiler 'IR Compiler-Bytecode' 0
IRFunction IRFunction ctu:ircompiler 'IR Compiler-IR' 0
IRInstruction IRInstruction ctu:ircompiler 'IR Compiler-IR' 0
IRInterpreter IRInterpreter ctu:ircompiler 'IR Compiler-IR' 0
IRSequence IRSequence ctu:ircompiler 'IR Compiler-IR' 0
IRStackCount IRStackCount ctu:ircompiler 'IR Compiler-Bytecode' 0
-IRTransformTest IRTransformTest ctu:ircompiler 'IR Compiler-Tests' 1
ctu_ircompiler ctu_ircompiler ctu:ircompiler '* Projects & Packages *' 3
IRAccess IRAccess ctu:ircompiler 'IR Compiler-IR' 0
IRClosure IRClosure ctu:ircompiler 'IR Compiler-IR' 0
--- a/bc.mak Thu Oct 30 22:23:12 2014 +0000
+++ b/bc.mak Thu Oct 30 22:27:09 2014 +0000
@@ -34,7 +34,7 @@
-LOCALINCLUDES= -I$(INCLUDE_TOP)\stx\goodies\refactoryBrowser\parser -I$(INCLUDE_TOP)\stx\goodies\sunit -I$(INCLUDE_TOP)\stx\libbasic -I$(INCLUDE_TOP)\stx\libcomp -I$(INCLUDE_TOP)\stx\libcompat -I$(INCLUDE_TOP)\stx\libtool -I$(INCLUDE_TOP)\stx\libwidg
+LOCALINCLUDES= -I$(INCLUDE_TOP)\stx\goodies\refactoryBrowser\parser -I$(INCLUDE_TOP)\stx\libbasic -I$(INCLUDE_TOP)\stx\libcomp -I$(INCLUDE_TOP)\stx\libcompat -I$(INCLUDE_TOP)\stx\libtool -I$(INCLUDE_TOP)\stx\libwidg
LOCALDEFINES=
STCLOCALOPT=-package=$(PACKAGE) -I. $(LOCALINCLUDES) -headerDir=. $(STCLOCALOPTIMIZATIONS) $(STCWARNINGS) $(LOCALDEFINES) -varPrefix=$(LIBNAME)
@@ -51,12 +51,7 @@
# build all mandatory prerequisite packages (containing superclasses) for this package
prereq:
pushd ..\..\stx\libbasic & $(MAKE_BAT) "CFLAGS_LOCAL=$(GLOBALDEFINES) "
- pushd ..\..\stx\libbasic2 & $(MAKE_BAT) "CFLAGS_LOCAL=$(GLOBALDEFINES) "
- pushd ..\..\stx\libbasic3 & $(MAKE_BAT) "CFLAGS_LOCAL=$(GLOBALDEFINES) "
pushd ..\..\stx\libcomp & $(MAKE_BAT) "CFLAGS_LOCAL=$(GLOBALDEFINES) "
- pushd ..\..\stx\libview & $(MAKE_BAT) "CFLAGS_LOCAL=$(GLOBALDEFINES) "
- pushd ..\..\stx\libview2 & $(MAKE_BAT) "CFLAGS_LOCAL=$(GLOBALDEFINES) "
- pushd ..\..\stx\goodies\sunit & $(MAKE_BAT) "CFLAGS_LOCAL=$(GLOBALDEFINES) "
--- a/ctu_ircompiler.st Thu Oct 30 22:23:12 2014 +0000
+++ b/ctu_ircompiler.st Thu Oct 30 22:27:09 2014 +0000
@@ -33,7 +33,6 @@
by searching along the inheritance chain of all of my classes."
^ #(
- #'stx:goodies/sunit' "TestAsserter - superclass of IRBuilderTest"
#'stx:libbasic' "Behavior - extended"
#'stx:libcomp' "ByteCodeCompiler - extended"
)
@@ -75,14 +74,12 @@
^ #(
"<className> or (<className> attributes...) in load order"
IRBuilder
- (IRBuilderTest autoload)
IRBytecodeGenerator
IRFunction
IRInstruction
IRInterpreter
IRSequence
IRStackCount
- (IRTransformTest autoload)
#'ctu_ircompiler'
IRAccess
IRClosure
--- a/ircompiler.rc Thu Oct 30 22:23:12 2014 +0000
+++ b/ircompiler.rc Thu Oct 30 22:27:09 2014 +0000
@@ -25,7 +25,7 @@
VALUE "LegalCopyright", "Copyright Jan Vrany & Mathieu Suen 2008\0"
VALUE "ProductName", "NewCompiler\0"
VALUE "ProductVersion", "6.2.4.0\0"
- VALUE "ProductDate", "Thu, 30 Oct 2014 22:22:54 GMT\0"
+ VALUE "ProductDate", "Thu, 30 Oct 2014 22:24:49 GMT\0"
END
END
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/IRBuilderTest.st Thu Oct 30 22:27:09 2014 +0000
@@ -0,0 +1,1031 @@
+"{ Package: 'ctu:ircompiler/tests' }"
+
+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 <vranyj1@fel.cvut.cz>"
+!
+
+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 <vranyj1@fel.cvut.cz>"
+ "Modified: / 28-03-2009 / 20:16:08 / Jan Vrany <vranyj1@fel.cvut.cz>"
+!
+
+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 <vranyj1@fel.cvut.cz>"
+!
+
+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 <vranyj1@fel.cvut.cz>"
+!
+
+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 <vranyj1@fel.cvut.cz>"
+!
+
+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 <vranyj1@fel.cvut.cz>"
+!
+
+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 <vranyj1@fel.cvut.cz>"
+!
+
+mock8
+
+ ^([:arg| arg ] value: 22)
+
+ "Created: / 30-03-2009 / 19:21:48 / Jan Vrany <vranyj1@fel.cvut.cz>"
+!
+
+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 <vranyj1@fel.cvut.cz>"
+! !
+
+!IRBuilderTest methodsFor:'testing'!
+
+halt
+ "Redefinition for testing the #send:toSuperOf:"
+
+ "Created: / 11-06-2008 / 16:08:52 / Jan Vrany <vranyj1@fel.cvut.cz>"
+!
+
+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 <vranyj1@fel.cvut.cz>"
+!
+
+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 <vranyj1@fel.cvut.cz>"
+!
+
+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 <vranyj1@fel.cvut.cz>"
+!
+
+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 <vranyj1@fel.cvut.cz>"
+!
+
+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 <vranyj1@fel.cvut.cz>"
+!
+
+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 <vranyj1@fel.cvut.cz>"
+!
+
+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 <vranyj1@fel.cvut.cz>"
+!
+
+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 <vranyj1@fel.cvut.cz>"
+!
+
+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 <vranyj1@fel.cvut.cz>"
+!
+
+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 <vranyj1@fel.cvut.cz>"
+!
+
+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 <vranyj1@fel.cvut.cz>"
+!
+
+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 <vranyj1@fel.cvut.cz>"
+!
+
+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 <vranyj1@fel.cvut.cz>"
+! !
+
+!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 <vranyj1@fel.cvut.cz>"
+!
+
+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 <vranyj1@fel.cvut.cz>"
+ "Modified: / 30-03-2009 / 19:16:25 / Jan Vrany <vranyj1@fel.cvut.cz>"
+!
+
+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 <vranyj1@fel.cvut.cz>"
+!
+
+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 <vranyj1@fel.cvut.cz>"
+!
+
+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 <vranyj1@fel.cvut.cz>"
+!
+
+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 <vranyj1@fel.cvut.cz>"
+!
+
+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 <vranyj1@fel.cvut.cz>"
+!
+
+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 <vranyj1@fel.cvut.cz>"
+ "Modified: / 01-04-2009 / 19:43:52 / Jan Vrany <vranyj1@fel.cvut.cz>"
+! !
+
+!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:: $'
+! !
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/IRTransformTest.st Thu Oct 30 22:27:09 2014 +0000
@@ -0,0 +1,172 @@
+"{ Package: 'ctu:ircompiler/tests' }"
+
+TestCase subclass:#IRTransformTest
+ instanceVariableNames:''
+ classVariableNames:''
+ poolDictionaries:''
+ category:'IR Compiler-Tests'
+!
+
+
+!IRTransformTest methodsFor:'testing'!
+
+testAdd
+ |iRMethod aCompiledMethod|
+
+ iRMethod := (IRBuilder new)
+ numRargs:1;
+ addTemps:#( #self );
+ pushLiteral:1;
+ returnTop;
+ ir.
+ (iRMethod allSequences last) last delete.
+ (iRMethod allSequences last) last delete.
+ (iRMethod allSequences last) add:(IRInstruction pushLiteral:2).
+ (iRMethod allSequences last) add:(IRInstruction returnTop).
+ aCompiledMethod := iRMethod compiledCode.
+ self should:[ (aCompiledMethod valueWithReceiver:nil arguments:#()) = 2 ].
+!
+
+testAddBefore
+ |iRMethod aCompiledMethod ret|
+
+ iRMethod := (IRBuilder new)
+ numRargs:1;
+ addTemps:#( #self );
+ pushLiteral:1;
+ returnTop;
+ ir.
+ (iRMethod allSequences last) last delete.
+ (iRMethod allSequences last) last delete.
+ ret := (IRInstruction returnTop).
+ (iRMethod allSequences last) add:ret.
+ (iRMethod allSequences last) add:(IRInstruction pushLiteral:2) before:ret.
+ aCompiledMethod := iRMethod compiledCode.
+ self should:[ (aCompiledMethod valueWithReceiver:nil arguments:#()) = 2 ].
+!
+
+testAddIntructions
+
+ | iRMethod aCompiledMethod |
+
+ iRMethod := IRBuilder new
+ numRargs: 1;
+ addTemps: #(self); "receiver and args declarations"
+ pushLiteral: 1;
+ returnTop;
+ ir.
+
+ (iRMethod allSequences last) last delete.
+ (iRMethod allSequences last) last delete.
+
+ (iRMethod allSequences last)
+ addInstructions: {(IRInstruction pushLiteral: 2). (IRInstruction returnTop)}.
+
+ aCompiledMethod := iRMethod compiledCode.
+ self should: [(aCompiledMethod valueWithReceiver: nil arguments: #() ) = 2].
+
+ "Modified: / 30-03-2009 / 19:40:10 / Jan Vrany <vranyj1@fel.cvut.cz>"
+!
+
+testAddIntructionsBefore
+
+ | iRMethod aCompiledMethod push |
+
+ iRMethod := IRBuilder new
+ numRargs: 1;
+ addTemps: #(self); "receiver and args declarations"
+ pushLiteral: 1;
+ returnTop;
+ ir.
+
+ push := (iRMethod allSequences last) at: (iRMethod allSequences size - 1) .
+
+ (iRMethod allSequences last)
+ addInstructions: {(IRInstruction pushLiteral: 2). (IRInstruction returnTop)} before: push.
+
+ aCompiledMethod := iRMethod compiledCode.
+ self should: [(aCompiledMethod valueWithReceiver: nil arguments: #() ) = 2].
+
+ "Modified: / 30-03-2009 / 19:40:21 / Jan Vrany <vranyj1@fel.cvut.cz>"
+!
+
+testAddIntructionsBeforeFromLList
+ |iRMethod aCompiledMethod push llist col|
+
+ iRMethod := (IRBuilder new)
+ numRargs:1;
+ addTemps:#( #self );
+ pushLiteral:1;
+ returnTop;
+ ir.
+ push := (iRMethod allSequences last) at:(iRMethod allSequences size - 1).
+ llist := LinkedList new.
+ llist add:(IRInstruction pushLiteral:2).
+ llist add:(IRInstruction returnTop).
+ col := llist asOrderedCollection.
+ (iRMethod allSequences last) addInstructions:col before:push.
+ aCompiledMethod := iRMethod compiledCode.
+ self should:[ (aCompiledMethod valueWithReceiver:nil arguments:#()) = 2 ].
+!
+
+testDelete
+ |iRMethod aCompiledMethod|
+
+ iRMethod := (IRBuilder new)
+ numRargs:1;
+ addTemps:#( #self );
+ pushLiteral:1;
+ pushLiteral:2;
+ returnTop;
+ ir.
+ ((iRMethod allSequences last)
+ detect:[:each | each isConstant:[:c | c == 2 ] ]) delete.
+ aCompiledMethod := iRMethod compiledCode.
+ self should:[ (aCompiledMethod valueWithReceiver:nil arguments:#()) = 1 ].
+!
+
+testReplace
+ |iRMethod aCompiledMethod|
+
+ iRMethod := (IRBuilder new)
+ numRargs:1;
+ addTemps:#( #self );
+ pushLiteral:1;
+ returnTop;
+ ir.
+ (iRMethod allSequences last at:1)
+ replaceWith:(IRInstruction pushLiteral:2).
+ aCompiledMethod := iRMethod compiledCode.
+ self should:[ (aCompiledMethod valueWithReceiver:nil arguments:#()) = 2 ].
+!
+
+testReplaceInstr
+
+ | iRMethod aCompiledMethod |
+
+ iRMethod := IRBuilder new
+ numRargs: 1;
+ addTemps: #(self); "receiver and args declarations"
+ pushLiteral: 1;
+ returnTop;
+ ir.
+
+ (iRMethod allSequences last at: 1)
+ replaceWithInstructions: {(IRInstruction pushLiteral: 2)}.
+
+ aCompiledMethod := iRMethod compiledCode.
+ self should: [(aCompiledMethod valueWithReceiver: nil arguments: #() ) = 2].
+
+ "Modified: / 30-03-2009 / 19:40:30 / Jan Vrany <vranyj1@fel.cvut.cz>"
+! !
+
+!IRTransformTest class methodsFor:'documentation'!
+
+version_CVS
+ ^ 'Header: /cvs/stx/cvut/stx/goodies/newcompiler/IRTransformTest.st,v 1.3 2009/10/08 11:56:52 fm Exp '
+!
+
+version_SVN
+ ^ '$Id:: $'
+! !
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/Make.proto Thu Oct 30 22:27:09 2014 +0000
@@ -0,0 +1,134 @@
+# $Header$
+#
+# DO NOT EDIT
+# automagically generated from the projectDefinition: ctu_ircompiler_tests.
+#
+# Warning: once you modify this file, do not rerun
+# stmkmp or projectDefinition-build again - otherwise, your changes are lost.
+#
+# The Makefile as generated by this Make.proto supports the following targets:
+# make - compile all st-files to a classLib
+# make clean - clean all temp files
+# make clobber - clean all
+#
+# This file contains definitions for Unix based platforms.
+# It shares common definitions with the win32-make in Make.spec.
+
+#
+# position (of this package) in directory hierarchy:
+# (must point to ST/X top directory, for tools and includes)
+TOP=../../../stx
+INCLUDE_TOP=$(TOP)/..
+
+# subdirectories where targets are to be made:
+SUBDIRS=
+
+
+# subdirectories where Makefiles are to be made:
+# (only define if different from SUBDIRS)
+# ALLSUBDIRS=
+
+REQUIRED_SUPPORT_DIRS=
+
+# if your embedded C code requires any system includes,
+# add the path(es) here:,
+# ********** OPTIONAL: MODIFY the next lines ***
+# LOCALINCLUDES=-Ifoo -Ibar
+LOCALINCLUDES= -I$(INCLUDE_TOP)/ctu/ircompiler -I$(INCLUDE_TOP)/stx/goodies/sunit -I$(INCLUDE_TOP)/stx/libbasic
+
+
+# if you need any additional defines for embedded C code,
+# add them here:,
+# ********** OPTIONAL: MODIFY the next lines ***
+# LOCALDEFINES=-Dfoo -Dbar -DDEBUG
+LOCALDEFINES=
+
+LIBNAME=libctu_ircompiler_tests
+STCLOCALOPT='-package=$(PACKAGE)' -I. $(LOCALINCLUDES) $(STCLOCALOPTIMIZATIONS) $(STCWARNINGS) $(LOCALDEFINES) -headerDir=. -varPrefix=$(LIBNAME)
+
+
+# ********** OPTIONAL: MODIFY the next line ***
+# additional C-libraries that should be pre-linked with the class-objects
+LD_OBJ_LIBS=
+LOCAL_SHARED_LIBS=
+
+
+# ********** OPTIONAL: MODIFY the next line ***
+# additional C targets or libraries should be added below
+LOCAL_EXTRA_TARGETS=
+
+OBJS= $(COMMON_OBJS) $(UNIX_OBJS)
+
+
+
+all:: preMake classLibRule postMake
+
+pre_objs::
+
+
+
+
+
+
+# Enforce recompilation of package definition class if Mercurial working
+# copy state changes. Together with --guessVersion it ensures that package
+# definition class always contains correct binary revision string.
+ifneq (**NOHG**, $(shell hg root 2> /dev/null || echo -n '**NOHG**'))
+ctu_ircompiler_tests.$(O): $(shell hg root)/.hg/dirstate
+endif
+
+
+
+
+# run default testsuite for this package
+test: $(TOP)/goodies/builder/reports
+ $(MAKE) -C $(TOP)/goodies/builder/reports -f Makefile.init
+ $(TOP)/goodies/builder/reports/report-runner.sh -D . -r Builder::TestReport -p $(PACKAGE)
+
+
+
+# add more install actions here
+install::
+
+# add more install actions for aux-files (resources) here
+installAux::
+
+# add more preMake actions here
+preMake::
+
+# add more postMake actions here
+postMake:: cleanjunk
+
+# build all mandatory prerequisite packages (containing superclasses) for this package
+prereq:
+ cd $(TOP)/libbasic && $(MAKE) "CFLAGS_LOCAL=$(GLOBALDEFINES)"
+ cd $(TOP)/libbasic2 && $(MAKE) "CFLAGS_LOCAL=$(GLOBALDEFINES)"
+ cd $(TOP)/libbasic3 && $(MAKE) "CFLAGS_LOCAL=$(GLOBALDEFINES)"
+ cd $(TOP)/libview && $(MAKE) "CFLAGS_LOCAL=$(GLOBALDEFINES)"
+ cd $(TOP)/libview2 && $(MAKE) "CFLAGS_LOCAL=$(GLOBALDEFINES)"
+ cd $(TOP)/goodies/sunit && $(MAKE) "CFLAGS_LOCAL=$(GLOBALDEFINES)"
+
+
+
+# build all packages containing referenced classes for this package
+# they are nor needed to compile the package
+references:
+
+
+cleanjunk::
+ -rm -f *.s *.s2
+
+clean::
+ -rm -f *.o *.H
+
+clobber:: clean
+ -rm -f *.so *.dll
+
+
+# BEGINMAKEDEPEND --- do not remove this line; make depend needs it
+$(OUTDIR)IRBuilderTest.$(O) IRBuilderTest.$(H): IRBuilderTest.st $(INCLUDE_TOP)/stx/goodies/sunit/TestAsserter.$(H) $(INCLUDE_TOP)/stx/goodies/sunit/TestCase.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
+$(OUTDIR)IRTransformTest.$(O) IRTransformTest.$(H): IRTransformTest.st $(INCLUDE_TOP)/stx/goodies/sunit/TestAsserter.$(H) $(INCLUDE_TOP)/stx/goodies/sunit/TestCase.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
+$(OUTDIR)ctu_ircompiler_tests.$(O) ctu_ircompiler_tests.$(H): ctu_ircompiler_tests.st $(INCLUDE_TOP)/stx/libbasic/LibraryDefinition.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(INCLUDE_TOP)/stx/libbasic/ProjectDefinition.$(H) $(STCHDR)
+
+# ENDMAKEDEPEND --- do not remove this line
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/Make.spec Thu Oct 30 22:27:09 2014 +0000
@@ -0,0 +1,66 @@
+# $Header$
+#
+# DO NOT EDIT
+# automagically generated from the projectDefinition: ctu_ircompiler_tests.
+#
+# Warning: once you modify this file, do not rerun
+# stmkmp or projectDefinition-build again - otherwise, your changes are lost.
+#
+# This file contains specifications which are common to all platforms.
+#
+
+# Do NOT CHANGE THESE DEFINITIONS
+# (otherwise, ST/X will have a hard time to find out the packages location from its packageID,
+# to find the source code of a class and to find the library for a package)
+MODULE=ctu
+MODULE_DIR=ircompiler/tests
+PACKAGE=$(MODULE):$(MODULE_DIR)
+
+
+# Argument(s) to the stc compiler (stc --usage).
+# -headerDir=. : create header files locally
+# (if removed, they will be created as common
+# -Pxxx : defines the package
+# -Zxxx : a prefix for variables within the classLib
+# -Dxxx : defines passed to to CC for inline C-code
+# -Ixxx : include path passed to CC for inline C-code
+# +optspace : optimized for space
+# +optspace2 : optimized more for space
+# +optspace3 : optimized even more for space
+# +optinline : generate inline code for some ST constructs
+# +inlineNew : additionally inline new
+# +inlineMath : additionally inline some floatPnt math stuff
+#
+# ********** OPTIONAL: MODIFY the next line(s) ***
+# STCLOCALOPTIMIZATIONS=+optinline +inlineNew
+# STCLOCALOPTIMIZATIONS=+optspace3
+STCLOCALOPTIMIZATIONS=+optspace3
+
+
+# Argument(s) to the stc compiler (stc --usage).
+# -warn : no warnings
+# -warnNonStandard : no warnings about ST/X extensions
+# -warnEOLComments : no warnings about EOL comment extension
+# -warnPrivacy : no warnings about privateClass extension
+#
+# ********** OPTIONAL: MODIFY the next line(s) ***
+# STCWARNINGS=-warn
+# STCWARNINGS=-warnNonStandard
+# STCWARNINGS=-warnEOLComments
+STCWARNINGS=-warnNonStandard
+
+COMMON_CLASSES= \
+ IRBuilderTest \
+ IRTransformTest \
+ ctu_ircompiler_tests \
+
+
+
+
+COMMON_OBJS= \
+ $(OUTDIR_SLASH)IRBuilderTest.$(O) \
+ $(OUTDIR_SLASH)IRTransformTest.$(O) \
+ $(OUTDIR_SLASH)ctu_ircompiler_tests.$(O) \
+
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/Makefile.init Thu Oct 30 22:27:09 2014 +0000
@@ -0,0 +1,27 @@
+#
+# DO NOT EDIT
+#
+# make uses this file (Makefile) only, if there is no
+# file named "makefile" (lower-case m) in the same directory.
+# My only task is to generate the real makefile and call make again.
+# Thereafter, I am no longer used and needed.
+#
+# MACOSX caveat:
+# as filenames are not case sensitive (in a default setup),
+# we cannot use the above trick. Therefore, this file is now named
+# "Makefile.init", and you have to execute "make -f Makefile.init" to
+# get the initial makefile. This is now also done by the toplevel CONFIG
+# script.
+
+.PHONY: run
+
+run: makefile
+ $(MAKE) -f makefile
+
+#only needed for the definition of $(TOP)
+include Make.proto
+
+makefile: mf
+
+mf:
+ $(TOP)/rules/stmkmf
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/abbrev.stc Thu Oct 30 22:27:09 2014 +0000
@@ -0,0 +1,6 @@
+# automagically generated by the project definition
+# this file is needed for stc to be able to compile modules independently.
+# it provides information about a classes filename, category and especially namespace.
+IRBuilderTest IRBuilderTest ctu:ircompiler/tests 'IR Compiler-Tests' 1
+IRTransformTest IRTransformTest ctu:ircompiler/tests 'IR Compiler-Tests' 1
+ctu_ircompiler_tests ctu_ircompiler_tests ctu:ircompiler/tests '* Projects & Packages *' 3
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/bc.mak Thu Oct 30 22:27:09 2014 +0000
@@ -0,0 +1,88 @@
+# $Header$
+#
+# DO NOT EDIT
+# automagically generated from the projectDefinition: ctu_ircompiler_tests.
+#
+# Warning: once you modify this file, do not rerun
+# stmkmp or projectDefinition-build again - otherwise, your changes are lost.
+#
+# Notice, that the name bc.mak is historical (from times, when only borland c was supported).
+# This file contains make rules for the win32 platform using either borland-bcc or visual-c.
+# It shares common definitions with the unix-make in Make.spec.
+# The bc.mak supports the following targets:
+# bmake - compile all st-files to a classLib (dll)
+# bmake clean - clean all temp files
+# bmake clobber - clean all
+#
+# Historic Note:
+# this used to contain only rules to make with borland
+# (called via bmake, by "make.exe -f bc.mak")
+# this has changed; it is now also possible to build using microsoft visual c
+# (called via vcmake, by "make.exe -f bc.mak -DUSEVC")
+#
+TOP=..\..\..\stx
+INCLUDE_TOP=$(TOP)\..
+
+
+
+!INCLUDE $(TOP)\rules\stdHeader_bc
+
+!INCLUDE Make.spec
+
+LIBNAME=libctu_ircompiler_tests
+RESFILES=tests.$(RES)
+
+
+
+LOCALINCLUDES= -I$(INCLUDE_TOP)\ctu\ircompiler -I$(INCLUDE_TOP)\stx\goodies\sunit -I$(INCLUDE_TOP)\stx\libbasic
+LOCALDEFINES=
+
+STCLOCALOPT=-package=$(PACKAGE) -I. $(LOCALINCLUDES) -headerDir=. $(STCLOCALOPTIMIZATIONS) $(STCWARNINGS) $(LOCALDEFINES) -varPrefix=$(LIBNAME)
+LOCALLIBS=
+
+OBJS= $(COMMON_OBJS) $(WIN32_OBJS)
+
+ALL:: classLibRule
+
+classLibRule: $(OUTDIR) $(OUTDIR)$(LIBNAME).dll
+
+!INCLUDE $(TOP)\rules\stdRules_bc
+
+# build all mandatory prerequisite packages (containing superclasses) for this package
+prereq:
+ pushd ..\..\..\stx\libbasic & $(MAKE_BAT) "CFLAGS_LOCAL=$(GLOBALDEFINES) "
+ pushd ..\..\..\stx\libbasic2 & $(MAKE_BAT) "CFLAGS_LOCAL=$(GLOBALDEFINES) "
+ pushd ..\..\..\stx\libbasic3 & $(MAKE_BAT) "CFLAGS_LOCAL=$(GLOBALDEFINES) "
+ pushd ..\..\..\stx\libview & $(MAKE_BAT) "CFLAGS_LOCAL=$(GLOBALDEFINES) "
+ pushd ..\..\..\stx\libview2 & $(MAKE_BAT) "CFLAGS_LOCAL=$(GLOBALDEFINES) "
+ pushd ..\..\..\stx\goodies\sunit & $(MAKE_BAT) "CFLAGS_LOCAL=$(GLOBALDEFINES) "
+
+
+
+
+
+
+
+test: $(TOP)\goodies\builder\reports\NUL
+ pushd $(TOP)\goodies\builder\reports & $(MAKE_BAT)
+ $(TOP)\goodies\builder\reports\report-runner.bat -D . -r Builder::TestReport -p $(PACKAGE)
+
+clean::
+ del *.$(CSUFFIX)
+
+
+# BEGINMAKEDEPEND --- do not remove this line; make depend needs it
+$(OUTDIR)IRBuilderTest.$(O) IRBuilderTest.$(H): IRBuilderTest.st $(INCLUDE_TOP)\stx\goodies\sunit\TestAsserter.$(H) $(INCLUDE_TOP)\stx\goodies\sunit\TestCase.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
+$(OUTDIR)IRTransformTest.$(O) IRTransformTest.$(H): IRTransformTest.st $(INCLUDE_TOP)\stx\goodies\sunit\TestAsserter.$(H) $(INCLUDE_TOP)\stx\goodies\sunit\TestCase.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
+$(OUTDIR)ctu_ircompiler_tests.$(O) ctu_ircompiler_tests.$(H): ctu_ircompiler_tests.st $(INCLUDE_TOP)\stx\libbasic\LibraryDefinition.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(INCLUDE_TOP)\stx\libbasic\ProjectDefinition.$(H) $(STCHDR)
+
+# ENDMAKEDEPEND --- do not remove this line
+
+# **Must be at end**
+
+# Enforce recompilation of package definition class if Mercurial working
+# copy state changes. Together with --guessVersion it ensures that package
+# definition class always contains correct binary revision string.
+!IFDEF HGROOT
+$(OUTDIR)ctu_ircompiler_tests.$(O): $(HGROOT)\.hg\dirstate
+!ENDIF
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/bmake.bat Thu Oct 30 22:27:09 2014 +0000
@@ -0,0 +1,12 @@
+@REM -------
+@REM make using Borland bcc32
+@REM type bmake, and wait...
+@REM do not edit - automatically generated from ProjectDefinition
+@REM -------
+@SET DEFINES=
+@REM Kludge got Mercurial, cannot be implemented in Borland make
+@FOR /F "tokens=*" %%i in ('hg root') do SET HGROOT=%%i
+@IF "%HGROOT%" NEQ "" SET DEFINES=%DEFINES% "-DHGROOT=%HGROOT%"
+make.exe -N -f bc.mak %DEFINES% %*
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/ctu_ircompiler_tests.st Thu Oct 30 22:27:09 2014 +0000
@@ -0,0 +1,117 @@
+"{ Package: 'ctu:ircompiler/tests' }"
+
+LibraryDefinition subclass:#ctu_ircompiler_tests
+ instanceVariableNames:''
+ classVariableNames:''
+ poolDictionaries:''
+ category:'* Projects & Packages *'
+!
+
+
+!ctu_ircompiler_tests class methodsFor:'description'!
+
+excludedFromPreRequisites
+ "list packages which are to be explicitely excluded from the automatic constructed
+ prerequisites list. If empty, everything that is found along the inheritance of any of
+ my classes is considered to be a prerequisite package."
+
+ ^ #(
+ )
+!
+
+mandatoryPreRequisites
+ "list packages which are mandatory as a prerequisite.
+ This are packages containing superclasses of my classes and classes which
+ are extended by myself.
+ They are mandatory, because we need these packages as a prerequisite for loading and compiling.
+ This method is generated automatically,
+ by searching along the inheritance chain of all of my classes."
+
+ ^ #(
+ #'stx:goodies/sunit' "TestAsserter - superclass of IRBuilderTest"
+ #'stx:libbasic' "LibraryDefinition - superclass of ctu_ircompiler_tests"
+ )
+!
+
+referencedPreRequisites
+ "list packages which are a prerequisite, because they contain
+ classes which are referenced by my classes.
+ We do not need these packages as a prerequisite for loading or compiling.
+ This method is generated automatically,
+ by searching all classes (and their packages) which are referenced by my classes."
+
+ ^ #(
+ #'ctu:ircompiler' "IRBuilder - referenced by IRBuilderTest>>testBlock_blockNesting_1"
+ )
+!
+
+subProjects
+ "list packages which are known as subprojects.
+ The generated makefile will enter those and make there as well.
+ However: they are not forced to be loaded when a package is loaded;
+ for those, redefine requiredPrerequisites."
+
+ ^ #(
+ )
+! !
+
+!ctu_ircompiler_tests class methodsFor:'description - contents'!
+
+classNamesAndAttributes
+ "lists the classes which are to be included in the project.
+ Each entry in the list may be: a single class-name (symbol),
+ or an array-literal consisting of class name and attributes.
+ Attributes are: #autoload or #<os> where os is one of win32, unix,..."
+
+ ^ #(
+ "<className> or (<className> attributes...) in load order"
+ IRBuilderTest
+ IRTransformTest
+ #'ctu_ircompiler_tests'
+ )
+!
+
+extensionMethodNames
+ "list class/selector pairs of extensions.
+ A correponding method with real names must be present in my concrete subclasses"
+
+ ^ #(
+ )
+! !
+
+!ctu_ircompiler_tests class methodsFor:'description - project information'!
+
+companyName
+ "Returns a company string which will appear in <lib>.rc.
+ Under win32, this is placed into the dlls file-info"
+
+ ^ 'My Company'
+!
+
+description
+ "Returns a description string which will appear in nt.def / bc.def"
+
+ ^ 'Class Library'
+!
+
+legalCopyright
+ "Returns a copyright string which will appear in <lib>.rc.
+ Under win32, this is placed into the dlls file-info"
+
+ ^ 'My CopyRight or CopyLeft'
+!
+
+productName
+ "Returns a product name which will appear in <lib>.rc.
+ Under win32, this is placed into the dlls file-info.
+ This method is usually redefined in a concrete application definition"
+
+ ^ 'LibraryName'
+! !
+
+!ctu_ircompiler_tests class methodsFor:'documentation'!
+
+version_HG
+ ^ '$Changeset: <not expanded> $'
+! !
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/lccmake.bat Thu Oct 30 22:27:09 2014 +0000
@@ -0,0 +1,8 @@
+@REM -------
+@REM make using lcc compiler
+@REM type lccmake, and wait...
+@REM do not edit - automatically generated from ProjectDefinition
+@REM -------
+make.exe -N -f bc.mak -DUSELCC=1 %*
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/libInit.cc Thu Oct 30 22:27:09 2014 +0000
@@ -0,0 +1,36 @@
+/*
+ * $Header$
+ *
+ * DO NOT EDIT
+ * automagically generated from the projectDefinition: ctu_ircompiler_tests.
+ */
+#define __INDIRECTVMINITCALLS__
+#include <stc.h>
+
+#ifdef WIN32
+# pragma codeseg INITCODE "INITCODE"
+#endif
+
+#if defined(INIT_TEXT_SECTION) || defined(DLL_EXPORT)
+DLL_EXPORT void _libctu_ircompiler_tests_Init() INIT_TEXT_SECTION;
+DLL_EXPORT void _libctu_ircompiler_tests_InitDefinition() INIT_TEXT_SECTION;
+#endif
+
+void _libctu_ircompiler_tests_InitDefinition(pass, __pRT__, snd)
+OBJ snd; struct __vmData__ *__pRT__; {
+__BEGIN_PACKAGE2__("libctu_ircompiler_tests__DFN", _libctu_ircompiler_tests_InitDefinition, "ctu:ircompiler/tests");
+_ctu_137ircompiler_137tests_Init(pass,__pRT__,snd);
+
+__END_PACKAGE__();
+}
+
+void _libctu_ircompiler_tests_Init(pass, __pRT__, snd)
+OBJ snd; struct __vmData__ *__pRT__; {
+__BEGIN_PACKAGE2__("libctu_ircompiler_tests", _libctu_ircompiler_tests_Init, "ctu:ircompiler/tests");
+_IRBuilderTest_Init(pass,__pRT__,snd);
+_IRTransformTest_Init(pass,__pRT__,snd);
+_ctu_137ircompiler_137tests_Init(pass,__pRT__,snd);
+
+
+__END_PACKAGE__();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/mingwmake.bat Thu Oct 30 22:27:09 2014 +0000
@@ -0,0 +1,16 @@
+@REM -------
+@REM make using mingw gnu compiler
+@REM type mingwmake, and wait...
+@REM do not edit - automatically generated from ProjectDefinition
+@REM -------
+@SET DEFINES=
+@REM Kludge got Mercurial, cannot be implemented in Borland make
+@FOR /F "tokens=*" %%i in ('hg root') do SET HGROOT=%%i
+@IF "%HGROOT%" NEQ "" SET DEFINES=%DEFINES% "-DHGROOT=%HGROOT%"
+
+@pushd ..\..\..\stx\rules
+@call find_mingw.bat
+@popd
+make.exe -N -f bc.mak %DEFINES% %USEMINGW_ARG% %*
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/tests.rc Thu Oct 30 22:27:09 2014 +0000
@@ -0,0 +1,37 @@
+//
+// DO NOT EDIT
+// automagically generated from the projectDefinition: ctu_ircompiler_tests.
+//
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION 6,2,32767,32767
+ PRODUCTVERSION 6,2,4,0
+#if (__BORLANDC__)
+ FILEFLAGSMASK VS_FF_DEBUG | VS_FF_PRERELEASE
+ FILEFLAGS VS_FF_PRERELEASE | VS_FF_SPECIALBUILD
+ FILEOS VOS_NT_WINDOWS32
+ FILETYPE VFT_DLL
+ FILESUBTYPE VS_USER_DEFINED
+#endif
+
+BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040904E4"
+ BEGIN
+ VALUE "CompanyName", "My Company\0"
+ VALUE "FileDescription", "Class Library (LIB)\0"
+ VALUE "FileVersion", "6.2.32767.32767\0"
+ VALUE "InternalName", "ctu:ircompiler/tests\0"
+ VALUE "LegalCopyright", "My CopyRight or CopyLeft\0"
+ VALUE "ProductName", "LibraryName\0"
+ VALUE "ProductVersion", "6.2.4.0\0"
+ VALUE "ProductDate", "Thu, 30 Oct 2014 22:24:51 GMT\0"
+ END
+
+ END
+
+ BLOCK "VarFileInfo"
+ BEGIN // Language | Translation
+ VALUE "Translation", 0x409, 0x4E4 // U.S. English, Windows Multilingual
+ END
+END
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/vcmake.bat Thu Oct 30 22:27:09 2014 +0000
@@ -0,0 +1,20 @@
+@REM -------
+@REM make using Microsoft Visual C compiler
+@REM type vcmake, and wait...
+@REM do not edit - automatically generated from ProjectDefinition
+@REM -------
+
+@if not defined VSINSTALLDIR (
+ pushd ..\..\..\stx\rules
+ call vcsetup.bat
+ popd
+)
+@SET DEFINES=
+@REM Kludge got Mercurial, cannot be implemented in Borland make
+@FOR /F "tokens=*" %%i in ('hg root') do SET HGROOT=%%i
+@IF "%HGROOT%" NEQ "" SET DEFINES=%DEFINES% "-DHGROOT=%HGROOT%"
+make.exe -N -f bc.mak -DUSEVC=1 %DEFINES% %*
+
+
+
+