Package org.renjin.eval

Examples of org.renjin.eval.EvalException


        return new NegativeSubscript(dimensionLength, vector);
      }
    } else if(argument == Null.INSTANCE) {
      return NullSubscript.INSTANCE;
    } else {
      throw new EvalException("invalid subscript type '%s'", argument.getTypeName());
    }
  }
View Full Code Here


      Vector sourceNames = RowNamesVector.purify(dimNames.getElementAsSEXP(dimIndex));
      if(sourceNames != Null.INSTANCE) {
        StringArrayVector.Builder names = new StringArrayVector.Builder();
        for(Integer index : getSelectionAlongDimension(dimIndex)) {
          if(index >= sourceNames.length()) {
            throw new EvalException("subscript out of bounds: ");
          }
          names.add( sourceNames.getElementAsString(index) );
        }
        return names.build();
      }
View Full Code Here

    Closure closure;
    if(definition instanceof Closure) {
      closure = (Closure)definition;
    } else if(definition == Null.INSTANCE) {
      if(context.getParent().getType() != Context.Type.FUNCTION) {
        throw new EvalException("match.call() was called from outside a function");
      }
      closure = context.getParent().getClosure();
    } else {
      throw new EvalException("match.call cannot use definition of type '%s'", definition.getTypeName());
    }
   
    PairList matched = Calls.matchArguments(closure.getFormals(), call.getArguments(), true);
   
    PairList.Builder expandedArgs = new PairList.Builder();
View Full Code Here

      return new BuiltinFunction(entry.name) {

        @Override
        public SEXP apply(Context context, Environment rho,
            FunctionCall call, PairList args) {
          throw new EvalException("Sorry! " + entry.name + " not yet implemented!");
        }
      };
    }
  }
View Full Code Here

    this.source = source;
    this.sourceDim = dimAsIntArray(source);

    if( subscriptArguments.size() != sourceDim.length) {
      throw new EvalException("Incorrect number of dimensions. Subscripts: " + subscriptArguments.size() + ", source dimension: "+ sourceDim.length );
    }

    subscripts = new Subscript[subscriptArguments.size()];
    for(int i=0; i!=subscripts.length;++i) {
      subscripts[i] = parseSubscript(subscriptArguments.get(i), i, sourceDim[i]);
View Full Code Here

  @Override
  protected AtomicVector getNames(int dimensionIndex) {
    Vector dimNames = (Vector) source.getAttribute(Symbols.DIMNAMES);
    if(dimNames == Null.INSTANCE) {
      throw new EvalException("no 'dimnames' attribute for array");
    }
    return (AtomicVector)dimNames.getElementAsSEXP(dimensionIndex);
  }
View Full Code Here

    if(source instanceof PairList.Node) {
      this.source = ((PairList.Node) source).toVector();
    } else if(source instanceof Vector) {
      this.source = (Vector) source;
    } else {
      throw new EvalException("Invalid source: " + source);
    }
    subscripts = Lists.newArrayList();
    for(int i=skipBeginning; i+skipEnd<arguments.length();++i) {
      subscripts.add(arguments.getElementAsSEXP(i));
    }
View Full Code Here

    // x[[1:2]] will throw an error, may be we can
    // just drop the distinction across the board?
    if(selection instanceof VectorIndexSelection ||
       selection instanceof CoordinateMatrixSelection) {
      if(selection.getElementCount() > 1) {
        throw new EvalException("attempt to select more than one element");
      }
    }

    if(selection.getElementCount() < 1) {
      throw new EvalException("attempt to select less than one element");
    }

    int index = selection.iterator().next();
    if(index < 0 || index >= source.length()) {
      throw new EvalException("subscript out of bounds");
    }
    return source.getElementAsSEXP(index);

  }
View Full Code Here

    } else if(subscripts.size() == 1 && subscripts.get(0) instanceof StringVector) {
      return replaceByName(elements);
    }
   
    if(!selection.isEmpty() && elements.length() == 0) {
      throw new EvalException("replacement has zero length");
    }

    Vector.Builder result = createReplacementBuilder(elements);
   
    int replacement = 0;
View Full Code Here

     
      // check the result
      if(!(x instanceof Vector) ||
          x.length() != funValue.length() ||
          ((Vector)x).getVectorType().isWiderThan(funValue)) {
        throw new EvalException("values must be type '%s',\n but %s result is type '%s'",
            funValue.getTypeName(),
            Deparse.deparseExp(context, call),
            x.getTypeName());
           
      }
View Full Code Here

TOP

Related Classes of org.renjin.eval.EvalException

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.