Package org.zkoss.zuss.metainfo

Examples of org.zkoss.zuss.metainfo.FunctionValue


          ctx.block.owner, name,
          new ArgumentDefinition[0], lineno));
        return;
      } else if (symbol == ';') { //use of function/mixin
        Expression expr = new Expression(ctx.block.owner, lineno);
        new FunctionValue(expr, name, lineno); //no parenthesis
        return;
      }
    } else if (t0 instanceof Op && ((Op)t0).getValue() == LPAREN) {
      //1) definition of function or mixin
      //2) use of function or mixin
View Full Code Here


        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

          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

   */
  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

      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

TOP

Related Classes of org.zkoss.zuss.metainfo.FunctionValue

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.