Examples of UnexpectedType


Examples of org.rascalmpl.interpreter.staticErrors.UnexpectedType

          }
          else if (subscripts[i] == null || relFieldType.comparable(subscriptType[i])){
            subscriptIsSet[i] = false;
          }
          else {
            throw new UnexpectedType(relFieldType, subscriptType[i], ctx.getCurrentAST());
          }
        } else {
          resFieldType[i - nSubs] = relFieldType;
        }
      }
View Full Code Here

Examples of org.rascalmpl.interpreter.staticErrors.UnexpectedType

      Type valueType = __eval.__getValue().getType();

      if (!valueType.isNode() && !valueType.isAbstractData()
          && !valueType.isConstructor()) {
        throw new UnexpectedType(
            org.rascalmpl.interpreter.AssignableEvaluator.__getTf()
                .nodeType(), __eval.__getValue().getType(),
            this);
      }
View Full Code Here

Examples of org.rascalmpl.interpreter.staticErrors.UnexpectedType

        __eval.__setValue(__eval.newResult(receiver.fieldAccess(label, __eval.getCurrentEnvt().getStore()), __eval
            .__getValue()));

        if (!result.getType().isSubtypeOf(receiver.getType())) {
          throw new UnexpectedType(receiver.getType(), result.getType(), __eval.getCurrentAST());
        }
        return __eval.recur(this, result);
      }
      else if (receiver.getType().isConstructor()
          || receiver.getType().isAbstractData()) {
        IConstructor cons = (IConstructor) receiver.getValue();
        Type node = cons.getConstructorType();

        if (node.hasField(label)) {
          int index = node.getFieldIndex(label);

          if (!__eval.__getValue().getType().isSubtypeOf(
              node.getFieldType(index))) {
            throw new UnexpectedType(node.getFieldType(index),
                __eval.__getValue().getType(), this);
          }
          __eval.__setValue(__eval.newResult(cons.get(index), __eval
              .__getValue()));

          IValue result = cons.set(index, __eval.__getValue().getValue());
          return __eval.recur(this,
              org.rascalmpl.interpreter.result.ResultFactory
              .makeResult(receiver.getType(), result, __eval
                  .__getEval()));
        }
        else if (node.hasKeywordParameter(label)) {
          if (!__eval.__getValue().getType().isSubtypeOf(
              node.getKeywordParameterType(label))) {
            throw new UnexpectedType(node.getKeywordParameterType(label),
                __eval.__getValue().getType(), this);
          }

          __eval.__setValue(__eval.newResult(cons.asWithKeywordParameters().getParameter(label), __eval.__getValue()));
View Full Code Here

Examples of org.rascalmpl.interpreter.staticErrors.UnexpectedType

          result = org.rascalmpl.interpreter.result.ResultFactory
              .makeResult(rec.hasInferredType() ? rec.getType()
                  .lub(map.getType()) : rec.getType(), map,
                  __eval.__getEval());
        } else {
          throw new UnexpectedType(keyType, subscript.getType(),
              this.getSubscript());
        }

      } else if (rec.getType().isNode()
          && subscript.getType().isInteger()) {
        int index = ((IInteger) subscript.getValue()).intValue();
        IConstructor node = (IConstructor) rec.getValue();

        if (index >= node.arity()) {
          throw org.rascalmpl.interpreter.utils.RuntimeExceptionFactory
              .indexOutOfBounds((IInteger) subscript.getValue(),
                  __eval.__getEval().getCurrentAST(), __eval
                      .__getEval().getStackTrace());
        }
        __eval.__setValue(__eval.newResult(node.get(index), __eval
            .__getValue()));
        node = node.set(index, __eval.__getValue().getValue());
        result = org.rascalmpl.interpreter.result.ResultFactory
            .makeResult(rec.getType(), node, __eval.__getEval());
      } else if (rec.getType().isTuple()
          && subscript.getType().isInteger()) {
        int index = ((IInteger) subscript.getValue()).intValue();
        ITuple tuple = (ITuple) rec.getValue();

        if (index >= tuple.arity()) {
          throw org.rascalmpl.interpreter.utils.RuntimeExceptionFactory
              .indexOutOfBounds((IInteger) subscript.getValue(),
                  __eval.__getEval().getCurrentAST(), __eval
                      .__getEval().getStackTrace());
        }

        __eval.__setValue(__eval.newResult(tuple.get(index), __eval
            .__getValue()));

        tuple = tuple.set(index, __eval.__getValue().getValue());
        result = org.rascalmpl.interpreter.result.ResultFactory
            .makeResult(rec.getType(), tuple, __eval.__getEval());
      } else if (rec.getType().isRelation()
          && subscript.getType().isSubtypeOf(
              rec.getType().getFieldType(0))) {
        ISet rel = (ISet) rec.getValue();
        IValue sub = subscript.getValue();

        if (rec.getType().getArity() != 2) {
          throw new UnsupportedSubscript(rec.getType(),
              subscript.getType(), this);
        }

        if (!__eval.__getValue().getType().isSubtypeOf(
            rec.getType().getFieldType(1))) {
          throw new UnexpectedType(
              rec.getType().getFieldType(1), __eval.__getValue()
                  .getType(), __eval.__getEval()
                  .getCurrentAST());
        }
View Full Code Here

Examples of org.rascalmpl.interpreter.staticErrors.UnexpectedType

    private void checkType(Type given, Type expected) {
      if (expected instanceof FunctionType) {
        return;
      }
      if (!given.isSubtypeOf(expected)) {
        throw new UnexpectedType(expected, given, this);
      }
    }
View Full Code Here

Examples of org.rascalmpl.interpreter.staticErrors.UnexpectedType

              .intValue());
          Type type = receiver.getType().getElementType();
          return normalizedResult(__eval, type, result);
        }

        throw new UnexpectedType(
            org.rascalmpl.interpreter.Evaluator.__getTf()
                .integerType(), subscript.getType(), this);
      } else if (receiver.getType().isMap()) {
        Type keyType = receiver.getType().getKeyType();

        if (receiver.hasInferredType()
            || subscript.getType().isSubtypeOf(keyType)) {
          IValue result = ((IMap) receiver.getValue()).get(subscript
              .getValue());

          if (result == null) {
            throw org.rascalmpl.interpreter.utils.RuntimeExceptionFactory
                .noSuchKey(subscript.getValue(), this, __eval
                    .getStackTrace());
          }
          Type type = receiver.getType().getValueType();
          return org.rascalmpl.interpreter.result.ResultFactory
              .makeResult(type, result, __eval);
        }

        throw new UnexpectedType(keyType, subscript.getType(),
            this.getSubscript());
      }
      // TODO implement other subscripts
      throw new UnsupportedOperation("subscript",
          receiver.getType(), this);
