本文整理了Java中org.mozilla.javascript.Node.newTarget()
方法的一些代码示例,展示了Node.newTarget()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Node.newTarget()
方法的具体详情如下:
包路径:org.mozilla.javascript.Node
类名称:Node
方法名:newTarget
暂无
代码示例来源:origin: rhino/js
/**
* Label
*/
Node createLabeledStatement(Node labelArg, Node statement)
{
Node.Jump label = (Node.Jump)labelArg;
// Make a target and put it _after_ the statement
// node. And in the LABEL node, so breaks get the
// right target.
Node breakTarget = Node.newTarget();
Node block = new Node(Token.BLOCK, label, statement, breakTarget);
label.target = breakTarget;
return block;
}
代码示例来源:origin: com.sun.phobos/phobos-rhino
/**
* Label
*/
Node createLabeledStatement(Node labelArg, Node statement)
{
Node.Jump label = (Node.Jump)labelArg;
// Make a target and put it _after_ the statement
// node. And in the LABEL node, so breaks get the
// right target.
Node breakTarget = Node.newTarget();
Node block = new Node(Token.BLOCK, label, statement, breakTarget);
label.target = breakTarget;
return block;
}
代码示例来源:origin: io.apigee/rhino
private Node createIf(Node cond, Node ifTrue, Node ifFalse, int lineno)
{
int condStatus = isAlwaysDefinedBoolean(cond);
if (condStatus == ALWAYS_TRUE_BOOLEAN) {
return ifTrue;
} else if (condStatus == ALWAYS_FALSE_BOOLEAN) {
if (ifFalse != null) {
return ifFalse;
}
// Replace if (false) xxx by empty block
return new Node(Token.BLOCK, lineno);
}
Node result = new Node(Token.BLOCK, lineno);
Node ifNotTarget = Node.newTarget();
Jump IFNE = new Jump(Token.IFNE, cond);
IFNE.target = ifNotTarget;
result.addChildToBack(IFNE);
result.addChildrenToBack(ifTrue);
if (ifFalse != null) {
Node endTarget = Node.newTarget();
result.addChildToBack(makeJump(Token.GOTO, endTarget));
result.addChildToBack(ifNotTarget);
result.addChildrenToBack(ifFalse);
result.addChildToBack(endTarget);
} else {
result.addChildToBack(ifNotTarget);
}
return result;
}
代码示例来源:origin: geogebra/geogebra
private Node createIf(Node cond, Node ifTrue, Node ifFalse, int lineno)
{
int condStatus = isAlwaysDefinedBoolean(cond);
if (condStatus == ALWAYS_TRUE_BOOLEAN) {
return ifTrue;
} else if (condStatus == ALWAYS_FALSE_BOOLEAN) {
if (ifFalse != null) {
return ifFalse;
}
// Replace if (false) xxx by empty block
return new Node(Token.BLOCK, lineno);
}
Node result = new Node(Token.BLOCK, lineno);
Node ifNotTarget = Node.newTarget();
Jump IFNE = new Jump(Token.IFNE, cond);
IFNE.target = ifNotTarget;
result.addChildToBack(IFNE);
result.addChildrenToBack(ifTrue);
if (ifFalse != null) {
Node endTarget = Node.newTarget();
result.addChildToBack(makeJump(Token.GOTO, endTarget));
result.addChildToBack(ifNotTarget);
result.addChildrenToBack(ifFalse);
result.addChildToBack(endTarget);
} else {
result.addChildToBack(ifNotTarget);
}
return result;
}
代码示例来源:origin: ro.isdc.wro4j/rhino
private Node createIf(Node cond, Node ifTrue, Node ifFalse, int lineno)
{
int condStatus = isAlwaysDefinedBoolean(cond);
if (condStatus == ALWAYS_TRUE_BOOLEAN) {
return ifTrue;
} else if (condStatus == ALWAYS_FALSE_BOOLEAN) {
if (ifFalse != null) {
return ifFalse;
}
// Replace if (false) xxx by empty block
return new Node(Token.BLOCK, lineno);
}
Node result = new Node(Token.BLOCK, lineno);
Node ifNotTarget = Node.newTarget();
Jump IFNE = new Jump(Token.IFNE, cond);
IFNE.target = ifNotTarget;
result.addChildToBack(IFNE);
result.addChildrenToBack(ifTrue);
if (ifFalse != null) {
Node endTarget = Node.newTarget();
result.addChildToBack(makeJump(Token.GOTO, endTarget));
result.addChildToBack(ifNotTarget);
result.addChildrenToBack(ifFalse);
result.addChildToBack(endTarget);
} else {
result.addChildToBack(ifNotTarget);
}
return result;
}
代码示例来源:origin: rhino/js
Node ifNotTarget = Node.newTarget();
Node.Jump IFNE = new Node.Jump(Token.IFNE, cond);
IFNE.target = ifNotTarget;
Node endTarget = Node.newTarget();
result.addChildToBack(makeJump(Token.GOTO, endTarget));
result.addChildToBack(ifNotTarget);
代码示例来源:origin: com.sun.phobos/phobos-rhino
void closeSwitch(Node switchBlock)
{
if (switchBlock.getType() != Token.BLOCK) throw Kit.codeBug();
Node.Jump switchNode = (Node.Jump)switchBlock.getFirstChild();
if (switchNode.getType() != Token.SWITCH) throw Kit.codeBug();
Node switchBreakTarget = Node.newTarget();
// switchNode.target is only used by NodeTransformer
// to detect switch end
switchNode.target = switchBreakTarget;
Node defaultTarget = switchNode.getDefault();
if (defaultTarget == null) {
defaultTarget = switchBreakTarget;
}
switchBlock.addChildAfter(makeJump(Token.GOTO, defaultTarget),
switchNode);
switchBlock.addChildToBack(switchBreakTarget);
}
代码示例来源:origin: rhino/js
void closeSwitch(Node switchBlock)
{
if (switchBlock.getType() != Token.BLOCK) throw Kit.codeBug();
Node.Jump switchNode = (Node.Jump)switchBlock.getFirstChild();
if (switchNode.getType() != Token.SWITCH) throw Kit.codeBug();
Node switchBreakTarget = Node.newTarget();
// switchNode.target is only used by NodeTransformer
// to detect switch end
switchNode.target = switchBreakTarget;
Node defaultTarget = switchNode.getDefault();
if (defaultTarget == null) {
defaultTarget = switchBreakTarget;
}
switchBlock.addChildAfter(makeJump(Token.GOTO, defaultTarget),
switchNode);
switchBlock.addChildToBack(switchBreakTarget);
}
代码示例来源:origin: ro.isdc.wro4j/rhino
private void closeSwitch(Node switchBlock)
{
if (switchBlock.getType() != Token.BLOCK) throw Kit.codeBug();
Jump switchNode = (Jump)switchBlock.getFirstChild();
if (switchNode.getType() != Token.SWITCH) throw Kit.codeBug();
Node switchBreakTarget = Node.newTarget();
// switchNode.target is only used by NodeTransformer
// to detect switch end
switchNode.target = switchBreakTarget;
Node defaultTarget = switchNode.getDefault();
if (defaultTarget == null) {
defaultTarget = switchBreakTarget;
}
switchBlock.addChildAfter(makeJump(Token.GOTO, defaultTarget),
switchNode);
switchBlock.addChildToBack(switchBreakTarget);
}
代码示例来源:origin: geogebra/geogebra
private Node transformLabeledStatement(LabeledStatement ls) {
Label label = ls.getFirstLabel();
List<Label> labels = ls.getLabels();
decompiler.addName(label.getName());
if (labels.size() > 1) {
// more than one label
for (Label lb : labels.subList(1, labels.size())) {
decompiler.addEOL(Token.COLON);
decompiler.addName(lb.getName());
}
}
if (ls.getStatement().getType() == Token.BLOCK) {
// reuse OBJECTLIT for ':' workaround, cf. transformObjectLiteral()
decompiler.addToken(Token.OBJECTLIT);
decompiler.addEOL(Token.LC);
} else {
decompiler.addEOL(Token.COLON);
}
Node statement = transform(ls.getStatement());
if (ls.getStatement().getType() == Token.BLOCK) {
decompiler.addEOL(Token.RC);
}
// Make a target and put it _after_ the statement node. Add in the
// LABEL node, so breaks get the right target.
Node breakTarget = Node.newTarget();
Node block = new Node(Token.BLOCK, label, statement, breakTarget);
label.target = breakTarget;
return block;
}
代码示例来源:origin: geogebra/geogebra
private void closeSwitch(Node switchBlock)
{
if (switchBlock.getType() != Token.BLOCK) throw Kit.codeBug();
Jump switchNode = (Jump)switchBlock.getFirstChild();
if (switchNode.getType() != Token.SWITCH) throw Kit.codeBug();
Node switchBreakTarget = Node.newTarget();
// switchNode.target is only used by NodeTransformer
// to detect switch end
switchNode.target = switchBreakTarget;
Node defaultTarget = switchNode.getDefault();
if (defaultTarget == null) {
defaultTarget = switchBreakTarget;
}
switchBlock.addChildAfter(makeJump(Token.GOTO, defaultTarget),
switchNode);
switchBlock.addChildToBack(switchBreakTarget);
}
代码示例来源:origin: io.apigee/rhino
private void closeSwitch(Node switchBlock)
{
if (switchBlock.getType() != Token.BLOCK) throw Kit.codeBug();
Jump switchNode = (Jump)switchBlock.getFirstChild();
if (switchNode.getType() != Token.SWITCH) throw Kit.codeBug();
Node switchBreakTarget = Node.newTarget();
// switchNode.target is only used by NodeTransformer
// to detect switch end
switchNode.target = switchBreakTarget;
Node defaultTarget = switchNode.getDefault();
if (defaultTarget == null) {
defaultTarget = switchBreakTarget;
}
switchBlock.addChildAfter(makeJump(Token.GOTO, defaultTarget),
switchNode);
switchBlock.addChildToBack(switchBreakTarget);
}
代码示例来源:origin: com.github.tntim96/rhino
private void closeSwitch(Node switchBlock)
{
if (switchBlock.getType() != Token.BLOCK) throw Kit.codeBug();
Jump switchNode = (Jump)switchBlock.getFirstChild();
if (switchNode.getType() != Token.SWITCH) throw Kit.codeBug();
Node switchBreakTarget = Node.newTarget();
// switchNode.target is only used by NodeTransformer
// to detect switch end
switchNode.target = switchBreakTarget;
Node defaultTarget = switchNode.getDefault();
if (defaultTarget == null) {
defaultTarget = switchBreakTarget;
}
switchBlock.addChildAfter(makeJump(Token.GOTO, defaultTarget),
switchNode);
switchBlock.addChildToBack(switchBreakTarget);
}
代码示例来源:origin: rhino/js
/**
* If caseExpression argument is null it indicate default label.
*/
void addSwitchCase(Node switchBlock, Node caseExpression, Node statements)
{
if (switchBlock.getType() != Token.BLOCK) throw Kit.codeBug();
Node.Jump switchNode = (Node.Jump)switchBlock.getFirstChild();
if (switchNode.getType() != Token.SWITCH) throw Kit.codeBug();
Node gotoTarget = Node.newTarget();
if (caseExpression != null) {
Node.Jump caseNode = new Node.Jump(Token.CASE, caseExpression);
caseNode.target = gotoTarget;
switchNode.addChildToBack(caseNode);
} else {
switchNode.setDefault(gotoTarget);
}
switchBlock.addChildToBack(gotoTarget);
switchBlock.addChildToBack(statements);
}
代码示例来源:origin: io.apigee/rhino
private Node transformLabeledStatement(LabeledStatement ls) {
Label label = ls.getFirstLabel();
List<Label> labels = ls.getLabels();
decompiler.addName(label.getName());
if (labels.size() > 1) {
// more than one label
for (Label lb : labels.subList(1, labels.size())) {
decompiler.addEOL(Token.COLON);
decompiler.addName(lb.getName());
}
}
if (ls.getStatement().getType() == Token.BLOCK) {
// reuse OBJECTLIT for ':' workaround, cf. transformObjectLiteral()
decompiler.addToken(Token.OBJECTLIT);
decompiler.addEOL(Token.LC);
} else {
decompiler.addEOL(Token.COLON);
}
Node statement = transform(ls.getStatement());
if (ls.getStatement().getType() == Token.BLOCK) {
decompiler.addEOL(Token.RC);
}
// Make a target and put it _after_ the statement node. Add in the
// LABEL node, so breaks get the right target.
Node breakTarget = Node.newTarget();
Node block = new Node(Token.BLOCK, label, statement, breakTarget);
label.target = breakTarget;
return block;
}
代码示例来源:origin: com.sun.phobos/phobos-rhino
/**
* If caseExpression argument is null it indicate default label.
*/
void addSwitchCase(Node switchBlock, Node caseExpression, Node statements)
{
if (switchBlock.getType() != Token.BLOCK) throw Kit.codeBug();
Node.Jump switchNode = (Node.Jump)switchBlock.getFirstChild();
if (switchNode.getType() != Token.SWITCH) throw Kit.codeBug();
Node gotoTarget = Node.newTarget();
if (caseExpression != null) {
Node.Jump caseNode = new Node.Jump(Token.CASE, caseExpression);
caseNode.target = gotoTarget;
switchNode.addChildToBack(caseNode);
} else {
switchNode.setDefault(gotoTarget);
}
switchBlock.addChildToBack(gotoTarget);
switchBlock.addChildToBack(statements);
}
代码示例来源:origin: geogebra/geogebra
/**
* If caseExpression argument is null it indicates a default label.
*/
private void addSwitchCase(Node switchBlock, Node caseExpression,
Node statements)
{
if (switchBlock.getType() != Token.BLOCK) throw Kit.codeBug();
Jump switchNode = (Jump)switchBlock.getFirstChild();
if (switchNode.getType() != Token.SWITCH) throw Kit.codeBug();
Node gotoTarget = Node.newTarget();
if (caseExpression != null) {
Jump caseNode = new Jump(Token.CASE, caseExpression);
caseNode.target = gotoTarget;
switchNode.addChildToBack(caseNode);
} else {
switchNode.setDefault(gotoTarget);
}
switchBlock.addChildToBack(gotoTarget);
switchBlock.addChildToBack(statements);
}
代码示例来源:origin: ro.isdc.wro4j/rhino
/**
* If caseExpression argument is null it indicates a default label.
*/
private void addSwitchCase(Node switchBlock, Node caseExpression,
Node statements)
{
if (switchBlock.getType() != Token.BLOCK) throw Kit.codeBug();
Jump switchNode = (Jump)switchBlock.getFirstChild();
if (switchNode.getType() != Token.SWITCH) throw Kit.codeBug();
Node gotoTarget = Node.newTarget();
if (caseExpression != null) {
Jump caseNode = new Jump(Token.CASE, caseExpression);
caseNode.target = gotoTarget;
switchNode.addChildToBack(caseNode);
} else {
switchNode.setDefault(gotoTarget);
}
switchBlock.addChildToBack(gotoTarget);
switchBlock.addChildToBack(statements);
}
代码示例来源:origin: com.github.tntim96/rhino
/**
* If caseExpression argument is null it indicates a default label.
*/
private void addSwitchCase(Node switchBlock, Node caseExpression,
Node statements)
{
if (switchBlock.getType() != Token.BLOCK) throw Kit.codeBug();
Jump switchNode = (Jump)switchBlock.getFirstChild();
if (switchNode.getType() != Token.SWITCH) throw Kit.codeBug();
Node gotoTarget = Node.newTarget();
if (caseExpression != null) {
Jump caseNode = new Jump(Token.CASE, caseExpression);
caseNode.target = gotoTarget;
switchNode.addChildToBack(caseNode);
} else {
switchNode.setDefault(gotoTarget);
}
switchBlock.addChildToBack(gotoTarget);
switchBlock.addChildToBack(statements);
}
代码示例来源:origin: io.apigee/rhino
/**
* If caseExpression argument is null it indicates a default label.
*/
private void addSwitchCase(Node switchBlock, Node caseExpression,
Node statements)
{
if (switchBlock.getType() != Token.BLOCK) throw Kit.codeBug();
Jump switchNode = (Jump)switchBlock.getFirstChild();
if (switchNode.getType() != Token.SWITCH) throw Kit.codeBug();
Node gotoTarget = Node.newTarget();
if (caseExpression != null) {
Jump caseNode = new Jump(Token.CASE, caseExpression);
caseNode.target = gotoTarget;
switchNode.addChildToBack(caseNode);
} else {
switchNode.setDefault(gotoTarget);
}
switchBlock.addChildToBack(gotoTarget);
switchBlock.addChildToBack(statements);
}
内容来源于网络,如有侵权,请联系作者删除!