Package org.renjin.sexp

Examples of org.renjin.sexp.Closure


  public void closureBody() throws IOException {
    assumingBasePackagesLoad();
    topLevelContext.evaluate(
    RParser.parseSource(new InputStreamReader(getClass().getResourceAsStream("/meanOnline.R"))));
   
    Closure closure = (Closure) topLevelContext.getGlobalEnvironment().getVariable("mean.online");
    IRBodyBuilder factory = new IRBodyBuilder(functionTable);
    factory.dump(closure.getBody());
  }
View Full Code Here


    tlContext.getNamespaceRegistry().createNamespace(new TestPackage());
   
    Iterable<NamedValue> namedValues = LazyLoadFrame.load(null, null);
    NamedValue namedValue = namedValues.iterator().next();
    assertThat(namedValue.getName(),equalTo("f"));
    Closure f = (Closure) namedValue.getValue().force(tlContext);
   
    assertThat(f.getEnclosingEnvironment(), equalTo(tlContext.getNamespaceRegistry().getNamespace("testns").getNamespaceEnvironment()));
   
  }
View Full Code Here

    eval( "assign('x', 42) ");
    assertThat( eval( "x" ) , equalTo( c(42) ));

    // make sure that closures are enclosed by the base namspace
    Closure closure = (Closure)getValue( topLevelContext.getSession().getBaseEnvironment(), "backsolve" );
    assertThat( closure.getEnclosingEnvironment(), equalTo(topLevelContext.getSession().getBaseNamespaceEnv() ));


    // make sure that base scripts are populated in both the base environment and the base namespace
    assertThat( getValue( topLevelContext.getSession().getBaseEnvironment(), "letters" ).length(), equalTo( 26 ));
  //  assertThat( getValue( topLevelContext.getSession().baseNamespaceEnv, "letters" ).length(), equalTo( 26 ));
View Full Code Here

  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

  }
 

  private boolean isZeroArgFunction(SEXP value) {
    if(value instanceof Closure) {
      Closure testFunction = (Closure)value;
      if(testFunction.getFormals().length() == 0) {
        return true;
      }
    }
    return false;
  }
View Full Code Here

TOP

Related Classes of org.renjin.sexp.Closure

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.