Package org.zkoss.zuss.metainfo

Examples of org.zkoss.zuss.metainfo.MixinDefinition


        parseExpression(ctx, expr, ';');
        new VariableDefinition(
          ctx.block.owner, name, expr, lineno);
        return;
      } else if (symbol == '{') { //mixin definition
        newBlock(ctx, new MixinDefinition(
          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
      char cc = _in.peekAfterRPAREN();
      if (cc == ';' || cc == '}' || cc == EOF) { //use of function/mixin
        putback(t0);
        putback(id);
        parseExpression(ctx, new Expression(ctx.block.owner, lineno), EOPAREN);

        t0 = next(ctx);
        if (t0 instanceof Symbol) {
          switch (((Symbol)t0).getValue()) {
          case '}':
            putback(t0);
            //fall thru
          case ';':
            return; //done
          }
        }
        throw error("';' expected; not "+t0, t0);
      }

      //definition of function/mixin
      final ArgumentDefinition[] adefs = parseArguments(ctx);
      t0 = next(ctx);
      if (t0 instanceof Symbol) {
        final char symbol = ((Symbol)t0).getValue();
        if (symbol == ':') { //function definition
          Token t1 = next(ctx);
          if (t1 instanceof Keyword && ((Keyword)t1).getValue() == IMPORT) {
            t0 = next(ctx);
            if (!(t0 instanceof Other))
              throw error("a class name expected, not "+t0, t0);
            nextAndCheck(ctx, ';', true);

            final Method mtd = Classes.getMethod(
              ((Other)t0).getValue(), name, adefs.length,
              getFilename(), t0.getLine());
            new FunctionDefinition(
              ctx.block.owner, name, adefs, mtd, lineno);
            return;
          } else {
            putback(t1);
            final Expression expr = new Expression(t0.getLine());
              //note: expr is NOT a child of any node but part of VariableDefinition below
            parseExpression(ctx, expr, ';');
            new FunctionDefinition(
              ctx.block.owner, name, adefs, expr, lineno);
            return;
          }
        } else if (symbol == '{') { //mixin
          newBlock(ctx, new MixinDefinition(
            ctx.block.owner, name, adefs, lineno));
          return;
        }
      }
    }
View Full Code Here


        //spec: evaluate when it is defined (not when it is used)
    } else if (node instanceof FunctionDefinition) {
      final FunctionDefinition fd = (FunctionDefinition)node;
      scope.setVariable(fd.getName(), fd);
    } else if (node instanceof MixinDefinition) {
      final MixinDefinition fd = (MixinDefinition)node;
      scope.setVariable(fd.getName(), fd);
    } else if (node instanceof IfDefinition) { //assume not in a rule (outerSel shall be null)
      for (NodeInfo child: node.getChildren()) {
        final BlockDefinition block = (BlockDefinition)child;
        final Expression expr = block.getCondition();
        if (expr == null || isTrue(scope, expr)) {
View Full Code Here

TOP

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

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.