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

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

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

Node.getLastChild介绍

暂无

代码示例

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

Node createCallOrNew(int nodeType, Node child)
{
  int type = Node.NON_SPECIALCALL;
  if (child.getType() == Token.NAME) {
    String name = child.getString();
    if (name.equals("eval")) {
      type = Node.SPECIALCALL_EVAL;
    } else if (name.equals("With")) {
      type = Node.SPECIALCALL_WITH;
    }
  } else if (child.getType() == Token.GETPROP) {
    String name = child.getLastChild().getString();
    if (name.equals("eval")) {
      type = Node.SPECIALCALL_EVAL;
    }
  }
  Node node = new Node(nodeType, child);
  if (type != Node.NON_SPECIALCALL) {
    // Calls to these functions require activation objects.
    setRequiresActivation();
    node.putIntProp(Node.SPECIALCALL_PROP, type);
  }
  return node;
}

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

private Node createCallOrNew(int nodeType, Node child) {
  int type = Node.NON_SPECIALCALL;
  if (child.getType() == Token.NAME) {
    String name = child.getString();
    if (name.equals("eval")) {
      type = Node.SPECIALCALL_EVAL;
    } else if (name.equals("With")) {
      type = Node.SPECIALCALL_WITH;
    }
  } else if (child.getType() == Token.GETPROP) {
    String name = child.getLastChild().getString();
    if (name.equals("eval")) {
      type = Node.SPECIALCALL_EVAL;
    }
  }
  Node node = new Node(nodeType, child);
  if (type != Node.NON_SPECIALCALL) {
    // Calls to these functions require activation objects.
    setRequiresActivation();
    node.putIntProp(Node.SPECIALCALL_PROP, type);
  }
  return node;
}

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

Node createCallOrNew(int nodeType, Node child)
{
  int type = Node.NON_SPECIALCALL;
  if (child.getType() == Token.NAME) {
    String name = child.getString();
    if (name.equals("eval")) {
      type = Node.SPECIALCALL_EVAL;
    } else if (name.equals("With")) {
      type = Node.SPECIALCALL_WITH;
    }
  } else if (child.getType() == Token.GETPROP) {
    String name = child.getLastChild().getString();
    if (name.equals("eval")) {
      type = Node.SPECIALCALL_EVAL;
    }
  }
  Node node = new Node(nodeType, child);
  if (type != Node.NON_SPECIALCALL) {
    // Calls to these functions require activation objects.
    setRequiresActivation();
    node.putIntProp(Node.SPECIALCALL_PROP, type);
  }
  return node;
}

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

private Node createCallOrNew(int nodeType, Node child) {
  int type = Node.NON_SPECIALCALL;
  if (child.getType() == Token.NAME) {
    String name = child.getString();
    if (name.equals("eval")) {
      type = Node.SPECIALCALL_EVAL;
    } else if (name.equals("With")) {
      type = Node.SPECIALCALL_WITH;
    }
  } else if (child.getType() == Token.GETPROP) {
    String name = child.getLastChild().getString();
    if (name.equals("eval")) {
      type = Node.SPECIALCALL_EVAL;
    }
  }
  Node node = new Node(nodeType, child);
  if (type != Node.NON_SPECIALCALL) {
    // Calls to these functions require activation objects.
    setRequiresActivation();
    node.putIntProp(Node.SPECIALCALL_PROP, type);
  }
  return node;
}

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

private Node createCallOrNew(int nodeType, Node child) {
  int type = Node.NON_SPECIALCALL;
  if (child.getType() == Token.NAME) {
    String name = child.getString();
    if (name.equals("eval")) {
      type = Node.SPECIALCALL_EVAL;
    } else if (name.equals("With")) {
      type = Node.SPECIALCALL_WITH;
    }
  } else if (child.getType() == Token.GETPROP) {
    String name = child.getLastChild().getString();
    if (name.equals("eval")) {
      type = Node.SPECIALCALL_EVAL;
    }
  }
  Node node = new Node(nodeType, child);
  if (type != Node.NON_SPECIALCALL) {
    // Calls to these functions require activation objects.
    setRequiresActivation();
    node.putIntProp(Node.SPECIALCALL_PROP, type);
  }
  return node;
}

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

