Package org.renjin.sexp

Examples of org.renjin.sexp.SEXP


  public void invalidIntercept() {
    build("y ~ 6");
  }
 
  private Formula build(String source) {
    SEXP expr = parse(source);
    return new FormulaInterpreter().interpret((FunctionCall) expr);
  }
View Full Code Here


    return new FormulaInterpreter().interpret((FunctionCall) expr);
  }

  private SEXP parse(String source) {
    ExpressionVector tree = RParser.parseSource(source + "\n");
    SEXP expr = tree.getElementAsSEXP(0);
    return expr;
  }
View Full Code Here

  }

  @Override
  public Object put(String name, Object value) {
    Symbol symbol = Symbol.get(name);
    SEXP previousValue = frame.getVariable(symbol);
    SEXP exp = Converters.get(value.getClass()).convertToR(value);
    frame.setVariable(symbol, exp);
    return previousValue;
  }
View Full Code Here

  }

  @Override
  public SEXP apply(Context context, Environment rho, FunctionCall call, PairList args) {
    PairList formals = EvalException.checkedCast(call.getArgument(0));
    SEXP body = call.getArgument(1);
    SEXP source = call.getArgument(2);

    return new Closure(rho,formals, body);
  }
View Full Code Here

    if(file instanceof StringVector) {
      String fileName = ((StringVector) file).getElementAsString(0);
      if(fileName.length() == 0) {
        lineReader = context.getSession().getConnectionTable().getStdin().getReader();
      } else {
        SEXP fileConn = Connections.file(context,fileName,"o",true,encoding,false);
        lineReader = Connections.getConnection(context, fileConn).getReader();
      }
    } else {
      lineReader = Connections.getConnection(context, file).getReader();
    }
View Full Code Here

    super("while");
  }
 
  @Override
  public SEXP apply(Context context, Environment rho, FunctionCall call, PairList args) {
    SEXP condition = args.getElementAsSEXP(0);
    SEXP statement = args.getElementAsSEXP(1);

    while(asLogicalNoNA(context, call, context.evaluate( condition, rho))) {

      try {
View Full Code Here

    super("repeat");
  }
 
  @Override
  public SEXP apply(Context context, Environment rho, FunctionCall call, PairList args) {
    SEXP statement = args.getElementAsSEXP(0);

    while(true) {
      try {
        context.evaluate( statement, rho);
      } catch(BreakException e) {
View Full Code Here

  }
 
  @Override
  public SEXP apply(Context context, Environment rho, FunctionCall call, PairList args) {
    checkArity(call, 2, 1);
    SEXP exp = call.getArgument(0);
    if(call.getArguments().length() == 2) {
      SEXP envirSexp = context.evaluate(call.getArgument(1), rho);
      return substitute(exp, envirSexp);
    } else {
      return substitute(exp, new EnvironmentContext(rho));
    }
  }
View Full Code Here

  }

  private static SEXP doApply(Context context, Environment rho, FunctionCall call, PairList args) {
    EvalException.check(call.length() > 1, "argument \"EXPR\" is missing");

    SEXP expr = context.evaluate(args.getElementAsSEXP(0),rho);
    EvalException.check(expr.length() == 1, "EXPR must return a length 1 vector");

    Iterable<PairList.Node> branches = Iterables.skip(args.nodes(), 1);

    if(expr instanceof StringVector) {
      String name = ((StringVector) expr).getElementAsString(0);
      if(StringVector.isNA(name)) {
        context.setInvisibleFlag();
        return Null.INSTANCE;
      }
      SEXP partialMatch = null;
      int partialMatchCount = 0;
      for(PairList.Node node : branches) {
        if(node.hasTag()) {
          String branchName = node.getTag().getPrintName();
          if(branchName.equals(name)) {
View Full Code Here

    MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "load",
        "(Lorg/renjin/eval/Context;Lorg/renjin/sexp/Environment;)V", null, null);
    mv.visitCode();

    for(Symbol symbol : rho.getSymbolNames()) {
      SEXP value = rho.getVariable(symbol);
      try {
        if(value instanceof Closure) {
          storeClosure(mv, packageName, symbol);       
        } else {
          storeConstant(mv, symbol, rho.getVariable(symbol));
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.