gnu.expr
Class ScopeExp

java.lang.Object
  extended by gnu.mapping.PropertySet
      extended by gnu.mapping.Procedure
          extended by gnu.mapping.Procedure0
              extended by gnu.expr.Expression
                  extended by gnu.expr.ScopeExp
All Implemented Interfaces:
Named, Printable, SourceLocator, org.xml.sax.Locator
Direct Known Subclasses:
CatchClause, LambdaExp, LetExp

public abstract class ScopeExp
extends Expression

Abstract class for expressions that add local variable bindings.


Field Summary
protected  int frameSize
          Size of evalFrame to allocate in interpreter.
 int id
          Unique id number, to ease print-outs and debugging.
 ScopeExp outer
          The statically enclosing binding contour.
 
Fields inherited from class gnu.expr.Expression
flags, NEXT_AVAIL_FLAG, noExpressions
 
Constructor Summary
ScopeExp()
           
 
Method Summary
 void add(Declaration decl)
           
 void add(Declaration prev, Declaration decl)
          Add a Declaration at a specified position.
 void addDeclaration(Declaration decl)
          Add a Declaration to the current Scope.
 Declaration addDeclaration(java.lang.Object name)
          Create a new declaration in the current Scope.
 Declaration addDeclaration(java.lang.Object name, Type type)
          Create a new declaration in the current Scope.
 int countDecls()
           
 LambdaExp currentLambda()
           
 ModuleExp currentModule()
           
static void duplicateDeclarationError(Declaration oldDecl, Declaration newDecl, Compilation comp)
           
 Declaration firstDecl()
           
 Declaration getDefine(java.lang.Object name, char severity, Compilation parser)
          Add a new Declaration, with a message if there is an existing one.
 Declaration getNoDefine(java.lang.Object name)
          Lookup a declaration, create a non-defining declaration if needed.
 Scope getVarScope()
           
 Declaration lookup(java.lang.Object sym)
          Find a Declaration by name.
 Declaration lookup(java.lang.Object sym, Language language, int namespace)
           
static int nesting(ScopeExp sc)
           
 void popScope(CodeAttr code)
          Clear bytecode resources for the ScopeExp.
 void remove(Declaration decl)
           
 void remove(Declaration prev, Declaration decl)
           
 void replaceFollowing(Declaration prev, Declaration newDecl)
          Replace the prev.next by newDecl.
protected  void setIndexes()
          Calculate offset and frameSize needed by interpreter.
 java.lang.String toString()
           
protected  Expression walk(ExpWalker walker)
           
 
Methods inherited from class gnu.expr.Expression
apply, apply0, compile, compile, compile, compileButFirst, compileNotePosition, compileWithPosition, compileWithPosition, eval, eval, getColumnNumber, getFileName, getFlag, getFlags, getLineNumber, getPublicId, getSystemId, getType, inline, isStableSourceLocation, makeWhile, match0, mustCompile, print, print, printLineColumn, setFile, setFlag, setFlag, setLine, setLine, setLine, setLine, setLocation, side_effects, valueIfConstant, walkChildren
 
Methods inherited from class gnu.mapping.Procedure0
apply1, apply2, apply3, apply4, applyN, numArgs
 
Methods inherited from class gnu.mapping.Procedure
apply, check0, check1, check2, check3, check4, checkArgCount, checkN, getSetter, getSourceLocation, match1, match2, match3, match4, matchN, maxArgs, minArgs, set0, set1, setN, setSetter, setSourceLocation
 
Methods inherited from class gnu.mapping.PropertySet
getName, getProperty, getSymbol, removeProperty, setName, setProperty, setProperty, setSymbol
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

outer

public ScopeExp outer
The statically enclosing binding contour.


frameSize

protected int frameSize
Size of evalFrame to allocate in interpreter.


id

public int id
Unique id number, to ease print-outs and debugging.

Constructor Detail

ScopeExp

public ScopeExp()
Method Detail

firstDecl

public Declaration firstDecl()

getVarScope

public Scope getVarScope()

popScope

public void popScope(CodeAttr code)
Clear bytecode resources for the ScopeExp. This potentially allows Kawa to generate code for the same (inlined, shared) ScopeExp multiple times - though we're not making use of that yet.


add

public void add(Declaration decl)

add

public void add(Declaration prev,
                Declaration decl)
Add a Declaration at a specified position.


replaceFollowing

public void replaceFollowing(Declaration prev,
                             Declaration newDecl)
Replace the prev.next by newDecl. If prev==null, replace the first decl.


remove

public void remove(Declaration decl)

remove

public void remove(Declaration prev,
                   Declaration decl)

currentLambda

public LambdaExp currentLambda()

currentModule

public ModuleExp currentModule()

lookup

public Declaration lookup(java.lang.Object sym)
Find a Declaration by name.

Parameters:
sym - the (interned) name of the Declaration sought
Returns:
the matching Declaration, if found; otherwise null

lookup

public Declaration lookup(java.lang.Object sym,
                          Language language,
                          int namespace)

getNoDefine

public Declaration getNoDefine(java.lang.Object name)
Lookup a declaration, create a non-defining declaration if needed.


getDefine

public Declaration getDefine(java.lang.Object name,
                             char severity,
                             Compilation parser)
Add a new Declaration, with a message if there is an existing one.


duplicateDeclarationError

public static void duplicateDeclarationError(Declaration oldDecl,
                                             Declaration newDecl,
                                             Compilation comp)

addDeclaration

public final Declaration addDeclaration(java.lang.Object name)
Create a new declaration in the current Scope.

Parameters:
name - name (interned) to give to the new Declaration.

addDeclaration

public final Declaration addDeclaration(java.lang.Object name,
                                        Type type)
Create a new declaration in the current Scope.

Parameters:
name - name (interned) to give to the new Declaration.
type - type of the new Declaration.

addDeclaration

public final void addDeclaration(Declaration decl)
Add a Declaration to the current Scope.


countDecls

public int countDecls()

nesting

public static int nesting(ScopeExp sc)

setIndexes

protected void setIndexes()
Calculate offset and frameSize needed by interpreter.


walk

protected Expression walk(ExpWalker walker)
Overrides:
walk in class Expression

toString

public java.lang.String toString()
Overrides:
toString in class Expression