mirror of
https://github.com/openjdk/jdk.git
synced 2026-04-10 15:08:43 +00:00
8013913: Removed Source field from all nodes except FunctionNode in order to save footprint
Reviewed-by: jlaskey, attila
This commit is contained in:
parent
5504a220f7
commit
a788347b73
@ -78,7 +78,6 @@ public final class NashornScriptEngine extends AbstractScriptEngine implements C
|
||||
this(factory, DEFAULT_OPTIONS, appLoader);
|
||||
}
|
||||
|
||||
@SuppressWarnings("LeakingThisInConstructor")
|
||||
NashornScriptEngine(final NashornScriptEngineFactory factory, final String[] args, final ClassLoader appLoader) {
|
||||
this.factory = factory;
|
||||
final Options options = new Options("nashorn");
|
||||
@ -102,7 +101,7 @@ public final class NashornScriptEngine extends AbstractScriptEngine implements C
|
||||
});
|
||||
|
||||
// create new global object
|
||||
this.global = createNashornGlobal();
|
||||
this.global = createNashornGlobal();
|
||||
// set the default engine scope for the default context
|
||||
context.setBindings(new ScriptObjectMirror(global, global), ScriptContext.ENGINE_SCOPE);
|
||||
|
||||
|
||||
@ -435,7 +435,6 @@ final class Attr extends NodeOperatorVisitor {
|
||||
final IdentNode callee = compilerConstant(CALLEE);
|
||||
VarNode selfInit =
|
||||
new VarNode(
|
||||
newFunctionNode.getSource(),
|
||||
newFunctionNode.getToken(),
|
||||
newFunctionNode.getFinish(),
|
||||
newFunctionNode.getIdent(),
|
||||
@ -531,6 +530,7 @@ final class Attr extends NodeOperatorVisitor {
|
||||
setBlockScope(name, symbol);
|
||||
|
||||
if (symbol != null && !identNode.isInitializedHere()) {
|
||||
|
||||
symbol.increaseUseCount();
|
||||
}
|
||||
addLocalUse(identNode.getName());
|
||||
@ -914,7 +914,6 @@ final class Attr extends NodeOperatorVisitor {
|
||||
final FunctionNode functionNode = getLexicalContext().getCurrentFunction();
|
||||
return (IdentNode)
|
||||
new IdentNode(
|
||||
functionNode.getSource(),
|
||||
functionNode.getToken(),
|
||||
functionNode.getFinish(),
|
||||
cc.symbolName()).
|
||||
|
||||
@ -261,14 +261,15 @@ final class CodeGenerator extends NodeOperatorVisitor {
|
||||
return method.load(symbol);
|
||||
}
|
||||
|
||||
final String name = symbol.getName();
|
||||
final String name = symbol.getName();
|
||||
final Source source = getLexicalContext().getCurrentFunction().getSource();
|
||||
|
||||
if (CompilerConstants.__FILE__.name().equals(name)) {
|
||||
return method.load(identNode.getSource().getName());
|
||||
return method.load(source.getName());
|
||||
} else if (CompilerConstants.__DIR__.name().equals(name)) {
|
||||
return method.load(identNode.getSource().getBase());
|
||||
return method.load(source.getBase());
|
||||
} else if (CompilerConstants.__LINE__.name().equals(name)) {
|
||||
return method.load(identNode.getSource().getLine(identNode.position())).convert(Type.OBJECT);
|
||||
return method.load(source.getLine(identNode.position())).convert(Type.OBJECT);
|
||||
} else {
|
||||
assert identNode.getSymbol().isScope() : identNode + " is not in scope!";
|
||||
|
||||
@ -2005,8 +2006,9 @@ final class CodeGenerator extends NodeOperatorVisitor {
|
||||
public boolean enterThrowNode(final ThrowNode throwNode) {
|
||||
method._new(ECMAException.class).dup();
|
||||
|
||||
final Source source = getLexicalContext().getCurrentFunction().getSource();
|
||||
|
||||
final Node expression = throwNode.getExpression();
|
||||
final Source source = throwNode.getSource();
|
||||
final int position = throwNode.position();
|
||||
final int line = source.getLine(position);
|
||||
final int column = source.getColumn(position);
|
||||
@ -3013,7 +3015,6 @@ final class CodeGenerator extends NodeOperatorVisitor {
|
||||
return;
|
||||
}
|
||||
|
||||
@SuppressWarnings("resource")
|
||||
final PrintWriter out = compiler.getEnv().getErr();
|
||||
out.println("[BLOCK in '" + ident + "']");
|
||||
if (!block.printSymbols(out)) {
|
||||
|
||||
@ -773,7 +773,7 @@ final class FinalizeTypes extends NodeOperatorVisitor {
|
||||
private Node convert(final Node node, final Type to) {
|
||||
assert !to.isUnknown() : "unknown type for " + node + " class=" + node.getClass();
|
||||
assert node != null : "node is null";
|
||||
assert node.getSymbol() != null : "node " + node + " " + node.getClass() + " has no symbol! " + getLexicalContext().getCurrentFunction() + " " + node.getSource();
|
||||
assert node.getSymbol() != null : "node " + node + " " + node.getClass() + " has no symbol! " + getLexicalContext().getCurrentFunction();
|
||||
assert node.tokenType() != TokenType.CONVERT : "assert convert in convert " + node + " in " + getLexicalContext().getCurrentFunction();
|
||||
|
||||
final Type from = node.getType();
|
||||
@ -798,7 +798,7 @@ final class FinalizeTypes extends NodeOperatorVisitor {
|
||||
assert node instanceof TypeOverride;
|
||||
return setTypeOverride(node, to);
|
||||
}
|
||||
resultNode = new UnaryNode(node.getSource(), Token.recast(node.getToken(), TokenType.CONVERT), node);
|
||||
resultNode = new UnaryNode(Token.recast(node.getToken(), TokenType.CONVERT), node);
|
||||
}
|
||||
|
||||
LOG.info("CONVERT('", node, "', ", to, ") => '", resultNode, "'");
|
||||
@ -813,7 +813,7 @@ final class FinalizeTypes extends NodeOperatorVisitor {
|
||||
|
||||
private static Node discard(final Node node) {
|
||||
if (node.getSymbol() != null) {
|
||||
final Node discard = new UnaryNode(node.getSource(), Token.recast(node.getToken(), TokenType.DISCARD), node);
|
||||
final Node discard = new UnaryNode(Token.recast(node.getToken(), TokenType.DISCARD), node);
|
||||
//discard never has a symbol in the discard node - then it would be a nop
|
||||
assert !node.isTerminal();
|
||||
return discard;
|
||||
@ -881,15 +881,15 @@ final class FinalizeTypes extends NodeOperatorVisitor {
|
||||
LiteralNode<?> literalNode = null;
|
||||
|
||||
if (type.isString()) {
|
||||
literalNode = LiteralNode.newInstance(source, token, finish, JSType.toString(value));
|
||||
literalNode = LiteralNode.newInstance(token, finish, JSType.toString(value));
|
||||
} else if (type.isBoolean()) {
|
||||
literalNode = LiteralNode.newInstance(source, token, finish, JSType.toBoolean(value));
|
||||
literalNode = LiteralNode.newInstance(token, finish, JSType.toBoolean(value));
|
||||
} else if (type.isInteger()) {
|
||||
literalNode = LiteralNode.newInstance(source, token, finish, JSType.toInt32(value));
|
||||
literalNode = LiteralNode.newInstance(token, finish, JSType.toInt32(value));
|
||||
} else if (type.isLong()) {
|
||||
literalNode = LiteralNode.newInstance(source, token, finish, JSType.toLong(value));
|
||||
literalNode = LiteralNode.newInstance(token, finish, JSType.toLong(value));
|
||||
} else if (type.isNumber() || parent.getType().isNumeric() && !parent.getType().isNumber()) {
|
||||
literalNode = LiteralNode.newInstance(source, token, finish, JSType.toNumber(value));
|
||||
literalNode = LiteralNode.newInstance(token, finish, JSType.toNumber(value));
|
||||
}
|
||||
|
||||
if (literalNode != null) {
|
||||
|
||||
@ -41,7 +41,6 @@ import jdk.nashorn.internal.ir.visitor.NodeVisitor;
|
||||
import jdk.nashorn.internal.runtime.DebugLogger;
|
||||
import jdk.nashorn.internal.runtime.JSType;
|
||||
import jdk.nashorn.internal.runtime.ScriptRuntime;
|
||||
import jdk.nashorn.internal.runtime.Source;
|
||||
|
||||
/**
|
||||
* Simple constant folding pass, executed before IR is starting to be lowered.
|
||||
@ -112,13 +111,11 @@ final class FoldConstants extends NodeVisitor {
|
||||
*/
|
||||
abstract static class ConstantEvaluator<T extends Node> {
|
||||
protected T parent;
|
||||
protected final Source source;
|
||||
protected final long token;
|
||||
protected final int finish;
|
||||
|
||||
protected ConstantEvaluator(final T parent) {
|
||||
this.parent = parent;
|
||||
this.source = parent.getSource();
|
||||
this.token = parent.getToken();
|
||||
this.finish = parent.getFinish();
|
||||
}
|
||||
@ -152,23 +149,23 @@ final class FoldConstants extends NodeVisitor {
|
||||
switch (parent.tokenType()) {
|
||||
case ADD:
|
||||
if (rhsInteger) {
|
||||
literalNode = LiteralNode.newInstance(source, token, finish, rhs.getInt32());
|
||||
literalNode = LiteralNode.newInstance(token, finish, rhs.getInt32());
|
||||
} else {
|
||||
literalNode = LiteralNode.newInstance(source, token, finish, rhs.getNumber());
|
||||
literalNode = LiteralNode.newInstance(token, finish, rhs.getNumber());
|
||||
}
|
||||
break;
|
||||
case SUB:
|
||||
if (rhsInteger && rhs.getInt32() != 0) { // @see test/script/basic/minuszero.js
|
||||
literalNode = LiteralNode.newInstance(source, token, finish, -rhs.getInt32());
|
||||
literalNode = LiteralNode.newInstance(token, finish, -rhs.getInt32());
|
||||
} else {
|
||||
literalNode = LiteralNode.newInstance(source, token, finish, -rhs.getNumber());
|
||||
literalNode = LiteralNode.newInstance(token, finish, -rhs.getNumber());
|
||||
}
|
||||
break;
|
||||
case NOT:
|
||||
literalNode = LiteralNode.newInstance(source, token, finish, !rhs.getBoolean());
|
||||
literalNode = LiteralNode.newInstance(token, finish, !rhs.getBoolean());
|
||||
break;
|
||||
case BIT_NOT:
|
||||
literalNode = LiteralNode.newInstance(source, token, finish, ~rhs.getInt32());
|
||||
literalNode = LiteralNode.newInstance(token, finish, ~rhs.getInt32());
|
||||
break;
|
||||
default:
|
||||
return null;
|
||||
@ -234,7 +231,7 @@ final class FoldConstants extends NodeVisitor {
|
||||
break;
|
||||
}
|
||||
assert res instanceof CharSequence : res + " was not a CharSequence, it was a " + res.getClass();
|
||||
return LiteralNode.newInstance(source, token, finish, res.toString());
|
||||
return LiteralNode.newInstance(token, finish, res.toString());
|
||||
}
|
||||
return null;
|
||||
case MUL:
|
||||
@ -247,33 +244,33 @@ final class FoldConstants extends NodeVisitor {
|
||||
value = lhs.getNumber() - rhs.getNumber();
|
||||
break;
|
||||
case SHR:
|
||||
return LiteralNode.newInstance(source, token, finish, (lhs.getInt32() >>> rhs.getInt32()) & JSType.MAX_UINT);
|
||||
return LiteralNode.newInstance(token, finish, (lhs.getInt32() >>> rhs.getInt32()) & JSType.MAX_UINT);
|
||||
case SAR:
|
||||
return LiteralNode.newInstance(source, token, finish, lhs.getInt32() >> rhs.getInt32());
|
||||
return LiteralNode.newInstance(token, finish, lhs.getInt32() >> rhs.getInt32());
|
||||
case SHL:
|
||||
return LiteralNode.newInstance(source, token, finish, lhs.getInt32() << rhs.getInt32());
|
||||
return LiteralNode.newInstance(token, finish, lhs.getInt32() << rhs.getInt32());
|
||||
case BIT_XOR:
|
||||
return LiteralNode.newInstance(source, token, finish, lhs.getInt32() ^ rhs.getInt32());
|
||||
return LiteralNode.newInstance(token, finish, lhs.getInt32() ^ rhs.getInt32());
|
||||
case BIT_AND:
|
||||
return LiteralNode.newInstance(source, token, finish, lhs.getInt32() & rhs.getInt32());
|
||||
return LiteralNode.newInstance(token, finish, lhs.getInt32() & rhs.getInt32());
|
||||
case BIT_OR:
|
||||
return LiteralNode.newInstance(source, token, finish, lhs.getInt32() | rhs.getInt32());
|
||||
return LiteralNode.newInstance(token, finish, lhs.getInt32() | rhs.getInt32());
|
||||
case GE:
|
||||
return LiteralNode.newInstance(source, token, finish, ScriptRuntime.GE(lhs.getObject(), rhs.getObject()));
|
||||
return LiteralNode.newInstance(token, finish, ScriptRuntime.GE(lhs.getObject(), rhs.getObject()));
|
||||
case LE:
|
||||
return LiteralNode.newInstance(source, token, finish, ScriptRuntime.LE(lhs.getObject(), rhs.getObject()));
|
||||
return LiteralNode.newInstance(token, finish, ScriptRuntime.LE(lhs.getObject(), rhs.getObject()));
|
||||
case GT:
|
||||
return LiteralNode.newInstance(source, token, finish, ScriptRuntime.GT(lhs.getObject(), rhs.getObject()));
|
||||
return LiteralNode.newInstance(token, finish, ScriptRuntime.GT(lhs.getObject(), rhs.getObject()));
|
||||
case LT:
|
||||
return LiteralNode.newInstance(source, token, finish, ScriptRuntime.LT(lhs.getObject(), rhs.getObject()));
|
||||
return LiteralNode.newInstance(token, finish, ScriptRuntime.LT(lhs.getObject(), rhs.getObject()));
|
||||
case NE:
|
||||
return LiteralNode.newInstance(source, token, finish, ScriptRuntime.NE(lhs.getObject(), rhs.getObject()));
|
||||
return LiteralNode.newInstance(token, finish, ScriptRuntime.NE(lhs.getObject(), rhs.getObject()));
|
||||
case NE_STRICT:
|
||||
return LiteralNode.newInstance(source, token, finish, ScriptRuntime.NE_STRICT(lhs.getObject(), rhs.getObject()));
|
||||
return LiteralNode.newInstance(token, finish, ScriptRuntime.NE_STRICT(lhs.getObject(), rhs.getObject()));
|
||||
case EQ:
|
||||
return LiteralNode.newInstance(source, token, finish, ScriptRuntime.EQ(lhs.getObject(), rhs.getObject()));
|
||||
return LiteralNode.newInstance(token, finish, ScriptRuntime.EQ(lhs.getObject(), rhs.getObject()));
|
||||
case EQ_STRICT:
|
||||
return LiteralNode.newInstance(source, token, finish, ScriptRuntime.EQ_STRICT(lhs.getObject(), rhs.getObject()));
|
||||
return LiteralNode.newInstance(token, finish, ScriptRuntime.EQ_STRICT(lhs.getObject(), rhs.getObject()));
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
@ -282,12 +279,12 @@ final class FoldConstants extends NodeVisitor {
|
||||
isLong &= value != 0.0 && JSType.isRepresentableAsLong(value);
|
||||
|
||||
if (isInteger) {
|
||||
return LiteralNode.newInstance(source, token, finish, JSType.toInt32(value));
|
||||
return LiteralNode.newInstance(token, finish, JSType.toInt32(value));
|
||||
} else if (isLong) {
|
||||
return LiteralNode.newInstance(source, token, finish, JSType.toLong(value));
|
||||
return LiteralNode.newInstance(token, finish, JSType.toLong(value));
|
||||
}
|
||||
|
||||
return LiteralNode.newInstance(source, token, finish, value);
|
||||
return LiteralNode.newInstance(token, finish, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -118,8 +118,9 @@ final class Lower extends NodeOperatorVisitor {
|
||||
@Override
|
||||
public boolean enterBlock(final Block block) {
|
||||
final LexicalContext lc = getLexicalContext();
|
||||
if (lc.isFunctionBody() && lc.getCurrentFunction().isProgram() && !lc.getCurrentFunction().hasDeclaredFunctions()) {
|
||||
new ExecuteNode(block.getSource(), block.getToken(), block.getFinish(), LiteralNode.newInstance(block, ScriptRuntime.UNDEFINED)).accept(this);
|
||||
final FunctionNode function = lc.getCurrentFunction();
|
||||
if (lc.isFunctionBody() && function.isProgram() && !function.hasDeclaredFunctions()) {
|
||||
new ExecuteNode(block.getToken(), block.getFinish(), LiteralNode.newInstance(block, ScriptRuntime.UNDEFINED)).accept(this);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -137,7 +138,6 @@ final class Lower extends NodeOperatorVisitor {
|
||||
final FunctionNode currentFunction = getLexicalContext().getCurrentFunction();
|
||||
final boolean isProgram = currentFunction.isProgram();
|
||||
final ReturnNode returnNode = new ReturnNode(
|
||||
currentFunction.getSource(),
|
||||
currentFunction.getToken(),
|
||||
currentFunction.getFinish(),
|
||||
isProgram ?
|
||||
@ -193,7 +193,6 @@ final class Lower extends NodeOperatorVisitor {
|
||||
if (!isInternalExpression(expr) && !isEvalResultAssignment(expr)) {
|
||||
node = executeNode.setExpression(
|
||||
new BinaryNode(
|
||||
executeNode.getSource(),
|
||||
Token.recast(
|
||||
executeNode.getToken(),
|
||||
TokenType.ASSIGN),
|
||||
@ -284,17 +283,16 @@ final class Lower extends NodeOperatorVisitor {
|
||||
}
|
||||
|
||||
private Block catchAllBlock(final TryNode tryNode) {
|
||||
final Source source = tryNode.getSource();
|
||||
final long token = tryNode.getToken();
|
||||
final int finish = tryNode.getFinish();
|
||||
|
||||
final IdentNode exception = new IdentNode(source, token, finish, getLexicalContext().getCurrentFunction().uniqueName("catch_all"));
|
||||
final IdentNode exception = new IdentNode(token, finish, getLexicalContext().getCurrentFunction().uniqueName("catch_all"));
|
||||
|
||||
final Block catchBody = new Block(source, token, finish, new ThrowNode(source, token, finish, new IdentNode(exception))).
|
||||
final Block catchBody = new Block(token, finish, new ThrowNode(token, finish, new IdentNode(exception))).
|
||||
setIsTerminal(getLexicalContext(), true); //ends with throw, so terminal
|
||||
|
||||
final CatchNode catchAllNode = new CatchNode(source, token, finish, new IdentNode(exception), null, catchBody);
|
||||
final Block catchAllBlock = new Block(source, token, finish, catchAllNode);
|
||||
final CatchNode catchAllNode = new CatchNode(token, finish, new IdentNode(exception), null, catchBody);
|
||||
final Block catchAllBlock = new Block(token, finish, catchAllNode);
|
||||
|
||||
//catchallblock -> catchallnode (catchnode) -> exception -> throw
|
||||
|
||||
@ -303,7 +301,7 @@ final class Lower extends NodeOperatorVisitor {
|
||||
|
||||
private IdentNode compilerConstant(final CompilerConstants cc) {
|
||||
final FunctionNode functionNode = getLexicalContext().getCurrentFunction();
|
||||
return new IdentNode(functionNode.getSource(), functionNode.getToken(), functionNode.getFinish(), cc.symbolName());
|
||||
return new IdentNode(functionNode.getToken(), functionNode.getFinish(), cc.symbolName());
|
||||
}
|
||||
|
||||
private static boolean isTerminal(final List<Node> statements) {
|
||||
@ -318,7 +316,6 @@ final class Lower extends NodeOperatorVisitor {
|
||||
* @return new try node after splicing finally code (same if nop)
|
||||
*/
|
||||
private Node spliceFinally(final TryNode tryNode, final List<ThrowNode> rethrows, final Block finallyBody) {
|
||||
final Source source = tryNode.getSource();
|
||||
final int finish = tryNode.getFinish();
|
||||
|
||||
assert tryNode.getFinallyBody() == null;
|
||||
@ -345,7 +342,7 @@ final class Lower extends NodeOperatorVisitor {
|
||||
if (!isTerminal(newStatements)) {
|
||||
newStatements.add(throwNode);
|
||||
}
|
||||
return new Block(source, throwNode.getToken(), throwNode.getFinish(), newStatements);
|
||||
return new Block(throwNode.getToken(), throwNode.getFinish(), newStatements);
|
||||
}
|
||||
return throwNode;
|
||||
}
|
||||
@ -370,7 +367,7 @@ final class Lower extends NodeOperatorVisitor {
|
||||
//we need to evaluate the result of the return in case it is complex while
|
||||
//still in the try block, store it in a result value and return it afterwards
|
||||
resultNode = new IdentNode(Lower.this.compilerConstant(RETURN));
|
||||
newStatements.add(new ExecuteNode(new BinaryNode(source, Token.recast(returnNode.getToken(), TokenType.ASSIGN), resultNode, expr)));
|
||||
newStatements.add(new ExecuteNode(new BinaryNode(Token.recast(returnNode.getToken(), TokenType.ASSIGN), resultNode, expr)));
|
||||
} else {
|
||||
resultNode = null;
|
||||
}
|
||||
@ -380,7 +377,7 @@ final class Lower extends NodeOperatorVisitor {
|
||||
newStatements.add(expr == null ? returnNode : returnNode.setExpression(resultNode));
|
||||
}
|
||||
|
||||
return new ExecuteNode(new Block(source, returnNode.getToken(), getLexicalContext().getCurrentBlock().getFinish(), newStatements));
|
||||
return new ExecuteNode(new Block(returnNode.getToken(), getLexicalContext().getCurrentBlock().getFinish(), newStatements));
|
||||
}
|
||||
|
||||
private Node copy(final Node endpoint, final Node targetNode) {
|
||||
@ -389,7 +386,7 @@ final class Lower extends NodeOperatorVisitor {
|
||||
if (!isTerminal(newStatements)) {
|
||||
newStatements.add(endpoint);
|
||||
}
|
||||
return new ExecuteNode(new Block(source, endpoint.getToken(), finish, newStatements));
|
||||
return new ExecuteNode(new Block(endpoint.getToken(), finish, newStatements));
|
||||
}
|
||||
return endpoint;
|
||||
}
|
||||
@ -451,7 +448,7 @@ final class Lower extends NodeOperatorVisitor {
|
||||
if (tryNode.getCatchBlocks().isEmpty()) {
|
||||
newTryNode = tryNode.setFinallyBody(null);
|
||||
} else {
|
||||
Block outerBody = new Block(tryNode.getSource(), tryNode.getToken(), tryNode.getFinish(), new ArrayList<Node>(Arrays.asList(tryNode.setFinallyBody(null))));
|
||||
Block outerBody = new Block(tryNode.getToken(), tryNode.getFinish(), new ArrayList<Node>(Arrays.asList(tryNode.setFinallyBody(null))));
|
||||
newTryNode = tryNode.setBody(outerBody).setCatchBlocks(null);
|
||||
}
|
||||
|
||||
@ -468,19 +465,19 @@ final class Lower extends NodeOperatorVisitor {
|
||||
public Node leaveVarNode(final VarNode varNode) {
|
||||
addStatement(varNode);
|
||||
if (varNode.getFlag(VarNode.IS_LAST_FUNCTION_DECLARATION) && getLexicalContext().getCurrentFunction().isProgram()) {
|
||||
new ExecuteNode(varNode.getSource(), varNode.getToken(), varNode.getFinish(), new IdentNode(varNode.getName())).accept(this);
|
||||
new ExecuteNode(varNode.getToken(), varNode.getFinish(), new IdentNode(varNode.getName())).accept(this);
|
||||
}
|
||||
return varNode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Node leaveWhileNode(final WhileNode whileNode) {
|
||||
final Node test = whileNode.getTest();
|
||||
final Node test = whileNode.getTest();
|
||||
final Block body = whileNode.getBody();
|
||||
|
||||
if (conservativeAlwaysTrue(test)) {
|
||||
//turn it into a for node without a test.
|
||||
final ForNode forNode = (ForNode)new ForNode(whileNode.getSource(), whileNode.getToken(), whileNode.getFinish(), null, null, body, null, ForNode.IS_FOR).accept(this);
|
||||
final ForNode forNode = (ForNode)new ForNode(whileNode.getToken(), whileNode.getFinish(), null, null, body, null, ForNode.IS_FOR).accept(this);
|
||||
getLexicalContext().replace(whileNode, forNode);
|
||||
return forNode;
|
||||
}
|
||||
@ -525,11 +522,12 @@ final class Lower extends NodeOperatorVisitor {
|
||||
* @param node a node
|
||||
* @return eval location
|
||||
*/
|
||||
private static String evalLocation(final IdentNode node) {
|
||||
private String evalLocation(final IdentNode node) {
|
||||
final Source source = getLexicalContext().getCurrentFunction().getSource();
|
||||
return new StringBuilder().
|
||||
append(node.getSource().getName()).
|
||||
append(source.getName()).
|
||||
append('#').
|
||||
append(node.getSource().getLine(node.position())).
|
||||
append(source.getLine(node.position())).
|
||||
append("<eval>").
|
||||
toString();
|
||||
}
|
||||
|
||||
@ -42,7 +42,6 @@ import jdk.nashorn.internal.ir.Node;
|
||||
import jdk.nashorn.internal.ir.SplitNode;
|
||||
import jdk.nashorn.internal.ir.visitor.NodeVisitor;
|
||||
import jdk.nashorn.internal.runtime.DebugLogger;
|
||||
import jdk.nashorn.internal.runtime.Source;
|
||||
import jdk.nashorn.internal.runtime.options.Options;
|
||||
|
||||
/**
|
||||
@ -221,12 +220,11 @@ final class Splitter extends NodeVisitor {
|
||||
* @return New split node.
|
||||
*/
|
||||
private SplitNode createBlockSplitNode(final Block parent, final FunctionNode function, final List<Node> statements, final long weight) {
|
||||
final Source source = parent.getSource();
|
||||
final long token = parent.getToken();
|
||||
final int finish = parent.getFinish();
|
||||
final String name = function.uniqueName(SPLIT_PREFIX.symbolName());
|
||||
|
||||
final Block newBlock = new Block(source, token, finish, statements);
|
||||
final Block newBlock = new Block(token, finish, statements);
|
||||
|
||||
return new SplitNode(name, newBlock, compiler.findUnit(weight + WeighNodes.FUNCTION_WEIGHT));
|
||||
}
|
||||
|
||||
@ -28,7 +28,6 @@ package jdk.nashorn.internal.ir;
|
||||
import jdk.nashorn.internal.codegen.types.Type;
|
||||
import jdk.nashorn.internal.ir.annotations.Immutable;
|
||||
import jdk.nashorn.internal.ir.visitor.NodeVisitor;
|
||||
import jdk.nashorn.internal.runtime.Source;
|
||||
|
||||
/**
|
||||
* IR representation of a property access (period operator.)
|
||||
@ -41,14 +40,13 @@ public final class AccessNode extends BaseNode {
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param source source code
|
||||
* @param token token
|
||||
* @param finish finish
|
||||
* @param base base node
|
||||
* @param property property
|
||||
*/
|
||||
public AccessNode(final Source source, final long token, final int finish, final Node base, final IdentNode property) {
|
||||
super(source, token, finish, base, false, false);
|
||||
public AccessNode(final long token, final int finish, final Node base, final IdentNode property) {
|
||||
super(token, finish, base, false, false);
|
||||
this.property = property.setIsPropertyName();
|
||||
}
|
||||
|
||||
|
||||
@ -29,7 +29,6 @@ import static jdk.nashorn.internal.codegen.ObjectClassGenerator.DEBUG_FIELDS;
|
||||
import jdk.nashorn.internal.codegen.ObjectClassGenerator;
|
||||
import jdk.nashorn.internal.codegen.types.Type;
|
||||
import jdk.nashorn.internal.ir.annotations.Immutable;
|
||||
import jdk.nashorn.internal.runtime.Source;
|
||||
|
||||
/**
|
||||
* IR base for accessing/indexing nodes.
|
||||
@ -50,15 +49,14 @@ public abstract class BaseNode extends Node implements FunctionCall, TypeOverrid
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param source source code
|
||||
* @param token token
|
||||
* @param finish finish
|
||||
* @param base base node
|
||||
* @param isFunction is this a function
|
||||
* @param hasCallSiteType does this access have a callsite type
|
||||
*/
|
||||
public BaseNode(final Source source, final long token, final int finish, final Node base, final boolean isFunction, final boolean hasCallSiteType) {
|
||||
super(source, token, base.getStart(), finish);
|
||||
public BaseNode(final long token, final int finish, final Node base, final boolean isFunction, final boolean hasCallSiteType) {
|
||||
super(token, base.getStart(), finish);
|
||||
this.base = base;
|
||||
this.isFunction = isFunction;
|
||||
this.hasCallSiteType = hasCallSiteType;
|
||||
|
||||
@ -29,7 +29,6 @@ import jdk.nashorn.internal.codegen.types.Type;
|
||||
import jdk.nashorn.internal.ir.annotations.Immutable;
|
||||
import jdk.nashorn.internal.ir.visitor.NodeVisitor;
|
||||
import jdk.nashorn.internal.parser.TokenType;
|
||||
import jdk.nashorn.internal.runtime.Source;
|
||||
|
||||
/**
|
||||
* BinaryNode nodes represent two operand operations.
|
||||
@ -44,13 +43,12 @@ public final class BinaryNode extends Node implements Assignment<Node> {
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param source source code
|
||||
* @param token token
|
||||
* @param lhs left hand side
|
||||
* @param rhs right hand side
|
||||
*/
|
||||
public BinaryNode(final Source source, final long token, final Node lhs, final Node rhs) {
|
||||
super(source, token, lhs.getStart(), rhs.getFinish());
|
||||
public BinaryNode(final long token, final Node lhs, final Node rhs) {
|
||||
super(token, lhs.getStart(), rhs.getFinish());
|
||||
this.lhs = lhs;
|
||||
this.rhs = rhs;
|
||||
}
|
||||
|
||||
@ -36,7 +36,6 @@ import java.util.Map;
|
||||
import jdk.nashorn.internal.codegen.Label;
|
||||
import jdk.nashorn.internal.ir.annotations.Immutable;
|
||||
import jdk.nashorn.internal.ir.visitor.NodeVisitor;
|
||||
import jdk.nashorn.internal.runtime.Source;
|
||||
|
||||
/**
|
||||
* IR representation for a list of statements and functions. All provides the
|
||||
@ -77,13 +76,12 @@ public class Block extends BreakableNode implements Flags<Block> {
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param source source code
|
||||
* @param token token
|
||||
* @param finish finish
|
||||
* @param statements statements
|
||||
*/
|
||||
public Block(final Source source, final long token, final int finish, final Node... statements) {
|
||||
super(source, token, finish, new Label("block_break"));
|
||||
public Block(final long token, final int finish, final Node... statements) {
|
||||
super(token, finish, new Label("block_break"));
|
||||
|
||||
this.statements = Arrays.asList(statements);
|
||||
this.symbols = new LinkedHashMap<>();
|
||||
@ -94,13 +92,12 @@ public class Block extends BreakableNode implements Flags<Block> {
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param source source code
|
||||
* @param token token
|
||||
* @param finish finish
|
||||
* @param statements statements
|
||||
*/
|
||||
public Block(final Source source, final long token, final int finish, final List<Node> statements) {
|
||||
this(source, token, finish, statements.toArray(new Node[statements.size()]));
|
||||
public Block(final long token, final int finish, final List<Node> statements) {
|
||||
this(token, finish, statements.toArray(new Node[statements.size()]));
|
||||
}
|
||||
|
||||
private Block(final Block block, final int finish, final List<Node> statements, final int flags, final Map<String, Symbol> symbols) {
|
||||
|
||||
@ -27,7 +27,6 @@ package jdk.nashorn.internal.ir;
|
||||
|
||||
import jdk.nashorn.internal.ir.annotations.Immutable;
|
||||
import jdk.nashorn.internal.ir.visitor.NodeVisitor;
|
||||
import jdk.nashorn.internal.runtime.Source;
|
||||
|
||||
/**
|
||||
* IR representation for {@code break} statements.
|
||||
@ -40,13 +39,12 @@ public final class BreakNode extends Node {
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param source source code
|
||||
* @param token token
|
||||
* @param finish finish
|
||||
* @param label label for break or null if none
|
||||
*/
|
||||
public BreakNode(final Source source, final long token, final int finish, final IdentNode label) {
|
||||
super(source, token, finish);
|
||||
public BreakNode(final long token, final int finish, final IdentNode label) {
|
||||
super(token, finish);
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
|
||||
@ -30,7 +30,6 @@ import java.util.List;
|
||||
|
||||
import jdk.nashorn.internal.codegen.Label;
|
||||
import jdk.nashorn.internal.ir.annotations.Immutable;
|
||||
import jdk.nashorn.internal.runtime.Source;
|
||||
|
||||
/**
|
||||
* This class represents a node from which control flow can execute
|
||||
@ -45,13 +44,12 @@ public abstract class BreakableNode extends LexicalContextNode {
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param source source code
|
||||
* @param token token
|
||||
* @param finish finish
|
||||
* @param breakLabel break label
|
||||
*/
|
||||
protected BreakableNode(final Source source, final long token, final int finish, final Label breakLabel) {
|
||||
super(source, token, finish);
|
||||
protected BreakableNode(final long token, final int finish, final Label breakLabel) {
|
||||
super(token, finish);
|
||||
this.breakLabel = breakLabel;
|
||||
}
|
||||
|
||||
|
||||
@ -31,7 +31,6 @@ import jdk.nashorn.internal.codegen.types.Type;
|
||||
import jdk.nashorn.internal.ir.annotations.Ignore;
|
||||
import jdk.nashorn.internal.ir.annotations.Immutable;
|
||||
import jdk.nashorn.internal.ir.visitor.NodeVisitor;
|
||||
import jdk.nashorn.internal.runtime.Source;
|
||||
|
||||
/**
|
||||
* IR representation for a function call.
|
||||
@ -137,14 +136,13 @@ public final class CallNode extends LexicalContextNode implements TypeOverride<C
|
||||
/**
|
||||
* Constructors
|
||||
*
|
||||
* @param source the source
|
||||
* @param token token
|
||||
* @param finish finish
|
||||
* @param function the function to call
|
||||
* @param args args to the call
|
||||
*/
|
||||
public CallNode(final Source source, final long token, final int finish, final Node function, final List<Node> args) {
|
||||
super(source, token, finish);
|
||||
public CallNode(final long token, final int finish, final Node function, final List<Node> args) {
|
||||
super(token, finish);
|
||||
|
||||
this.function = function;
|
||||
this.args = args;
|
||||
|
||||
@ -28,7 +28,6 @@ package jdk.nashorn.internal.ir;
|
||||
import jdk.nashorn.internal.codegen.Label;
|
||||
import jdk.nashorn.internal.ir.annotations.Immutable;
|
||||
import jdk.nashorn.internal.ir.visitor.NodeVisitor;
|
||||
import jdk.nashorn.internal.runtime.Source;
|
||||
|
||||
/**
|
||||
* IR representation of CASE clause.
|
||||
@ -48,14 +47,13 @@ public final class CaseNode extends Node {
|
||||
/**
|
||||
* Constructors
|
||||
*
|
||||
* @param source the source
|
||||
* @param token token
|
||||
* @param finish finish
|
||||
* @param test case test node, can be any node in JavaScript
|
||||
* @param body case body
|
||||
*/
|
||||
public CaseNode(final Source source, final long token, final int finish, final Node test, final Block body) {
|
||||
super(source, token, finish);
|
||||
public CaseNode(final long token, final int finish, final Node test, final Block body) {
|
||||
super(token, finish);
|
||||
|
||||
this.test = test;
|
||||
this.body = body;
|
||||
|
||||
@ -27,7 +27,6 @@ package jdk.nashorn.internal.ir;
|
||||
|
||||
import jdk.nashorn.internal.ir.annotations.Immutable;
|
||||
import jdk.nashorn.internal.ir.visitor.NodeVisitor;
|
||||
import jdk.nashorn.internal.runtime.Source;
|
||||
|
||||
/**
|
||||
* IR representation of a catch clause.
|
||||
@ -46,16 +45,14 @@ public final class CatchNode extends Node {
|
||||
/**
|
||||
* Constructors
|
||||
*
|
||||
* @param source the source
|
||||
* @param token token
|
||||
* @param finish finish
|
||||
* @param exception variable name of exception
|
||||
* @param exceptionCondition exception condition
|
||||
* @param body catch body
|
||||
*/
|
||||
public CatchNode(final Source source, final long token, final int finish, final IdentNode exception, final Node exceptionCondition, final Block body) {
|
||||
super(source, token, finish);
|
||||
|
||||
public CatchNode(final long token, final int finish, final IdentNode exception, final Node exceptionCondition, final Block body) {
|
||||
super(token, finish);
|
||||
this.exception = exception;
|
||||
this.exceptionCondition = exceptionCondition;
|
||||
this.body = body;
|
||||
@ -63,7 +60,6 @@ public final class CatchNode extends Node {
|
||||
|
||||
private CatchNode(final CatchNode catchNode, final IdentNode exception, final Node exceptionCondition, final Block body) {
|
||||
super(catchNode);
|
||||
|
||||
this.exception = exception;
|
||||
this.exceptionCondition = exceptionCondition;
|
||||
this.body = body;
|
||||
|
||||
@ -27,7 +27,6 @@ package jdk.nashorn.internal.ir;
|
||||
|
||||
import jdk.nashorn.internal.ir.annotations.Immutable;
|
||||
import jdk.nashorn.internal.ir.visitor.NodeVisitor;
|
||||
import jdk.nashorn.internal.runtime.Source;
|
||||
|
||||
/**
|
||||
* IR representation for CONTINUE statements.
|
||||
@ -40,13 +39,12 @@ public class ContinueNode extends Node {
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param source source code
|
||||
* @param token token
|
||||
* @param finish finish
|
||||
* @param label label for break or null if none
|
||||
*/
|
||||
public ContinueNode(final Source source, final long token, final int finish, final IdentNode label) {
|
||||
super(source, token, finish);
|
||||
public ContinueNode(final long token, final int finish, final IdentNode label) {
|
||||
super(token, finish);
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
|
||||
@ -27,7 +27,6 @@ package jdk.nashorn.internal.ir;
|
||||
|
||||
import jdk.nashorn.internal.ir.annotations.Immutable;
|
||||
import jdk.nashorn.internal.ir.visitor.NodeVisitor;
|
||||
import jdk.nashorn.internal.runtime.Source;
|
||||
|
||||
/**
|
||||
* IR representation for an empty statement.
|
||||
@ -47,12 +46,11 @@ public final class EmptyNode extends Node {
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param source the source
|
||||
* @param token token
|
||||
* @param finish finish
|
||||
*/
|
||||
public EmptyNode(final Source source, final long token, final int finish) {
|
||||
super(source, token, finish);
|
||||
public EmptyNode(final long token, final int finish) {
|
||||
super(token, finish);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -27,7 +27,6 @@ package jdk.nashorn.internal.ir;
|
||||
|
||||
import jdk.nashorn.internal.ir.annotations.Immutable;
|
||||
import jdk.nashorn.internal.ir.visitor.NodeVisitor;
|
||||
import jdk.nashorn.internal.runtime.Source;
|
||||
|
||||
/**
|
||||
* IR representation for executing bare expressions. Basically, an expression
|
||||
@ -42,13 +41,12 @@ public final class ExecuteNode extends Node {
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param source the source
|
||||
* @param token token
|
||||
* @param finish finish
|
||||
* @param expression the expression to execute
|
||||
*/
|
||||
public ExecuteNode(final Source source, final long token, final int finish, final Node expression) {
|
||||
super(source, token, finish);
|
||||
public ExecuteNode(final long token, final int finish, final Node expression) {
|
||||
super(token, finish);
|
||||
this.expression = expression;
|
||||
}
|
||||
|
||||
@ -63,7 +61,7 @@ public final class ExecuteNode extends Node {
|
||||
* @param expression an expression to wrap, from which source, tokens and finish are also inherited
|
||||
*/
|
||||
public ExecuteNode(final Node expression) {
|
||||
super(expression.getSource(), expression.getToken(), expression.getFinish());
|
||||
super(expression.getToken(), expression.getFinish());
|
||||
this.expression = expression;
|
||||
}
|
||||
|
||||
|
||||
@ -27,7 +27,6 @@ package jdk.nashorn.internal.ir;
|
||||
|
||||
import jdk.nashorn.internal.ir.annotations.Immutable;
|
||||
import jdk.nashorn.internal.ir.visitor.NodeVisitor;
|
||||
import jdk.nashorn.internal.runtime.Source;
|
||||
|
||||
/**
|
||||
* IR representing a FOR statement.
|
||||
@ -57,7 +56,6 @@ public final class ForNode extends LoopNode {
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param source the source
|
||||
* @param token token
|
||||
* @param finish finish
|
||||
* @param init init
|
||||
@ -66,8 +64,8 @@ public final class ForNode extends LoopNode {
|
||||
* @param modify modify
|
||||
* @param flags flags
|
||||
*/
|
||||
public ForNode(final Source source, final long token, final int finish, final Node init, final Node test, final Block body, final Node modify, final int flags) {
|
||||
super(source, token, finish, test, body, false);
|
||||
public ForNode(final long token, final int finish, final Node init, final Node test, final Block body, final Node modify, final int flags) {
|
||||
super(token, finish, test, body, false);
|
||||
this.init = init;
|
||||
this.modify = modify;
|
||||
this.flags = flags;
|
||||
|
||||
@ -86,6 +86,8 @@ public final class FunctionNode extends LexicalContextNode implements Flags<Func
|
||||
/** method has been emitted to bytecode */
|
||||
EMITTED
|
||||
}
|
||||
/** Source of entity. */
|
||||
private final Source source;
|
||||
|
||||
/** External function identifier. */
|
||||
@Ignore
|
||||
@ -223,8 +225,9 @@ public final class FunctionNode extends LexicalContextNode implements Flags<Func
|
||||
final List<IdentNode> parameters,
|
||||
final FunctionNode.Kind kind,
|
||||
final int flags) {
|
||||
super(source, token, finish);
|
||||
super(token, finish);
|
||||
|
||||
this.source = source;
|
||||
this.ident = ident;
|
||||
this.name = name;
|
||||
this.kind = kind;
|
||||
@ -265,6 +268,7 @@ public final class FunctionNode extends LexicalContextNode implements Flags<Func
|
||||
this.hints = hints;
|
||||
|
||||
// the fields below never change - they are final and assigned in constructor
|
||||
this.source = functionNode.source;
|
||||
this.name = functionNode.name;
|
||||
this.ident = functionNode.ident;
|
||||
this.namespace = functionNode.namespace;
|
||||
@ -281,6 +285,14 @@ public final class FunctionNode extends LexicalContextNode implements Flags<Func
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the source for this function
|
||||
* @return the source
|
||||
*/
|
||||
public Source getSource() {
|
||||
return source;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the version of this function node's code as it looked upon construction
|
||||
* i.e typically parsed and nothing else
|
||||
@ -300,6 +312,9 @@ public final class FunctionNode extends LexicalContextNode implements Flags<Func
|
||||
if (this.snapshot == this) {
|
||||
return this;
|
||||
}
|
||||
if (isProgram() || parameters.isEmpty()) {
|
||||
return this; //never specialize anything that won't be recompiled
|
||||
}
|
||||
return Node.replaceInLexicalContext(lc, this, new FunctionNode(this, lastToken, flags, returnType, compileUnit, compilationState, body, parameters, this, hints));
|
||||
}
|
||||
|
||||
|
||||
@ -34,7 +34,6 @@ import jdk.nashorn.internal.codegen.ObjectClassGenerator;
|
||||
import jdk.nashorn.internal.codegen.types.Type;
|
||||
import jdk.nashorn.internal.ir.annotations.Immutable;
|
||||
import jdk.nashorn.internal.ir.visitor.NodeVisitor;
|
||||
import jdk.nashorn.internal.runtime.Source;
|
||||
|
||||
/**
|
||||
* IR representation for an identifier.
|
||||
@ -56,13 +55,12 @@ public final class IdentNode extends Node implements PropertyKey, TypeOverride<I
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param source the source
|
||||
* @param token token
|
||||
* @param finish finish position
|
||||
* @param name name of identifier
|
||||
*/
|
||||
public IdentNode(final Source source, final long token, final int finish, final String name) {
|
||||
super(source, token, finish);
|
||||
public IdentNode(final long token, final int finish, final String name) {
|
||||
super(token, finish);
|
||||
this.name = name;
|
||||
this.callSiteType = null;
|
||||
this.flags = 0;
|
||||
|
||||
@ -27,7 +27,6 @@ package jdk.nashorn.internal.ir;
|
||||
|
||||
import jdk.nashorn.internal.ir.annotations.Immutable;
|
||||
import jdk.nashorn.internal.ir.visitor.NodeVisitor;
|
||||
import jdk.nashorn.internal.runtime.Source;
|
||||
|
||||
/**
|
||||
* IR representation for an IF statement.
|
||||
@ -46,15 +45,14 @@ public final class IfNode extends Node {
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param source the source
|
||||
* @param token token
|
||||
* @param finish finish
|
||||
* @param test test
|
||||
* @param pass block to execute when test passes
|
||||
* @param fail block to execute when test fails or null
|
||||
*/
|
||||
public IfNode(final Source source, final long token, final int finish, final Node test, final Block pass, final Block fail) {
|
||||
super(source, token, finish);
|
||||
public IfNode(final long token, final int finish, final Node test, final Block pass, final Block fail) {
|
||||
super(token, finish);
|
||||
this.test = test;
|
||||
this.pass = pass;
|
||||
this.fail = fail;
|
||||
|
||||
@ -28,7 +28,6 @@ package jdk.nashorn.internal.ir;
|
||||
import jdk.nashorn.internal.codegen.types.Type;
|
||||
import jdk.nashorn.internal.ir.annotations.Immutable;
|
||||
import jdk.nashorn.internal.ir.visitor.NodeVisitor;
|
||||
import jdk.nashorn.internal.runtime.Source;
|
||||
|
||||
/**
|
||||
* IR representation of an indexed access (brackets operator.)
|
||||
@ -41,14 +40,13 @@ public final class IndexNode extends BaseNode {
|
||||
/**
|
||||
* Constructors
|
||||
*
|
||||
* @param source the source
|
||||
* @param token token
|
||||
* @param finish finish
|
||||
* @param base base node for access
|
||||
* @param index index for access
|
||||
*/
|
||||
public IndexNode(final Source source, final long token, final int finish, final Node base, final Node index) {
|
||||
super(source, token, finish, base, false, false);
|
||||
public IndexNode(final long token, final int finish, final Node base, final Node index) {
|
||||
super(token, finish, base, false, false);
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
|
||||
@ -27,7 +27,6 @@ package jdk.nashorn.internal.ir;
|
||||
|
||||
import jdk.nashorn.internal.ir.annotations.Immutable;
|
||||
import jdk.nashorn.internal.ir.visitor.NodeVisitor;
|
||||
import jdk.nashorn.internal.runtime.Source;
|
||||
|
||||
/**
|
||||
* IR representation for a labeled statement.
|
||||
@ -43,14 +42,13 @@ public final class LabelNode extends LexicalContextNode {
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param source the source
|
||||
* @param token token
|
||||
* @param finish finish
|
||||
* @param label label identifier
|
||||
* @param body body of label node
|
||||
*/
|
||||
public LabelNode(final Source source, final long token, final int finish, final IdentNode label, final Block body) {
|
||||
super(source, token, finish);
|
||||
public LabelNode(final long token, final int finish, final IdentNode label, final Block body) {
|
||||
super(token, finish);
|
||||
|
||||
this.label = label;
|
||||
this.body = body;
|
||||
|
||||
@ -392,8 +392,7 @@ public class LexicalContext {
|
||||
*/
|
||||
public boolean isFunctionDefinedInCurrentCall(FunctionNode functionNode) {
|
||||
final LexicalContextNode parent = stack[sp - 2];
|
||||
if(parent instanceof CallNode && ((CallNode)parent).getFunction() == functionNode) {
|
||||
assert functionNode.getSource() == peek().getSource();
|
||||
if (parent instanceof CallNode && ((CallNode)parent).getFunction() == functionNode) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -540,13 +539,16 @@ public class LexicalContext {
|
||||
sb.append('@');
|
||||
sb.append(Debug.id(node));
|
||||
sb.append(':');
|
||||
final Source source = node.getSource();
|
||||
String src = source.toString();
|
||||
if (src.indexOf(File.pathSeparator) != -1) {
|
||||
src = src.substring(src.lastIndexOf(File.pathSeparator));
|
||||
if (node instanceof FunctionNode) {
|
||||
final Source source = ((FunctionNode)node).getSource();
|
||||
String src = source.toString();
|
||||
if (src.indexOf(File.pathSeparator) != -1) {
|
||||
src = src.substring(src.lastIndexOf(File.pathSeparator));
|
||||
}
|
||||
src += ' ';
|
||||
src += source.getLine(node.getStart());
|
||||
sb.append(src);
|
||||
}
|
||||
src += ' ';
|
||||
src += source.getLine(node.getStart());
|
||||
sb.append(' ');
|
||||
}
|
||||
sb.append(" ==> ]");
|
||||
|
||||
@ -25,7 +25,6 @@
|
||||
package jdk.nashorn.internal.ir;
|
||||
|
||||
import jdk.nashorn.internal.ir.visitor.NodeVisitor;
|
||||
import jdk.nashorn.internal.runtime.Source;
|
||||
|
||||
/**
|
||||
* Superclass for nodes that can be part of the lexical context
|
||||
@ -35,12 +34,11 @@ public abstract class LexicalContextNode extends Node {
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param source source
|
||||
* @param token token
|
||||
* @param finish finish
|
||||
*/
|
||||
protected LexicalContextNode(final Source source, final long token, final int finish) {
|
||||
super(source, token, finish);
|
||||
protected LexicalContextNode(final long token, final int finish) {
|
||||
super(token, finish);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -28,7 +28,6 @@ package jdk.nashorn.internal.ir;
|
||||
import jdk.nashorn.internal.ir.annotations.Immutable;
|
||||
import jdk.nashorn.internal.ir.visitor.NodeVisitor;
|
||||
import jdk.nashorn.internal.parser.Token;
|
||||
import jdk.nashorn.internal.runtime.Source;
|
||||
|
||||
/**
|
||||
* IR Node representing a line number
|
||||
@ -41,12 +40,11 @@ public final class LineNumberNode extends Node {
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param source the source
|
||||
* @param token token
|
||||
* @param lineNumber the line number
|
||||
*/
|
||||
public LineNumberNode(final Source source, final long token, final int lineNumber) {
|
||||
super(source, token, Token.descPosition(token));
|
||||
public LineNumberNode(final long token, final int lineNumber) {
|
||||
super(token, Token.descPosition(token));
|
||||
this.lineNumber = lineNumber;
|
||||
}
|
||||
|
||||
|
||||
@ -37,7 +37,6 @@ import jdk.nashorn.internal.parser.Token;
|
||||
import jdk.nashorn.internal.parser.TokenType;
|
||||
import jdk.nashorn.internal.runtime.JSType;
|
||||
import jdk.nashorn.internal.runtime.ScriptRuntime;
|
||||
import jdk.nashorn.internal.runtime.Source;
|
||||
import jdk.nashorn.internal.runtime.Undefined;
|
||||
|
||||
/**
|
||||
@ -50,16 +49,15 @@ public abstract class LiteralNode<T> extends Node implements PropertyKey {
|
||||
/** Literal value */
|
||||
protected final T value;
|
||||
|
||||
/**
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param source the source
|
||||
* @param token token
|
||||
* @param finish finish
|
||||
* @param value the value of the literal
|
||||
*/
|
||||
protected LiteralNode(final Source source, final long token, final int finish, final T value) {
|
||||
super(source, token, finish);
|
||||
protected LiteralNode(final long token, final int finish, final T value) {
|
||||
super(token, finish);
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@ -238,14 +236,13 @@ public abstract class LiteralNode<T> extends Node implements PropertyKey {
|
||||
/**
|
||||
* Create a new null literal
|
||||
*
|
||||
* @param source the source
|
||||
* @param token token
|
||||
* @param finish finish
|
||||
*
|
||||
* @return the new literal node
|
||||
*/
|
||||
public static LiteralNode<Node> newInstance(final Source source, final long token, final int finish) {
|
||||
return new NodeLiteralNode(source, token, finish);
|
||||
public static LiteralNode<Node> newInstance(final long token, final int finish) {
|
||||
return new NodeLiteralNode(token, finish);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -256,14 +253,14 @@ public abstract class LiteralNode<T> extends Node implements PropertyKey {
|
||||
* @return the new literal node
|
||||
*/
|
||||
public static LiteralNode<?> newInstance(final Node parent) {
|
||||
return new NodeLiteralNode(parent.getSource(), parent.getToken(), parent.getFinish());
|
||||
return new NodeLiteralNode(parent.getToken(), parent.getFinish());
|
||||
}
|
||||
|
||||
@Immutable
|
||||
private static final class BooleanLiteralNode extends LiteralNode<Boolean> {
|
||||
|
||||
private BooleanLiteralNode(final Source source, final long token, final int finish, final boolean value) {
|
||||
super(source, Token.recast(token, value ? TokenType.TRUE : TokenType.FALSE), finish, value);
|
||||
private BooleanLiteralNode(final long token, final int finish, final boolean value) {
|
||||
super(Token.recast(token, value ? TokenType.TRUE : TokenType.FALSE), finish, value);
|
||||
}
|
||||
|
||||
private BooleanLiteralNode(final BooleanLiteralNode literalNode) {
|
||||
@ -289,15 +286,14 @@ public abstract class LiteralNode<T> extends Node implements PropertyKey {
|
||||
/**
|
||||
* Create a new boolean literal
|
||||
*
|
||||
* @param source the source
|
||||
* @param token token
|
||||
* @param finish finish
|
||||
* @param value true or false
|
||||
*
|
||||
* @return the new literal node
|
||||
*/
|
||||
public static LiteralNode<Boolean> newInstance(final Source source, final long token, final int finish, final boolean value) {
|
||||
return new BooleanLiteralNode(source, token, finish, value);
|
||||
public static LiteralNode<Boolean> newInstance(final long token, final int finish, final boolean value) {
|
||||
return new BooleanLiteralNode(token, finish, value);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -309,7 +305,7 @@ public abstract class LiteralNode<T> extends Node implements PropertyKey {
|
||||
* @return the new literal node
|
||||
*/
|
||||
public static LiteralNode<?> newInstance(final Node parent, final boolean value) {
|
||||
return new BooleanLiteralNode(parent.getSource(), parent.getToken(), parent.getFinish(), value);
|
||||
return new BooleanLiteralNode(parent.getToken(), parent.getFinish(), value);
|
||||
}
|
||||
|
||||
@Immutable
|
||||
@ -317,8 +313,8 @@ public abstract class LiteralNode<T> extends Node implements PropertyKey {
|
||||
|
||||
private final Type type = numberGetType(value);
|
||||
|
||||
private NumberLiteralNode(final Source source, final long token, final int finish, final Number value) {
|
||||
super(source, Token.recast(token, TokenType.DECIMAL), finish, value);
|
||||
private NumberLiteralNode(final long token, final int finish, final Number value) {
|
||||
super(Token.recast(token, TokenType.DECIMAL), finish, value);
|
||||
}
|
||||
|
||||
private NumberLiteralNode(final NumberLiteralNode literalNode) {
|
||||
@ -353,15 +349,14 @@ public abstract class LiteralNode<T> extends Node implements PropertyKey {
|
||||
/**
|
||||
* Create a new number literal
|
||||
*
|
||||
* @param source the source
|
||||
* @param token token
|
||||
* @param finish finish
|
||||
* @param value literal value
|
||||
*
|
||||
* @return the new literal node
|
||||
*/
|
||||
public static LiteralNode<Number> newInstance(final Source source, final long token, final int finish, final Number value) {
|
||||
return new NumberLiteralNode(source, token, finish, value);
|
||||
public static LiteralNode<Number> newInstance(final long token, final int finish, final Number value) {
|
||||
return new NumberLiteralNode(token, finish, value);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -373,12 +368,12 @@ public abstract class LiteralNode<T> extends Node implements PropertyKey {
|
||||
* @return the new literal node
|
||||
*/
|
||||
public static LiteralNode<?> newInstance(final Node parent, final Number value) {
|
||||
return new NumberLiteralNode(parent.getSource(), parent.getToken(), parent.getFinish(), value);
|
||||
return new NumberLiteralNode(parent.getToken(), parent.getFinish(), value);
|
||||
}
|
||||
|
||||
private static class UndefinedLiteralNode extends LiteralNode<Undefined> {
|
||||
private UndefinedLiteralNode(final Source source, final long token, final int finish) {
|
||||
super(source, Token.recast(token, TokenType.OBJECT), finish, ScriptRuntime.UNDEFINED);
|
||||
private UndefinedLiteralNode(final long token, final int finish) {
|
||||
super(Token.recast(token, TokenType.OBJECT), finish, ScriptRuntime.UNDEFINED);
|
||||
}
|
||||
|
||||
private UndefinedLiteralNode(final UndefinedLiteralNode literalNode) {
|
||||
@ -389,15 +384,14 @@ public abstract class LiteralNode<T> extends Node implements PropertyKey {
|
||||
/**
|
||||
* Create a new undefined literal
|
||||
*
|
||||
* @param source the source
|
||||
* @param token token
|
||||
* @param finish finish
|
||||
* @param value undefined value, passed only for polymorphisism discrimination
|
||||
*
|
||||
* @return the new literal node
|
||||
*/
|
||||
public static LiteralNode<Undefined> newInstance(final Source source, final long token, final int finish, final Undefined value) {
|
||||
return new UndefinedLiteralNode(source, token, finish);
|
||||
public static LiteralNode<Undefined> newInstance(final long token, final int finish, final Undefined value) {
|
||||
return new UndefinedLiteralNode(token, finish);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -409,13 +403,13 @@ public abstract class LiteralNode<T> extends Node implements PropertyKey {
|
||||
* @return the new literal node
|
||||
*/
|
||||
public static LiteralNode<?> newInstance(final Node parent, final Undefined value) {
|
||||
return new UndefinedLiteralNode(parent.getSource(), parent.getToken(), parent.getFinish());
|
||||
return new UndefinedLiteralNode(parent.getToken(), parent.getFinish());
|
||||
}
|
||||
|
||||
@Immutable
|
||||
private static class StringLiteralNode extends LiteralNode<String> {
|
||||
private StringLiteralNode(final Source source, final long token, final int finish, final String value) {
|
||||
super(source, Token.recast(token, TokenType.STRING), finish, value);
|
||||
private StringLiteralNode(final long token, final int finish, final String value) {
|
||||
super(Token.recast(token, TokenType.STRING), finish, value);
|
||||
}
|
||||
|
||||
private StringLiteralNode(final StringLiteralNode literalNode) {
|
||||
@ -433,15 +427,14 @@ public abstract class LiteralNode<T> extends Node implements PropertyKey {
|
||||
/**
|
||||
* Create a new string literal
|
||||
*
|
||||
* @param source the source
|
||||
* @param token token
|
||||
* @param finish finish
|
||||
* @param value string value
|
||||
*
|
||||
* @return the new literal node
|
||||
*/
|
||||
public static LiteralNode<String> newInstance(final Source source, final long token, final int finish, final String value) {
|
||||
return new StringLiteralNode(source, token, finish, value);
|
||||
public static LiteralNode<String> newInstance(final long token, final int finish, final String value) {
|
||||
return new StringLiteralNode(token, finish, value);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -453,13 +446,13 @@ public abstract class LiteralNode<T> extends Node implements PropertyKey {
|
||||
* @return the new literal node
|
||||
*/
|
||||
public static LiteralNode<?> newInstance(final Node parent, final String value) {
|
||||
return new StringLiteralNode(parent.getSource(), parent.getToken(), parent.getFinish(), value);
|
||||
return new StringLiteralNode(parent.getToken(), parent.getFinish(), value);
|
||||
}
|
||||
|
||||
@Immutable
|
||||
private static class LexerTokenLiteralNode extends LiteralNode<LexerToken> {
|
||||
private LexerTokenLiteralNode(final Source source, final long token, final int finish, final LexerToken value) {
|
||||
super(source, Token.recast(token, TokenType.STRING), finish, value); //TODO is string the correct token type here?
|
||||
private LexerTokenLiteralNode(final long token, final int finish, final LexerToken value) {
|
||||
super(Token.recast(token, TokenType.STRING), finish, value); //TODO is string the correct token type here?
|
||||
}
|
||||
|
||||
private LexerTokenLiteralNode(final LexerTokenLiteralNode literalNode) {
|
||||
@ -480,15 +473,14 @@ public abstract class LiteralNode<T> extends Node implements PropertyKey {
|
||||
/**
|
||||
* Create a new literal node for a lexer token
|
||||
*
|
||||
* @param source the source
|
||||
* @param token token
|
||||
* @param finish finish
|
||||
* @param value lexer token value
|
||||
*
|
||||
* @return the new literal node
|
||||
*/
|
||||
public static LiteralNode<LexerToken> newInstance(final Source source, final long token, final int finish, final LexerToken value) {
|
||||
return new LexerTokenLiteralNode(source, token, finish, value);
|
||||
public static LiteralNode<LexerToken> newInstance(final long token, final int finish, final LexerToken value) {
|
||||
return new LexerTokenLiteralNode(token, finish, value);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -500,17 +492,17 @@ public abstract class LiteralNode<T> extends Node implements PropertyKey {
|
||||
* @return the new literal node
|
||||
*/
|
||||
public static LiteralNode<?> newInstance(final Node parent, final LexerToken value) {
|
||||
return new LexerTokenLiteralNode(parent.getSource(), parent.getToken(), parent.getFinish(), value);
|
||||
return new LexerTokenLiteralNode(parent.getToken(), parent.getFinish(), value);
|
||||
}
|
||||
|
||||
private static final class NodeLiteralNode extends LiteralNode<Node> {
|
||||
|
||||
private NodeLiteralNode(final Source source, final long token, final int finish) {
|
||||
this(source, token, finish, null);
|
||||
private NodeLiteralNode(final long token, final int finish) {
|
||||
this(token, finish, null);
|
||||
}
|
||||
|
||||
private NodeLiteralNode(final Source source, final long token, final int finish, final Node value) {
|
||||
super(source, Token.recast(token, TokenType.OBJECT), finish, value);
|
||||
private NodeLiteralNode(final long token, final int finish, final Node value) {
|
||||
super(Token.recast(token, TokenType.OBJECT), finish, value);
|
||||
}
|
||||
|
||||
private NodeLiteralNode(final LiteralNode<Node> literalNode) {
|
||||
@ -550,15 +542,14 @@ public abstract class LiteralNode<T> extends Node implements PropertyKey {
|
||||
/**
|
||||
* Create a new node literal for an arbitrary node
|
||||
*
|
||||
* @param source the source
|
||||
* @param token token
|
||||
* @param finish finish
|
||||
* @param value the literal value node
|
||||
*
|
||||
* @return the new literal node
|
||||
*/
|
||||
public static LiteralNode<Node> newInstance(final Source source, final long token, final int finish, final Node value) {
|
||||
return new NodeLiteralNode(source, token, finish, value);
|
||||
public static LiteralNode<Node> newInstance(final long token, final int finish, final Node value) {
|
||||
return new NodeLiteralNode(token, finish, value);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -570,7 +561,7 @@ public abstract class LiteralNode<T> extends Node implements PropertyKey {
|
||||
* @return the new literal node
|
||||
*/
|
||||
public static LiteralNode<?> newInstance(final Node parent, final Node value) {
|
||||
return new NodeLiteralNode(parent.getSource(), parent.getToken(), parent.getFinish(), value);
|
||||
return new NodeLiteralNode(parent.getToken(), parent.getFinish(), value);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -645,13 +636,12 @@ public abstract class LiteralNode<T> extends Node implements PropertyKey {
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param source the source
|
||||
* @param token token
|
||||
* @param finish finish
|
||||
* @param value array literal value, a Node array
|
||||
*/
|
||||
protected ArrayLiteralNode(final Source source, final long token, final int finish, final Node[] value) {
|
||||
super(source, Token.recast(token, TokenType.ARRAY), finish, value);
|
||||
protected ArrayLiteralNode(final long token, final int finish, final Node[] value) {
|
||||
super(Token.recast(token, TokenType.ARRAY), finish, value);
|
||||
this.elementType = Type.UNKNOWN;
|
||||
}
|
||||
|
||||
@ -886,15 +876,14 @@ public abstract class LiteralNode<T> extends Node implements PropertyKey {
|
||||
/**
|
||||
* Create a new array literal of Nodes from a list of Node values
|
||||
*
|
||||
* @param source the source
|
||||
* @param token token
|
||||
* @param finish finish
|
||||
* @param value literal value list
|
||||
*
|
||||
* @return the new literal node
|
||||
*/
|
||||
public static LiteralNode<Node[]> newInstance(final Source source, final long token, final int finish, final List<Node> value) {
|
||||
return new ArrayLiteralNode(source, token, finish, value.toArray(new Node[value.size()]));
|
||||
public static LiteralNode<Node[]> newInstance(final long token, final int finish, final List<Node> value) {
|
||||
return new ArrayLiteralNode(token, finish, value.toArray(new Node[value.size()]));
|
||||
}
|
||||
|
||||
|
||||
@ -907,20 +896,19 @@ public abstract class LiteralNode<T> extends Node implements PropertyKey {
|
||||
* @return the new literal node
|
||||
*/
|
||||
public static LiteralNode<?> newInstance(final Node parent, final List<Node> value) {
|
||||
return new ArrayLiteralNode(parent.getSource(), parent.getToken(), parent.getFinish(), value.toArray(new Node[value.size()]));
|
||||
return new ArrayLiteralNode(parent.getToken(), parent.getFinish(), value.toArray(new Node[value.size()]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new array literal of Nodes
|
||||
*
|
||||
* @param source the source
|
||||
* @param token token
|
||||
* @param finish finish
|
||||
* @param value literal value array
|
||||
*
|
||||
* @return the new literal node
|
||||
*/
|
||||
public static LiteralNode<Node[]> newInstance(final Source source, final long token, final int finish, final Node[] value) {
|
||||
return new ArrayLiteralNode(source, token, finish, value);
|
||||
public static LiteralNode<Node[]> newInstance(final long token, final int finish, final Node[] value) {
|
||||
return new ArrayLiteralNode(token, finish, value);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,134 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package jdk.nashorn.internal.ir;
|
||||
|
||||
import jdk.nashorn.internal.parser.Token;
|
||||
import jdk.nashorn.internal.parser.TokenType;
|
||||
import jdk.nashorn.internal.runtime.Source;
|
||||
|
||||
/**
|
||||
* Used to locate an entity back to it's source file.
|
||||
*/
|
||||
public class Location implements Cloneable {
|
||||
/** Source of entity. */
|
||||
private final Source source;
|
||||
|
||||
/** Token descriptor. */
|
||||
private final long token;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param source the source
|
||||
* @param token token
|
||||
*/
|
||||
public Location(final Source source, final long token) {
|
||||
this.source = source;
|
||||
this.token = token;
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy constructor
|
||||
*
|
||||
* @param location source node
|
||||
*/
|
||||
protected Location(final Location location) {
|
||||
this.source = location.source;
|
||||
this.token = location.token;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object clone() {
|
||||
try {
|
||||
return super.clone();
|
||||
} catch(CloneNotSupportedException e) {
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean equals(final Object other) {
|
||||
return super.equals(other);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int hashCode() {
|
||||
return super.hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return token position from a token descriptor.
|
||||
*
|
||||
* @return Start position of the token in the source.
|
||||
*/
|
||||
public int position() {
|
||||
return Token.descPosition(token);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return token length from a token descriptor.
|
||||
*
|
||||
* @return Length of the token.
|
||||
*/
|
||||
public int length() {
|
||||
return Token.descLength(token);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return token tokenType from a token descriptor.
|
||||
*
|
||||
* @return Type of token.
|
||||
*/
|
||||
public TokenType tokenType() {
|
||||
return Token.descType(token);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test token tokenType.
|
||||
*
|
||||
* @param type a type to check this token against
|
||||
* @return true if token types match.
|
||||
*/
|
||||
public boolean isTokenType(final TokenType type) {
|
||||
return Token.descType(token) == type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the source for this location
|
||||
* @return the source
|
||||
*/
|
||||
public Source getSource() {
|
||||
return source;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the token for this location
|
||||
* @return the token
|
||||
*/
|
||||
public long getToken() {
|
||||
return token;
|
||||
}
|
||||
}
|
||||
@ -29,7 +29,6 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import jdk.nashorn.internal.codegen.Label;
|
||||
import jdk.nashorn.internal.runtime.Source;
|
||||
|
||||
/**
|
||||
* A loop node, for example a while node, do while node or for node
|
||||
@ -50,15 +49,14 @@ public abstract class LoopNode extends BreakableNode {
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param source source
|
||||
* @param token token
|
||||
* @param finish finish
|
||||
* @param test test, or null if infinite loop
|
||||
* @param body loop body
|
||||
* @param controlFlowEscapes controlFlowEscapes
|
||||
*/
|
||||
protected LoopNode(final Source source, final long token, final int finish, final Node test, final Block body, final boolean controlFlowEscapes) {
|
||||
super(source, token, finish, new Label("while_break"));
|
||||
protected LoopNode(final long token, final int finish, final Node test, final Block body, final boolean controlFlowEscapes) {
|
||||
super(token, finish, new Label("while_break"));
|
||||
this.continueLabel = new Label("while_continue");
|
||||
this.test = test;
|
||||
this.body = body;
|
||||
|
||||
@ -31,12 +31,12 @@ import java.util.List;
|
||||
import jdk.nashorn.internal.codegen.types.Type;
|
||||
import jdk.nashorn.internal.ir.visitor.NodeVisitor;
|
||||
import jdk.nashorn.internal.parser.Token;
|
||||
import jdk.nashorn.internal.runtime.Source;
|
||||
import jdk.nashorn.internal.parser.TokenType;
|
||||
|
||||
/**
|
||||
* Nodes are used to compose Abstract Syntax Trees.
|
||||
*/
|
||||
public abstract class Node extends Location {
|
||||
public abstract class Node implements Cloneable {
|
||||
/** Node symbol. */
|
||||
private Symbol symbol;
|
||||
|
||||
@ -46,16 +46,17 @@ public abstract class Node extends Location {
|
||||
/** End of source range. */
|
||||
protected int finish;
|
||||
|
||||
/** Token descriptor. */
|
||||
private final long token;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param source the source
|
||||
* @param token token
|
||||
* @param finish finish
|
||||
*/
|
||||
public Node(final Source source, final long token, final int finish) {
|
||||
super(source, token);
|
||||
|
||||
public Node(final long token, final int finish) {
|
||||
this.token = token;
|
||||
this.start = Token.descPosition(token);
|
||||
this.finish = finish;
|
||||
}
|
||||
@ -63,16 +64,14 @@ public abstract class Node extends Location {
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param source source
|
||||
* @param token token
|
||||
* @param start start
|
||||
* @param finish finish
|
||||
*/
|
||||
protected Node(final Source source, final long token, final int start, final int finish) {
|
||||
super(source, token);
|
||||
|
||||
protected Node(final long token, final int start, final int finish) {
|
||||
this.start = start;
|
||||
this.finish = finish;
|
||||
this.token = token;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -81,8 +80,7 @@ public abstract class Node extends Location {
|
||||
* @param node source node
|
||||
*/
|
||||
protected Node(final Node node) {
|
||||
super(node);
|
||||
|
||||
this.token = node.token;
|
||||
this.symbol = node.symbol;
|
||||
this.start = node.start;
|
||||
this.finish = node.finish;
|
||||
@ -248,6 +246,15 @@ public abstract class Node extends Location {
|
||||
return symbol;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object clone() {
|
||||
try {
|
||||
return super.clone();
|
||||
} catch (final CloneNotSupportedException e) {
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Assign a symbol to this node. See {@link Node#getSymbol()} for explanation
|
||||
* of what a symbol is
|
||||
@ -265,6 +272,62 @@ public abstract class Node extends Location {
|
||||
return newNode;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public final boolean equals(final Object other) {
|
||||
return super.equals(other);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int hashCode() {
|
||||
return super.hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return token position from a token descriptor.
|
||||
*
|
||||
* @return Start position of the token in the source.
|
||||
*/
|
||||
public int position() {
|
||||
return Token.descPosition(token);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return token length from a token descriptor.
|
||||
*
|
||||
* @return Length of the token.
|
||||
*/
|
||||
public int length() {
|
||||
return Token.descLength(token);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return token tokenType from a token descriptor.
|
||||
*
|
||||
* @return Type of token.
|
||||
*/
|
||||
public TokenType tokenType() {
|
||||
return Token.descType(token);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test token tokenType.
|
||||
*
|
||||
* @param type a type to check this token against
|
||||
* @return true if token types match.
|
||||
*/
|
||||
public boolean isTokenType(final TokenType type) {
|
||||
return Token.descType(token) == type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the token for this location
|
||||
* @return the token
|
||||
*/
|
||||
public long getToken() {
|
||||
return token;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this a terminal Node, i.e. does it end control flow like a throw or return
|
||||
* expression does?
|
||||
|
||||
@ -30,7 +30,6 @@ import java.util.List;
|
||||
|
||||
import jdk.nashorn.internal.ir.annotations.Immutable;
|
||||
import jdk.nashorn.internal.ir.visitor.NodeVisitor;
|
||||
import jdk.nashorn.internal.runtime.Source;
|
||||
|
||||
/**
|
||||
* IR representation of an object literal.
|
||||
@ -44,13 +43,12 @@ public final class ObjectNode extends Node {
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param source the source
|
||||
* @param token token
|
||||
* @param finish finish
|
||||
* @param elements the elements used to initialize this ObjectNode
|
||||
*/
|
||||
public ObjectNode(final Source source, final long token, final int finish, final List<Node> elements) {
|
||||
super(source, token, finish);
|
||||
public ObjectNode(final long token, final int finish, final List<Node> elements) {
|
||||
super(token, finish);
|
||||
this.elements = elements;
|
||||
}
|
||||
|
||||
|
||||
@ -27,7 +27,6 @@ package jdk.nashorn.internal.ir;
|
||||
|
||||
import jdk.nashorn.internal.ir.annotations.Immutable;
|
||||
import jdk.nashorn.internal.ir.visitor.NodeVisitor;
|
||||
import jdk.nashorn.internal.runtime.Source;
|
||||
|
||||
/**
|
||||
* IR representation of an object literal property.
|
||||
@ -50,7 +49,6 @@ public final class PropertyNode extends Node {
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param source the source
|
||||
* @param token token
|
||||
* @param finish finish
|
||||
* @param key the key of this property
|
||||
@ -58,8 +56,8 @@ public final class PropertyNode extends Node {
|
||||
* @param getter getter function body
|
||||
* @param setter setter function body
|
||||
*/
|
||||
public PropertyNode(final Source source, final long token, final int finish, final PropertyKey key, final Node value, final FunctionNode getter, final FunctionNode setter) {
|
||||
super(source, token, finish);
|
||||
public PropertyNode(final long token, final int finish, final PropertyKey key, final Node value, final FunctionNode getter, final FunctionNode setter) {
|
||||
super(token, finish);
|
||||
this.key = key;
|
||||
this.value = value;
|
||||
this.getter = getter;
|
||||
|
||||
@ -29,7 +29,6 @@ import static jdk.nashorn.internal.parser.TokenType.RETURN;
|
||||
import static jdk.nashorn.internal.parser.TokenType.YIELD;
|
||||
import jdk.nashorn.internal.ir.annotations.Immutable;
|
||||
import jdk.nashorn.internal.ir.visitor.NodeVisitor;
|
||||
import jdk.nashorn.internal.runtime.Source;
|
||||
|
||||
/**
|
||||
* IR representation for RETURN or YIELD statements.
|
||||
@ -42,13 +41,12 @@ public class ReturnNode extends Node {
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param source the source
|
||||
* @param token token
|
||||
* @param finish finish
|
||||
* @param expression expression to return
|
||||
*/
|
||||
public ReturnNode(final Source source, final long token, final int finish, final Node expression) {
|
||||
super(source, token, finish);
|
||||
public ReturnNode(final long token, final int finish, final Node expression) {
|
||||
super(token, finish);
|
||||
this.expression = expression;
|
||||
}
|
||||
|
||||
|
||||
@ -33,7 +33,6 @@ import jdk.nashorn.internal.codegen.types.Type;
|
||||
import jdk.nashorn.internal.ir.annotations.Immutable;
|
||||
import jdk.nashorn.internal.ir.visitor.NodeVisitor;
|
||||
import jdk.nashorn.internal.parser.TokenType;
|
||||
import jdk.nashorn.internal.runtime.Source;
|
||||
|
||||
/**
|
||||
* IR representation for a runtime call.
|
||||
@ -280,14 +279,13 @@ public class RuntimeNode extends Node implements TypeOverride<RuntimeNode> {
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param source the source
|
||||
* @param token token
|
||||
* @param finish finish
|
||||
* @param request the request
|
||||
* @param args arguments to request
|
||||
*/
|
||||
public RuntimeNode(final Source source, final long token, final int finish, final Request request, final List<Node> args) {
|
||||
super(source, token, finish);
|
||||
public RuntimeNode(final long token, final int finish, final Request request, final List<Node> args) {
|
||||
super(token, finish);
|
||||
|
||||
this.request = request;
|
||||
this.args = args;
|
||||
@ -307,14 +305,13 @@ public class RuntimeNode extends Node implements TypeOverride<RuntimeNode> {
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param source the source
|
||||
* @param token token
|
||||
* @param finish finish
|
||||
* @param request the request
|
||||
* @param args arguments to request
|
||||
*/
|
||||
public RuntimeNode(final Source source, final long token, final int finish, final Request request, final Node... args) {
|
||||
this(source, token, finish, request, Arrays.asList(args));
|
||||
public RuntimeNode(final long token, final int finish, final Request request, final Node... args) {
|
||||
this(token, finish, request, Arrays.asList(args));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -51,7 +51,7 @@ public class SplitNode extends LexicalContextNode {
|
||||
* @param compileUnit compile unit to use for the body
|
||||
*/
|
||||
public SplitNode(final String name, final Node body, final CompileUnit compileUnit) {
|
||||
super(body.getSource(), body.getToken(), body.getFinish());
|
||||
super(body.getToken(), body.getFinish());
|
||||
this.name = name;
|
||||
this.body = body;
|
||||
this.compileUnit = compileUnit;
|
||||
|
||||
@ -32,7 +32,6 @@ import java.util.List;
|
||||
import jdk.nashorn.internal.codegen.Label;
|
||||
import jdk.nashorn.internal.ir.annotations.Immutable;
|
||||
import jdk.nashorn.internal.ir.visitor.NodeVisitor;
|
||||
import jdk.nashorn.internal.runtime.Source;
|
||||
|
||||
/**
|
||||
* IR representation of a SWITCH statement.
|
||||
@ -54,15 +53,14 @@ public final class SwitchNode extends BreakableNode {
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param source the source
|
||||
* @param token token
|
||||
* @param finish finish
|
||||
* @param expression switch expression
|
||||
* @param cases cases
|
||||
* @param defaultCase the default case node - null if none, otherwise has to be present in cases list
|
||||
*/
|
||||
public SwitchNode(final Source source, final long token, final int finish, final Node expression, final List<CaseNode> cases, final CaseNode defaultCase) {
|
||||
super(source, token, finish, new Label("switch_break"));
|
||||
public SwitchNode(final long token, final int finish, final Node expression, final List<CaseNode> cases, final CaseNode defaultCase) {
|
||||
super(token, finish, new Label("switch_break"));
|
||||
this.expression = expression;
|
||||
this.cases = cases;
|
||||
this.defaultCaseIndex = defaultCase == null ? -1 : cases.indexOf(defaultCase);
|
||||
|
||||
@ -27,7 +27,6 @@ package jdk.nashorn.internal.ir;
|
||||
|
||||
import jdk.nashorn.internal.ir.annotations.Immutable;
|
||||
import jdk.nashorn.internal.ir.visitor.NodeVisitor;
|
||||
import jdk.nashorn.internal.runtime.Source;
|
||||
|
||||
/**
|
||||
* TernaryNode nodes represent three operand operations (?:).
|
||||
@ -44,14 +43,13 @@ public final class TernaryNode extends Node {
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param source the source
|
||||
* @param token token
|
||||
* @param lhs left hand side node
|
||||
* @param rhs right hand side node
|
||||
* @param third third node
|
||||
*/
|
||||
public TernaryNode(final Source source, final long token, final Node lhs, final Node rhs, final Node third) {
|
||||
super(source, token, third.getFinish());
|
||||
public TernaryNode(final long token, final Node lhs, final Node rhs, final Node third) {
|
||||
super(token, third.getFinish());
|
||||
this.lhs = lhs;
|
||||
this.rhs = rhs;
|
||||
this.third = third;
|
||||
|
||||
@ -27,7 +27,6 @@ package jdk.nashorn.internal.ir;
|
||||
|
||||
import jdk.nashorn.internal.ir.annotations.Immutable;
|
||||
import jdk.nashorn.internal.ir.visitor.NodeVisitor;
|
||||
import jdk.nashorn.internal.runtime.Source;
|
||||
|
||||
/**
|
||||
* IR representation for THROW statements.
|
||||
@ -40,14 +39,12 @@ public final class ThrowNode extends Node {
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param source the source
|
||||
* @param token token
|
||||
* @param finish finish
|
||||
* @param expression expression to throw
|
||||
*/
|
||||
public ThrowNode(final Source source, final long token, final int finish, final Node expression) {
|
||||
super(source, token, finish);
|
||||
|
||||
public ThrowNode(final long token, final int finish, final Node expression) {
|
||||
super(token, finish);
|
||||
this.expression = expression;
|
||||
}
|
||||
|
||||
|
||||
@ -32,7 +32,6 @@ import java.util.List;
|
||||
import jdk.nashorn.internal.codegen.Label;
|
||||
import jdk.nashorn.internal.ir.annotations.Immutable;
|
||||
import jdk.nashorn.internal.ir.visitor.NodeVisitor;
|
||||
import jdk.nashorn.internal.runtime.Source;
|
||||
|
||||
/**
|
||||
* IR representation of a TRY statement.
|
||||
@ -60,15 +59,14 @@ public final class TryNode extends Node {
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param source the source
|
||||
* @param token token
|
||||
* @param finish finish
|
||||
* @param body try node body
|
||||
* @param catchBlocks list of catch blocks in order
|
||||
* @param finallyBody body of finally block or null if none
|
||||
*/
|
||||
public TryNode(final Source source, final long token, final int finish, final Block body, final List<Block> catchBlocks, final Block finallyBody) {
|
||||
super(source, token, finish);
|
||||
public TryNode(final long token, final int finish, final Block body, final List<Block> catchBlocks, final Block finallyBody) {
|
||||
super(token, finish);
|
||||
this.body = body;
|
||||
this.catchBlocks = catchBlocks;
|
||||
this.finallyBody = finallyBody;
|
||||
|
||||
@ -35,7 +35,6 @@ import jdk.nashorn.internal.ir.annotations.Immutable;
|
||||
import jdk.nashorn.internal.ir.visitor.NodeVisitor;
|
||||
import jdk.nashorn.internal.parser.Token;
|
||||
import jdk.nashorn.internal.parser.TokenType;
|
||||
import jdk.nashorn.internal.runtime.Source;
|
||||
|
||||
/**
|
||||
* UnaryNode nodes represent single operand operations.
|
||||
@ -48,24 +47,23 @@ public final class UnaryNode extends Node implements Assignment<Node> {
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param source the source
|
||||
* @param token token
|
||||
* @param rhs expression
|
||||
*/
|
||||
public UnaryNode(final Source source, final long token, final Node rhs) {
|
||||
this(source, token, Math.min(rhs.getStart(), Token.descPosition(token)), Math.max(Token.descPosition(token) + Token.descLength(token), rhs.getFinish()), rhs);
|
||||
public UnaryNode(final long token, final Node rhs) {
|
||||
this(token, Math.min(rhs.getStart(), Token.descPosition(token)), Math.max(Token.descPosition(token) + Token.descLength(token), rhs.getFinish()), rhs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param source the source
|
||||
*
|
||||
* @param token token
|
||||
* @param start start
|
||||
* @param finish finish
|
||||
* @param rhs expression
|
||||
*/
|
||||
public UnaryNode(final Source source, final long token, final int start, final int finish, final Node rhs) {
|
||||
super(source, token, start, finish);
|
||||
public UnaryNode(final long token, final int start, final int finish, final Node rhs) {
|
||||
super(token, start, finish);
|
||||
this.rhs = rhs;
|
||||
}
|
||||
|
||||
|
||||
@ -27,7 +27,6 @@ package jdk.nashorn.internal.ir;
|
||||
|
||||
import jdk.nashorn.internal.ir.annotations.Immutable;
|
||||
import jdk.nashorn.internal.ir.visitor.NodeVisitor;
|
||||
import jdk.nashorn.internal.runtime.Source;
|
||||
|
||||
/**
|
||||
* Node represents a var/let declaration.
|
||||
@ -54,14 +53,13 @@ public final class VarNode extends Node implements Assignment<IdentNode> {
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param source the source
|
||||
* @param token token
|
||||
* @param finish finish
|
||||
* @param name name of variable
|
||||
* @param init init node or null if just a declaration
|
||||
*/
|
||||
public VarNode(final Source source, final long token, final int finish, final IdentNode name, final Node init) {
|
||||
this(source, token, finish, name, init, IS_STATEMENT);
|
||||
public VarNode(final long token, final int finish, final IdentNode name, final Node init) {
|
||||
this(token, finish, name, init, IS_STATEMENT);
|
||||
}
|
||||
|
||||
private VarNode(final VarNode varNode, final IdentNode name, final Node init, final int flags) {
|
||||
@ -74,15 +72,14 @@ public final class VarNode extends Node implements Assignment<IdentNode> {
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param source the source
|
||||
* @param token token
|
||||
* @param finish finish
|
||||
* @param name name of variable
|
||||
* @param init init node or null if just a declaration
|
||||
* @param flags flags
|
||||
*/
|
||||
public VarNode(final Source source, final long token, final int finish, final IdentNode name, final Node init, final int flags) {
|
||||
super(source, token, finish);
|
||||
public VarNode(final long token, final int finish, final IdentNode name, final Node init, final int flags) {
|
||||
super(token, finish);
|
||||
|
||||
this.name = init == null ? name : name.setIsInitializedHere();
|
||||
this.init = init;
|
||||
|
||||
@ -27,7 +27,6 @@ package jdk.nashorn.internal.ir;
|
||||
|
||||
import jdk.nashorn.internal.ir.annotations.Immutable;
|
||||
import jdk.nashorn.internal.ir.visitor.NodeVisitor;
|
||||
import jdk.nashorn.internal.runtime.Source;
|
||||
|
||||
/**
|
||||
* IR representation for a WHILE statement. This is the superclass of all
|
||||
@ -42,13 +41,12 @@ public final class WhileNode extends LoopNode {
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param source the source
|
||||
* @param token token
|
||||
* @param finish finish
|
||||
* @param isDoWhile is this a do while loop?
|
||||
*/
|
||||
public WhileNode(final Source source, final long token, final int finish, final boolean isDoWhile) {
|
||||
super(source, token, finish, null, null, false);
|
||||
public WhileNode(final long token, final int finish, final boolean isDoWhile) {
|
||||
super(token, finish, null, null, false);
|
||||
this.isDoWhile = isDoWhile;
|
||||
}
|
||||
|
||||
|
||||
@ -27,7 +27,6 @@ package jdk.nashorn.internal.ir;
|
||||
|
||||
import jdk.nashorn.internal.ir.annotations.Immutable;
|
||||
import jdk.nashorn.internal.ir.visitor.NodeVisitor;
|
||||
import jdk.nashorn.internal.runtime.Source;
|
||||
|
||||
/**
|
||||
* IR representation for {@code with} statements.
|
||||
@ -43,20 +42,17 @@ public final class WithNode extends LexicalContextNode {
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param source the source
|
||||
* @param token token
|
||||
* @param finish finish
|
||||
*/
|
||||
public WithNode(final Source source, final long token, final int finish) {
|
||||
super(source, token, finish);
|
||||
|
||||
public WithNode(final long token, final int finish) {
|
||||
super(token, finish);
|
||||
this.expression = null;
|
||||
this.body = null;
|
||||
}
|
||||
|
||||
private WithNode(final WithNode node, final Node expression, final Block body) {
|
||||
super(node);
|
||||
|
||||
this.expression = expression;
|
||||
this.body = body;
|
||||
}
|
||||
|
||||
@ -971,7 +971,7 @@ public final class JSONWriter extends NodeVisitor {
|
||||
objectStart("loc");
|
||||
|
||||
// source name
|
||||
final Source src = node.getSource();
|
||||
final Source src = getLexicalContext().getCurrentFunction().getSource();
|
||||
property("source", src.getName());
|
||||
comma();
|
||||
|
||||
|
||||
@ -178,7 +178,6 @@ public final class NativeDebug extends ScriptObject {
|
||||
* @param self self reference
|
||||
* @return undefined
|
||||
*/
|
||||
@SuppressWarnings("resource")
|
||||
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
|
||||
public static Object dumpCounters(final Object self) {
|
||||
final PrintWriter out = Context.getCurrentErr();
|
||||
|
||||
@ -364,7 +364,7 @@ public abstract class AbstractParser {
|
||||
next();
|
||||
|
||||
// Create IDENT node.
|
||||
return new IdentNode(source, identToken, finish, ident);
|
||||
return new IdentNode(identToken, finish, ident);
|
||||
}
|
||||
|
||||
// Get IDENT.
|
||||
@ -373,7 +373,7 @@ public abstract class AbstractParser {
|
||||
return null;
|
||||
}
|
||||
// Create IDENT node.
|
||||
return new IdentNode(source, identToken, finish, ident);
|
||||
return new IdentNode(identToken, finish, ident);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -408,7 +408,7 @@ public abstract class AbstractParser {
|
||||
final String ident = (String)getValue(identToken);
|
||||
next();
|
||||
// Create IDENT node.
|
||||
return new IdentNode(source, identToken, finish, ident);
|
||||
return new IdentNode(identToken, finish, ident);
|
||||
} else {
|
||||
expect(IDENT);
|
||||
return null;
|
||||
@ -433,11 +433,11 @@ public abstract class AbstractParser {
|
||||
LiteralNode<?> node = null;
|
||||
|
||||
if (value == null) {
|
||||
node = LiteralNode.newInstance(source, literalToken, finish);
|
||||
node = LiteralNode.newInstance(literalToken, finish);
|
||||
} else if (value instanceof Number) {
|
||||
node = LiteralNode.newInstance(source, literalToken, finish, (Number)value);
|
||||
node = LiteralNode.newInstance(literalToken, finish, (Number)value);
|
||||
} else if (value instanceof String) {
|
||||
node = LiteralNode.newInstance(source, literalToken, finish, (String)value);
|
||||
node = LiteralNode.newInstance(literalToken, finish, (String)value);
|
||||
} else if (value instanceof LexerToken) {
|
||||
if (value instanceof RegexToken) {
|
||||
final RegexToken regex = (RegexToken)value;
|
||||
@ -447,7 +447,7 @@ public abstract class AbstractParser {
|
||||
throw error(e.getMessage());
|
||||
}
|
||||
}
|
||||
node = LiteralNode.newInstance(source, literalToken, finish, (LexerToken)value);
|
||||
node = LiteralNode.newInstance(literalToken, finish, (LexerToken)value);
|
||||
} else {
|
||||
assert false : "unknown type for LiteralNode: " + value.getClass();
|
||||
}
|
||||
|
||||
@ -193,13 +193,13 @@ public class JSONParser extends AbstractParser {
|
||||
return getLiteral();
|
||||
case FALSE:
|
||||
next();
|
||||
return LiteralNode.newInstance(source, literalToken, finish, false);
|
||||
return LiteralNode.newInstance(literalToken, finish, false);
|
||||
case TRUE:
|
||||
next();
|
||||
return LiteralNode.newInstance(source, literalToken, finish, true);
|
||||
return LiteralNode.newInstance(literalToken, finish, true);
|
||||
case NULL:
|
||||
next();
|
||||
return LiteralNode.newInstance(source, literalToken, finish);
|
||||
return LiteralNode.newInstance(literalToken, finish);
|
||||
case LBRACKET:
|
||||
return arrayLiteral();
|
||||
case LBRACE:
|
||||
@ -218,7 +218,7 @@ public class JSONParser extends AbstractParser {
|
||||
|
||||
if (value instanceof Number) {
|
||||
next();
|
||||
return new UnaryNode(source, literalToken, LiteralNode.newInstance(source, realToken, finish, (Number)value));
|
||||
return new UnaryNode(literalToken, LiteralNode.newInstance(realToken, finish, (Number)value));
|
||||
}
|
||||
|
||||
throw error(AbstractParser.message("expected", "number", type.getNameOrType()));
|
||||
@ -250,7 +250,7 @@ loop:
|
||||
switch (type) {
|
||||
case RBRACKET:
|
||||
next();
|
||||
result = LiteralNode.newInstance(source, arrayToken, finish, elements);
|
||||
result = LiteralNode.newInstance(arrayToken, finish, elements);
|
||||
break loop;
|
||||
|
||||
case COMMARIGHT:
|
||||
@ -310,7 +310,7 @@ loop:
|
||||
}
|
||||
|
||||
// Construct new object literal.
|
||||
return new ObjectNode(source, objectToken, finish, elements);
|
||||
return new ObjectNode(objectToken, finish, elements);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -331,7 +331,7 @@ loop:
|
||||
if (name != null) {
|
||||
expect(COLON);
|
||||
final Node value = jsonLiteral();
|
||||
return new PropertyNode(source, propertyToken, value.getFinish(), name, value, null, null);
|
||||
return new PropertyNode(propertyToken, value.getFinish(), name, value, null, null);
|
||||
}
|
||||
|
||||
// Raise an error.
|
||||
|
||||
@ -275,8 +275,7 @@ loop:
|
||||
* @return New block.
|
||||
*/
|
||||
private Block newBlock() {
|
||||
final Block block = new Block(source, token, Token.descPosition(token));
|
||||
return lc.push(block);
|
||||
return lc.push(new Block(token, Token.descPosition(token)));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -479,7 +478,7 @@ loop:
|
||||
}
|
||||
|
||||
// Build up node.
|
||||
return new BinaryNode(source, op, lhs, rhs);
|
||||
return new BinaryNode(op, lhs, rhs);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -490,12 +489,12 @@ loop:
|
||||
* @param isPostfix Prefix or postfix.
|
||||
* @return Reduced expression.
|
||||
*/
|
||||
private Node incDecExpression(final long firstToken, final TokenType tokenType, final Node expression, final boolean isPostfix) {
|
||||
private static Node incDecExpression(final long firstToken, final TokenType tokenType, final Node expression, final boolean isPostfix) {
|
||||
if (isPostfix) {
|
||||
return new UnaryNode(source, Token.recast(firstToken, tokenType == DECPREFIX ? DECPOSTFIX : INCPOSTFIX), expression.getStart(), Token.descPosition(firstToken) + Token.descLength(firstToken), expression);
|
||||
return new UnaryNode(Token.recast(firstToken, tokenType == DECPREFIX ? DECPOSTFIX : INCPOSTFIX), expression.getStart(), Token.descPosition(firstToken) + Token.descLength(firstToken), expression);
|
||||
}
|
||||
|
||||
return new UnaryNode(source, firstToken, expression);
|
||||
return new UnaryNode(firstToken, expression);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -524,7 +523,7 @@ loop:
|
||||
|
||||
FunctionNode script = newFunctionNode(
|
||||
functionToken,
|
||||
new IdentNode(source, functionToken, Token.descPosition(functionToken), scriptName),
|
||||
new IdentNode(functionToken, Token.descPosition(functionToken), scriptName),
|
||||
new ArrayList<IdentNode>(),
|
||||
FunctionNode.Kind.SCRIPT);
|
||||
|
||||
@ -774,7 +773,7 @@ loop:
|
||||
private void block() {
|
||||
final Block newBlock = getBlock(true);
|
||||
// Force block execution.
|
||||
appendStatement(new ExecuteNode(source, newBlock.getToken(), finish, newBlock));
|
||||
appendStatement(new ExecuteNode(newBlock.getToken(), finish, newBlock));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -867,7 +866,7 @@ loop:
|
||||
}
|
||||
|
||||
// Allocate var node.
|
||||
final VarNode var = new VarNode(source, varToken, finish, name, init);
|
||||
final VarNode var = new VarNode(varToken, finish, name, init);
|
||||
vars.add(var);
|
||||
appendStatement(var);
|
||||
|
||||
@ -899,7 +898,7 @@ loop:
|
||||
*/
|
||||
private void emptyStatement() {
|
||||
if (env._empty_statements) {
|
||||
appendStatement(new EmptyNode(source, token, Token.descPosition(token) + Token.descLength(token)));
|
||||
appendStatement(new EmptyNode(token, Token.descPosition(token) + Token.descLength(token)));
|
||||
}
|
||||
|
||||
// SEMICOLON checked in caller.
|
||||
@ -923,7 +922,7 @@ loop:
|
||||
|
||||
ExecuteNode executeNode = null;
|
||||
if (expression != null) {
|
||||
executeNode = new ExecuteNode(source, expressionToken, finish, expression);
|
||||
executeNode = new ExecuteNode(expressionToken, finish, expression);
|
||||
appendStatement(executeNode);
|
||||
} else {
|
||||
expect(null);
|
||||
@ -963,7 +962,7 @@ loop:
|
||||
fail = getStatement();
|
||||
}
|
||||
|
||||
appendStatement(new IfNode(source, ifToken, fail != null ? fail.getFinish() : pass.getFinish(), test, pass, fail));
|
||||
appendStatement(new IfNode(ifToken, fail != null ? fail.getFinish() : pass.getFinish(), test, pass, fail));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -980,7 +979,7 @@ loop:
|
||||
*/
|
||||
private void forStatement() {
|
||||
// Create FOR node, capturing FOR token.
|
||||
ForNode forNode = new ForNode(source, token, Token.descPosition(token), null, null, null, null, ForNode.IS_FOR);
|
||||
ForNode forNode = new ForNode(token, Token.descPosition(token), null, null, null, null, ForNode.IS_FOR);
|
||||
|
||||
|
||||
// Set up new block for scope of vars. Captures first token.
|
||||
@ -1084,7 +1083,7 @@ loop:
|
||||
outer = restoreBlock(outer);
|
||||
}
|
||||
|
||||
appendStatement(new ExecuteNode(source, outer.getToken(), outer.getFinish(), outer));
|
||||
appendStatement(new ExecuteNode(outer.getToken(), outer.getFinish(), outer));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1120,7 +1119,7 @@ loop:
|
||||
next();
|
||||
|
||||
// Construct WHILE node.
|
||||
WhileNode whileNode = new WhileNode(source, whileToken, Token.descPosition(whileToken), false);
|
||||
WhileNode whileNode = new WhileNode(whileToken, Token.descPosition(whileToken), false);
|
||||
lc.push(whileNode);
|
||||
|
||||
try {
|
||||
@ -1150,7 +1149,7 @@ loop:
|
||||
// DO tested in the caller.
|
||||
next();
|
||||
|
||||
WhileNode doWhileNode = new WhileNode(source, doToken, Token.descPosition(doToken), true);
|
||||
WhileNode doWhileNode = new WhileNode(doToken, Token.descPosition(doToken), true);
|
||||
lc.push(doWhileNode);
|
||||
|
||||
try {
|
||||
@ -1216,7 +1215,7 @@ loop:
|
||||
endOfLine();
|
||||
|
||||
// Construct and add CONTINUE node.
|
||||
appendStatement(new ContinueNode(source, continueToken, finish, label == null ? null : new IdentNode(label)));
|
||||
appendStatement(new ContinueNode(continueToken, finish, label == null ? null : new IdentNode(label)));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1263,7 +1262,7 @@ loop:
|
||||
endOfLine();
|
||||
|
||||
// Construct and add BREAK node.
|
||||
appendStatement(new BreakNode(source, breakToken, finish, label == null ? null : new IdentNode(label)));
|
||||
appendStatement(new BreakNode(breakToken, finish, label == null ? null : new IdentNode(label)));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1302,7 +1301,7 @@ loop:
|
||||
endOfLine();
|
||||
|
||||
// Construct and add RETURN node.
|
||||
appendStatement(new ReturnNode(source, returnToken, finish, expression));
|
||||
appendStatement(new ReturnNode(returnToken, finish, expression));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1336,7 +1335,7 @@ loop:
|
||||
endOfLine();
|
||||
|
||||
// Construct and add YIELD node.
|
||||
appendStatement(new ReturnNode(source, yieldToken, finish, expression));
|
||||
appendStatement(new ReturnNode(yieldToken, finish, expression));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1359,7 +1358,7 @@ loop:
|
||||
}
|
||||
|
||||
// Get WITH expression.
|
||||
WithNode withNode = new WithNode(source, withToken, finish);
|
||||
WithNode withNode = new WithNode(withToken, finish);
|
||||
|
||||
try {
|
||||
lc.push(withNode);
|
||||
@ -1402,7 +1401,7 @@ loop:
|
||||
next();
|
||||
|
||||
// Create and add switch statement.
|
||||
SwitchNode switchNode = new SwitchNode(source, switchToken, Token.descPosition(switchToken), null, new ArrayList<CaseNode>(), null);
|
||||
SwitchNode switchNode = new SwitchNode(switchToken, Token.descPosition(switchToken), null, new ArrayList<CaseNode>(), null);
|
||||
lc.push(switchNode);
|
||||
|
||||
try {
|
||||
@ -1444,7 +1443,7 @@ loop:
|
||||
|
||||
// Get CASE body.
|
||||
final Block statements = getBlock(false);
|
||||
final CaseNode caseNode = new CaseNode(source, caseToken, finish, caseExpression, statements);
|
||||
final CaseNode caseNode = new CaseNode(caseToken, finish, caseExpression, statements);
|
||||
statements.setFinish(finish);
|
||||
|
||||
if (caseExpression == null) {
|
||||
@ -1484,7 +1483,7 @@ loop:
|
||||
throw error(AbstractParser.message("duplicate.label", ident.getName()), labelToken);
|
||||
}
|
||||
|
||||
LabelNode labelNode = new LabelNode(source, labelToken, finish, ident, null);
|
||||
LabelNode labelNode = new LabelNode(labelToken, finish, ident, null);
|
||||
try {
|
||||
lc.push(labelNode);
|
||||
labelNode = labelNode.setBody(lc, getStatement());
|
||||
@ -1530,7 +1529,7 @@ loop:
|
||||
|
||||
endOfLine();
|
||||
|
||||
appendStatement(new ThrowNode(source, throwToken, finish, expression));
|
||||
appendStatement(new ThrowNode(throwToken, finish, expression));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1588,7 +1587,7 @@ loop:
|
||||
try {
|
||||
// Get CATCH body.
|
||||
final Block catchBody = getBlock(true);
|
||||
final CatchNode catchNode = new CatchNode(source, catchToken, finish, exception, ifExpression, catchBody);
|
||||
final CatchNode catchNode = new CatchNode(catchToken, finish, exception, ifExpression, catchBody);
|
||||
appendStatement(catchNode);
|
||||
} finally {
|
||||
catchBlock = restoreBlock(catchBlock);
|
||||
@ -1614,7 +1613,7 @@ loop:
|
||||
throw error(AbstractParser.message("missing.catch.or.finally"), tryToken);
|
||||
}
|
||||
|
||||
final TryNode tryNode = new TryNode(source, tryToken, Token.descPosition(tryToken), tryBody, catchBlocks, finallyStatements);
|
||||
final TryNode tryNode = new TryNode(tryToken, Token.descPosition(tryToken), tryBody, catchBlocks, finallyStatements);
|
||||
// Add try.
|
||||
assert lc.peek() == outer;
|
||||
appendStatement(tryNode);
|
||||
@ -1626,7 +1625,7 @@ loop:
|
||||
outer = restoreBlock(outer);
|
||||
}
|
||||
|
||||
appendStatement(new ExecuteNode(source, outer.getToken(), outer.getFinish(), outer));
|
||||
appendStatement(new ExecuteNode(outer.getToken(), outer.getFinish(), outer));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1643,7 +1642,7 @@ loop:
|
||||
// DEBUGGER tested in caller.
|
||||
next();
|
||||
endOfLine();
|
||||
appendStatement(new RuntimeNode(source, debuggerToken, finish, RuntimeNode.Request.DEBUGGER, new ArrayList<Node>()));
|
||||
appendStatement(new RuntimeNode(debuggerToken, finish, RuntimeNode.Request.DEBUGGER, new ArrayList<Node>()));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1669,7 +1668,7 @@ loop:
|
||||
case THIS:
|
||||
final String name = type.getName();
|
||||
next();
|
||||
return new IdentNode(source, primaryToken, finish, name);
|
||||
return new IdentNode(primaryToken, finish, name);
|
||||
case IDENT:
|
||||
final IdentNode ident = getIdent();
|
||||
if (ident == null) {
|
||||
@ -1693,13 +1692,13 @@ loop:
|
||||
return execString(primaryToken);
|
||||
case FALSE:
|
||||
next();
|
||||
return LiteralNode.newInstance(source, primaryToken, finish, false);
|
||||
return LiteralNode.newInstance(primaryToken, finish, false);
|
||||
case TRUE:
|
||||
next();
|
||||
return LiteralNode.newInstance(source, primaryToken, finish, true);
|
||||
return LiteralNode.newInstance(primaryToken, finish, true);
|
||||
case NULL:
|
||||
next();
|
||||
return LiteralNode.newInstance(source, primaryToken, finish);
|
||||
return LiteralNode.newInstance(primaryToken, finish);
|
||||
case LBRACKET:
|
||||
return arrayLiteral();
|
||||
case LBRACE:
|
||||
@ -1736,7 +1735,7 @@ loop:
|
||||
*/
|
||||
Node execString(final long primaryToken) {
|
||||
// Synthesize an ident to call $EXEC.
|
||||
final IdentNode execIdent = new IdentNode(source, primaryToken, finish, ScriptingFunctions.EXEC_NAME);
|
||||
final IdentNode execIdent = new IdentNode(primaryToken, finish, ScriptingFunctions.EXEC_NAME);
|
||||
// Skip over EXECSTRING.
|
||||
next();
|
||||
// Set up argument list for call.
|
||||
@ -1748,7 +1747,7 @@ loop:
|
||||
// Skip ending of edit string expression.
|
||||
expect(RBRACE);
|
||||
|
||||
return new CallNode(source, primaryToken, finish, execIdent, arguments);
|
||||
return new CallNode(primaryToken, finish, execIdent, arguments);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1819,7 +1818,7 @@ loop:
|
||||
}
|
||||
}
|
||||
|
||||
return LiteralNode.newInstance(source, arrayToken, finish, elements);
|
||||
return LiteralNode.newInstance(arrayToken, finish, elements);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1926,7 +1925,7 @@ loop:
|
||||
map.put(key, newProperty = newProperty.setValue(value));
|
||||
} else {
|
||||
final long propertyToken = Token.recast(newProperty.getToken(), COMMARIGHT);
|
||||
map.put(key, newProperty = newProperty.setValue(new BinaryNode(source, propertyToken, prevValue, value)));
|
||||
map.put(key, newProperty = newProperty.setValue(new BinaryNode(propertyToken, prevValue, value)));
|
||||
}
|
||||
|
||||
map.put(key, newProperty = newProperty.setGetter(null).setSetter(null));
|
||||
@ -1943,7 +1942,7 @@ loop:
|
||||
}
|
||||
}
|
||||
|
||||
return new ObjectNode(source, objectToken, finish, new ArrayList<Node>(map.values()));
|
||||
return new ObjectNode(objectToken, finish, new ArrayList<Node>(map.values()));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2013,16 +2012,16 @@ loop:
|
||||
case "get":
|
||||
final PropertyKey getIdent = propertyName();
|
||||
final String getterName = getIdent.getPropertyName();
|
||||
final IdentNode getNameNode = new IdentNode(source, ((Node)getIdent).getToken(), finish, "get " + getterName);
|
||||
final IdentNode getNameNode = new IdentNode(((Node)getIdent).getToken(), finish, "get " + getterName);
|
||||
expect(LPAREN);
|
||||
expect(RPAREN);
|
||||
functionNode = functionBody(getSetToken, getNameNode, new ArrayList<IdentNode>(), FunctionNode.Kind.GETTER);
|
||||
return new PropertyNode(source, propertyToken, finish, getIdent, null, functionNode, null);
|
||||
return new PropertyNode(propertyToken, finish, getIdent, null, functionNode, null);
|
||||
|
||||
case "set":
|
||||
final PropertyKey setIdent = propertyName();
|
||||
final String setterName = setIdent.getPropertyName();
|
||||
final IdentNode setNameNode = new IdentNode(source, ((Node)setIdent).getToken(), finish, "set " + setterName);
|
||||
final IdentNode setNameNode = new IdentNode(((Node)setIdent).getToken(), finish, "set " + setterName);
|
||||
expect(LPAREN);
|
||||
final IdentNode argIdent = getIdent();
|
||||
verifyStrictIdent(argIdent, "setter argument");
|
||||
@ -2030,21 +2029,21 @@ loop:
|
||||
List<IdentNode> parameters = new ArrayList<>();
|
||||
parameters.add(argIdent);
|
||||
functionNode = functionBody(getSetToken, setNameNode, parameters, FunctionNode.Kind.SETTER);
|
||||
return new PropertyNode(source, propertyToken, finish, setIdent, null, null, functionNode);
|
||||
return new PropertyNode(propertyToken, finish, setIdent, null, null, functionNode);
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
propertyName = new IdentNode(source, propertyToken, finish, ident);
|
||||
propertyName = new IdentNode(propertyToken, finish, ident);
|
||||
} else {
|
||||
propertyName = propertyName();
|
||||
}
|
||||
|
||||
expect(COLON);
|
||||
|
||||
return new PropertyNode(source, propertyToken, finish, propertyName, assignmentExpression(false), null, null);
|
||||
return new PropertyNode(propertyToken, finish, propertyName, assignmentExpression(false), null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2076,7 +2075,7 @@ loop:
|
||||
detectSpecialFunction((IdentNode)lhs);
|
||||
}
|
||||
|
||||
lhs = new CallNode(source, callToken, finish, lhs, arguments);
|
||||
lhs = new CallNode(callToken, finish, lhs, arguments);
|
||||
}
|
||||
|
||||
loop:
|
||||
@ -2090,7 +2089,7 @@ loop:
|
||||
final List<Node> arguments = argumentList();
|
||||
|
||||
// Create call node.
|
||||
lhs = new CallNode(source, callToken, finish, lhs, arguments);
|
||||
lhs = new CallNode(callToken, finish, lhs, arguments);
|
||||
|
||||
break;
|
||||
|
||||
@ -2103,7 +2102,7 @@ loop:
|
||||
expect(RBRACKET);
|
||||
|
||||
// Create indexing node.
|
||||
lhs = new IndexNode(source, callToken, finish, lhs, rhs);
|
||||
lhs = new IndexNode(callToken, finish, lhs, rhs);
|
||||
|
||||
break;
|
||||
|
||||
@ -2113,7 +2112,7 @@ loop:
|
||||
final IdentNode property = getIdentifierName();
|
||||
|
||||
// Create property access node.
|
||||
lhs = new AccessNode(source, callToken, finish, lhs, property);
|
||||
lhs = new AccessNode(callToken, finish, lhs, property);
|
||||
|
||||
break;
|
||||
|
||||
@ -2169,9 +2168,9 @@ loop:
|
||||
arguments.add(objectLiteral());
|
||||
}
|
||||
|
||||
final CallNode callNode = new CallNode(source, constructor.getToken(), finish, constructor, arguments);
|
||||
final CallNode callNode = new CallNode(constructor.getToken(), finish, constructor, arguments);
|
||||
|
||||
return new UnaryNode(source, newToken, callNode);
|
||||
return new UnaryNode(newToken, callNode);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2223,7 +2222,7 @@ loop:
|
||||
expect(RBRACKET);
|
||||
|
||||
// Create indexing node.
|
||||
lhs = new IndexNode(source, callToken, finish, lhs, index);
|
||||
lhs = new IndexNode(callToken, finish, lhs, index);
|
||||
|
||||
break;
|
||||
|
||||
@ -2237,7 +2236,7 @@ loop:
|
||||
final IdentNode property = getIdentifierName();
|
||||
|
||||
// Create property access node.
|
||||
lhs = new AccessNode(source, callToken, finish, lhs, property);
|
||||
lhs = new AccessNode(callToken, finish, lhs, property);
|
||||
|
||||
break;
|
||||
|
||||
@ -2326,7 +2325,7 @@ loop:
|
||||
boolean isAnonymous = false;
|
||||
if (name == null) {
|
||||
final String tmpName = "_L" + source.getLine(Token.descPosition(token));
|
||||
name = new IdentNode(source, functionToken, Token.descPosition(functionToken), tmpName);
|
||||
name = new IdentNode(functionToken, Token.descPosition(functionToken), tmpName);
|
||||
isAnonymous = true;
|
||||
}
|
||||
|
||||
@ -2377,7 +2376,7 @@ loop:
|
||||
// rename in non-strict mode
|
||||
parameterName = functionNode.uniqueName(parameterName);
|
||||
final long parameterToken = parameter.getToken();
|
||||
parameters.set(i, new IdentNode(source, parameterToken, Token.descPosition(parameterToken), functionNode.uniqueName(parameterName)));
|
||||
parameters.set(i, new IdentNode(parameterToken, Token.descPosition(parameterToken), functionNode.uniqueName(parameterName)));
|
||||
}
|
||||
|
||||
parametersSet.add(parameterName);
|
||||
@ -2389,7 +2388,7 @@ loop:
|
||||
}
|
||||
|
||||
if (isStatement) {
|
||||
final VarNode varNode = new VarNode(source, functionToken, finish, name, functionNode, VarNode.IS_STATEMENT);
|
||||
final VarNode varNode = new VarNode(functionToken, finish, name, functionNode, VarNode.IS_STATEMENT);
|
||||
if (topLevel) {
|
||||
functionDeclarations.add(lineNumber);
|
||||
functionDeclarations.add(varNode);
|
||||
@ -2469,7 +2468,7 @@ loop:
|
||||
assert lc.getCurrentBlock() == lc.getFunctionBody(functionNode);
|
||||
// create a return statement - this creates code in itself and does not need to be
|
||||
// wrapped into an ExecuteNode
|
||||
final ReturnNode returnNode = new ReturnNode(source, expr.getToken(), finish, expr);
|
||||
final ReturnNode returnNode = new ReturnNode(expr.getToken(), finish, expr);
|
||||
appendStatement(returnNode);
|
||||
lastToken = token;
|
||||
functionNode.setFinish(Token.descPosition(token) + Token.descLength(token));
|
||||
@ -2511,16 +2510,16 @@ loop:
|
||||
}
|
||||
}
|
||||
|
||||
private RuntimeNode referenceError(final Node lhs, final Node rhs) {
|
||||
private static RuntimeNode referenceError(final Node lhs, final Node rhs) {
|
||||
final ArrayList<Node> args = new ArrayList<>();
|
||||
args.add(lhs);
|
||||
if (rhs == null) {
|
||||
args.add(LiteralNode.newInstance(source, lhs.getToken(), lhs.getFinish()));
|
||||
args.add(LiteralNode.newInstance(lhs.getToken(), lhs.getFinish()));
|
||||
} else {
|
||||
args.add(rhs);
|
||||
}
|
||||
args.add(LiteralNode.newInstance(source, lhs.getToken(), lhs.getFinish(), lhs.toString()));
|
||||
return new RuntimeNode(source, lhs.getToken(), lhs.getFinish(), RuntimeNode.Request.REFERENCE_ERROR, args);
|
||||
args.add(LiteralNode.newInstance(lhs.getToken(), lhs.getFinish(), lhs.toString()));
|
||||
return new RuntimeNode(lhs.getToken(), lhs.getFinish(), RuntimeNode.Request.REFERENCE_ERROR, args);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -2570,7 +2569,7 @@ loop:
|
||||
case NOT:
|
||||
next();
|
||||
final Node expr = unaryExpression();
|
||||
return new UnaryNode(source, unaryToken, expr);
|
||||
return new UnaryNode(unaryToken, expr);
|
||||
|
||||
case INCPREFIX:
|
||||
case DECPREFIX:
|
||||
@ -2759,7 +2758,7 @@ loop:
|
||||
final Node third = expression(unaryExpression(), ASSIGN.getPrecedence(), noIn);
|
||||
|
||||
// Build up node.
|
||||
lhs = new TernaryNode(source, op, lhs, rhs, third);
|
||||
lhs = new TernaryNode(op, lhs, rhs, third);
|
||||
} else {
|
||||
// Skip operator.
|
||||
next();
|
||||
@ -2820,7 +2819,7 @@ loop:
|
||||
*/
|
||||
private LineNumberNode lineNumber() {
|
||||
if (env._debug_lines) {
|
||||
return new LineNumberNode(source, token, line);
|
||||
return new LineNumberNode(token, line);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -229,6 +229,10 @@ public final class RecompilableScriptFunctionData extends ScriptFunctionData {
|
||||
}
|
||||
|
||||
final FunctionNode snapshot = functionNode.getSnapshot();
|
||||
if (snapshot == null) {
|
||||
return mh;
|
||||
}
|
||||
|
||||
int i;
|
||||
|
||||
//classes known at runtime
|
||||
|
||||
@ -970,9 +970,7 @@ public abstract class ScriptObject extends PropertyListenerManager implements Pr
|
||||
* @param bindName null or name to bind to second argument (property not found method.)
|
||||
*
|
||||
* @return value of property as a MethodHandle or null.
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("static-method")
|
||||
protected MethodHandle getCallMethodHandle(final FindProperty find, final MethodType type, final String bindName) {
|
||||
return getCallMethodHandle(getObjectValue(find), type, bindName);
|
||||
}
|
||||
|
||||
@ -57,7 +57,6 @@ abstract public class ArrayLikeIterator<T> implements Iterator<T> {
|
||||
* Is this a reverse order iteration?
|
||||
* @return true if reverse
|
||||
*/
|
||||
@SuppressWarnings("static-method")
|
||||
public boolean isReverse() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -275,7 +275,6 @@ public class LinkerCallSite extends ChainedCallSite {
|
||||
}
|
||||
|
||||
static class ProfileDumper implements Runnable {
|
||||
@SuppressWarnings("resource")
|
||||
@Override
|
||||
public void run() {
|
||||
PrintWriter out = null;
|
||||
@ -447,7 +446,7 @@ public class LinkerCallSite extends ChainedCallSite {
|
||||
*
|
||||
* @throws Throwable if invocation fails or throws exception/error
|
||||
*/
|
||||
@SuppressWarnings({"unused", "resource"})
|
||||
@SuppressWarnings("unused")
|
||||
public Object traceObject(final MethodHandle mh, final Object... args) throws Throwable {
|
||||
final PrintWriter out = Context.getCurrentErr();
|
||||
tracePrint(out, "ENTER ", args, null);
|
||||
@ -465,7 +464,7 @@ public class LinkerCallSite extends ChainedCallSite {
|
||||
*
|
||||
* @throws Throwable if invocation fails or throws exception/error
|
||||
*/
|
||||
@SuppressWarnings({"unused", "resource"})
|
||||
@SuppressWarnings("unused")
|
||||
public void traceVoid(final MethodHandle mh, final Object... args) throws Throwable {
|
||||
final PrintWriter out = Context.getCurrentErr();
|
||||
tracePrint(out, "ENTER ", args, null);
|
||||
|
||||
@ -392,7 +392,6 @@ public class Shell {
|
||||
* @param global global scope object to use
|
||||
* @return return code
|
||||
*/
|
||||
@SuppressWarnings("resource")
|
||||
private static int readEvalPrint(final Context context, final ScriptObject global) {
|
||||
final String prompt = bundle.getString("shell.prompt");
|
||||
final BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user