gnu.expr

Class ScopeExp

public abstract class ScopeExp extends Expression

Abstract class for expressions that add local variable bindings.
Field Summary
protected intframeSize
Size of evalFrame to allocate in interpreter.
intid
Unique id number, to ease print-outs and debugging.
ScopeExpouter
The statically enclosing binding contour.
Constructor Summary
ScopeExp()
Method Summary
voidadd(Declaration decl)
voidadd(Declaration prev, Declaration decl)
Add a Declaration at a specified position.
DeclarationaddDeclaration(Object name)
Create a new declaration in the current Scope.
DeclarationaddDeclaration(Object name, Type type)
Create a new declaration in the current Scope.
voidaddDeclaration(Declaration decl)
Add a Declaration to the current Scope.
intcountDecls()
LambdaExpcurrentLambda()
ModuleExpcurrentModule()
static voidduplicateDeclarationError(Declaration oldDecl, Declaration newDecl, Compilation comp)
DeclarationfirstDecl()
DeclarationgetDefine(Object name, char severity, Compilation parser)
Add a new Declaration, with a message if there is an existing one.
DeclarationgetNoDefine(Object name)
Lookup a declaration, create a non-defining declaration if needed.
ScopegetVarScope()
Declarationlookup(Object sym)
Find a Declaration by name.
Declarationlookup(Object sym, Language language, int namespace)
static intnesting(ScopeExp sc)
voidpopScope(CodeAttr code)
Clear bytecode resources for the ScopeExp.
voidremove(Declaration decl)
voidremove(Declaration prev, Declaration decl)
voidreplaceFollowing(Declaration prev, Declaration newDecl)
Replace the prev.next by newDecl.
protected voidsetIndexes()
Calculate offset and frameSize needed by interpreter.
StringtoString()
protected Expressionwalk(ExpWalker walker)

Field Detail

frameSize

protected int frameSize
Size of evalFrame to allocate in interpreter.

id

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

outer

public ScopeExp outer
The statically enclosing binding contour.

Constructor Detail

ScopeExp

public ScopeExp()

Method Detail

add

public void add(Declaration decl)

add

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

addDeclaration

public final Declaration addDeclaration(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(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()

currentLambda

public LambdaExp currentLambda()

currentModule

public ModuleExp currentModule()

duplicateDeclarationError

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

firstDecl

public Declaration firstDecl()

getDefine

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

getNoDefine

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

getVarScope

public Scope getVarScope()

lookup

public Declaration lookup(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(Object sym, Language language, int namespace)

nesting

public static int nesting(ScopeExp sc)

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.

remove

public void remove(Declaration decl)

remove

public void remove(Declaration prev, Declaration decl)

replaceFollowing

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

setIndexes

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

toString

public String toString()

walk

protected Expression walk(ExpWalker walker)