View Full Code Here

Examples of org.rascalmpl.interpreter.staticErrors.UnexpectedType

      if (name.equals("year")) {
        if (dt.isTime()) {
          throw new UnsupportedOperation("Can not update the year on a time value",ctx.getCurrentAST());
        }     
        if (!replType.isInteger()) {
          throw new UnexpectedType(getTypeFactory().integerType(), replType, ctx.getCurrentAST());
        }
        year = ((IInteger) replValue).intValue();
      } else if (name.equals("month")) {
        if (dt.isTime()) {
          throw new UnsupportedOperation("Can not update the month on a time value",ctx.getCurrentAST());
        }     
        if (!replType.isInteger()) {
          throw new UnexpectedType(getTypeFactory().integerType(), replType, ctx.getCurrentAST());
        }
        month = ((IInteger) replValue).intValue();       
      } else if (name.equals("day")) {
        if (dt.isTime()) {
          throw new UnsupportedOperation("Can not update the day on a time value",ctx.getCurrentAST());
        }     
        if (!replType.isInteger()) {
          throw new UnexpectedType(getTypeFactory().integerType(), replType, ctx.getCurrentAST());
        }
        day = ((IInteger) replValue).intValue();       
      } else if (name.equals("hour")) {
        if (dt.isDate()) {
          throw new UnsupportedOperation("Can not update the hour on a date value",ctx.getCurrentAST());
        }     
        if (!replType.isInteger()) {
          throw new UnexpectedType(getTypeFactory().integerType(), replType, ctx.getCurrentAST());
        }
        hour = ((IInteger) replValue).intValue();       
      } else if (name.equals("minute")) {
        if (dt.isDate()) {
          throw new UnsupportedOperation("Can not update the minute on a date value",ctx.getCurrentAST());
        }     
        if (!replType.isInteger()) {
          throw new UnexpectedType(getTypeFactory().integerType(), replType, ctx.getCurrentAST());
        }
        minute = ((IInteger) replValue).intValue();       
      } else if (name.equals("second")) {
        if (dt.isDate()) {
          throw new UnsupportedOperation("Can not update the second on a date value",ctx.getCurrentAST());
        }     
        if (!replType.isInteger()) {
          throw new UnexpectedType(getTypeFactory().integerType(), replType, ctx.getCurrentAST());
        }
        second = ((IInteger) replValue).intValue();       
      } else if (name.equals("millisecond")) {
        if (dt.isDate()) {
          throw new UnsupportedOperation("Can not update the millisecond on a date value",ctx.getCurrentAST());
        }     
        if (!replType.isInteger()) {
          throw new UnexpectedType(getTypeFactory().integerType(), replType, ctx.getCurrentAST());
        }
        milli = ((IInteger) replValue).intValue();     
      } else if (name.equals("timezoneOffsetHours")) {
        if (dt.isDate()) {
          throw new UnsupportedOperation("Can not update the timezone offset hours on a date value",ctx.getCurrentAST());
        }     
        if (!replType.isInteger()) {
          throw new UnexpectedType(getTypeFactory().integerType(), replType, ctx.getCurrentAST());
        }
        tzOffsetHour = ((IInteger) replValue).intValue();       
      } else if (name.equals("timezoneOffsetMinutes")) {
        if (dt.isDate()) {
          throw new UnsupportedOperation("Can not update the timezone offset minutes on a date value",ctx.getCurrentAST());
        }     
        if (!replType.isInteger()) {
          throw new UnexpectedType(getTypeFactory().integerType(), replType, ctx.getCurrentAST());
        }
        tzOffsetMin = ((IInteger) replValue).intValue();       
      } else {
        throw new UndeclaredField(name, getTypeFactory().dateTimeType(), ctx.getCurrentAST());
      }
