[Pkg-javascript-commits] [node-acorn-jsx] 51/484: Make the walker's scope module use objects for variables
Bastien Roucariès
rouca at moszumanska.debian.org
Sat Aug 19 14:20:03 UTC 2017
This is an automated email from the git hooks/post-receive script.
rouca pushed a commit to branch master
in repository node-acorn-jsx.
commit cb6cd3038eac3b0e9d4595edd404a577e9c54cc5
Author: Marijn Haverbeke <marijnh at gmail.com>
Date: Wed Nov 7 12:15:32 2012 +0100
Make the walker's scope module use objects for variables
So that subsequent passes can attach and retrieve information
from them.
---
util/walk.js | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/util/walk.js b/util/walk.js
index 5ad251f..97321ac 100644
--- a/util/walk.js
+++ b/util/walk.js
@@ -187,18 +187,19 @@
Function: function(node, scope, c) {
var inner = makeScope(scope);
for (var i = 0; i < node.params.length; ++i)
- inner.vars[node.params[i].name] = "argument";
- if (node.type == "FunctionDeclaration")
- scope.vars[node.id.name] = "function";
- else if (node.id)
- inner.vars[node.id.name] = "function'";
+ inner.vars[node.params[i].name] = {type: "argument", node: node.params[i]};
+ if (node.id) {
+ var decl = node.type == "FunctionDeclaration";
+ (decl ? scope : inner).vars[node.id.name] =
+ {type: decl ? "function" : "function name", node: node.id};
+ }
c(node.body, inner, "ScopeBody");
},
TryStatement: function(node, scope, c) {
c(node.block, scope, "Statement");
for (var i = 0; i < node.handlers.length; ++i) {
var handler = node.handlers[i], inner = makeScope(scope);
- inner.vars[handler.param.name] = "catch";
+ inner.vars[handler.param.name] = {type: "catch clause", node: handler.param};
c(handler.body, inner, "ScopeBody");
}
if (node.finalizer) c(node.finalizer, scope, "Statement");
@@ -206,7 +207,7 @@
VariableDeclaration: function(node, scope, c) {
for (var i = 0; i < node.declarations.length; ++i) {
var decl = node.declarations[i];
- scope.vars[decl.id.name] = "var";
+ scope.vars[decl.id.name] = {type: "var", node: decl.id};
if (decl.init) c(decl.init, scope, "Expression");
}
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-acorn-jsx.git
More information about the Pkg-javascript-commits
mailing list