jsint
Class LexicalEnvironment

java.lang.Object
  extended byjsint.LexicalEnvironment
All Implemented Interfaces:
java.io.Serializable

public class LexicalEnvironment
extends java.lang.Object
implements java.io.Serializable

Environments store mappings from symbols to locations. At compile time, we can lookup to see if a symbol names a location, and at run time we can get or set the value in a location.

Author:
Peter Norvig, Copyright 1998, peter@norvig.com, license subsequently modified by Jscheme project members licensed under zlib licence (see license.txt)
See Also:
Serialized Form

Field Summary
static LexicalEnvironment NULLENV
          The global environment.
 
Constructor Summary
LexicalEnvironment(java.lang.Object vars, java.lang.Object[] vals, LexicalEnvironment parent)
          Create an LexicalEnvironment with local variables and values, and a parent LexicalEnvironment.
LexicalEnvironment(java.lang.Object vars, java.lang.Object[] vals, LexicalEnvironment parent, boolean isNullEnv)
           
 
Method Summary
 java.lang.Object get(LocalVariable var)
          Get the value of the LocalVariable in this LexicalEnvironment.
 LocalVariable lookup(Symbol var)
           
 LocalVariable lookup(Symbol var, int up, int in, java.lang.Object vars)
          Lookup the symbol in the environment.
 java.lang.Object set(LocalVariable var, java.lang.Object newVal)
          Set the value of the LocalVariable in this LexicalEnvironment to a new value.
 void show(java.io.PrintWriter s)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NULLENV

public static final LexicalEnvironment NULLENV
The global environment. All info is in the Symbols themselves.

Constructor Detail

LexicalEnvironment

public LexicalEnvironment(java.lang.Object vars,
                          java.lang.Object[] vals,
                          LexicalEnvironment parent)
Create an LexicalEnvironment with local variables and values, and a parent LexicalEnvironment.


LexicalEnvironment

public LexicalEnvironment(java.lang.Object vars,
                          java.lang.Object[] vals,
                          LexicalEnvironment parent,
                          boolean isNullEnv)
Method Detail

lookup

public LocalVariable lookup(Symbol var)

lookup

public LocalVariable lookup(Symbol var,
                            int up,
                            int in,
                            java.lang.Object vars)
Lookup the symbol in the environment. Return either a LocalVariable a Symbol representing the global variable.


get

public java.lang.Object get(LocalVariable var)
Get the value of the LocalVariable in this LexicalEnvironment.


set

public java.lang.Object set(LocalVariable var,
                            java.lang.Object newVal)
Set the value of the LocalVariable in this LexicalEnvironment to a new value.


toString

public java.lang.String toString()

show

public void show(java.io.PrintWriter s)