src/jdk/nashorn/internal/codegen/CodeGenerator.java

changeset 1552
b0888b955b31
parent 1550
e9ea7010825b
child 1720
c09b105e7be5
equal deleted inserted replaced
1551:5391219122ee 1552:b0888b955b31
127 import jdk.nashorn.internal.ir.UnaryNode; 127 import jdk.nashorn.internal.ir.UnaryNode;
128 import jdk.nashorn.internal.ir.VarNode; 128 import jdk.nashorn.internal.ir.VarNode;
129 import jdk.nashorn.internal.ir.WhileNode; 129 import jdk.nashorn.internal.ir.WhileNode;
130 import jdk.nashorn.internal.ir.WithNode; 130 import jdk.nashorn.internal.ir.WithNode;
131 import jdk.nashorn.internal.ir.visitor.NodeOperatorVisitor; 131 import jdk.nashorn.internal.ir.visitor.NodeOperatorVisitor;
132 import jdk.nashorn.internal.ir.visitor.NodeVisitor; 132 import jdk.nashorn.internal.ir.visitor.SimpleNodeVisitor;
133 import jdk.nashorn.internal.objects.Global; 133 import jdk.nashorn.internal.objects.Global;
134 import jdk.nashorn.internal.parser.Lexer.RegexToken; 134 import jdk.nashorn.internal.parser.Lexer.RegexToken;
135 import jdk.nashorn.internal.parser.TokenType; 135 import jdk.nashorn.internal.parser.TokenType;
136 import jdk.nashorn.internal.runtime.Context; 136 import jdk.nashorn.internal.runtime.Context;
137 import jdk.nashorn.internal.runtime.Debug; 137 import jdk.nashorn.internal.runtime.Debug;
1431 final List<Expression> args = callNode.getArgs(); 1431 final List<Expression> args = callNode.getArgs();
1432 final Expression function = callNode.getFunction(); 1432 final Expression function = callNode.getFunction();
1433 final Block currentBlock = lc.getCurrentBlock(); 1433 final Block currentBlock = lc.getCurrentBlock();
1434 final CodeGeneratorLexicalContext codegenLexicalContext = lc; 1434 final CodeGeneratorLexicalContext codegenLexicalContext = lc;
1435 1435
1436 function.accept(new NodeVisitor<LexicalContext>(new LexicalContext()) { 1436 function.accept(new SimpleNodeVisitor() {
1437
1438 private MethodEmitter sharedScopeCall(final IdentNode identNode, final int flags) { 1437 private MethodEmitter sharedScopeCall(final IdentNode identNode, final int flags) {
1439 final Symbol symbol = identNode.getSymbol(); 1438 final Symbol symbol = identNode.getSymbol();
1440 final boolean isFastScope = isFastScope(symbol); 1439 final boolean isFastScope = isFastScope(symbol);
1441 new OptimisticOperation(callNode, resultBounds) { 1440 new OptimisticOperation(callNode, resultBounds) {
1442 @Override 1441 @Override
2459 return new Supplier<Boolean>() { 2458 return new Supplier<Boolean>() {
2460 boolean contains; 2459 boolean contains;
2461 2460
2462 @Override 2461 @Override
2463 public Boolean get() { 2462 public Boolean get() {
2464 value.accept(new NodeVisitor<LexicalContext>(new LexicalContext()) { 2463 value.accept(new SimpleNodeVisitor() {
2465 @Override 2464 @Override
2466 public boolean enterFunctionNode(final FunctionNode functionNode) { 2465 public boolean enterFunctionNode(final FunctionNode functionNode) {
2467 return false; 2466 return false;
2468 } 2467 }
2469 2468
2797 } 2796 }
2798 return new Supplier<Boolean>() { 2797 return new Supplier<Boolean>() {
2799 boolean contains; 2798 boolean contains;
2800 @Override 2799 @Override
2801 public Boolean get() { 2800 public Boolean get() {
2802 rootExpr.accept(new NodeVisitor<LexicalContext>(new LexicalContext()) { 2801 rootExpr.accept(new SimpleNodeVisitor() {
2803 @Override 2802 @Override
2804 public boolean enterFunctionNode(final FunctionNode functionNode) { 2803 public boolean enterFunctionNode(final FunctionNode functionNode) {
2805 return false; 2804 return false;
2806 } 2805 }
2807 @Override 2806 @Override
4345 /* 4344 /*
4346 * This loads the parts of the target, e.g base and index. they are kept 4345 * This loads the parts of the target, e.g base and index. they are kept
4347 * on the stack throughout the store and used at the end to execute it 4346 * on the stack throughout the store and used at the end to execute it
4348 */ 4347 */
4349 4348
4350 target.accept(new NodeVisitor<LexicalContext>(new LexicalContext()) { 4349 target.accept(new SimpleNodeVisitor() {
4351 @Override 4350 @Override
4352 public boolean enterIdentNode(final IdentNode node) { 4351 public boolean enterIdentNode(final IdentNode node) {
4353 if (node.getSymbol().isScope()) { 4352 if (node.getSymbol().isScope()) {
4354 method.loadCompilerConstant(SCOPE); 4353 method.loadCompilerConstant(SCOPE);
4355 depth += Type.SCOPE.getSlots(); 4354 depth += Type.SCOPE.getSlots();
4444 * 4443 *
4445 * The case that targetSymbol is in scope (!hasSlot) and we actually 4444 * The case that targetSymbol is in scope (!hasSlot) and we actually
4446 * need to do a conversion on non-equivalent types exists, but is 4445 * need to do a conversion on non-equivalent types exists, but is
4447 * very rare. See for example test/script/basic/access-specializer.js 4446 * very rare. See for example test/script/basic/access-specializer.js
4448 */ 4447 */
4449 target.accept(new NodeVisitor<LexicalContext>(new LexicalContext()) { 4448 target.accept(new SimpleNodeVisitor() {
4450 @Override 4449 @Override
4451 protected boolean enterDefault(final Node node) { 4450 protected boolean enterDefault(final Node node) {
4452 throw new AssertionError("Unexpected node " + node + " in store epilogue"); 4451 throw new AssertionError("Unexpected node " + node + " in store epilogue");
4453 } 4452 }
4454 4453

mercurial