IRBytecodeGenerator.st
changeset 10 0fd549e0c784
parent 9 04518c7fb91c
child 11 0a50d475c1ff
--- a/IRBytecodeGenerator.st	Mon Mar 30 14:47:18 2009 +0000
+++ b/IRBytecodeGenerator.st	Mon Mar 30 17:49:01 2009 +0000
@@ -23,6 +23,17 @@
 
 !IRBytecodeGenerator methodsFor:'accessing'!
 
+getCode
+
+    "
+        Private entry for IRBytecodeGenerator>>makeBlock:
+    "
+
+    ^code
+
+    "Created: / 30-03-2009 / 19:00:07 / Jan Vrany <vranyj1@fel.cvut.cz>"
+!
+
 properties: aDictionary
 
     properties := aDictionary.
@@ -158,6 +169,30 @@
     "Modified: / 02-12-2008 / 10:38:20 / Jan Vrany <vranyj1@fel.cvut.cz>"
 !
 
+makeBlock: irClosure
+
+    | closureCode |
+
+    stack push.
+
+    self 
+        nextPut: #makeBlock;
+        nextPut: nil "Number of block bytecodes. Patched later";
+        nextPut: irClosure numVars;
+        nextPut: irClosure numArgs.
+
+    closureCode := (IRTranslator new)
+                        interpret: irClosure;
+                        getCode.
+
+    "Patch number of closure bytecodes"
+    code at: code size - 2 put: (closureCode size + 5).
+    code addAll: closureCode.
+
+    "Created: / 30-03-2009 / 18:16:10 / Jan Vrany <vranyj1@fel.cvut.cz>"
+    "Modified: / 30-03-2009 / 19:39:50 / Jan Vrany <vranyj1@fel.cvut.cz>"
+!
+
 popTop
 
         stack pop.
@@ -167,6 +202,28 @@
     "Modified: / 11-06-2008 / 14:17:22 / Jan Vrany <vranyj1@fel.cvut.cz>"
 !
 
+pushBlockArg: index
+
+    stack push.
+    self
+        nextPut: #pushBlockArg;
+        nextPut: index
+
+    "Created: / 30-03-2009 / 19:07:01 / Jan Vrany <vranyj1@fel.cvut.cz>"
+!
+
+pushBlockVar: index
+
+    stack push.
+    numArgs := index max: numArgs.
+
+    self
+        nextPut: #pushBlockVar;
+        nextPut: index
+
+    "Created: / 30-03-2009 / 19:07:12 / Jan Vrany <vranyj1@fel.cvut.cz>"
+!
+
 pushDup
 
         stack push.
@@ -345,6 +402,29 @@
     "Modified: / 02-12-2008 / 09:10:37 / Jan Vrany <vranyj1@fel.cvut.cz>"
 !
 
+storeBlockArg: index
+
+    stack pop.
+
+    self
+        nextPut:#storeBlockArg;
+        nextPut:index
+
+    "Created: / 30-03-2009 / 19:06:43 / Jan Vrany <vranyj1@fel.cvut.cz>"
+!
+
+storeBlockVar: index
+
+    stack pop.
+    numVars := index max: numVars.
+
+    self
+        nextPut:#storeBlockVar;
+        nextPut:index
+
+    "Created: / 30-03-2009 / 19:03:55 / Jan Vrany <vranyj1@fel.cvut.cz>"
+!
+
 storeInstVar: index
 
     self