Package org.renjin.sexp

Examples of org.renjin.sexp.SEXP


  public MemberBinding getMemberBinding(Symbol name) {
    if(name == NEW) {
      return classBinding.getConstructorBinding();
    }

    final SEXP staticMember = classBinding.getStaticMember(name);
    if(staticMember == null) {
      throw new EvalException("Class %s has no static member named '%s'",
          classBinding.getBoundClass().getName(), name);
    }
View Full Code Here


    super(context.getEnvironment(), Symbol.get(name));
  }

  @Override
  protected SEXP doEval(Context context) {
    SEXP value = environment.findVariable((Symbol)expression);
    if(value == Symbol.UNBOUND_VALUE) {
      throw new EvalException("object '" + expression + "' not found");
    }
    return value.force(context);
  }
View Full Code Here

    Collections.sort(sources);
   
    for(File source : sources) {
      FileReader reader = new FileReader(source);
      try {
        SEXP expr = RParser.parseAllSource(reader);
        evalContext.evaluate(expr);
      } catch(Exception e) {
        throw new RuntimeException("Error evaluating " + source.getName() + ": " + e.getMessage(), e);
      } finally {
        reader.close();       
View Full Code Here

    nc = data.size();
    nr = 0;                     /* -Wall */
    if (nc > 0) {
      nr = nrows(data.get(0));
      for(int i=0;i<nc;++i) {
        SEXP element = data.get(i);
        if(element instanceof AtomicVector) {
          if(nrows(element) != nr) {
            throw new EvalException("variable lengths differ (found for '%s')", names.get(i));
          }
        } else {
          throw new EvalException("invalid type (%s) for variable '%s'", element.getTypeName(), names.get(i));
        }
      }
    } else {
      nr = row_names.length();
    }
View Full Code Here

    return sexp == Null.INSTANCE || sexp instanceof ListVector;
  }
 
  public static int nrows(SEXP s) {
    if (s instanceof Vector) {
        SEXP dim = s.getAttribute(Symbols.DIM);
        if(dim == Null.INSTANCE) {
          return s.length();
        } else {
          return ((IntVector)dim).getElementAsInt(0);
        }
View Full Code Here

  }

  @Override
  public void visitConstant(Constant constant) {
    if(constant.getValue() instanceof SEXP) {
      SEXP exp = (SEXP)constant.getValue();
      exp.accept(new ConstantGeneratingVisitor(mv));
    } else if (constant.getValue() instanceof Integer) {
      ByteCodeUtil.pushInt(mv, (Integer)constant.getValue());
    } else {
      throw new UnsupportedOperationException();
    }
View Full Code Here

        mv.visitInsn(DUP);
        pushInt(i);
   
        Expression arg = call.getArguments().get(i);
        if(arg instanceof IRThunk) {
          SEXP sexp = ((IRThunk) arg).getSEXP();
          if(sexp instanceof Symbol) {
            // since this is a simple case, just do it inline
            visitEnvironmentVariable(new EnvironmentVariable((Symbol) sexp));
          } else {
            // otherwise call out to the corresponding thunk's
View Full Code Here

 
  public FactorVariable(String name, SEXP vector) {
    this.name = name;
    this.vector = (Vector)vector;
   
    SEXP contrasts = vector.getAttribute(Symbol.get("contrasts"));
    if(contrasts != Null.INSTANCE) {
      contrastMatrix = new ContrastMatrix(contrasts);
    } else {
      throw new EvalException("Invalid contrast matrix for " + name);
    }
View Full Code Here

  public Symbol getName() {
    return name;
  }
  @Override
  public Object retrieveValue(Context context, Object[] temps) {
    SEXP value = context.getEnvironment().findVariable(name);
    if(value == Symbol.UNBOUND_VALUE) {
      throw new EvalException("object '" + name + "' not found");
    }
    return value.force(context);
  }
View Full Code Here

  private StringBuilder code = new StringBuilder();
 
  @Override
  public void visit(ListVector list) {
    SEXP tag = list.getAttribute(Symbol.get("Rd_tag"));
    if(tag != Null.INSTANCE) {
      StringVector tagName = (StringVector)tag;
      if(tagName.getElementAsString(0).equals("\\examples")) {
        for(SEXP exp : list) {
          exp.accept(this);
View Full Code Here

TOP

Related Classes of org.renjin.sexp.SEXP

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.