org.mozilla.javascript.Node.newTarget()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 JavaScript  
字(12.7k)|赞(0)|评价(0)|浏览(308)

本文整理了Java中org.mozilla.javascript.Node.newTarget()方法的一些代码示例,展示了Node.newTarget()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Node.newTarget()方法的具体详情如下:
包路径:org.mozilla.javascript.Node
类名称:Node
方法名:newTarget

Node.newTarget介绍

暂无

代码示例

代码示例来源:origin: rhino/js

  1. /**
  2. * Label
  3. */
  4. Node createLabeledStatement(Node labelArg, Node statement)
  5. {
  6. Node.Jump label = (Node.Jump)labelArg;
  7. // Make a target and put it _after_ the statement
  8. // node. And in the LABEL node, so breaks get the
  9. // right target.
  10. Node breakTarget = Node.newTarget();
  11. Node block = new Node(Token.BLOCK, label, statement, breakTarget);
  12. label.target = breakTarget;
  13. return block;
  14. }

代码示例来源:origin: com.sun.phobos/phobos-rhino

  1. /**
  2. * Label
  3. */
  4. Node createLabeledStatement(Node labelArg, Node statement)
  5. {
  6. Node.Jump label = (Node.Jump)labelArg;
  7. // Make a target and put it _after_ the statement
  8. // node. And in the LABEL node, so breaks get the
  9. // right target.
  10. Node breakTarget = Node.newTarget();
  11. Node block = new Node(Token.BLOCK, label, statement, breakTarget);
  12. label.target = breakTarget;
  13. return block;
  14. }

代码示例来源:origin: io.apigee/rhino

  1. private Node createIf(Node cond, Node ifTrue, Node ifFalse, int lineno)
  2. {
  3. int condStatus = isAlwaysDefinedBoolean(cond);
  4. if (condStatus == ALWAYS_TRUE_BOOLEAN) {
  5. return ifTrue;
  6. } else if (condStatus == ALWAYS_FALSE_BOOLEAN) {
  7. if (ifFalse != null) {
  8. return ifFalse;
  9. }
  10. // Replace if (false) xxx by empty block
  11. return new Node(Token.BLOCK, lineno);
  12. }
  13. Node result = new Node(Token.BLOCK, lineno);
  14. Node ifNotTarget = Node.newTarget();
  15. Jump IFNE = new Jump(Token.IFNE, cond);
  16. IFNE.target = ifNotTarget;
  17. result.addChildToBack(IFNE);
  18. result.addChildrenToBack(ifTrue);
  19. if (ifFalse != null) {
  20. Node endTarget = Node.newTarget();
  21. result.addChildToBack(makeJump(Token.GOTO, endTarget));
  22. result.addChildToBack(ifNotTarget);
  23. result.addChildrenToBack(ifFalse);
  24. result.addChildToBack(endTarget);
  25. } else {
  26. result.addChildToBack(ifNotTarget);
  27. }
  28. return result;
  29. }

代码示例来源:origin: geogebra/geogebra

  1. private Node createIf(Node cond, Node ifTrue, Node ifFalse, int lineno)
  2. {
  3. int condStatus = isAlwaysDefinedBoolean(cond);
  4. if (condStatus == ALWAYS_TRUE_BOOLEAN) {
  5. return ifTrue;
  6. } else if (condStatus == ALWAYS_FALSE_BOOLEAN) {
  7. if (ifFalse != null) {
  8. return ifFalse;
  9. }
  10. // Replace if (false) xxx by empty block
  11. return new Node(Token.BLOCK, lineno);
  12. }
  13. Node result = new Node(Token.BLOCK, lineno);
  14. Node ifNotTarget = Node.newTarget();
  15. Jump IFNE = new Jump(Token.IFNE, cond);
  16. IFNE.target = ifNotTarget;
  17. result.addChildToBack(IFNE);
  18. result.addChildrenToBack(ifTrue);
  19. if (ifFalse != null) {
  20. Node endTarget = Node.newTarget();
  21. result.addChildToBack(makeJump(Token.GOTO, endTarget));
  22. result.addChildToBack(ifNotTarget);
  23. result.addChildrenToBack(ifFalse);
  24. result.addChildToBack(endTarget);
  25. } else {
  26. result.addChildToBack(ifNotTarget);
  27. }
  28. return result;
  29. }

