--- a/IRBytecodeGenerator.st Tue Mar 23 13:38:08 2010 +0000
+++ b/IRBytecodeGenerator.st Wed Mar 24 07:50:55 2010 +0000
@@ -37,17 +37,6 @@
!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.
@@ -224,7 +213,6 @@
at: index + 1
put: (closureCode at: index + 1) + pos + 4]].
-
code addAll: closureCode.
"Patch number of closure bytecodes"
@@ -232,6 +220,7 @@
"Created: / 30-03-2009 / 18:16:10 / Jan Vrany <vranyj1@fel.cvut.cz>"
"Modified: / 12-05-2009 / 08:58:11 / Jan Vrany <vranyj1@fel.cvut.cz>"
+ "Modified: / 23-03-2010 / 22:34:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
popTop
@@ -726,6 +715,38 @@
"Modified: / 13-05-2009 / 10:42:16 / Jan Vrany <vranyj1@fel.cvut.cz>"
!
+getCode
+
+ | stream basicBlockStartOffset |
+ [ orderSeq
+ inject: false
+ into: [:changed :seqId | (self updateJump: seqId) | changed]
+ ] whileTrue.
+
+ stream := (OrderedCollection new: 200) writeStream.
+ basicBlockStartOffset := 0.
+ orderSeq do: [:seqId |
+ (instrMaps at: seqId) do: [:assoc |
+ assoc key "instr" bytecodeIndex: stream position + assoc value.
+ ].
+ "Patch makeBlock offsets"
+ (seqCode at: seqId) withIndexDo:
+ [:instr :index|
+ instr == #makeBlock ifTrue:
+ [(seqCode at: seqId)
+ at: index + 1
+ put: ((seqCode at: seqId) at: index + 1) + basicBlockStartOffset]].
+
+ stream nextPutAll: (seqCode at: seqId).
+ basicBlockStartOffset := basicBlockStartOffset + (seqCode at: seqId) size.
+ ].
+ ^stream contents
+
+ "Created: / 11-06-2008 / 14:00:43 / Jan Vrany <vranyj1@fel.cvut.cz>"
+ "Modified: / 13-05-2009 / 11:15:41 / Jan Vrany <vranyj1@fel.cvut.cz>"
+ "Modified: / 24-03-2010 / 08:42:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
literals
^literals asArray