Skip to content

Commit

Permalink
fixed files form Closure #30
Browse files Browse the repository at this point in the history
  • Loading branch information
tdurieux committed Mar 7, 2017
1 parent e5dad44 commit 8c3b992
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public void exitScope(NodeTraversal t) {}

@Override
public void process(Node externs, Node root) {
(new NodeTraversal(compiler, this)).traverse(root);
(new NodeTraversal(compiler, this)).traverseRoots(externs, root);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ final class MustBeReachingVariableDef extends
private static class Definition {
final Node node;
final Set<Var> depends = Sets.newHashSet();
private boolean unknownDependencies = false;

Definition(Node node) {
this.node = node;
Expand Down Expand Up @@ -393,9 +394,13 @@ private void computeDependence(final Definition def, Node rValue) {
new AbstractCfgNodeTraversalCallback() {
@Override
public void visit(NodeTraversal t, Node n, Node parent) {
if (n.isName() && jsScope.isDeclared(n.getString(), true)) {
if (n.isName()) {
Var dep = jsScope.getVar(n.getString());
if (dep == null) {
def.unknownDependencies = true;
} else {
def.depends.add(dep);
}
}
}
});
Expand Down Expand Up @@ -427,6 +432,9 @@ boolean dependsOnOuterScopeVars(String name, Node useNode) {
GraphNode<Node, Branch> n = getCfg().getNode(useNode);
FlowState<MustDef> state = n.getAnnotation();
Definition def = state.getIn().reachingDef.get(jsScope.getVar(name));
if (def.unknownDependencies) {
return true;
}

for (Var s : def.depends) {
if (s.scope != jsScope) {
Expand Down

0 comments on commit 8c3b992

Please sign in to comment.