Examples of UnexpectedType


Examples of org.rascalmpl.interpreter.staticErrors.UnexpectedType

  public void check(Result<IValue> r,
      org.eclipse.imp.pdb.facts.type.Type t, String kind,
      Expression expr) {
    if (!r.getType().isSubtypeOf(t)) {
      throw new UnexpectedType(t, r.getType(), expr);
    }
  }
View Full Code Here

Examples of org.rascalmpl.interpreter.staticErrors.UnexpectedType

        try {
          IList list = (IList) rec.getValue();
         
          IValue repl = __eval.__getValue().getValue();
          if(!repl.getType().isList()){
            throw new UnexpectedType(rec.getType(), repl.getType(), __eval.__getEval().getCurrentAST());
          }
         
          __eval.__setValue(__eval.newResult(list, __eval.__getValue()));
          list = list.replace(firstIndex, secondIndex, endIndex, (IList) repl);
         
          result = org.rascalmpl.interpreter.result.ResultFactory
              .makeResult(rec.hasInferredType() ? rec.getType()
                  .lub(list.getType()) : rec.getType(), list,
                  __eval.__getEval());
        } catch (IndexOutOfBoundsException e) { // include last in message
          throw org.rascalmpl.interpreter.utils.RuntimeExceptionFactory
          .indexOutOfBounds((IInteger) first.getValue(),
              __eval.__getEval().getCurrentAST(), __eval
              .__getEval().getStackTrace());
        }
      } else if (rec.getType().isString()) {
        try {
          IString str = (IString) rec.getValue();
         
          IValue repl = __eval.__getValue().getValue();
          if(!repl.getType().isString()){
            throw new UnexpectedType(rec.getType(), repl.getType(), __eval.__getEval().getCurrentAST());
          }
         
          __eval.__setValue(__eval.newResult(str, __eval.__getValue()));
          str = str.replace(firstIndex, secondIndex, endIndex, (IString) repl);
         
          result = org.rascalmpl.interpreter.result.ResultFactory
              .makeResult(rec.hasInferredType() ? rec.getType()
                  .lub(str.getType()) : rec.getType(), str,
                  __eval.__getEval());
        } catch (IndexOutOfBoundsException e) { // include last in message
          throw org.rascalmpl.interpreter.utils.RuntimeExceptionFactory
          .indexOutOfBounds((IInteger) first.getValue(),
              __eval.__getEval().getCurrentAST(), __eval
              .__getEval().getStackTrace());
        }
      } else if (rec.getType().isNode()) {

        try {
          INode node = (INode) rec.getValue();

          IValue repl = __eval.__getValue().getValue();
          if(!repl.getType().isList()){
            throw new UnexpectedType(rec.getType(), repl.getType(), __eval.__getEval().getCurrentAST());
          }

          __eval.__setValue(__eval.newResult(node, __eval.__getValue()));
          node = node.replace(firstIndex, secondIndex, endIndex, (IList) repl);
View Full Code Here

Examples of org.rascalmpl.interpreter.staticErrors.UnexpectedType

        try {
          IList list = (IList) rec.getValue();         
         
          IValue repl = __eval.__getValue().getValue();
          if(!repl.getType().isList()){
            throw new UnexpectedType(rec.getType(), repl.getType(), __eval.__getEval().getCurrentAST());
          }
         
          __eval.__setValue(__eval.newResult(list, __eval.__getValue()));         
          list = list.replace(firstIndex, secondIndex, endIndex, (IList) repl);
         
          result = org.rascalmpl.interpreter.result.ResultFactory
              .makeResult(rec.hasInferredType() ? rec.getType()
                  .lub(list.getType()) : rec.getType(), list,
                  __eval.__getEval());
        } catch (IndexOutOfBoundsException e) { // include last in message
          throw org.rascalmpl.interpreter.utils.RuntimeExceptionFactory
          .indexOutOfBounds((IInteger) first.getValue(),
              __eval.__getEval().getCurrentAST(), __eval
              .__getEval().getStackTrace());
        }
      } else if (rec.getType().isString()) {
        try {
          IString str = (IString) rec.getValue();

          IValue repl = __eval.__getValue().getValue();
          if(!repl.getType().isString()){
            throw new UnexpectedType(rec.getType(), repl.getType(), __eval.__getEval().getCurrentAST());
          }
         
          __eval.__setValue(__eval.newResult(str, __eval.__getValue()));
          str = str.replace(firstIndex, secondIndex, endIndex, (IString) repl);
         
          result = org.rascalmpl.interpreter.result.ResultFactory
              .makeResult(rec.hasInferredType() ? rec.getType()
                  .lub(str.getType()) : rec.getType(), str,
                  __eval.__getEval());
        } catch (IndexOutOfBoundsException e) { // include last in message
          throw org.rascalmpl.interpreter.utils.RuntimeExceptionFactory
          .indexOutOfBounds((IInteger) first.getValue(),
              __eval.__getEval().getCurrentAST(), __eval
              .__getEval().getStackTrace());
        }
       
      } else if (rec.getType().isNode()) {

        try {
          INode node = (INode) rec.getValue();

          IValue repl = __eval.__getValue().getValue();
          if(!repl.getType().isList()){
            throw new UnexpectedType(rec.getType(), repl.getType(), __eval.__getEval().getCurrentAST());
          }

          __eval.__setValue(__eval.newResult(node, __eval.__getValue()));
          node = node.replace(firstIndex, secondIndex, endIndex, (IList) repl);
View Full Code Here

Examples of org.rascalmpl.interpreter.staticErrors.UnexpectedType

        throw new MatchFailed();
      }
      env.storeTypeBindings(bindings);
    }
    catch (FactTypeUseException e) {
      throw new UnexpectedType(formals, actualTypes, ast);
    }
  } 
