IRBuilderTest.st
changeset 9 04518c7fb91c
parent 6 49a61123c743
child 10 0fd549e0c784
--- a/IRBuilderTest.st	Wed Feb 25 16:49:21 2009 +0000
+++ b/IRBuilderTest.st	Mon Mar 30 14:47:18 2009 +0000
@@ -26,6 +26,129 @@
     ^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>"
 ! !
 
 !IRBuilderTest methodsFor:'testing'!
@@ -41,699 +164,598 @@
 !
 
 testDup
+    |iRMethod aCompiledMethod|
 
-	| iRMethod aCompiledMethod |
-	iRMethod := IRBuilder new
-		numRargs: 1;
-		addTemps: #(self);		"receiver and args declarations"
-			
-		pushLiteral: 3;
-		pushDup;
-		
-		send: #=;
-		
-		returnTop;
-		ir.
-
-	aCompiledMethod := iRMethod compiledMethod.
-
-	self assert: (aCompiledMethod isKindOf: CompiledMethod).
-     self assert: ((aCompiledMethod valueWithReceiver: nil arguments: #() ) = true).
-	
+    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|
 
-        | aCompiledMethod irBuilder |
-        irBuilder := IRBuilder new
-                numRargs: 1;
-                addTemps: #(self);              "receiver and args declarations"
-
-                pushInstVar: 1;
-                pushInstVar: 2;
-                send: #+;
-                
+    irBuilder := (IRBuilder new)
+                numRargs:1;
+                addTemps:#( #self );
+                pushInstVar:1;
+                pushInstVar:2;
+                send:#'+';
                 returnTop;
                 ir.
-
-        aCompiledMethod := irBuilder compiledMethod.
-
-        self assert: (aCompiledMethod isKindOf: CompiledMethod).
-     self assert: ((aCompiledMethod valueWithReceiver: (3@4) arguments: #() ) = 7).
+    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 aCompiledMethod |
-	iRMethod := IRBuilder new
-		numRargs: 1;
-		addTemps: #(self);		"receiver and args declarations"
-		pushTemp: #self	;
-			
-		jumpAheadTo: #end;
-		pushLiteral: 3;
-		jumpAheadTarget: #end;	
-		
-		returnTop;
-		ir.
-
-	aCompiledMethod := iRMethod compiledMethod.
-
-	self assert: (aCompiledMethod isKindOf: CompiledMethod).
-     self assert: ((aCompiledMethod valueWithReceiver: nil arguments: #() ) = nil).
-	
+    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 aCompiledMethod |
-	iRMethod := IRBuilder new
-		numRargs: 1;
-		addTemps: #(self);		"receiver and args declarations"
-		pushTemp: #self	;
-		pushLiteral: true;
-		
-		"jumpAhaedTo pop the first element of thz stack"
-		jumpAheadTo: #end if: true;
-		pushLiteral: 3;
-		jumpAheadTarget: #end;	
-		
-		returnTop;
-		ir.
-
-	aCompiledMethod := iRMethod compiledMethod.
-
-	self assert: (aCompiledMethod isKindOf: CompiledMethod).
-     self assert: ((aCompiledMethod valueWithReceiver: nil arguments: #() ) = nil).
-	
+    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 aCompiledMethod |
-	iRMethod := IRBuilder new
-		numRargs: 1;
-		addTemps: #(self);		"receiver and args declarations"
-		pushTemp: #self	;
-		pushLiteral: false;
-		jumpBackTarget: #begin;
-		
-		"jumpAhaedTo pop the first element of the stack"
-		jumpAheadTo: #end if: true;
-		pushLiteral: true;
-		jumpBackTo: #begin;
-		jumpAheadTarget: #end;	
-		
-		returnTop;
-		ir.
-
-	aCompiledMethod := iRMethod compiledMethod.
-
-	self assert: (aCompiledMethod isKindOf: CompiledMethod).
-     self assert: ((aCompiledMethod valueWithReceiver: nil arguments: #() ) = nil).
-	
+    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 aCompiledMethod |
-        iRMethod := IRBuilder new
-                numRargs: 1;
-                addTemps: #(self); "receiver and args declarations"
-
-                line: 5;
-                pushLiteral: true;
+    iRMethod := (IRBuilder new)
+                numRargs:1;
+                addTemps:#( #self );
+                line:5;
+                pushLiteral:true;
                 returnTop;
                 ir.
-
-        aCompiledMethod := iRMethod compiledMethod.
-
-        self assert: (aCompiledMethod isKindOf: CompiledMethod).
-     self assert: ((aCompiledMethod valueWithReceiver: nil arguments: #() ) = true).
+    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 aCompiledMethod |
-        iRMethod := IRBuilder new
-                numRargs: 1;
-                addTemps: #(self); "receiver and args declarations"
-
-                line: 5;
-                pushLiteral: true;
-                pushLiteral: false;
-                send: #&;
+    iRMethod := (IRBuilder new)
+                numRargs:1;
+                addTemps:#( #self );
+                line:5;
+                pushLiteral:true;
+                pushLiteral:false;
+                send:#'&';
                 returnTop;
                 ir.
-
-        aCompiledMethod := iRMethod compiledMethod.
-
-        self assert: (aCompiledMethod isKindOf: CompiledMethod).
-     self assert: ((aCompiledMethod valueWithReceiver: nil arguments: #() ) = false).
+    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 aCompiledMethod |
-	iRMethod := IRBuilder new
-		numRargs: 1;
-		addTemps: #(self);		"receiver and args declarations"
-			
-		pushLiteral: #(test 4 you); 	
-		returnTop;
-		ir.
-
-	aCompiledMethod := iRMethod compiledMethod.
-
-	self assert: (aCompiledMethod isKindOf: CompiledMethod).
-     self assert: ((aCompiledMethod valueWithReceiver: nil arguments: #() ) = #(test 4 you)).
-
-	
+    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 aCompiledMethod |
-	iRMethod := IRBuilder new
-		numRargs: 1;
-		addTemps: #(self);		"receiver and args declarations"
-			
-		pushLiteral: true; 	
-		returnTop;
-		ir.
-
-	aCompiledMethod := iRMethod compiledMethod.
-
-	self assert: (aCompiledMethod isKindOf: CompiledMethod).
-     self assert: ((aCompiledMethod valueWithReceiver: nil arguments: #() ) = true).
-
-	
+    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 aCompiledMethod |
-	iRMethod := IRBuilder new
-		numRargs: 1;
-		addTemps: #(self);		"receiver and args declarations"
-			
-		pushLiteral: $e; 	
-		returnTop;
-		ir.
-
-	aCompiledMethod := iRMethod compiledMethod.
-
-	self assert: (aCompiledMethod isKindOf: CompiledMethod).
-     self assert: ((aCompiledMethod valueWithReceiver: nil arguments: #() ) = $e).
-
-	
+    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 aCompiledMethod |
-        iRMethod := IRBuilder new
-                numRargs: 1;
-                addTemps: #(self);              "receiver and args declarations"
-                        
-                pushLiteral: 2.0;       
+    iRMethod := (IRBuilder new)
+                numRargs:1;
+                addTemps:#( #self );
+                pushLiteral:2.0;
                 returnTop;
                 ir.
-
-        aCompiledMethod := iRMethod compiledMethod.
-
-        self assert: (aCompiledMethod isKindOf: CompiledMethod).
-     self assert: ((aCompiledMethod valueWithReceiver: nil arguments: #() ) = 2.0).
+    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 aCompiledMethod |
-	iRMethod := IRBuilder new
-		numRargs: 1;
-		addTemps: #(self);		"receiver and args declarations"
-			
-		pushLiteral: 2; 	
-		returnTop;
-		ir.
-
-	aCompiledMethod := iRMethod compiledMethod.
-
-	self assert: (aCompiledMethod isKindOf: CompiledMethod).
-     self assert: ((aCompiledMethod valueWithReceiver: nil arguments: #() ) = 2).
-
-	
+    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 aCompiledMethod |
-	iRMethod := IRBuilder new
-		numRargs: 1;
-		addTemps: #(self);		"receiver and args declarations"
-			
-		pushLiteral: nil; 	
-		returnTop;
-		ir.
-
-	aCompiledMethod := iRMethod compiledMethod.
-
-	self assert: (aCompiledMethod isKindOf: CompiledMethod).
-     self assert: ((aCompiledMethod valueWithReceiver: 4 arguments: #() ) = nil).
-
-	
+    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 aCompiledMethod |
-	iRMethod := IRBuilder new
-		numRargs: 1;
-		addTemps: #(self);		"receiver and args declarations"
-			
-		pushLiteral: 'hello'; 	
-		returnTop;
-		ir.
-
-	aCompiledMethod := iRMethod compiledMethod.
-
-	self assert: (aCompiledMethod isKindOf: CompiledMethod).
-     self assert: ((aCompiledMethod valueWithReceiver: nil arguments: #() ) = 'hello').
-
-	
+    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 aCompiledMethod |
-	iRMethod := IRBuilder new
-		numRargs: 1;
-		addTemps: #(self);		"receiver and args declarations"
-			
-		pushLiteral: #you; 	
-		returnTop;
-		ir.
-
-	aCompiledMethod := iRMethod compiledMethod.
-
-	self assert: (aCompiledMethod isKindOf: CompiledMethod).
-     self assert: ((aCompiledMethod valueWithReceiver: nil arguments: #() ) = #you).
-
-	
+    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 aCompiledMethod |
-	iRMethod := IRBuilder new
-		numRargs: 1;
-		addTemps: #(self);		"receiver and args declarations"
-			
-		pushLiteralVariable: Object binding;	
-		returnTop;
-		ir.
-
-	aCompiledMethod := iRMethod compiledMethod.
-
-	self assert: (aCompiledMethod isKindOf: CompiledMethod).
-     self assert: ((aCompiledMethod valueWithReceiver: nil arguments: #() ) = Object).
-
-	
+    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 aCompiledMethod |
-        iRMethod := IRBuilder new
-                numRargs: 1;
-                addTemps: #(self);              "receiver and args declarations"
-                        
-                pushLiteralVariable: (ArithmeticValue bindingOf: #ArithmeticSignal);   
+    iRMethod := (IRBuilder new)
+                numRargs:1;
+                addTemps:#( #self );
+                pushLiteralVariable:(ArithmeticValue bindingOf:#ArithmeticSignal);
                 returnTop;
                 ir.
-
-        aCompiledMethod := iRMethod compiledMethod.
-
-        self assert: (aCompiledMethod isKindOf: CompiledMethod).
-     self assert: ((aCompiledMethod valueWithReceiver: nil arguments: #() ) = ArithmeticValue arithmeticSignal).
+    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 aCompiledMethod |
-        iRMethod := IRBuilder new
-                numRargs: 1;
-                addTemps: #(self);              "receiver and args declarations"
-                        
-                pushLiteralVariable: Smalltalk binding;     
+    iRMethod := (IRBuilder new)
+                numRargs:1;
+                addTemps:#( #self );
+                pushLiteralVariable:Smalltalk binding;
                 returnTop;
                 ir.
-
-        aCompiledMethod := iRMethod compiledMethod.
-
-        self assert: (aCompiledMethod isKindOf: CompiledMethod).
-     self assert: ((aCompiledMethod valueWithReceiver: nil arguments: #() ) = Smalltalk).
+    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 aCompiledMethod |
-        iRMethod := IRBuilder new
-                numRargs: 1;
-                addTemps: #(self);              "receiver and args declarations"
-                pushLiteral: true         ;
-                        
-                pushLiteral: false;
+    iRMethod := (IRBuilder new)
+                numRargs:1;
+                addTemps:#( #self );
+                pushLiteral:true;
+                pushLiteral:false;
                 popTop;
-                
                 returnTop;
                 ir.
-
-        aCompiledMethod := iRMethod compiledMethod.
-
-        self assert: (aCompiledMethod isKindOf: CompiledMethod).
-     self assert: ((aCompiledMethod valueWithReceiver: nil arguments: #() ) = true).
+    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 aCompiledMethod receiver |
-	iRMethod := IRBuilder new
-		numRargs: 1;
-		addTemps: #(self);		"receiver and args declarations"
-		pushReceiver;
-		returnTop;
-		ir.
-
-	aCompiledMethod := iRMethod compiledMethod.
-	
-	receiver :=  (5@8).
-
-	self assert: (aCompiledMethod isKindOf: CompiledMethod).
-     self assert: ((aCompiledMethod valueWithReceiver: receiver arguments: #() ) == 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 aCompiledMethod  |
-	iRMethod := IRBuilder new
-		numRargs: 3;
-		addTemps: #(self a b);		"receiver and args declarations"
-		pushTemp: #a;
-		pushTemp: #b;
-		send: #+;
-		returnTop;
-		ir.
-
-	aCompiledMethod := iRMethod compiledMethod.
-
-
-	self assert: (aCompiledMethod isKindOf: CompiledMethod).
-     self assert: ((aCompiledMethod valueWithReceiver: nil arguments: #(2 8) ) = 10).
-	
+    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 aCompiledMethod |
-	iRMethod := IRBuilder new
-		numRargs: 1;
-		addTemps: #(self);		"receiver and args declarations"
-		pushTemp: #self;
-		send: #class;
-		returnTop;
-		ir.
-
-	aCompiledMethod := iRMethod compiledMethod.
-
-
-	self assert: (aCompiledMethod isKindOf: CompiledMethod).
-     self assert: ((aCompiledMethod valueWithReceiver: nil arguments: #() ) == UndefinedObject).
-	
+    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);		"receiver and args declarations"
-	
-		pushTemp: #a;
+    |iRMethod aCompiledMethod|
 
-		returnTop;
-		ir.
-
-	aCompiledMethod := iRMethod compiledMethod.
-
-
-	self assert: (aCompiledMethod isKindOf: CompiledMethod).
-     self assert: ((aCompiledMethod valueWithReceiver: 5 arguments: #() ) = nil).
-	
+    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);		"receiver and args declarations"
-	
-		pushThisContext;
-		send: #receiver;
+    |iRMethod aCompiledMethod|
 
-		returnTop;
-		ir.
-
-	aCompiledMethod := iRMethod compiledMethod.
-
-
-	self assert: (aCompiledMethod isKindOf: CompiledMethod).
-     self assert: ((aCompiledMethod valueWithReceiver: 5 arguments: #() ) = 5).
-	
+    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 aCompiledMethod receiver|
 
-        iRMethod := IRBuilder new
-                numRargs: 1;
-                addTemps: #(self);              "receiver and args declarations"
+    ^ self.
+    iRMethod := (IRBuilder new)
+                numRargs:1;
+                addTemps:#( #self );
                 pushThisContext;
-                pushLiteral: 5;
-                pushLiteral: ClosureEnvironment;
-                pushLiteral: 1;
-                send: #new:;
-                send: #privSetInstVar:put:;
+                pushLiteral:5;
+                pushLiteral:ClosureEnvironment;
+                pushLiteral:1;
+                send:#new:;
+                send:#privSetInstVar:put:;
                 pushThisEnv;
                 returnTop;
                 ir.
-
-        aCompiledMethod := iRMethod compiledMethod.
-
-        receiver := Object new.
-        
-        self assert: (aCompiledMethod isKindOf: CompiledMethod).
-     self assert: ((aCompiledMethod valueWithReceiver: receiver arguments: #()) isKindOf: ClosureEnvironment)
-
-    "Modified: / 11-06-2008 / 14:47:36 / Jan Vrany <vranyj1@fel.cvut.cz>"
+    aCompiledMethod := iRMethod compiledCode.
+    receiver := Object new.
+    self assert:(aCompiledMethod isKindOf:CompiledMethod).
+    self assert:((aCompiledMethod valueWithReceiver:receiver arguments:#()) 
+                isKindOf:ClosureEnvironment)
 !
 
 testSendNumArgs1
+    |iRMethod aCompiledMethod|
 
-        | iRMethod aCompiledMethod  |
-        iRMethod := IRBuilder new
-                numRargs: 1;
-                addTemps: #(self);              "receiver and args declarations"
-        
+    iRMethod := (IRBuilder new)
+                numRargs:1;
+                addTemps:#( #self );
                 pushReceiver;
-                pushLiteral: 1;
-                pushLiteral: 2;
-                send: #mock1 numArgs:2;
+                pushLiteral:1;
+                pushLiteral:2;
+                send:#mock1 numArgs:2;
                 returnTop;
                 ir.
-
-        aCompiledMethod := iRMethod compiledMethod.
-        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.
+    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 aCompiledMethod  |
-        iRMethod := IRBuilder new
-                numRargs: 1;
-                addTemps: #(self);              "receiver and args declarations"
-        
+    iRMethod := (IRBuilder new)
+                numRargs:1;
+                addTemps:#( #self );
                 pushReceiver;
-                pushLiteral: 1;
-                send: #mock1 numArgs:1;
+                pushLiteral:1;
+                send:#mock1 numArgs:1;
                 returnTop;
                 ir.
-
-        aCompiledMethod := iRMethod compiledMethod.
-        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.
+    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 aCompiledMethod  |
-        iRMethod := IRBuilder new
-                numRargs: 1;
-                addTemps: #(self);              "receiver and args declarations"
-        
+    iRMethod := (IRBuilder new)
+                numRargs:1;
+                addTemps:#( #self );
                 pushReceiver;
-                send: #halt toSuperOf: IRBuilderTest;
-
+                send:#halt toSuperOf:IRBuilderTest;
                 returnTop;
                 ir.
-
-        aCompiledMethod := iRMethod compiledMethod.
-
-
-        self assert: (aCompiledMethod isKindOf: CompiledMethod).
-     self should: [(aCompiledMethod valueWithReceiver: (IRBuilderTest new) arguments: #())] raise: Error.
+    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);		"receiver and args declarations"
-	
-		pushLiteral: 4;
-		storeIntoLiteralVariable: (IRBuilderTest bindingOf: #TestToPush);
+    |iRMethod aCompiledMethod|
 
-		returnTop;
-		ir.
-
-	aCompiledMethod := iRMethod compiledMethod.
-
-
-	self assert: (aCompiledMethod isKindOf: CompiledMethod).
-     aCompiledMethod valueWithReceiver: nil arguments: #().
-	self assert: (IRBuilderTest testToPush = 4).
-	IRBuilderTest testToPush: nil.
-
-	
+    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 aCompiledMethod  |
-        iRMethod := IRBuilder new
-                numRargs: 1;
-                addTemps: #(self a);            "receiver and args declarations"
-        
-                pushLiteral: 34;
-                storeTemp: #a;
-                pushTemp: #a;
-
+    iRMethod := (IRBuilder new)
+                numRargs:1;
+                addTemps:#( #self #a );
+                pushLiteral:34;
+                storeTemp:#a;
+                pushTemp:#a;
                 returnTop;
                 ir.
-
-        aCompiledMethod := iRMethod compiledMethod.
-
-        self assert: (aCompiledMethod isKindOf: CompiledMethod).
-     self assert: ((aCompiledMethod valueWithReceiver: nil arguments: #() ) = 34).
+    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 aCompiledMethod|
 
-        iRMethod := IRBuilder new
-                numRargs: 1;
-                addTemps: #(self a);            "receiver and args declarations"
-                pushLiteral: ClosureEnvironment;
-                pushLiteral: 1;
-                send: #new:;
+    ^ self.
+    iRMethod := (IRBuilder new)
+                numRargs:1;
+                addTemps:#( #self #a );
+                pushLiteral:ClosureEnvironment;
+                pushLiteral:1;
+                send:#new:;
                 storeThisEnv;
                 pushThisContext;
-                pushLiteral: 5;
-                send: #privGetInstVar:;
+                pushLiteral:5;
+                send:#privGetInstVar:;
                 returnTop;
                 ir.
-
-        aCompiledMethod := iRMethod compiledMethod.
-
-        self assert: (aCompiledMethod isKindOf: CompiledMethod).
-     self assert: ((aCompiledMethod valueWithReceiver: nil arguments: #() ) isKindOf: ClosureEnvironment).
+    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 aCompiledMethod |
-        iRMethod := IRBuilder new
-                numRargs: 1;
-                addTemps: #(self);              "receiver and args declarations"
-                pushTemp: #self         ;
-                pushLiteral: false;
-                jumpAheadTo: #end if: true;
-                pushLiteral: true;
-                jumpAheadTo: #end if: true;
-                pushLiteral: 3;
-                jumpAheadTarget: #end;  
-                
+    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 compiledMethod.
-
-        self assert: (aCompiledMethod isKindOf: CompiledMethod).
-     self assert: ((aCompiledMethod valueWithReceiver: nil arguments: #() ) = nil).
+    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_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.
+    aCompiledMethod := irBuilder compiledCode.
+    self assert:(aCompiledMethod isKindOf:CompiledMethod).
+    self assert:((aCompiledMethod valueWithReceiver:nil arguments:#()) = 22).
+
+    "Created: / 30-03-2009 / 14:26:18 / Jan Vrany <vranyj1@fel.cvut.cz>"
+! !
+
 !IRBuilderTest class methodsFor:'documentation'!
 
 version