Skip to content

Commit 21e62f9

Browse files
committed
Always use newBlock(Scope).
1 parent 5addcb6 commit 21e62f9

File tree

1 file changed

+7
-13
lines changed
  • graal-js/src/com.oracle.js.parser/src/com/oracle/js/parser

1 file changed

+7
-13
lines changed

graal-js/src/com.oracle.js.parser/src/com/oracle/js/parser/Parser.java

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -738,14 +738,8 @@ private void recover(final Exception e) {
738738
}
739739
}
740740

741-
/**
742-
* Set up a new block.
743-
*
744-
* @return New block.
745-
*/
746-
private ParserContextBlockNode newBlock() {
747-
Scope scope = Scope.createBlock(lc.getCurrentScope());
748-
return newBlock(scope);
741+
private Scope newBlockScope() {
742+
return Scope.createBlock(lc.getCurrentScope());
749743
}
750744

751745
/**
@@ -833,7 +827,7 @@ private ParserContextBlockNode restoreBlock(final ParserContextBlockNode block)
833827
*/
834828
private Block getBlock(boolean yield, boolean await, boolean needsBraces) {
835829
final long blockToken = token;
836-
final ParserContextBlockNode newBlock = newBlock();
830+
final ParserContextBlockNode newBlock = newBlock(newBlockScope());
837831
try {
838832
// Block opening brace.
839833
if (needsBraces) {
@@ -895,7 +889,7 @@ private Block getStatement(boolean yield, boolean await, boolean labelledStateme
895889
return getBlock(yield, await, true);
896890
}
897891
// Set up new block. Captures first token.
898-
final ParserContextBlockNode newBlock = newBlock();
892+
final ParserContextBlockNode newBlock = newBlock(newBlockScope());
899893
newBlock.setFlag(Block.IS_SYNTHETIC);
900894
try {
901895
statement(yield, await, false, 0, true, labelledStatement, mayBeFunctionDeclaration, mayBeLabeledFunctionDeclaration);
@@ -2928,7 +2922,7 @@ private void forStatement(boolean yield, boolean await) {
29282922
// When ES6 for-let is enabled we create a container block to capture the LET.
29292923
ParserContextBlockNode outer;
29302924
if (useBlockScope()) {
2931-
outer = newBlock();
2925+
outer = newBlock(newBlockScope());
29322926
outer.setFlag(Block.IS_SYNTHETIC);
29332927
} else {
29342928
outer = null;
@@ -3608,7 +3602,7 @@ private void switchStatement(boolean yield, boolean await) {
36083602
// Block around the switch statement with a variable capturing the switch expression value.
36093603
final ParserContextBlockNode outerBlock;
36103604
if (useBlockScope()) {
3611-
outerBlock = newBlock();
3605+
outerBlock = newBlock(newBlockScope());
36123606
outerBlock.setFlag(Block.IS_SYNTHETIC);
36133607
} else {
36143608
outerBlock = null;
@@ -3813,7 +3807,7 @@ private void tryStatement(boolean yield, boolean await) {
38133807

38143808
// Container block needed to act as target for labeled break statements
38153809
final int startLine = line;
3816-
final ParserContextBlockNode outer = newBlock();
3810+
final ParserContextBlockNode outer = newBlock(newBlockScope());
38173811
// Create try.
38183812

38193813
try {

0 commit comments

Comments
 (0)