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

x33g5p2x  于2022-01-26 转载在 JavaScript  
字(8.0k)|赞(0)|评价(0)|浏览(474)

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

Parser.createName介绍

[英]Create a Name node using the token info from the last scanned name. In some cases we need to either synthesize a name node, or we lost the name token information by peeking. If the token parameter is not Token#NAME, then we use token info saved in instance vars.
[中]使用上次扫描的名称中的令牌信息创建名称节点。在某些情况下,我们需要合成一个名称节点,或者通过偷看丢失名称标记信息。如果token参数不是token#NAME,那么我们使用实例变量中保存的token info。

代码示例

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

  1. protected Node createName(int type, String name, Node child) {
  2. Node result = createName(name);
  3. result.setType(type);
  4. if (child != null)
  5. result.addChildToBack(child);
  6. return result;
  7. }

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

  1. param.getValue(), createName(param.getKey()));
  2. destructuringNode.addChildToBack(assign);

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

  1. protected Node createName(int type, String name, Node child) {
  2. Node result = createName(name);
  3. result.setType(type);
  4. if (child != null)
  5. result.addChildToBack(child);
  6. return result;
  7. }

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

  1. protected Node createName(int type, String name, Node child) {
  2. Node result = createName(name);
  3. result.setType(type);
  4. if (child != null)
  5. result.addChildToBack(child);
  6. return result;
  7. }

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

  1. protected Node createName(int type, String name, Node child) {
  2. Node result = createName(name);
  3. result.setType(type);
  4. if (child != null)
  5. result.addChildToBack(child);
  6. return result;
  7. }

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

  1. /**
  2. * Given a destructuring assignment with a left hand side parsed
  3. * as an array or object literal and a right hand side expression,
  4. * rewrite as a series of assignments to the variables defined in
  5. * left from property accesses to the expression on the right.
  6. * @param type declaration type: Token.VAR or Token.LET or -1
  7. * @param left array or object literal containing NAME nodes for
  8. * variables to assign
  9. * @param right expression to assign from
  10. * @return expression that performs a series of assignments to
  11. * the variables defined in left
  12. */
  13. Node createDestructuringAssignment(int type, Node left, Node right)
  14. {
  15. String tempName = currentScriptOrFn.getNextTempName();
  16. Node result = destructuringAssignmentHelper(type, left, right,
  17. tempName);
  18. Node comma = result.getLastChild();
  19. comma.addChildToBack(createName(tempName));
  20. return result;
  21. }

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

  1. /**
  2. * Given a destructuring assignment with a left hand side parsed
  3. * as an array or object literal and a right hand side expression,
  4. * rewrite as a series of assignments to the variables defined in
  5. * left from property accesses to the expression on the right.
  6. * @param type declaration type: Token.VAR or Token.LET or -1
  7. * @param left array or object literal containing NAME nodes for
  8. * variables to assign
  9. * @param right expression to assign from
  10. * @return expression that performs a series of assignments to
  11. * the variables defined in left
  12. */
  13. Node createDestructuringAssignment(int type, Node left, Node right)
  14. {
  15. String tempName = currentScriptOrFn.getNextTempName();
  16. Node result = destructuringAssignmentHelper(type, left, right,
  17. tempName);
  18. Node comma = result.getLastChild();
  19. comma.addChildToBack(createName(tempName));
  20. return result;
  21. }

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

  1. /**
  2. * Given a destructuring assignment with a left hand side parsed
  3. * as an array or object literal and a right hand side expression,
  4. * rewrite as a series of assignments to the variables defined in
  5. * left from property accesses to the expression on the right.
  6. * @param type declaration type: Token.VAR or Token.LET or -1
  7. * @param left array or object literal containing NAME nodes for
  8. * variables to assign
  9. * @param right expression to assign from
  10. * @return expression that performs a series of assignments to
  11. * the variables defined in left
  12. */
  13. Node createDestructuringAssignment(int type, Node left, Node right)
  14. {
  15. String tempName = currentScriptOrFn.getNextTempName();
  16. Node result = destructuringAssignmentHelper(type, left, right,
  17. tempName);
  18. Node comma = result.getLastChild();
  19. comma.addChildToBack(createName(tempName));
  20. return result;
  21. }

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

  1. /**
  2. * Given a destructuring assignment with a left hand side parsed
  3. * as an array or object literal and a right hand side expression,
  4. * rewrite as a series of assignments to the variables defined in
  5. * left from property accesses to the expression on the right.
  6. * @param type declaration type: Token.VAR or Token.LET or -1
  7. * @param left array or object literal containing NAME nodes for
  8. * variables to assign
  9. * @param right expression to assign from
  10. * @return expression that performs a series of assignments to
  11. * the variables defined in left
  12. */
  13. Node createDestructuringAssignment(int type, Node left, Node right)
  14. {
  15. String tempName = currentScriptOrFn.getNextTempName();
  16. Node result = destructuringAssignmentHelper(type, left, right,
  17. tempName);
  18. Node comma = result.getLastChild();
  19. comma.addChildToBack(createName(tempName));
  20. return result;
  21. }

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

  1. createName(tempName),
  2. createNumber(index));
  3. if (n.getType() == Token.NAME) {
  4. String name = n.getString();
  5. parent.addChildToBack(new Node(setOp,
  6. createName(Token.BINDNAME,
  7. name, null),
  8. rightElem));

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

  1. createName(tempName),
  2. createNumber(index));
  3. if (n.getType() == Token.NAME) {
  4. String name = n.getString();
  5. parent.addChildToBack(new Node(setOp,
  6. createName(Token.BINDNAME,
  7. name, null),
  8. rightElem));

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

  1. createName(tempName),
  2. createNumber(index));
  3. if (n.getType() == Token.NAME) {
  4. String name = n.getString();
  5. parent.addChildToBack(new Node(setOp,
  6. createName(Token.BINDNAME,
  7. name, null),
  8. rightElem));

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

  1. createName(tempName),
  2. createNumber(index));
  3. if (n.getType() == Token.NAME) {
  4. String name = n.getString();
  5. parent.addChildToBack(new Node(setOp,
  6. createName(Token.BINDNAME,
  7. name, null),
  8. rightElem));

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

  1. if (id instanceof Name) {
  2. Node s = Node.newString(((Name)id).getIdentifier());
  3. rightElem = new Node(Token.GETPROP, createName(tempName), s);
  4. } else if (id instanceof StringLiteral) {
  5. Node s = Node.newString(((StringLiteral)id).getValue());
  6. rightElem = new Node(Token.GETPROP, createName(tempName), s);
  7. } else if (id instanceof NumberLiteral) {
  8. Node s = createNumber((int)((NumberLiteral)id).getNumber());
  9. rightElem = new Node(Token.GETELEM, createName(tempName), s);
  10. } else {
  11. throw codeBug();
  12. String name = ((Name)value).getIdentifier();
  13. parent.addChildToBack(new Node(setOp,
  14. createName(Token.BINDNAME,
  15. name, null),
  16. rightElem));

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

  1. if (id instanceof Name) {
  2. Node s = Node.newString(((Name)id).getIdentifier());
  3. rightElem = new Node(Token.GETPROP, createName(tempName), s);
  4. } else if (id instanceof StringLiteral) {
  5. Node s = Node.newString(((StringLiteral)id).getValue());
  6. rightElem = new Node(Token.GETPROP, createName(tempName), s);
  7. } else if (id instanceof NumberLiteral) {
  8. Node s = createNumber((int)((NumberLiteral)id).getNumber());
  9. rightElem = new Node(Token.GETELEM, createName(tempName), s);
  10. } else {
  11. throw codeBug();
  12. String name = ((Name)value).getIdentifier();
  13. parent.addChildToBack(new Node(setOp,
  14. createName(Token.BINDNAME,
  15. name, null),
  16. rightElem));

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

  1. if (id instanceof Name) {
  2. Node s = Node.newString(((Name)id).getIdentifier());
  3. rightElem = new Node(Token.GETPROP, createName(tempName), s);
  4. } else if (id instanceof StringLiteral) {
  5. Node s = Node.newString(((StringLiteral)id).getValue());
  6. rightElem = new Node(Token.GETPROP, createName(tempName), s);
  7. } else if (id instanceof NumberLiteral) {
  8. Node s = createNumber((int)((NumberLiteral)id).getNumber());
  9. rightElem = new Node(Token.GETELEM, createName(tempName), s);
  10. } else {
  11. throw codeBug();
  12. String name = ((Name)value).getIdentifier();
  13. parent.addChildToBack(new Node(setOp,
  14. createName(Token.BINDNAME,
  15. name, null),
  16. rightElem));

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

  1. createName(Token.NAME, tempName, right)));
  2. try {
  3. pushScope(result);
  4. reportError("msg.bad.assign.left");
  5. comma.addChildToBack(simpleAssignment(left, createName(tempName)));
  6. break;
  7. default:

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

  1. createName(Token.NAME, tempName, right)));
  2. try {
  3. pushScope(result);
  4. reportError("msg.bad.assign.left");
  5. comma.addChildToBack(simpleAssignment(left, createName(tempName)));
  6. break;
  7. default:

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

  1. createName(Token.NAME, tempName, right)));
  2. try {
  3. pushScope(result);
  4. reportError("msg.bad.assign.left");
  5. comma.addChildToBack(simpleAssignment(left, createName(tempName)));
  6. break;
  7. default:

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

  1. createName(Token.NAME, tempName, right)));
  2. try {
  3. pushScope(result);
  4. reportError("msg.bad.assign.left");
  5. comma.addChildToBack(simpleAssignment(left, createName(tempName)));
  6. break;
  7. default:

相关文章

Parser类方法