代码示例来源:origin: ro.isdc.wro4j/rhino

  1. private Node createIf(Node cond, Node ifTrue, Node ifFalse, int lineno)
  2. {
  3. int condStatus = isAlwaysDefinedBoolean(cond);
  4. if (condStatus == ALWAYS_TRUE_BOOLEAN) {
  5. return ifTrue;
  6. } else if (condStatus == ALWAYS_FALSE_BOOLEAN) {
  7. if (ifFalse != null) {
  8. return ifFalse;
  9. }
  10. // Replace if (false) xxx by empty block
  11. return new Node(Token.BLOCK, lineno);
  12. }
  13. Node result = new Node(Token.BLOCK, lineno);
  14. Node ifNotTarget = Node.newTarget();
  15. Jump IFNE = new Jump(Token.IFNE, cond);
  16. IFNE.target = ifNotTarget;
  17. result.addChildToBack(IFNE);
  18. result.addChildrenToBack(ifTrue);
  19. if (ifFalse != null) {
  20. Node endTarget = Node.newTarget();
  21. result.addChildToBack(makeJump(Token.GOTO, endTarget));
  22. result.addChildToBack(ifNotTarget);
  23. result.addChildrenToBack(ifFalse);
  24. result.addChildToBack(endTarget);
  25. } else {
  26. result.addChildToBack(ifNotTarget);
  27. }
  28. return result;
  29. }

代码示例来源:origin: rhino/js

  1. Node ifNotTarget = Node.newTarget();
  2. Node.Jump IFNE = new Node.Jump(Token.IFNE, cond);
  3. IFNE.target = ifNotTarget;
  4. Node endTarget = Node.newTarget();
  5. result.addChildToBack(makeJump(Token.GOTO, endTarget));
  6. result.addChildToBack(ifNotTarget);

代码示例来源:origin: com.sun.phobos/phobos-rhino

  1. void closeSwitch(Node switchBlock)
  2. {
  3. if (switchBlock.getType() != Token.BLOCK) throw Kit.codeBug();
  4. Node.Jump switchNode = (Node.Jump)switchBlock.getFirstChild();
  5. if (switchNode.getType() != Token.SWITCH) throw Kit.codeBug();
  6. Node switchBreakTarget = Node.newTarget();
  7. // switchNode.target is only used by NodeTransformer
  8. // to detect switch end
  9. switchNode.target = switchBreakTarget;
  10. Node defaultTarget = switchNode.getDefault();
  11. if (defaultTarget == null) {
  12. defaultTarget = switchBreakTarget;
  13. }
  14. switchBlock.addChildAfter(makeJump(Token.GOTO, defaultTarget),
  15. switchNode);
  16. switchBlock.addChildToBack(switchBreakTarget);
  17. }

代码示例来源:origin: rhino/js

  1. void closeSwitch(Node switchBlock)
  2. {
  3. if (switchBlock.getType() != Token.BLOCK) throw Kit.codeBug();
  4. Node.Jump switchNode = (Node.Jump)switchBlock.getFirstChild();
  5. if (switchNode.getType() != Token.SWITCH) throw Kit.codeBug();
  6. Node switchBreakTarget = Node.newTarget();
  7. // switchNode.target is only used by NodeTransformer
  8. // to detect switch end
  9. switchNode.target = switchBreakTarget;
  10. Node defaultTarget = switchNode.getDefault();
  11. if (defaultTarget == null) {
  12. defaultTarget = switchBreakTarget;
  13. }
  14. switchBlock.addChildAfter(makeJump(Token.GOTO, defaultTarget),
  15. switchNode);
  16. switchBlock.addChildToBack(switchBreakTarget);
  17. }

