sisc.interpreter
Class AppContext

java.lang.Object
  extended by sisc.util.Util
      extended by sisc.interpreter.AppContext
All Implemented Interfaces:
Version

public class AppContext
extends Util

The AppContext is the root of all data in an instance of SISC. This encapsulates mainly the procedures and data which are defined in the global environment. It is also the token used by most Java to Scheme operations.

Typically, an AppContext is created using the default constructor, then initialized with a heap using utility methods in REPL.


Field Summary
 SymbolicEnvironment symenv
           
 SymbolicEnvironment toplevel_env
           
 
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
AppContext()
          Create a new, AppContext with default values, the recommended constructor for normal usage.
AppContext(java.util.Properties props)
          Create a new AppContext, providing a set of properties explicitly.
AppContext(SymbolicEnvironment symenv)
          Create a new AppContext, providing a custom global environment.
 
Method Summary
 void addDefaultHeap()
          Attempts to find and load the default SISC heap into this AppContext.
 boolean addHeap(SeekableInputStream in)
          Given a SeekableInputStream which is attached to a SISC heap file, loads the heap into this AppContext and initializes it.
 void defineContextEnv(Symbol s, SymbolicEnvironment env)
           
static java.net.URL findHeap(java.net.URL heapLocation)
          Locate a heap.
 Expression getExpression(Symbol name)
           
 java.lang.String getProperty(java.lang.String name)
           
 java.lang.String getProperty(java.lang.String name, java.lang.String def)
           
 void loadEnv(SeekableDataInputStream i)
           
 LibraryBinding lookupBinding(Expression e)
           
 SymbolicEnvironment lookupContextEnv(Symbol s)
           
static SeekableInputStream openHeap(java.net.URL u)
           
 Expression resolveBinding(LibraryBinding lb)
           
 void saveEnv(java.io.OutputStream o, LibraryBuilder lb)
           
 
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

symenv

public SymbolicEnvironment symenv

toplevel_env

public SymbolicEnvironment toplevel_env
Constructor Detail

AppContext

public AppContext()
Create a new, AppContext with default values, the recommended constructor for normal usage.


AppContext

public AppContext(java.util.Properties props)
Create a new AppContext, providing a set of properties explicitly.

Parameters:
props - Properties which govern the underlying Scheme environment.

AppContext

public AppContext(SymbolicEnvironment symenv)
Create a new AppContext, providing a custom global environment.

Parameters:
symenv - the global environment
Method Detail

getExpression

public Expression getExpression(Symbol name)

loadEnv

public void loadEnv(SeekableDataInputStream i)
             throws java.io.IOException,
                    java.lang.ClassNotFoundException
Throws:
java.io.IOException
java.lang.ClassNotFoundException

saveEnv

public void saveEnv(java.io.OutputStream o,
                    LibraryBuilder lb)
             throws java.io.IOException
Throws:
java.io.IOException

lookupContextEnv

public SymbolicEnvironment lookupContextEnv(Symbol s)

defineContextEnv

public void defineContextEnv(Symbol s,
                             SymbolicEnvironment env)

getProperty

public java.lang.String getProperty(java.lang.String name)

getProperty

public java.lang.String getProperty(java.lang.String name,
                                    java.lang.String def)

resolveBinding

public Expression resolveBinding(LibraryBinding lb)
                          throws java.io.IOException
Throws:
java.io.IOException

lookupBinding

public LibraryBinding lookupBinding(Expression e)
                             throws java.io.IOException
Throws:
java.io.IOException

addHeap

public boolean addHeap(SeekableInputStream in)
                throws java.lang.ClassNotFoundException
Given a SeekableInputStream which is attached to a SISC heap file, loads the heap into this AppContext and initializes it. Returns true on success, false otherwise.

Throws:
java.lang.ClassNotFoundException

addDefaultHeap

public void addDefaultHeap()
                    throws java.io.IOException
Attempts to find and load the default SISC heap into this AppContext.

Throws:
java.io.IOException
See Also:
findHeap(URL)

openHeap

public static SeekableInputStream openHeap(java.net.URL u)
                                    throws java.io.IOException
Throws:
java.io.IOException

findHeap

public static java.net.URL findHeap(java.net.URL heapLocation)
Locate a heap. If the heap cannot be located at the supplied location then an attempt is made to find it as a resource "sisc.shp".

Parameters:
heapLocation - The URL for the heap file. When this is null it defaults to the value of the sisc.heap system property and, if that is not present, "sisc.shp"