Package org.mozilla.javascript

Examples of org.mozilla.javascript.Node$Symbol


   * @param scope
   *          表达式子节点生存域
   */
  public MemberExpression(Node node, ScriptOrFnNode root, Scope scope) {
    super(node.getLineno());
    Node firstChild = node.getFirstChild();
    target = addExpression(firstChild, root, scope);

    node = firstChild.getNext();
    if (node.getType() == Token.STRING) {
      member = scope.addConstant(node.getString(), true);
    } else {
      memberExpression = addExpression(node, root, scope);
    }
View Full Code Here


    ScriptOrFnNode root = parser.parse(reader, null, 1);

    Environment env = new Environment(keepLineno, mode);
    GlobalScope globalScope = new GlobalScope();
    StatementList statements = new StatementList();
    Node node = root.getFirstChild();
    while (node != null) {
      IStatement statement = Utils.createStatement(node, root, globalScope);
      statements.add(statement);
      node = statement.getNext();
    }
View Full Code Here

   * @param scope
   *          表达式子节点生存域
   */
  public BinaryExpression(Node node, ScriptOrFnNode root, Scope scope) {
    super(node.getLineno());
    Node firstChild = node.getFirstChild();

    tokenType = node.getType();

    if (firstChild.getType() != Token.USE_STACK) {
      if (tokenType == Token.SETPROP || tokenType == Token.SETELEM
          || tokenType == Token.SETPROP_OP || tokenType == Token.SETELEM_OP) {
        leftExpression = new MemberExpression(node, root, scope);
        leftExpression.setParent(this);
      } else {
View Full Code Here

            Object value;
            try {
              if(!(expression.getFirstChild().getType() == Token.GETPROP && expression.getFirstChild().getFirstChild().getType() == Token.THIS))
                throw new QueryCantBeHandled("Can't handle non-direct property comparisons");
              property = expression.getFirstChild().getLastChild().getString();
              Node valueNode = expression.getLastChild();
              switch(valueNode.getType()){
                case Token.STRING:
                  value = valueNode.getString();
                  break;
                case Token.NUMBER:
                  value = valueNode.getDouble();
                  break;
                case Token.NULL:
                  value = null;
                  break;
                case Token.TRUE:
                  value = true;
                  break;
                case Token.FALSE:
                  value = false;
                  break;
                case Token.AND:
                  if(valueNode.getLastChild().getType() == Token.GETPROP && "__ids__".equals(valueNode.getLastChild().getFirstChild().getString())){
                    value = Identification.idForString(valueNode.getFirstChild().getString());
                    break;
                  }
                  throw new QueryCantBeHandled("unknown value type");
                case Token.CALL:
                  if(valueNode.getFirstChild().getType() == Token.NAME &&
                      "date".equals(valueNode.getFirstChild().getString())){
                    value = new Date((long) valueNode.getLastChild().getDouble());
                    break;
                  }
                default:
                  throw new QueryCantBeHandled("unknown value type");
              }
View Full Code Here

    newQuery.source = oldQuery.source;
    newQuery.subObjectId = oldQuery.subObjectId;
    Parser p = new Parser(compilerEnvirons, compilerEnvirons.getErrorReporter());
        ScriptOrFnNode tree;
        tree = p.parse("(" + queryStr + ")", "jsonpath-sub-expression", 0);
        Node functionBody = tree.getFunctionNode(0).getFirstChild();
        Node returnNode = functionBody.getFirstChild();
        if(returnNode.getType() != Token.RETURN){
          returnNode = returnNode.getFirstChild().getFirstChild().getFirstChild();
        }
        Node queryNode = returnNode.getFirstChild();
        replaceStrings(queryNode, returnNode, parameters);
        if(condition){
          if(oldQuery.condition == null)
            newQuery.condition = queryNode;
          else{
            Node andNode = new Node(Token.AND);
            andNode.addChildToBack(oldQuery.condition);
            andNode.addChildToBack(queryNode);
            newQuery.condition = andNode;
          }
        }
        else {
          newQuery.condition = oldQuery.condition;
View Full Code Here

        }
    return newQuery;
  }
  static void replaceStrings(Node node, Node parent, Scriptable parameters) {
    if (node.getType() == Token.CALL) {
      Node caller = node.getFirstChild();
    }
    if (node.getType() == Token.NAME && ("$obj".equals(node.getString()) || "$obj".equals(node.getString()))) {
      node.setType(Token.THIS);
    }
    if (node.getType() == Token.GETPROP && node.getFirstChild().getType() == Token.NAME &&
        "args".equals(node.getFirstChild().getString()) && node.getLastChild().getType() == Token.STRING &&
        node.getLastChild().getString().startsWith("param")) {
      Object value = parameters.get(node.getLastChild().getString(),parameters);
      if (value instanceof String) {
        parent.replaceChild(node,Node.newString((String) value));
      }
      else if (value instanceof Number) {
        parent.replaceChild(node,Node.newNumber(((Number) value).doubleValue()));
      }
      else if (value instanceof Persistable) {
        node.setType(Token.EQ);
        while(node.getFirstChild() != null)
          node.removeChild(node.getFirstChild());
        node.addChildToFront(new Node(Token.DOT,new Node(Token.THIS),new Node(Token.NAME)));
        node.addChildToFront(new Node(Token.STRING));
        node.getFirstChild().getLastChild().setString("id");
        node.getLastChild().setString(((Persistable)value).getId().subObjectId);
      }
      //TODO: Do the rest of these
    }
View Full Code Here

   * Update internal literal member list with
   * current values by traversing child nodes of literal declaration.
   */
  protected void parseArrayPropertyValues() {
    arrayPropertyValues = new ArrayList<Object>();   
    Node arrayItem = literalNode.getFirstChild();
   
    while(arrayItem != null) {
      arrayPropertyValues.add(extractPropertyValue(arrayItem));     
      arrayItem = arrayItem.getNext();
    }     
  }
View Full Code Here

    List<String> keys = getKeys();

    int index = keys.indexOf(key);

    if (index != -1) {
      Node propertyValue = literalNode.getFirstChild();
      while (index > 0) {
        propertyValue = propertyValue.getNext()
        index--;
      }
      literalValues.put(key, extractPropertyValue(propertyValue));
    }               
  } 
View Full Code Here

   *
   * @param node - AST node
   * @return AST node is global configuration declaration
   */
  protected boolean isGlobalDefinition(Node node) {
    Node globalNameReference = node.getFirstChild();
   
    if (globalNameReference != null && Token.SETNAME == globalNameReference.getType()) {
      String label = getStringNodeLabel(globalNameReference.getFirstChild());             
      if (matchesLoaderConfigName(label)) {
        addConfigurationLiteral(node, globalNameReference.getLastChild());
        return true;
      }
    }
   
    return false;
View Full Code Here

   *
   * @param node - AST node
   * @return AST node is local configuration declaration
   */
  protected boolean isLocalDefinition(Node node) {
    Node localNameReference = node.getFirstChild();
   
    if (localNameReference != null && Token.NAME == localNameReference.getType()) {
      String label = getStringNodeLabel(localNameReference);             
      if (matchesLoaderConfigName(label)) {
        addConfigurationLiteral(node, localNameReference.getLastChild());
        return true;
      }
    }
   
    return false;
View Full Code Here

TOP

Related Classes of org.mozilla.javascript.Node$Symbol

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.