private Node createCallOrNew(int nodeType, Node child) {
  int type = Node.NON_SPECIALCALL;
  if (child.getType() == Token.NAME) {
    String name = child.getString();
    if (name.equals("eval")) {
      type = Node.SPECIALCALL_EVAL;
    } else if (name.equals("With")) {
      type = Node.SPECIALCALL_WITH;
    }
  } else if (child.getType() == Token.GETPROP) {
    String name = child.getLastChild().getString();
    if (name.equals("eval")) {
      type = Node.SPECIALCALL_EVAL;
    }
  }
  Node node = new Node(nodeType, child);
  if (type != Node.NON_SPECIALCALL) {
    // Calls to these functions require activation objects.
    setRequiresActivation();
    node.putIntProp(Node.SPECIALCALL_PROP, type);
  }
  return node;
}

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

/**
 * Given a destructuring assignment with a left hand side parsed
 * as an array or object literal and a right hand side expression,
 * rewrite as a series of assignments to the variables defined in
 * left from property accesses to the expression on the right.
 * @param type declaration type: Token.VAR or Token.LET or -1
 * @param left array or object literal containing NAME nodes for
 *        variables to assign
 * @param right expression to assign from
 * @return expression that performs a series of assignments to
 *         the variables defined in left
 */
Node createDestructuringAssignment(int type, Node left, Node right)
{
  String tempName = currentScriptOrFn.getNextTempName();
  Node result = destructuringAssignmentHelper(type, left, right,
    tempName);
  Node comma = result.getLastChild();
  comma.addChildToBack(createName(tempName));
  return result;
}

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

/**
 * Given a destructuring assignment with a left hand side parsed
 * as an array or object literal and a right hand side expression,
 * rewrite as a series of assignments to the variables defined in
 * left from property accesses to the expression on the right.
 * @param type declaration type: Token.VAR or Token.LET or -1
 * @param left array or object literal containing NAME nodes for
 *        variables to assign
 * @param right expression to assign from
 * @return expression that performs a series of assignments to
 *         the variables defined in left
 */
Node createDestructuringAssignment(int type, Node left, Node right)
{
  String tempName = parser.currentScriptOrFn.getNextTempName();
  Node result = destructuringAssignmentHelper(type, left, right,
    tempName);
  Node comma = result.getLastChild();
  comma.addChildToBack(createName(tempName));
  return result;
}

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

/**
 * Given a destructuring assignment with a left hand side parsed
 * as an array or object literal and a right hand side expression,
 * rewrite as a series of assignments to the variables defined in
 * left from property accesses to the expression on the right.
 * @param type declaration type: Token.VAR or Token.LET or -1
 * @param left array or object literal containing NAME nodes for
 *        variables to assign
 * @param right expression to assign from
 * @return expression that performs a series of assignments to
 *         the variables defined in left
 */
Node createDestructuringAssignment(int type, Node left, Node right)
{
  String tempName = currentScriptOrFn.getNextTempName();
  Node result = destructuringAssignmentHelper(type, left, right,
    tempName);
  Node comma = result.getLastChild();
  comma.addChildToBack(createName(tempName));
  return result;
}

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

/**
 * Given a destructuring assignment with a left hand side parsed
 * as an array or object literal and a right hand side expression,
 * rewrite as a series of assignments to the variables defined in
 * left from property accesses to the expression on the right.
 * @param type declaration type: Token.VAR or Token.LET or -1
 * @param left array or object literal containing NAME nodes for
 *        variables to assign
 * @param right expression to assign from
 * @return expression that performs a series of assignments to
 *         the variables defined in left
 */
