--- a/ParseNode.st Thu Oct 10 11:35:17 2019 +0200
+++ b/ParseNode.st Sun Oct 13 23:31:57 2019 +0200
@@ -675,6 +675,25 @@
^ 9999
!
+whoDefines:aName
+ "return the node (blockNode) in which this variable is defined.
+ (nil if instvar, classvar or global)"
+
+ |p|
+
+ "/ TODO
+"/ block notNil ifTrue:[
+"/ self halt
+"/ ].
+ p := parent.
+ [p notNil and:[p isFunctionNode not and:[p isBlockNode not]]] whileTrue:[ p := p parent].
+ p notNil ifTrue:[
+ ((p arguments ? #()) contains:[:var | var name = aName]) ifTrue:[^ p].
+ ((p localVariables ? #()) contains:[:var | var name = aName]) ifTrue:[^ p].
+ ].
+ ^ nil
+!
+
withConstantValueDo:aBlock
"return true, if this evaluates to a constant value
and evaluate aBlock with it"