public abstract class Context extends Util
AppContext
, using the Interpreter for one or more
evaluations, then exiting the context, as follows:
AppContext ctx = ... Interpreter r=Context.enter(ctx); r.eval(someProcedure, new Value[] { ... some arguments ... }); Context.exit();Preferrably, one should use the SchemeCaller supported visitor pattern to allow Context to handle the management of the Interpreter Context, as follows:
Object returnValue=Context.execute(ctx, mySchemeCaller);The provided SchemeCaller instance's execute method is invoked with an Interpreter which is automatically obtained and then returned when the call completes. The return value of the SchemeCaller's execute method is returned from the Context method.
SchemeCaller
,
AppContext
,
Interpreter
BACKQUOTE, BEGIN, bundles, caseSensitive, EMPTYLIST, EMPTYVEC, EOF, ERRORK, EVAL, EXPSC, EXPTOP, FALSE, FCONT, FIVE, JEXCEPTION, LAMBDA, LOCATION, maxFloatPrecision, MESSAGE, minFloatPrecision, NAME, OTHER, PARENT, permitInterrupts, QUOTE, QUOTESYM, REPORT, SETBANG, SISC, SISC_SPECIFIC, SISCB, SOURCE_COLUMN, SOURCE_FILE, SOURCE_LINE, SYMENV, THIS, TOPLEVEL, TRUE, UNQUOTE, UNQUOTE_SPLICING, VOID, ZV
Constructor and Description |
---|
Context() |
Modifier and Type | Method and Description |
---|---|
static AppContext |
currentAppContext()
Returns the AppContext of any current interpreter in an
internal call, or the default AppContext if no current
interpreter is present.
|
static Interpreter |
currentInterpreter()
Fetches the current Interpreter, if this is an internal call (that is,
a call from Java to Scheme in the contex of a Scheme->Java call).
|
static Interpreter |
currentInterpreter(AppContext ctx)
Fetches the nearest enclosing Interpreter that operates on a
given AppContext, if this is an internal call (that is, a call
from Java to Scheme in the contex of a Scheme->Java call).
|
static Interpreter |
enter()
Returns an Interpreter that shares the AppContext and
DynamicEnvironment with the current Interpreter.
|
static Interpreter |
enter(AppContext ctx)
Returns an Interpreter bound to the given AppContext with same
DynamicEnvironment as the nearest enclosing Interpreter in the
same thread that is bound to the same AppContext.
|
static Interpreter |
enter(DynamicEnvironment dynenv)
Returns an Interpreter bound to the given DynamicEnvironment.
|
static Interpreter |
enter(java.lang.String appName)
Deprecated.
use
enter(AppContext) instead |
static java.lang.Object |
execute(AppContext ctx,
SchemeCaller caller)
Calls caller with an Interpreter bound to the given AppContext
with same DynamicEnvironment as the nearest enclosing
Interpreter in the same thread that is bound to the same
AppContext.
|
static java.lang.Object |
execute(DynamicEnvironment dynenv,
SchemeCaller caller)
Obtains an Interpreter bound to the given DynamicEnvironment
and invokes caller.execute(Interpreter) with that Interper.
|
static java.lang.Object |
execute(SchemeCaller caller)
Calls caller with an Interpreter that shares the AppContext and
DynamicEnvironment with the current Interpreter.
|
static java.lang.Object |
execute(java.lang.String appName,
SchemeCaller caller)
Deprecated.
use
execute(AppContext, SchemeCaller) instead |
static void |
exit()
Exits the current context, releasing the current Interpreter.
|
static AppContext |
getDefaultAppContext()
Returns the currently set default AppContext, or creates
a new AppContext with default values if non was already set,
and attempts to initialize it with the default heap.
|
static AppContext |
lookup(java.lang.String appName)
Deprecated.
|
static ThreadContext |
lookupThreadContext()
thread context lookup
|
static void |
register(java.lang.String appName,
AppContext ctx)
Deprecated.
|
static void |
setDefaultAppContext(AppContext ctx)
Sets the default AppContext, which is used sparingly whenever
a call originates from uncontrolled Java source that involves
the Scheme environment.
|
static void |
unregister(java.lang.String appName)
Deprecated.
|
annotated, annotatedAppEval, append, argCheck, argsToSymbols, assq, bininport, bininstream, binoutport, binoutstream, box, character, charinport, charinreader, charoutport, charoutwriter, charsetFromString, chr, cont, currentClassLoader, env, error, error, error, error, error, error, error, expr, getDefaultCharacterSet, immutablePair, immutableVector, inport, javaExceptionToString, javaWrap, justify, length, liMessage, liMessage, liMessage, liMessage, liMessage, liMessage, liMessage, list, list, list, list, list, makeURL, mapcar, memq, nlib, num, outport, pair, pairToExpressions, pairToExpVect, pairToValues, proc, read, registerBundle, reverse, reverseInPlace, simpleErrorToString, sourceAnnotations, str, string, sym, symbol, symval, truePair, truth, truth, typeError, typeError, updateName, url, url, url, valArrayToList, valArrayToList, valArrayToVec, vec, warn, warn, warn
public static void register(java.lang.String appName, AppContext ctx)
public static void unregister(java.lang.String appName)
public static AppContext lookup(java.lang.String appName)
public static ThreadContext lookupThreadContext()
public static Interpreter currentInterpreter()
public static Interpreter currentInterpreter(AppContext ctx)
ctx
- the AppContextpublic static void setDefaultAppContext(AppContext ctx)
ctx
- the AppContext to make the default.public static AppContext getDefaultAppContext()
public static AppContext currentAppContext()
public static Interpreter enter()
Interpreter
public static Interpreter enter(AppContext ctx)
ctx
- The AppContextpublic static Interpreter enter(DynamicEnvironment dynenv)
dynenv
- The DynamicEnvironmentpublic static Interpreter enter(java.lang.String appName)
enter(AppContext)
insteadpublic static void exit()
public static java.lang.Object execute(SchemeCaller caller) throws SchemeException
caller
- The SchemeCaller to invokeSchemeException
public static java.lang.Object execute(AppContext ctx, SchemeCaller caller) throws SchemeException
ctx
- The AppContextcaller
- The SchemeCaller to invoke.SchemeException
public static java.lang.Object execute(DynamicEnvironment dynenv, SchemeCaller caller) throws SchemeException
dynenv
- The DynamicEnvironment.caller
- The SchemeCaller to invoke.SchemeException
public static java.lang.Object execute(java.lang.String appName, SchemeCaller caller)
execute(AppContext, SchemeCaller)
instead