Package gw.lang.parser
Class ThreadSafeSymbolTable
java.lang.Object
gw.lang.parser.ThreadSafeSymbolTable
- All Implemented Interfaces:
IStackProvider,ISymbolTable
- Direct Known Subclasses:
CompiledGosuClassSymbolTable
-
Field Summary
FieldsFields inherited from interface gw.lang.parser.IStackProvider
START_POS, SUPER_POS, THIS_POS -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcopy()Perform a semi-deep copy of this symbol table.voidDefine symbols that are considered ubiquitous.protected ISymbolTableintFor compile-time assignment of stack indexes.intgetNextStackIndexForScope(IScope scope) For compile-time assignment of stack indexes at a particular scope.intintgetSymbol(CharSequence name) getSymbols(int iScopeOffset, int iPrivateGlobalIndex) Get the 'this' symbol from either the stack or the table.protected abstract ISymbolTableGet a thread-local symbol table.intbooleanFor compile-time use.booleanisSymbolWithinScope(ISymbol sym, IScope scope) peekScope(int iPos) voidpopGlobalScope(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.voidpushPrivateGlobalScope(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.voidMaps a name to a symbol in the table.removeSymbol(CharSequence name) Removes a previously mapped symbol.
-
Field Details
-
_defaultSymTable
-
-
Constructor Details
-
ThreadSafeSymbolTable
public ThreadSafeSymbolTable(boolean bDefineCommonSymbols)
-
-
Method Details
-
copy
Description copied from interface:ISymbolTablePerform a semi-deep copy of this symbol table. Symbols need not be cloned.- Specified by:
copyin interfaceISymbolTable- Returns:
- A semi-deep copy of this symbol table.
-
getSymbol
- Specified by:
getSymbolin interfaceISymbolTable- Returns:
- The symbol mapped to the specified name.
-
putSymbol
Description copied from interface:ISymbolTableMaps a name to a symbol in the table.- Specified by:
putSymbolin interfaceISymbolTable
-
removeSymbol
Description copied from interface:ISymbolTableRemoves a previously mapped symbol.- Specified by:
removeSymbolin interfaceISymbolTable- Parameters:
name- The name mapped to the symbol to remove.
-
getSymbols
- Specified by:
getSymbolsin interfaceISymbolTable- Returns:
- A list of currently mapped ISymbols e.g., the values in a hash table based implementation.
-
getSymbols
- Specified by:
getSymbolsin interfaceISymbolTable- Parameters:
iScopeOffset- 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.
-
getTotalSymbolCount
public int getTotalSymbolCount()- Specified by:
getTotalSymbolCountin interfaceISymbolTable- Returns:
- the number of symbols exist in this table.
-
getScopeCount
public int getScopeCount()- Specified by:
getScopeCountin interfaceISymbolTable- 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
public int getPrivateGlobalScopeCount()- Specified by:
getPrivateGlobalScopeCountin interfaceISymbolTable- 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
Description copied from interface:ISymbolTablePush a local scope context onto the symbol table.- Specified by:
pushScopein interfaceISymbolTable- Returns:
- The pushed scope.
-
pushScope
Description copied from interface:ISymbolTablePush a local scope context onto the symbol table.- Specified by:
pushScopein interfaceISymbolTable- Parameters:
scope- the scope to push- Returns:
- The pushed scope.
-
pushPrivateGlobalScope
Description copied from interface:ISymbolTablePush 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.- Specified by:
pushPrivateGlobalScopein interfaceISymbolTable- See Also:
-
popGlobalScope
Description copied from interface:ISymbolTablePops a global scope previously pushed viapushGlobalScope( IScope )orpushPrivateGlobalScope( IScope ). You probably shouldn't call this method.- Specified by:
popGlobalScopein interfaceISymbolTable- See Also:
-
popScope
Description copied from interface:ISymbolTablePop a local scope context from the symbol table. See pushScope() for implementation suggestions.- Specified by:
popScopein interfaceISymbolTable- Returns:
- The popped scope.
-
peekScope
- Specified by:
peekScopein interfaceISymbolTable- Returns:
- the currently active scope
-
peekScope
- Specified by:
peekScopein interfaceISymbolTable
-
popScope
- Specified by:
popScopein interfaceISymbolTable
-
pushIsolatedScope
Description copied from interface:ISymbolTablePush 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.- Specified by:
pushIsolatedScopein interfaceISymbolTable- Parameters:
activationCtx- The context for the activation record.- Returns:
- The isolated scope (aka the activation record).
-
defineCommonSymbols
public void defineCommonSymbols()Description copied from interface:ISymbolTableDefine symbols that are considered ubiquitous. There may be none.- Specified by:
defineCommonSymbolsin interfaceISymbolTable
-
getNextStackIndex
public int getNextStackIndex()Description copied from interface:IStackProviderFor compile-time assignment of stack indexes.- Specified by:
getNextStackIndexin interfaceIStackProvider
-
getNextStackIndexForScope
Description copied from interface:IStackProviderFor compile-time assignment of stack indexes at a particular scope.- Specified by:
getNextStackIndexForScopein interfaceIStackProvider
-
hasIsolatedScope
public boolean hasIsolatedScope()Description copied from interface:IStackProviderFor compile-time use. Returns true iff an isolated scope is visible.- Specified by:
hasIsolatedScopein interfaceIStackProvider
-
getThisSymbolFromStackOrMap
Description copied from interface:ISymbolTableGet the 'this' symbol from either the stack or the table.- Specified by:
getThisSymbolFromStackOrMapin interfaceISymbolTable
-
getTargetSymbolTable
-
isSymbolWithinScope
- Specified by:
isSymbolWithinScopein interfaceISymbolTable- Returns:
- true if the given symbol is within the given scope
-
peekIsolatedScope
- Specified by:
peekIsolatedScopein interfaceISymbolTable- Returns:
- the top-most isolated scope
-
getDefaultSymbolTable
-
clearDefaultSymbolTable
public void clearDefaultSymbolTable() -
getThreadLocalSymbolTable
Get a thread-local symbol table. This is typically an instance of StandardSymbol table you maintain in a simple ThreadLocal.
-