Package gw.lang.parser
Interface ISymbolTable
- All Superinterfaces:
IStackProvider
- All Known Implementing Classes:
CompiledGosuClassSymbolTable
,StandardSymbolTable
,ThreadSafeSymbolTable
-
Field Summary
Fields inherited from interface gw.lang.parser.IStackProvider
START_POS, SUPER_POS, THIS_POS
-
Method Summary
Modifier and TypeMethodDescriptioncopy()
Perform a semi-deep copy of this symbol table.void
Define symbols that are considered ubiquitous.int
int
getSymbol
(CharSequence name) getSymbols
(int iScopeIndex, int iPrivateGlobalIndex) Get the 'this' symbol from either the stack or the table.int
boolean
isSymbolWithinScope
(ISymbol sym, IScope scope) peekScope
(int iPos) void
popGlobalScope
(IScope scope) Pops a global scope previously pushed viapushGlobalScope( IScope )
orpushPrivateGlobalScope( IScope )
.popScope()
Pop a local scope context from the symbol table.pushIsolatedScope
(IActivationContext activationCtx) Push a scope that demarcates an activation record.void
pushPrivateGlobalScope
(IScope scope) Push a global scope you specify onto the private global scope space.Push a local scope context onto the symbol table.Push a local scope context onto the symbol table.void
Maps a name to a symbol in the table.removeSymbol
(CharSequence name) Removes a previously mapped symbol.Methods inherited from interface gw.lang.parser.IStackProvider
getNextStackIndex, getNextStackIndexForScope, hasIsolatedScope
-
Method Details
-
getSymbol
- Returns:
- The symbol mapped to the specified name.
-
putSymbol
Maps a name to a symbol in the table. -
removeSymbol
Removes a previously mapped symbol.- Parameters:
name
- The name mapped to the symbol to remove.
-
getSymbols
Map getSymbols()- Returns:
- A list of currently mapped ISymbols e.g., the values in a hash table based implementation.
-
getSymbols
- Parameters:
iScopeIndex
- Scopes positioned on the stack at an index greater than this number are not included. Very useful for examining a specific scope e.g., for a debugger. Note an index < 0 indicates that all scopes are included.- Returns:
- A list of currently mapped ISymbols e.g., the values in a hash table based implementation.
-
getScopeCount
int getScopeCount()- Returns:
- The number of scopes on the stack. These include all scopes: global, isolated, and local. Useful for recording a specific offset in the symbol table e.g., a debugger needs this to jump to a position in a call stack.
- See Also:
-
getPrivateGlobalScopeCount
int getPrivateGlobalScopeCount()- Returns:
- The number of scopes on the private global stack. Useful for recording a specific offset in the symbol table e.g., a debugger needs this to jump to a position in a call stack.
- See Also:
-
pushScope
IScope pushScope()Push a local scope context onto the symbol table.- Returns:
- The pushed scope.
-
pushScope
Push a local scope context onto the symbol table.- Parameters:
scope
- the scope to push- Returns:
- The pushed scope.
-
popScope
IScope popScope()Pop a local scope context from the symbol table. See pushScope() for implementation suggestions.- Returns:
- The popped scope.
-
peekScope
IScope peekScope()- Returns:
- the currently active scope
-
peekScope
-
popScope
-
pushIsolatedScope
Push a scope that demarcates an activation record. The behavior is nearly identical to pushScope(), the [big] difference is that activation record scopes cannot access symbols from other activation record scopes. Use popScope() to pop a scope pushed via this method.- Parameters:
activationCtx
- The context for the activation record.- Returns:
- The isolated scope (aka the activation record).
-
pushPrivateGlobalScope
Push a global scope you specify onto the private global scope space. Useful for handling private global scopes for libraries, namespaces, etc. As this functionality is primarily for Gosu runtime, you'll likely never need to call this. If you need to push a scope with restricted visibility, consider callingpushIsolatedScope()
instead. -
popGlobalScope
Pops a global scope previously pushed viapushGlobalScope( IScope )
orpushPrivateGlobalScope( IScope )
. You probably shouldn't call this method.- See Also:
-
copy
ISymbolTable copy()Perform a semi-deep copy of this symbol table. Symbols need not be cloned.- Returns:
- A semi-deep copy of this symbol table.
-
getThisSymbolFromStackOrMap
ISymbol getThisSymbolFromStackOrMap()Get the 'this' symbol from either the stack or the table. -
defineCommonSymbols
void defineCommonSymbols()Define symbols that are considered ubiquitous. There may be none. -
getTotalSymbolCount
int getTotalSymbolCount()- Returns:
- the number of symbols exist in this table.
-
isSymbolWithinScope
- Returns:
- true if the given symbol is within the given scope
-
peekIsolatedScope
IScope peekIsolatedScope()- Returns:
- the top-most isolated scope
-