Package org.renjin.sexp

Examples of org.renjin.sexp.SEXP


   */
  public static String parseExamples(File file) throws IOException {
    try {
      FileReader reader = new FileReader(file);
      RdParser parser = new RdParser();
      SEXP rd = parser.R_ParseRd(reader, StringVector.valueOf(file.getName()), false);

      ExamplesParser examples = new ExamplesParser();
      rd.accept(examples);

      return examples.code.toString();
    } catch(Exception e) {
      System.err.println("WARNING: Failed to parse examples from " + file.getName() + ": " + e.getMessage());
      return "";
View Full Code Here


    // this loop handles nested, complex assignments, such as:
    // class(x) <- "foo"
    // x$a[3] <- 4
    // class(x$a[3]) <- "foo"

    SEXP lhs = assignment.getArgument(0);
   
    while(lhs instanceof FunctionCall) {
      FunctionCall call = (FunctionCall) lhs;
     
      rhs = builder.translateSetterCall(context, call, rhs);
      lhs = call.getArgument(0);
    }

    LValue target;
    if( lhs instanceof Symbol) {
      target = new EnvironmentVariable((Symbol) lhs);
    } else if(lhs instanceof StringVector) {
      target =  new EnvironmentVariable( Symbol.get(((StringVector) lhs).getElementAsString(0)) );
    } else {
      throw new EvalException("cannot assign to value of type " + lhs.getTypeName());
    }

    doAssignment(builder, target, rhs);
   
  }
View Full Code Here

    return vector;
  }
 
  @Override
  public Object retrieveValue(Context context, Object[] temps) {
    SEXP exp = (SEXP) vector.retrieveValue(context, temps);
    return exp.length();
  }
View Full Code Here

    Variable elementVariable = new EnvironmentVariable(symbol);
   
    Expression vector =
        factory.translateSimpleExpression(context, call.getArgument(1));
   
    SEXP body = call.getArgument(2);

    IRLabel counterLabel = factory.newLabel();
    IRLabel bodyLabel = factory.newLabel();
    IRLabel nextLabel = factory.newLabel();
    IRLabel exitLabel = factory.newLabel();
View Full Code Here

    // This is renjin's own convention, but it's nice to be
    // able to see the results of many tests rather than
    // topping at the first error
    for(Symbol name : session.getGlobalEnvironment().getSymbolNames()) {
      if(name.getPrintName().startsWith("test.")) {
        SEXP value = session.getGlobalEnvironment().getVariable(name);
        if(isZeroArgFunction(value)) {
          executeTestFunction(session.getTopLevelContext(), name);
        }
      }
    }
View Full Code Here

    addLoop(builder, context, call);
  }
  private void addLoop(IRBodyBuilder factory, TranslationContext context, FunctionCall call) {
   
    SEXP condition = call.getArgument(0);
   
    SEXP body = call.getArgument(1);

    IRLabel checkLabel = factory.newLabel();
    IRLabel bodyLabel = factory.newLabel();
    IRLabel exitLabel = factory.newLabel();
      
View Full Code Here

  }

  @Override
  public Expression translateToExpression(IRBodyBuilder builder,
      TranslationContext context, FunctionCall call) {
    SEXP argument = call.getArgument(0);
    if(!(argument instanceof FunctionCall)) {
      throw new InvalidSyntaxException(".Internal() expects a language object as its only argument");
    }
    FunctionCall primitiveCall = (FunctionCall) argument;
View Full Code Here

  protected SEXP c(String... values) {
    return new StringArrayVector(values);
  }

  protected SEXP eval(String source)  {
    SEXP expr;
    try {
      expr = RParser.parseAllSource(new StringReader(source));
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
View Full Code Here

  }



  protected final void printWarnings() {
    SEXP warnings = context.getEnvironment().getBaseEnvironment().getVariable(Warning.LAST_WARNING);
    if(warnings != Symbol.UNBOUND_VALUE) {
      context.evaluate( FunctionCall.newCall(Symbol.get("print.warnings"), warnings),
              context.getEnvironment().getBaseEnvironment());
    }
  }
View Full Code Here

      context.setInvisibleFlag();
      return Null.INSTANCE;

    } else {

      SEXP value = call.getArgument(0);
      boolean add = false;
      if(call.getArguments().length() == 2) {
        add = context.evaluate(call.getArgument(1), rho).asReal() != 0;
      }
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.