Do not use RBProgramNode>>variableNodesDo: as this method is not present in Pharo.
authorJan Vrany <jan.vrany@fit.cvut.cz>
Thu, 18 Jun 2015 22:05:13 +0100
changeset 497 501ba969803d
parent 496 0433a9d7fbcd
child 498 f208cca9aea2
Do not use RBProgramNode>>variableNodesDo: as this method is not present in Pharo. Use local helper method instead.
compiler/PPCCodeGenerator.st
--- a/compiler/PPCCodeGenerator.st	Thu Jun 18 21:20:15 2015 +0100
+++ b/compiler/PPCCodeGenerator.st	Thu Jun 18 22:05:13 2015 +0100
@@ -108,6 +108,25 @@
     ^ compiler checkCache: (compiler idFor: node)
 ! !
 
+!PPCCodeGenerator methodsFor:'private'!
+
+withAllVariableNodesOf: anRBProgramNode do: aBlock
+    "Enumerate all chilren of `anRBProgramNode` (including itself)
+     and evaluate `aBlock` for each variable node.
+     This is a replacement for Smalltalk/X's RBProgramNode>>variableNodesDo:
+     which is not present in Pharo"
+
+    anRBProgramNode isVariable ifTrue:[ 
+        aBlock value: anRBProgramNode.
+        ^ self.
+    ].
+    anRBProgramNode children do:[:each | 
+        self withAllVariableNodesOf: each do: aBlock
+    ].
+
+    "Created: / 18-06-2015 / 22:02:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
 !PPCCodeGenerator methodsFor:'support'!
 
 compileTokenWhitespace: node
@@ -235,7 +254,7 @@
         blockNeedsCollection := false.
         blockMatches := IdentityDictionary new."Must use IDENTITY dict as nodes have overwritten their #=!!!!!!"
         childValueVars := node child preferredChildrenVariableNames.
-        blockBody variableNodesDo:[:variableNode| 
+        self withAllVariableNodesOf: blockBody do:[:variableNode| 
             variableNode name = blockNodesVar name ifTrue:[ 
                 "Check if variable node matches..."
                 variableNode parent isMessage ifTrue:[ 
@@ -304,7 +323,7 @@
         compiler code: blockBody.    
     ]
 
-    "Modified: / 16-06-2015 / 07:41:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 18-06-2015 / 22:03:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 visitAndNode: node
@@ -512,7 +531,7 @@
         | blockArg |
 
         blockArg := blockNode arguments first.
-        blockBody variableNodesDo:[:variableNode| 
+        self withAllVariableNodesOf: blockBody do:[:variableNode| 
             variableNode name = blockArg name ifTrue:[ 
                 variableNode token value: self retvalVar.
             ].
@@ -538,7 +557,7 @@
     ]
 
     "Created: / 02-06-2015 / 17:28:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 18-06-2015 / 06:34:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 18-06-2015 / 22:03:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 visitMessagePredicateNode: node