Beispiel #1
0
 public int getFrameDepth() {
   int nframe = 0;
   Context cptr = this;
   while (!cptr.isTopLevel()) {
     if (cptr.getType() == Type.FUNCTION) nframe++;
     cptr = cptr.getParent();
   }
   return nframe;
 }
Beispiel #2
0
 protected void evalBaseResource(String resourceName) throws IOException {
   Context evalContext = this.beginEvalContext(session.getBaseNamespaceEnv());
   InputStream in = getClass().getResourceAsStream(resourceName);
   if (in == null) {
     throw new IOException("Could not load resource '" + resourceName + "'");
   }
   Reader reader = new InputStreamReader(in);
   try {
     evalContext.evaluate(RParser.parseSource(reader));
   } finally {
     reader.close();
   }
 }
Beispiel #3
0
 public Context beginFunction(
     Environment rho, FunctionCall call, Closure closure, PairList arguments) {
   Context context = new Context();
   context.type = Type.FUNCTION;
   context.parent = this;
   context.evaluationDepth = evaluationDepth + 1;
   context.closure = closure;
   context.environment = Environment.createChildEnvironment(closure.getEnclosingEnvironment());
   context.session = session;
   context.arguments = arguments;
   context.call = call;
   context.callingEnvironment = rho;
   return context;
 }
Beispiel #4
0
 public Context beginEvalContext(Environment environment) {
   Context context = new Context();
   context.type = Type.RETURN;
   context.parent = this;
   context.evaluationDepth = evaluationDepth + 1;
   context.environment = environment;
   context.session = session;
   return context;
 }