代码示例来源:origin: ro.isdc.wro4j/rhino

  1. private void closeSwitch(Node switchBlock)
  2. {
  3. if (switchBlock.getType() != Token.BLOCK) throw Kit.codeBug();
  4. Jump switchNode = (Jump)switchBlock.getFirstChild();
  5. if (switchNode.getType() != Token.SWITCH) throw Kit.codeBug();
  6. Node switchBreakTarget = Node.newTarget();
  7. // switchNode.target is only used by NodeTransformer
  8. // to detect switch end
  9. switchNode.target = switchBreakTarget;
  10. Node defaultTarget = switchNode.getDefault();
  11. if (defaultTarget == null) {
  12. defaultTarget = switchBreakTarget;
  13. }
  14. switchBlock.addChildAfter(makeJump(Token.GOTO, defaultTarget),
  15. switchNode);
  16. switchBlock.addChildToBack(switchBreakTarget);
  17. }

代码示例来源:origin: geogebra/geogebra

  1. private Node transformLabeledStatement(LabeledStatement ls) {
  2. Label label = ls.getFirstLabel();
  3. List<Label> labels = ls.getLabels();
  4. decompiler.addName(label.getName());
  5. if (labels.size() > 1) {
  6. // more than one label
  7. for (Label lb : labels.subList(1, labels.size())) {
  8. decompiler.addEOL(Token.COLON);
  9. decompiler.addName(lb.getName());
  10. }
  11. }
  12. if (ls.getStatement().getType() == Token.BLOCK) {
  13. // reuse OBJECTLIT for ':' workaround, cf. transformObjectLiteral()
  14. decompiler.addToken(Token.OBJECTLIT);
  15. decompiler.addEOL(Token.LC);
  16. } else {
  17. decompiler.addEOL(Token.COLON);
  18. }
  19. Node statement = transform(ls.getStatement());
  20. if (ls.getStatement().getType() == Token.BLOCK) {
  21. decompiler.addEOL(Token.RC);
  22. }
  23. // Make a target and put it _after_ the statement node. Add in the
  24. // LABEL node, so breaks get the right target.
  25. Node breakTarget = Node.newTarget();
  26. Node block = new Node(Token.BLOCK, label, statement, breakTarget);
  27. label.target = breakTarget;
  28. return block;
  29. }

代码示例来源:origin: geogebra/geogebra

  1. private void closeSwitch(Node switchBlock)
  2. {
  3. if (switchBlock.getType() != Token.BLOCK) throw Kit.codeBug();
  4. Jump switchNode = (Jump)switchBlock.getFirstChild();
  5. if (switchNode.getType() != Token.SWITCH) throw Kit.codeBug();
  6. Node switchBreakTarget = Node.newTarget();
  7. // switchNode.target is only used by NodeTransformer
  8. // to detect switch end
  9. switchNode.target = switchBreakTarget;
  10. Node defaultTarget = switchNode.getDefault();
  11. if (defaultTarget == null) {
  12. defaultTarget = switchBreakTarget;
  13. }
  14. switchBlock.addChildAfter(makeJump(Token.GOTO, defaultTarget),
  15. switchNode);
  16. switchBlock.addChildToBack(switchBreakTarget);
  17. }

代码示例来源:origin: io.apigee/rhino

  1. private void closeSwitch(Node switchBlock)
  2. {
  3. if (switchBlock.getType() != Token.BLOCK) throw Kit.codeBug();
  4. Jump switchNode = (Jump)switchBlock.getFirstChild();
  5. if (switchNode.getType() != Token.SWITCH) throw Kit.codeBug();
  6. Node switchBreakTarget = Node.newTarget();
  7. // switchNode.target is only used by NodeTransformer
  8. // to detect switch end
  9. switchNode.target = switchBreakTarget;
  10. Node defaultTarget = switchNode.getDefault();
  11. if (defaultTarget == null) {
  12. defaultTarget = switchBreakTarget;
  13. }
  14. switchBlock.addChildAfter(makeJump(Token.GOTO, defaultTarget),
  15. switchNode);
  16. switchBlock.addChildToBack(switchBreakTarget);
  17. }

