|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object sisc.util.Util sisc.interpreter.Interpreter
public class Interpreter
The SISC engine.
Interpreter is the SISC engine. It contains the engine registers, and the main loop responsible for repeatedly executing the nxp register and maintaining the stack. Interpreter also localizes all thread-specific information. Interpreters must only execute in the thread which created them. Furthermore, nested calls from Java into Scheme must be carried out in fresh interpreter instances; thus at any point in time a thread contains a stack of interpreters, the top of which is the interpreter currently in use.
Additionally, it is the interface from Java code for evaluating Scheme code or calling Scheme procedures.
Context
Nested Class Summary | |
---|---|
static class |
Interpreter.ThrowSchemeException
|
Field Summary | |
---|---|
Value |
acc
|
static Compiler |
compiler
|
protected Value[] |
dv1
|
protected Value[] |
dv2
|
protected Value[] |
dv3
|
protected Value[] |
dv4
|
DynamicEnvironment |
dynenv
|
Value[] |
env
|
CallFrame |
fk
|
protected CallFrame |
frameFreeList
|
protected int |
frameFreeListSize
|
protected static int |
FRAMEPOOLMAX
|
Value[][] |
IAI
|
Value[] |
lcl
|
Expression |
nxp
|
ThreadContext |
tctx
|
SymbolicEnvironment |
tpl
|
Value[] |
vlr
|
Fields inherited from class sisc.util.Util |
---|
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 |
Fields inherited from interface sisc.util.Version |
---|
VERSION |
Constructor Summary | |
---|---|
Interpreter(ThreadContext tctx,
DynamicEnvironment dynenv)
|
Method Summary | |
---|---|
Procedure |
captureContinuation()
|
Procedure |
captureEscapingContinuation()
|
Expression |
compile(Value v)
|
Expression |
compile(Value v,
SymbolicEnvironment env)
|
Value[] |
createValues(int size)
|
void |
define(Symbol s,
Value v,
Symbol context)
Defines a new binding in a named environment. |
void |
defineContextEnv(Symbol s,
SymbolicEnvironment env)
|
void |
error(Pair error)
|
Value |
eval(Procedure p,
Value[] args)
Applies the given procedure to the given values |
Value |
eval(java.lang.String expr)
Parses and evaluates s-expression(s) |
Value |
eval(Value v)
Evaluates a Scheme value as code. |
Value |
eval(Value v,
SymbolicEnvironment env)
Evaluates a Scheme value as code. |
Value |
evalInput(java.io.PushbackReader port)
Parses and evaluates s-expression(s) from an input port |
SymbolicEnvironment |
getContextEnv(Symbol s)
|
AppContext |
getCtx()
|
Symbol |
getSymbol(java.lang.String v)
|
protected void |
interpret()
|
Value |
interpret(Expression e)
|
boolean |
loadSourceFiles(java.lang.String[] files)
Loads zero or more Scheme source files or compiled libraries. |
Expression |
lookup(Symbol s,
Symbol context)
Retrieves the value of a binding in a named environment |
SymbolicEnvironment |
lookupContextEnv(Symbol s)
|
StackTracer |
makeStackTracer()
|
void |
newVLR(int size)
|
void |
newVLR(Value[] vlr)
|
void |
next(Expression nextExpr)
|
void |
pop(CallFrame c)
|
void |
push(Expression n)
|
void |
pushExpr(Expression e)
|
void |
returnFrame(CallFrame f)
|
void |
returnValues(Value[] v)
|
void |
returnVLR()
|
void |
setFailureContinuation(Expression e)
|
void |
setupTailCall(Expression e,
Value vlr0)
|
void |
setupTailCall(Expression e,
Value[] newvlr)
|
void |
setVLR(int pos,
Value v)
|
void |
trace(Expression e)
|
void |
undefine(Symbol s,
Symbol context)
Removes a binding in a named environment |
Value[] |
vlrToArgs()
Returns a Value[] prepared as a value rib for a procedure with a fixed argument count. |
Value[] |
vlrToRestArgs(int fcount)
Returns a Value[] prepared as a value rib for a for procedure expecting rest args in the last rib position. |
Methods inherited from class sisc.util.Util |
---|
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 |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static Compiler compiler
public ThreadContext tctx
public DynamicEnvironment dynenv
public Value[][] IAI
public Value acc
public Expression nxp
public Value[] vlr
public Value[] lcl
public Value[] env
public CallFrame fk
public SymbolicEnvironment tpl
protected static final int FRAMEPOOLMAX
protected CallFrame frameFreeList
protected int frameFreeListSize
protected Value[] dv1
protected Value[] dv2
protected Value[] dv3
protected Value[] dv4
Constructor Detail |
---|
public Interpreter(ThreadContext tctx, DynamicEnvironment dynenv)
Method Detail |
---|
public AppContext getCtx()
public Symbol getSymbol(java.lang.String v)
public Expression compile(Value v) throws ContinuationException
ContinuationException
public Expression compile(Value v, SymbolicEnvironment env) throws ContinuationException
ContinuationException
public Value interpret(Expression e) throws SchemeException
SchemeException
protected void interpret() throws SchemeException
SchemeException
public final void next(Expression nextExpr) throws ContinuationException
ContinuationException
public final void newVLR(int size)
public final void newVLR(Value[] vlr)
public final void pop(CallFrame c)
public final StackTracer makeStackTracer()
public final void setVLR(int pos, Value v)
public final void pushExpr(Expression e)
public final void setFailureContinuation(Expression e)
public final Procedure captureContinuation()
public final Procedure captureEscapingContinuation()
public void trace(Expression e)
public void error(Pair error) throws ContinuationException
ContinuationException
public Value evalInput(java.io.PushbackReader port) throws java.io.IOException, SchemeException
port
- input port
java.io.IOException
- Raised if the port does not
contain a parseable s-expression
Interpreter.ThrowSchemeException
- Raised if the evaluation of
an expression results in an error
SchemeException
public Value eval(java.lang.String expr) throws java.io.IOException, SchemeException
expr
- s-expressions(s)
java.io.IOException
- Raised if the given string does not
contain a parseable s-expression
Interpreter.ThrowSchemeException
- Raised if the evaluation of
an expression results in an error
SchemeException
public Value eval(Value v) throws SchemeException
v
- A Scheme Value
Interpreter.ThrowSchemeException
- Raised if the evaluation of the
expression results in an error
SchemeException
public Value eval(Value v, SymbolicEnvironment env) throws SchemeException
v
- A Scheme Valueenv
- The environment in which to evaluate the value
Interpreter.ThrowSchemeException
- Raised if the evaluation of the
expression results in an error
SchemeException
public Value eval(Procedure p, Value[] args) throws SchemeException
p
- A procedureargs
- Arguments to call the procedure with
Interpreter.ThrowSchemeException
- Raised if applying the
procedure results in an error
SchemeException
public boolean loadSourceFiles(java.lang.String[] files)
files
- An array of Strings naming files to load.
public SymbolicEnvironment lookupContextEnv(Symbol s)
public void defineContextEnv(Symbol s, SymbolicEnvironment env)
public SymbolicEnvironment getContextEnv(Symbol s)
public void define(Symbol s, Value v, Symbol context)
s
- The name of the new bindingv
- The value of the new bindingcontext
- The name of the environment in which to
create the bindingpublic Expression lookup(Symbol s, Symbol context)
s
- The name of the bindingcontext
- The name of the environment from which
the binding will be retrieved
public void undefine(Symbol s, Symbol context)
s
- The name of the bindingcontext
- The name of the environment from which
the binding will be retrievedpublic final void push(Expression n)
public final void returnFrame(CallFrame f)
public final Value[] createValues(int size)
public final void returnVLR()
public final void setupTailCall(Expression e, Value vlr0)
public final void setupTailCall(Expression e, Value[] newvlr)
public final void returnValues(Value[] v)
public Value[] vlrToArgs()
public Value[] vlrToRestArgs(int fcount)
fcount
- The number of arguments to prepare
including the rest variable
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |