IRBuilderTest.st
changeset 17 df6f26442169
parent 16 f325defc9c7e
child 19 3bb7360f9dff
--- a/IRBuilderTest.st	Mon May 11 20:20:05 2009 +0000
+++ b/IRBuilderTest.st	Tue May 12 11:10:22 2009 +0000
@@ -156,6 +156,32 @@
     ^([: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'!
@@ -739,6 +765,42 @@
 
 !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|