< prev index next >

src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/Lower.java

Print this page




 237                             expressionStatement.getToken(),
 238                             TokenType.ASSIGN),
 239                         compilerConstant(RETURN),
 240                     expr));
 241             }
 242         }
 243 
 244         return addStatement(node);
 245     }
 246 
 247     @Override
 248     public Node leaveBlockStatement(final BlockStatement blockStatement) {
 249         return addStatement(blockStatement);
 250     }
 251 
 252     @Override
 253     public Node leaveForNode(final ForNode forNode) {
 254         ForNode newForNode = forNode;
 255 
 256         final Expression test = forNode.getTest();
 257         if (!forNode.isForIn() && isAlwaysTrue(test)) {
 258             newForNode = forNode.setTest(lc, null);
 259         }
 260 
 261         newForNode = checkEscape(newForNode);
 262         if(!es6 && newForNode.isForIn()) {
 263             // Wrap it in a block so its internally created iterator is restricted in scope, unless we are running
 264             // in ES6 mode, in which case the parser already created a block to capture let/const declarations.
 265             addStatementEnclosedInBlock(newForNode);
 266         } else {
 267             addStatement(newForNode);
 268         }
 269         return newForNode;
 270     }
 271 
 272     @Override
 273     public Node leaveFunctionNode(final FunctionNode functionNode) {
 274         log.info("END FunctionNode: ", functionNode.getName());
 275         return functionNode;
 276     }
 277 
 278     @Override
 279     public Node leaveIfNode(final IfNode ifNode) {
 280         return addStatement(ifNode);
 281     }
 282 




 237                             expressionStatement.getToken(),
 238                             TokenType.ASSIGN),
 239                         compilerConstant(RETURN),
 240                     expr));
 241             }
 242         }
 243 
 244         return addStatement(node);
 245     }
 246 
 247     @Override
 248     public Node leaveBlockStatement(final BlockStatement blockStatement) {
 249         return addStatement(blockStatement);
 250     }
 251 
 252     @Override
 253     public Node leaveForNode(final ForNode forNode) {
 254         ForNode newForNode = forNode;
 255 
 256         final Expression test = forNode.getTest();
 257         if (!forNode.isForIn() && !forNode.isForOf() && isAlwaysTrue(test)) {
 258             newForNode = forNode.setTest(lc, null);
 259         }
 260 
 261         newForNode = checkEscape(newForNode);
 262         if(!es6 && (newForNode.isForIn() || newForNode.isForOf())) {
 263             // Wrap it in a block so its internally created iterator is restricted in scope, unless we are running
 264             // in ES6 mode, in which case the parser already created a block to capture let/const declarations.
 265             addStatementEnclosedInBlock(newForNode);
 266         } else {
 267             addStatement(newForNode);
 268         }
 269         return newForNode;
 270     }
 271 
 272     @Override
 273     public Node leaveFunctionNode(final FunctionNode functionNode) {
 274         log.info("END FunctionNode: ", functionNode.getName());
 275         return functionNode;
 276     }
 277 
 278     @Override
 279     public Node leaveIfNode(final IfNode ifNode) {
 280         return addStatement(ifNode);
 281     }
 282 


< prev index next >