Package org.mvel2

Examples of org.mvel2.CompileException


            cursor = ParseTools.skipWhitespace(expr, cursor);
            start = cursor;
            while (cursor < endOffset && isIdentifierPart(expr[cursor])) cursor++;

            if (start == cursor) {
              throw new CompileException("attempt to declare an anonymous function as a prototype member",
                  expr, start);
            }

            FunctionParser parser =
                new FunctionParser(new String(expr, start, cursor - start),
                    cursor, endOffset, expr, 0, pCtx, null);

            proto.declareReceiver(parser.getName(), parser.parse());
            cursor = parser.getCursor() + 1;

            tk1 = null;
            continue;
          }
        }

        cursor = ParseTools.skipWhitespace(expr, cursor);
      }

      if (cursor > endOffset) {
        throw new CompileException("unexpected end of statement in proto declaration: " + protoName,
            expr, start);
      }

      switch (expr[cursor]) {
        case ';':
View Full Code Here


          type = DeferredTypeResolve.class;
          deferredName = tk1;
          name = tk2;
        }
        else {
          throw new CompileException("could not resolve class: " + tk1, expr, cursor, e);
        }
      }
    }
    else {
      type = Object.class;
View Full Code Here

        while (cursor > last && ParseTools.isWhitespace(expr[cursor])) cursor--;
        while (cursor > last && ParseTools.isIdentifierPart(expr[cursor])) cursor--;
        while (cursor > last && (ParseTools.isWhitespace(expr[cursor]) || expr[cursor] == ';')) cursor--;

        if (cursor != last) {
          throw new CompileException("unresolved reference (possible illegal forward-reference?): " +
              ProtoParser.getNextUnresolvedWaiting(), expr, proto.getCursorStart());
        }
      }
    }
  }
View Full Code Here

  protected boolean idxAlloc = false;

  public IfNode(char[] expr, int start, int offset, int blockStart, int blockOffset, int fields, ParserContext pCtx) {
    super(pCtx);
    if ((this.expr = expr) == null || offset == 0) {
      throw new CompileException("statement expected", expr, start);
    }
    this.start = start;
    this.offset = offset;
    this.blockStart = blockStart;
    this.blockOffset = blockOffset;
View Full Code Here

        else if (tkOp.isOperator() && tkOp.getOperator() < 21) {
          int op = tkOp.getOperator();
          int op2;

          if (op == -1) {
            throw new CompileException("illegal use of operator: " + tkOp.getName(), tkOp.getExpr(), tk.getStart());
          }


          ASTNode tk2 = astLinkedList.nextNode();
          BinaryOperation bo;
View Full Code Here

  public static void expectType(Accessor expression, Class type, boolean compileMode) {
    Class retType = expression.getKnownEgressType();
    if (compileMode) {
      if ((retType == null || !boxPrimitive(type).isAssignableFrom(boxPrimitive(retType))) && (!Object.class.equals(retType)
          || getCurrentThreadParserContext().isStrictTypeEnforcement())) {
        throw new CompileException("was expecting type: " + type.getName() + "; but found type: "
            + (retType != null ? retType.getName() : "<Unknown>"), new char[0], 0);
      }
    }
    else if (retType == null || !Object.class.equals(retType) && !boxPrimitive(type).isAssignableFrom(boxPrimitive(retType))) {
      throw new CompileException("was expecting type: " + type.getName() + "; but found type: "
          + (retType != null ? retType.getName() : "<Unknown>"), new char[0], 0);
    }
  }
View Full Code Here

    Class retType = boxPrimitive(node.getEgressType());
    if (compileMode) {
      if ((retType == null || !boxPrimitive(type).isAssignableFrom(retType)) && (!Object.class.equals(retType) &&
          (getCurrentThreadParserContext().isStrictTypeEnforcement()
              || getCurrentThreadParserContext().isStrictTypeEnforcement()))) {
        throw new CompileException("was expecting type: " + type.getName() + "; but found type: "
            + (retType != null ? retType.getName() : "<Unknown>"), new char[0], 0);
      }
    }
    else if (retType == null || !Object.class.equals(retType) && !boxPrimitive(type).isAssignableFrom(retType)) {
      throw new CompileException("was expecting type: " + type.getName() + "; but found type: "
          + (retType != null ? retType.getName() : "<Unknown>"), new char[0], 0);
    }
  }
View Full Code Here

    }
    else if (number instanceof Short) {
      return -((Short) number);
    }
    else {
      throw new CompileException("expected a numeric type but found: " + number.getClass().getName(), new char[0], 0);
    }
  }
View Full Code Here

    try {
      String i = String.valueOf(soundslike.getReducedValue(ctx, thisValue, factory));
      if (i == null) throw new ClassCastException();

      String x = (String) stmt.getReducedValue(ctx, thisValue, factory);
      if (x == null) throw new CompileException("not a string: " + stmt.getName(), stmt.getExpr(), getStart());

      return similarity(i, x);
    }
    catch (ClassCastException e) {
      throw new CompileException("not a string: " + soundslike.getName(), soundslike.getExpr(), soundslike.getStart());
    }

  }
View Full Code Here

    }
  }

  public Object getReducedValueAccelerated(Object ctx, Object thisValue, VariableResolverFactory factory) {
    if (!factory.isResolveable(name)) factory.createVariable(name, null, egressType);
    else throw new CompileException("variable defined within scope: " + name, expr, start);
    return null;
  }
View Full Code Here

TOP

Related Classes of org.mvel2.CompileException

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.