aboutsummaryrefslogtreecommitdiff
path: root/lib/scope.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/scope.js')
-rw-r--r--lib/scope.js17
1 files changed, 13 insertions, 4 deletions
diff --git a/lib/scope.js b/lib/scope.js
index bc5db90d..ae792a0a 100644
--- a/lib/scope.js
+++ b/lib/scope.js
@@ -184,6 +184,17 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(options){
var func = null;
var globals = self.globals = new Dictionary();
var tw = new TreeWalker(function(node, descend){
+ function isModified(node, level) {
+ var parent = tw.parent(level);
+ if (parent instanceof AST_Unary && (parent.operator === "++" || parent.operator === "--")
+ || parent instanceof AST_Assign && parent.left === node
+ || parent instanceof AST_Call && parent.expression === node) {
+ return true;
+ } else if (parent instanceof AST_PropAccess && parent.expression === node) {
+ return isModified(parent, level + 1);
+ }
+ }
+
if (node instanceof AST_Lambda) {
var prev_func = func;
func = node;
@@ -197,8 +208,7 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(options){
}
if (node instanceof AST_SymbolRef) {
var name = node.name;
- var parent = tw.parent();
- if (name == "eval" && parent instanceof AST_Call) {
+ if (name == "eval" && tw.parent() instanceof AST_Call) {
for (var s = node.scope; s && !s.uses_eval; s = s.parent_scope) {
s.uses_eval = true;
}
@@ -220,8 +230,7 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(options){
sym = g;
}
node.thedef = sym;
- if (parent instanceof AST_Unary && (parent.operator === "++" || parent.operator === "--")
- || parent instanceof AST_Assign && parent.left === node) {
+ if (isModified(node, 0)) {
sym.modified = true;
}
node.reference();