代码示例来源:origin: com.github.tntim96/rhino

  1. private void closeSwitch(Node switchBlock)
  2. {
  3. if (switchBlock.getType() != Token.BLOCK) throw Kit.codeBug();
  4. Jump switchNode = (Jump)switchBlock.getFirstChild();
  5. if (switchNode.getType() != Token.SWITCH) throw Kit.codeBug();
  6. Node switchBreakTarget = Node.newTarget();
  7. // switchNode.target is only used by NodeTransformer
  8. // to detect switch end
  9. switchNode.target = switchBreakTarget;
  10. Node defaultTarget = switchNode.getDefault();
  11. if (defaultTarget == null) {
  12. defaultTarget = switchBreakTarget;
  13. }
  14. switchBlock.addChildAfter(makeJump(Token.GOTO, defaultTarget),
  15. switchNode);
  16. switchBlock.addChildToBack(switchBreakTarget);
  17. }

代码示例来源:origin: rhino/js

  1. /**
  2. * If caseExpression argument is null it indicate default label.
  3. */
  4. void addSwitchCase(Node switchBlock, Node caseExpression, Node statements)
  5. {
  6. if (switchBlock.getType() != Token.BLOCK) throw Kit.codeBug();
  7. Node.Jump switchNode = (Node.Jump)switchBlock.getFirstChild();
  8. if (switchNode.getType() != Token.SWITCH) throw Kit.codeBug();
  9. Node gotoTarget = Node.newTarget();
  10. if (caseExpression != null) {
  11. Node.Jump caseNode = new Node.Jump(Token.CASE, caseExpression);
  12. caseNode.target = gotoTarget;
  13. switchNode.addChildToBack(caseNode);
  14. } else {
  15. switchNode.setDefault(gotoTarget);
  16. }
  17. switchBlock.addChildToBack(gotoTarget);
  18. switchBlock.addChildToBack(statements);
  19. }

代码示例来源:origin: io.apigee/rhino

  1. private Node transformLabeledStatement(LabeledStatement ls) {
  2. Label label = ls.getFirstLabel();
  3. List<Label> labels = ls.getLabels();
  4. decompiler.addName(label.getName());
  5. if (labels.size() > 1) {
  6. // more than one label
  7. for (Label lb : labels.subList(1, labels.size())) {
  8. decompiler.addEOL(Token.COLON);
  9. decompiler.addName(lb.getName());
  10. }
  11. }
  12. if (ls.getStatement().getType() == Token.BLOCK) {
  13. // reuse OBJECTLIT for ':' workaround, cf. transformObjectLiteral()
  14. decompiler.addToken(Token.OBJECTLIT);
  15. decompiler.addEOL(Token.LC);
  16. } else {
  17. decompiler.addEOL(Token.COLON);
  18. }
  19. Node statement = transform(ls.getStatement());
  20. if (ls.getStatement().getType() == Token.BLOCK) {
  21. decompiler.addEOL(Token.RC);
  22. }
  23. // Make a target and put it _after_ the statement node. Add in the
  24. // LABEL node, so breaks get the right target.
  25. Node breakTarget = Node.newTarget();
  26. Node block = new Node(Token.BLOCK, label, statement, breakTarget);
  27. label.target = breakTarget;
  28. return block;
  29. }

代码示例来源:origin: com.sun.phobos/phobos-rhino

  1. /**
  2. * If caseExpression argument is null it indicate default label.
  3. */
  4. void addSwitchCase(Node switchBlock, Node caseExpression, Node statements)
  5. {
  6. if (switchBlock.getType() != Token.BLOCK) throw Kit.codeBug();
  7. Node.Jump switchNode = (Node.Jump)switchBlock.getFirstChild();
  8. if (switchNode.getType() != Token.SWITCH) throw Kit.codeBug();
  9. Node gotoTarget = Node.newTarget();
  10. if (caseExpression != null) {
  11. Node.Jump caseNode = new Node.Jump(Token.CASE, caseExpression);
  12. caseNode.target = gotoTarget;
  13. switchNode.addChildToBack(caseNode);
  14. } else {
  15. switchNode.setDefault(gotoTarget);
  16. }
  17. switchBlock.addChildToBack(gotoTarget);
  18. switchBlock.addChildToBack(statements);
  19. }

