Skip to content

Commit

Permalink
fixed files form Closure #98
Browse files Browse the repository at this point in the history
  • Loading branch information
tdurieux committed Mar 7, 2017
1 parent ea5118d commit ecacb74
Showing 1 changed file with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,14 @@ boolean isAssignedOnceInLifetime() {
}

// Make sure this assignment is not in a loop.
for (BasicBlock block = ref.getBasicBlock();
block != null; block = block.getParent()) {
if (block.isFunction) {
break;
} else if (block.isLoop) {
return false;
}
}

return true;
}
Expand Down Expand Up @@ -542,10 +550,12 @@ static final class BasicBlock {
/**
* Whether this block denotes a function scope.
*/
private final boolean isFunction;

/**
* Whether this block denotes a loop.
*/
private final boolean isLoop;

/**
* Creates a new block.
Expand All @@ -558,7 +568,16 @@ static final class BasicBlock {
// only named functions may be hoisted.
this.isHoisted = NodeUtil.isHoistedFunctionDeclaration(root);

this.isFunction = root.getType() == Token.FUNCTION;

if (root.getParent() != null) {
int pType = root.getParent().getType();
this.isLoop = pType == Token.DO ||
pType == Token.WHILE ||
pType == Token.FOR;
} else {
this.isLoop = false;
}
}

BasicBlock getParent() {
Expand Down

0 comments on commit ecacb74

Please sign in to comment.