View Full Code Here

Examples of org.rascalmpl.interpreter.staticErrors.UnexpectedType

      List<org.rascalmpl.ast.Assignable> arguments = this.getElements();

      if (!__eval.__getValue().getType().isTuple()) {
        // TODO construct a better expected type
        throw new UnexpectedType(
            org.rascalmpl.interpreter.AssignableEvaluator.__getTf()
                .tupleEmpty(), __eval.__getValue().getType(),
            this);
      }
View Full Code Here

Examples of org.rascalmpl.interpreter.staticErrors.UnexpectedType

    if (subscripts.length != 1) {
      throw new UnsupportedSubscriptArity(getType(), subscripts.length, ctx.getCurrentAST());
    }
    Result<IValue> key = (Result<IValue>) subscripts[0];
    if (!getType().getKeyType().comparable(key.getType())) {
      throw new UnexpectedType(getType().getKeyType(), key.getType(), ctx.getCurrentAST());
    }
    IValue v = getValue().get(key.getValue());
    if (v == null){
      throw RuntimeExceptionFactory.noSuchKey(key.getValue(), ctx.getCurrentAST(), ctx.getStackTrace());
    }
View Full Code Here

Examples of org.rascalmpl.interpreter.staticErrors.UnexpectedType

        throw new UnsupportedOperation("You can not update the keys of a map using the field update operator", ctx.getCurrentAST());
      }
      else if (type.getValueLabel().equals(name)) {
        // interesting operation, sets the image of all keys to one default
        if (!repl.getType().isSubtypeOf(type.getValueType())) {
          throw new UnexpectedType(type.getValueType(), repl.getType(), ctx.getCurrentAST());
        }

        IMapWriter w = getValueFactory().mapWriter();

        for (IValue key : value) {
View Full Code Here

Examples of org.rascalmpl.interpreter.staticErrors.UnexpectedType

      __eval.notifyAboutSuspension(this);
     
      Result<IValue> r = this.getExpression().interpret(__eval);
      if (!r.getType().equals(
          org.rascalmpl.interpreter.Evaluator.__getTf().boolType())) {
        throw new UnexpectedType(
            org.rascalmpl.interpreter.Evaluator.__getTf()
                .boolType(), r.getType(), this);
      }

      if (r.getValue().isEqual(__eval.__getVf().bool(false))) {
View Full Code Here

Examples of org.rascalmpl.interpreter.staticErrors.UnexpectedType

      __eval.notifyAboutSuspension(this);

      Result<IValue> r = this.getExpression().interpret(__eval);
      if (!r.getType().equals(
          org.rascalmpl.interpreter.Evaluator.__getTf().boolType())) {
        throw new UnexpectedType(
            org.rascalmpl.interpreter.Evaluator.__getTf()
                .boolType(), r.getType(), this);
      }
      if (r.getValue().isEqual(__eval.__getVf().bool(false))) {
        Result<IValue> msgValue = this.getMessage().interpret(__eval);
View Full Code Here

Examples of org.rascalmpl.interpreter.staticErrors.UnexpectedType

        Bound bound = this.getBound();
        if (bound.isDefault()) {
          Result<IValue> res = bound.getExpression()
              .interpret(__eval);
          if (!res.getType().isInteger()) {
            throw new UnexpectedType(
                org.rascalmpl.interpreter.Evaluator.__getTf()
                    .integerType(), res.getType(), this);
          }
          max = ((IInteger) res.getValue()).intValue();
          if (max <= 0) {
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.