代码示例来源:origin: geogebra/geogebra

  1. /**
  2. * If caseExpression argument is null it indicates a default label.
  3. */
  4. private void addSwitchCase(Node switchBlock, Node caseExpression,
  5. Node statements)
  6. {
  7. if (switchBlock.getType() != Token.BLOCK) throw Kit.codeBug();
  8. Jump switchNode = (Jump)switchBlock.getFirstChild();
  9. if (switchNode.getType() != Token.SWITCH) throw Kit.codeBug();
  10. Node gotoTarget = Node.newTarget();
  11. if (caseExpression != null) {
  12. Jump caseNode = new Jump(Token.CASE, caseExpression);
  13. caseNode.target = gotoTarget;
  14. switchNode.addChildToBack(caseNode);
  15. } else {
  16. switchNode.setDefault(gotoTarget);
  17. }
  18. switchBlock.addChildToBack(gotoTarget);
  19. switchBlock.addChildToBack(statements);
  20. }

代码示例来源:origin: ro.isdc.wro4j/rhino

  1. /**
  2. * If caseExpression argument is null it indicates a default label.
  3. */
  4. private void addSwitchCase(Node switchBlock, Node caseExpression,
  5. Node statements)
  6. {
  7. if (switchBlock.getType() != Token.BLOCK) throw Kit.codeBug();
  8. Jump switchNode = (Jump)switchBlock.getFirstChild();
  9. if (switchNode.getType() != Token.SWITCH) throw Kit.codeBug();
  10. Node gotoTarget = Node.newTarget();
  11. if (caseExpression != null) {
  12. Jump caseNode = new Jump(Token.CASE, caseExpression);
  13. caseNode.target = gotoTarget;
  14. switchNode.addChildToBack(caseNode);
  15. } else {
  16. switchNode.setDefault(gotoTarget);
  17. }
  18. switchBlock.addChildToBack(gotoTarget);
  19. switchBlock.addChildToBack(statements);
  20. }

代码示例来源:origin: com.github.tntim96/rhino

  1. /**
  2. * If caseExpression argument is null it indicates a default label.
  3. */
  4. private void addSwitchCase(Node switchBlock, Node caseExpression,
  5. Node statements)
  6. {
  7. if (switchBlock.getType() != Token.BLOCK) throw Kit.codeBug();
  8. Jump switchNode = (Jump)switchBlock.getFirstChild();
  9. if (switchNode.getType() != Token.SWITCH) throw Kit.codeBug();
  10. Node gotoTarget = Node.newTarget();
  11. if (caseExpression != null) {
  12. Jump caseNode = new Jump(Token.CASE, caseExpression);
  13. caseNode.target = gotoTarget;
  14. switchNode.addChildToBack(caseNode);
  15. } else {
  16. switchNode.setDefault(gotoTarget);
  17. }
  18. switchBlock.addChildToBack(gotoTarget);
  19. switchBlock.addChildToBack(statements);
  20. }

代码示例来源:origin: io.apigee/rhino

  1. /**
  2. * If caseExpression argument is null it indicates a default label.
  3. */
  4. private void addSwitchCase(Node switchBlock, Node caseExpression,
  5. Node statements)
  6. {
  7. if (switchBlock.getType() != Token.BLOCK) throw Kit.codeBug();
  8. Jump switchNode = (Jump)switchBlock.getFirstChild();
  9. if (switchNode.getType() != Token.SWITCH) throw Kit.codeBug();
  10. Node gotoTarget = Node.newTarget();
  11. if (caseExpression != null) {
  12. Jump caseNode = new Jump(Token.CASE, caseExpression);
  13. caseNode.target = gotoTarget;
  14. switchNode.addChildToBack(caseNode);
  15. } else {
  16. switchNode.setDefault(gotoTarget);
  17. }
  18. switchBlock.addChildToBack(gotoTarget);
  19. switchBlock.addChildToBack(statements);
  20. }

相关文章