Examples of FunctionValue


Examples of org.zkoss.zuss.metainfo.FunctionValue

        if (_in.peek() == '(') { //a function invocation
          putback(token);
          parseExpression(ctx, new Expression(sdef, token.getLine()), EOPAREN);
            //note: the expression is a child of sdef
        } else {
          new FunctionValue(sdef, ((Id)token).getValue(), token.getLine()); //no parenthesis
        }
      }
    }
  }
View Full Code Here

Examples of org.zkoss.zuss.metainfo.FunctionValue

          l_pop:
          while (!ops.isEmpty()) {
            final Op xop = ops.remove(0);
            switch (xop.getValue()) {
            case FUNC:
              new FunctionValue(expr, xop.getData(), argc, xop.getLine());
              //fall thru
            case LPAREN:
              break l_pop; //done
            case COMMA:
              ++argc;
              break;
            default:
              new Operator(expr, xop.getValue(), xop.getLine());
            }
          }
          if (endcc == EOPAREN && ops.isEmpty())
            break; //done
          continue; //next token
        } else if (op.getValue() == LPAREN)
          throw error("unexpected '('", op);

        //push an operator
        while (!ops.isEmpty()) {
          final Op xop = ops.get(0);
          final Operator.Type xtype = xop.getValue();
          if (xtype.getPrecedence() > op.getValue().getPrecedence())
            break;
          //move ops[0] to expression since the precedence is GE
          ops.remove(0);
          new Operator(expr, xop.getValue(), xop.getLine());
        }
        ops.add(0, op);
        opExpected = false;
      } else {
        if (opExpected)
          throw error("an operator expected, not "+token, token);

        if (token instanceof Id) {
          final String nm = ((Id)token).getValue();
          Token t = next(ctx);
          if (!(t instanceof Op) || ((Op)t).getValue() != LPAREN) {
            putback(t);
            new FunctionValue(expr, nm, token.getLine()); //no parenthesis
          } else { //function invocation
            t = next(ctx);
            if (t instanceof Op && ((Op)t).getValue() == RPAREN) {
              //handle no arg invocation special, since it is not easy
              //to tell the difference between f(a) vs. f()
              new FunctionValue(expr, nm, 0, token.getLine()); //empty parenthesis
              if (endcc == EOPAREN && ops.isEmpty())
                break; //done
            } else {
              putback(t);
              ops.add(0, new Op(FUNC, nm, token.getLine())); //pass name as op's data
View Full Code Here

Examples of org.zkoss.zuss.metainfo.FunctionValue

   */
  private MixinInfo getMixinInfo(Scope scope, Expression expr)
  throws IOException {
    final List<NodeInfo> exprList = expr.getChildren();
    final int j;
    final FunctionValue fv;
    Object fn;
    if ((j = exprList.size() - 1) >= 0
    && ((fn=exprList.get(j)) instanceof FunctionValue)
    && (fn = scope.getVariable((fv=(FunctionValue)fn).getName(), false))
      instanceof MixinDefinition) {
      List<Object> values = evalExpression(scope, exprList.subList(0, j));
      return new MixinInfo((MixinDefinition)fn,
         getArgumentMap(
          ((MixinDefinition)fn).getArgumentDefinitions(),
          getArguments(values, fv.getArgumentNumber(), fv.getLine())));
    }
    return null;
  }
View Full Code Here

Examples of org.zkoss.zuss.metainfo.FunctionValue

      if (node instanceof Operator) {
        final Operator.Type opType = ((Operator)node).getType();
        values.add(opType.invoke(getArguments(
          values, opType.getArgumentNumber(), node.getLine())));
      } else if (node instanceof FunctionValue) {
        final FunctionValue fv = (FunctionValue)node;
        values.add(evalFunctionValue(scope, fv,
          getArguments(values, fv.getArgumentNumber(), fv.getLine())));
      } else {
        values.add(evalNode(scope, node));
      }
    }
    return values;
View Full Code Here

Examples of railo.runtime.type.FunctionValue

    Array[] columns=new Array[arr.length];
    int count=0;
   
    for(int i=0;i<arr.length;i++) {
      if(arr[i] instanceof FunctionValue) {
        FunctionValue vf = (FunctionValue)arr[i];
        if(vf.getValue() instanceof Array) {
          names[count]=vf.getNameAsString();
          columns[count]=(Array) vf.getValue();
          count++;
        }
        else throw new DatabaseException("invalid argument for function query, only array as value are allowed","example: query(column1:array(1,2,3))",null,null);
      }
      else throw new DatabaseException("invalid argument for function query, only named argument are allowed","example: query(column1:array(1,2,3))",null,null);
View Full Code Here

Examples of railo.runtime.type.FunctionValue

   
    Struct namedArguments=null;
    Object[] arguments=null;
    if(objArr.length<=3)arguments=ArrayUtil.OBJECT_EMPTY;
    else if(objArr[3] instanceof FunctionValue){
      FunctionValue fv;
      namedArguments=new StructImpl();
      if(caller)namedArguments.setEL(KeyConstants._caller, Duplicator.duplicate(pc.undefinedScope(),false));
      for(int i=3;i<objArr.length;i++){
        fv=toFunctionValue(name,objArr[i]);
        namedArguments.set(fv.getName(), fv.getValue());
      }
    }
    else {
      int offset=(caller?2:3);
      arguments=new Object[objArr.length-offset];
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.