public int getFrameDepth() { int nframe = 0; Context cptr = this; while (!cptr.isTopLevel()) { if (cptr.getType() == Type.FUNCTION) nframe++; cptr = cptr.getParent(); } return nframe; }
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(); } }
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; }
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; }