View Full Code Here

Examples of org.rascalmpl.interpreter.staticErrors.UnexpectedType

        Type nont = RascalTypeFactory.getInstance().nonTerminalType(foundType);
        if (repl.getType().isSubtypeOf(nont)) {
          IList args = TreeAdapter.getArgs(tree).put(found, repl.getValue());
          return makeResult(getType(), tree.set("args", args), ctx);
        }
        throw new UnexpectedType(nont, repl.getType(), ctx.getCurrentAST());
      }
     
      if (Factory.Tree_Appl.hasField(name)) {
        Type fieldType = Factory.Tree_Appl.getFieldType(name);
        if (repl.getType().isSubtypeOf(fieldType)) {
          throw new UnsupportedOperation("changing " + name + " in concrete tree", ctx.getCurrentAST());
        }
        throw new UnexpectedType(fieldType, repl.getType(), ctx.getCurrentAST());
      }

      throw RuntimeExceptionFactory.noSuchField(name, ctx.getCurrentAST(), ctx.getStackTrace());
    }
    throw new UnsupportedOperation("field update", ctx.getCurrentAST());
View Full Code Here

Examples of org.rascalmpl.interpreter.staticErrors.UnexpectedType

    }

    @Override
    public IBooleanResult buildBacktracker(IEvaluatorContext __eval) {

      throw new UnexpectedType(TF.boolType(), this
          .interpret(__eval.getEvaluator()).getType(),
          this);

    }
View Full Code Here

Examples of org.rascalmpl.interpreter.staticErrors.UnexpectedType

            PROGRESS.Continuing, FIXEDPOINT.No);
       
        if (!val.getType().isSubtypeOf(subject.getType())) {
          // this is not a static error but an extra run-time sanity check
          throw new ImplementationError("this should really never happen",
              new UnexpectedType(subject.getType(), val.getType(), this));
        }
       
        return org.rascalmpl.interpreter.result.ResultFactory.makeResult(subject.getType(),
            val, __eval);
      } finally {
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.