Package gnu.expr
Class ScopeExp
- java.lang.Object
-
- gnu.mapping.PropertySet
-
- gnu.mapping.Procedure
-
- gnu.expr.Expression
-
- gnu.expr.ScopeExp
-
- All Implemented Interfaces:
gnu.kawa.format.Printable
,Named
,SourceLocator
,SourceLocator
,Locator
public abstract class ScopeExp extends Expression
Abstract class for expressions that add local variable bindings.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface gnu.text.SourceLocator
SourceLocator.Simple
-
-
Field Summary
Fields Modifier and Type Field Description protected int
frameSize
Size of evalFrame to allocate in interpreter.int
id
Unique id number, to ease print-outs and debugging.protected Scope
scope
-
Fields inherited from class gnu.expr.Expression
applyMethodExpression, flags, NEXT_AVAIL_FLAG, noExpressions, type, VALIDATED
-
Fields inherited from class gnu.mapping.Procedure
applyMethodType, applyToConsumerDefault, applyToConsumerMethod, applyToObjectDefault, applyToObjectMethod, compilerKey, compilerXKey, inlineIfConstantSymbol, validateApplyKey, validateXApplyKey
-
Fields inherited from class gnu.mapping.PropertySet
nameKey
-
-
Constructor Summary
Constructors Constructor Description ScopeExp()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description 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(Object name)
Create a new declaration in the current Scope.Declaration
addDeclaration(Object name, Type type)
Create a new declaration in the current Scope.void
clearCallList()
int
countDecls()
LambdaExp
currentLambda()
ModuleExp
currentModule()
static void
duplicateDeclarationError(Declaration oldDecl, Declaration newDecl, Compilation comp)
Declaration
firstDecl()
Declaration
getDefine(Object name, Compilation parser)
Add a new Declaration, with a message if there is an existing one.Declaration
getNoDefine(Object name)
Lookup a declaration, create a non-defining declaration if needed.ScopeExp
getOuter()
Return the statically enclosing binding contour.Scope
getVarScope()
boolean
isClassGenerated()
True if a class is generated for this scope.Declaration
lastDecl()
Declaration
lookup(Object sym)
Find a Declaration by name.Declaration
lookup(Object sym, Language language, int namespace)
boolean
nestedIn(ScopeExp outer)
True if given scope is nesed in this scope, perhaps indirectly.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 theprev.next
bynewDecl
.protected void
setIndexes()
Calculate offset and frameSize needed by interpreter.void
setOuter(ScopeExp outer)
ScopeExp
topLevel()
Return the outermost non-module scope, if there is one.String
toString()
protected <R,D>
Rvisit(ExpVisitor<R,D> visitor, D d)
-
Methods inherited from class gnu.expr.Expression
apply, applyMethodExpression, calculateType, checkLiteralKeyword, compile, compile, compile, compileWithPosition, compileWithPosition, deepCopy, deepCopy, deepCopy, deepCopy, eval, eval, getColumnNumber, getEndColumn, getEndLine, getFileName, getFlag, getFlags, getLineNumber, getPublicId, getStartColumn, getStartLine, getSystemId, getType, getTypeRaw, isSingleValue, isStableSourceLocation, makeWhile, maybeSetLine, mustCompile, neverReturns, numArgs, print, print, printLineColumn, setFile, setFlag, setFlag, setLine, setLine, setLine, setLine, setLine, setLocation, setType, side_effects, validateApply, valueIfConstant, visitChildren
-
Methods inherited from class gnu.mapping.Procedure
apply0, apply1, apply2, apply3, apply4, applyL, applyN, applyToConsumerDefault, applyToObjectDefault, checkArgCount, checkBadCode, getApplyMethod, getApplyToConsumerMethod, getApplyToObjectMethod, getReturnType, getSetter, getSourceLocation, isSideEffectFree, lookupApplyHandle, maxArgs, maxArgs, minArgs, minArgs, set0, set1, setN, setSetter, setSourceLocation
-
Methods inherited from class gnu.mapping.PropertySet
getName, getProperty, getSymbol, removeProperty, setName, setProperty, setProperty, setSymbol
-
-
-
-
Field Detail
-
scope
protected Scope scope
-
frameSize
protected int frameSize
Size of evalFrame to allocate in interpreter.
-
id
public int id
Unique id number, to ease print-outs and debugging.
-
-
Method Detail
-
firstDecl
public Declaration firstDecl()
-
lastDecl
public Declaration lastDecl()
-
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 theprev.next
bynewDecl
. Ifprev==null
, replace the first decl.
-
remove
public void remove(Declaration decl)
-
remove
public void remove(Declaration prev, Declaration decl)
-
getOuter
public ScopeExp getOuter()
Return the statically enclosing binding contour.
-
setOuter
public void setOuter(ScopeExp outer)
-
currentLambda
public LambdaExp currentLambda()
-
topLevel
public ScopeExp topLevel()
Return the outermost non-module scope, if there is one.
-
currentModule
public ModuleExp currentModule()
-
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)
-
getNoDefine
public Declaration getNoDefine(Object name)
Lookup a declaration, create a non-defining declaration if needed.
-
getDefine
public Declaration getDefine(Object name, 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(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()
-
clearCallList
public void clearCallList()
-
nesting
public static int nesting(ScopeExp sc)
-
nestedIn
public boolean nestedIn(ScopeExp outer)
True if given scope is nesed in this scope, perhaps indirectly.
-
setIndexes
protected void setIndexes()
Calculate offset and frameSize needed by interpreter.
-
visit
protected <R,D> R visit(ExpVisitor<R,D> visitor, D d)
- Overrides:
visit
in classExpression
-
isClassGenerated
public final boolean isClassGenerated()
True if a class is generated for this scope.
-
toString
public String toString()
- Overrides:
toString
in classExpression
-
-