Node createDestructuringAssignment(int type, Node left, Node right)
{
  String tempName = currentScriptOrFn.getNextTempName();
  Node result = destructuringAssignmentHelper(type, left, right,
    tempName);
  Node comma = result.getLastChild();
  comma.addChildToBack(createName(tempName));
  return result;
}

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

/**
 * Given a destructuring assignment with a left hand side parsed
 * as an array or object literal and a right hand side expression,
 * rewrite as a series of assignments to the variables defined in
 * left from property accesses to the expression on the right.
 * @param type declaration type: Token.VAR or Token.LET or -1
 * @param left array or object literal containing NAME nodes for
 *        variables to assign
 * @param right expression to assign from
 * @return expression that performs a series of assignments to
 *         the variables defined in left
 */
Node createDestructuringAssignment(int type, Node left, Node right)
{
  String tempName = currentScriptOrFn.getNextTempName();
  Node result = destructuringAssignmentHelper(type, left, right,
    tempName);
  Node comma = result.getLastChild();
  comma.addChildToBack(createName(tempName));
  return result;
}

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

private Node simpleAssignment(Node left, Node right)
{
  int nodeType = left.getType();
  switch (nodeType) {
   case Token.NAME:
    left.setType(Token.BINDNAME);
    return new Node(Token.SETNAME, left, right);
   case Token.GETPROP:
   case Token.GETELEM: {
    Node obj = left.getFirstChild();
    Node id = left.getLastChild();
    int type;
    if (nodeType == Token.GETPROP) {
      type = Token.SETPROP;
    } else {
      type = Token.SETELEM;
    }
    return new Node(type, obj, id, right);
   }
   case Token.GET_REF: {
    Node ref = left.getFirstChild();
    checkMutableReference(ref);
    return new Node(Token.SET_REF, ref, right);
   }
  }
  throw Kit.codeBug();
}

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

private Node simpleAssignment(Node left, Node right)
{
  int nodeType = left.getType();
  switch (nodeType) {
   case Token.NAME:
    left.setType(Token.BINDNAME);
    return new Node(Token.SETNAME, left, right);
   case Token.GETPROP:
   case Token.GETELEM: {
    Node obj = left.getFirstChild();
    Node id = left.getLastChild();
    int type;
    if (nodeType == Token.GETPROP) {
      type = Token.SETPROP;
    } else {
      type = Token.SETELEM;
    }
    return new Node(type, obj, id, right);
   }
   case Token.GET_REF: {
    Node ref = left.getFirstChild();
    checkMutableReference(ref);
    return new Node(Token.SET_REF, ref, right);
   }
  }
  throw Kit.codeBug();
}

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

Node lastStmt = statements.getLastChild();
if (lastStmt == null || lastStmt.getType() != Token.RETURN) {
  statements.addChildToBack(new Node(Token.RETURN));

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

Node lastStmt = statements.getLastChild();
if (lastStmt == null || lastStmt.getType() != Token.RETURN) {
  statements.addChildToBack(new Node(Token.RETURN));

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

Node lastChild = lhs.getLastChild();
if (lhs.getFirstChild() != lastChild) {
  parser.reportError("msg.mult.index");

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

Node lastStmt = statements.getLastChild();
if (lastStmt == null || lastStmt.getType() != Token.RETURN) {
  statements.addChildToBack(new Node(Token.RETURN));

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

Node lastStmt = statements.getLastChild();
if (lastStmt == null || lastStmt.getType() != Token.RETURN) {
  statements.addChildToBack(new Node(Token.RETURN));

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

Node lastStmt = statements.getLastChild();
if (lastStmt == null || lastStmt.getType() != Token.RETURN) {
  statements.addChildToBack(new Node(Token.RETURN));

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

Node lastStmt = statements.getLastChild();
if (lastStmt == null || lastStmt.getType() != Token.RETURN) {
  statements.addChildToBack(new Node(Token.RETURN));

相关文章

微信公众号