Class StandardSymbolTable

    • Field Detail

      • PRINT

        public static final java.lang.reflect.Method PRINT
      • _stackScopes

        private java.util.ArrayList _stackScopes
      • _stackPrivateGlobalScopes

        private java.util.LinkedList _stackPrivateGlobalScopes
      • _scopeSizes

        private int[] _scopeSizes
        The sizes of the scopes are maintained in the array. Note the zeroth one is reserved for the Global scope, which may or may not be meainingful depending on the context e.g., plain expressions have a global scope, but gosu classes don't.
      • _iScopeCsr

        private int _iScopeCsr
    • Constructor Detail

      • StandardSymbolTable

        public StandardSymbolTable()
      • StandardSymbolTable

        public StandardSymbolTable​(boolean bDefineCommonSymbols)
        Parameters:
        bDefineCommonSymbols -
      • StandardSymbolTable

        private StandardSymbolTable​(StandardSymbolTable source)
        Parameters:
        source -
    • Method Detail

      • init

        private void init()
      • getSymbol

        public ISymbol getSymbol​(java.lang.CharSequence name)
        Specified by:
        getSymbol in interface ISymbolTable
        Returns:
        The symbol mapped to the specified name.
      • removeSymbol

        public ISymbol removeSymbol​(java.lang.CharSequence name)
        Description copied from interface: ISymbolTable
        Removes a previously mapped symbol.
        Specified by:
        removeSymbol in interface ISymbolTable
        Parameters:
        name - The name mapped to the symbol to remove.
      • getTotalSymbolCount

        public int getTotalSymbolCount()
        Specified by:
        getTotalSymbolCount in interface ISymbolTable
        Returns:
        the number of symbols exist in this table.
      • getSymbols

        public java.util.Map getSymbols()
        Specified by:
        getSymbols in interface ISymbolTable
        Returns:
        A list of currently mapped ISymbols e.g., the values in a hash table based implementation.
      • getSymbols

        public java.util.Map getSymbols​(int iStartIndex,
                                        int iPrivateGlobalIndex)
        Specified by:
        getSymbols in interface ISymbolTable
        Parameters:
        iStartIndex - 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

        public int getScopeCount()
        Specified by:
        getScopeCount in interface ISymbolTable
        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:
        ISymbolTable.getSymbols(int,int)
      • getPrivateGlobalScopeCount

        public int getPrivateGlobalScopeCount()
        Specified by:
        getPrivateGlobalScopeCount in interface ISymbolTable
        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:
        ISymbolTable.getSymbols(int,int)
      • pushScope

        public IScope pushScope()
        Description copied from interface: ISymbolTable
        Push a local scope context onto the symbol table.
        Specified by:
        pushScope in interface ISymbolTable
        Returns:
        The pushed scope.
      • pushScope

        public IScope pushScope​(IScope scope)
        Description copied from interface: ISymbolTable
        Push a local scope context onto the symbol table.
        Specified by:
        pushScope in interface ISymbolTable
        Parameters:
        scope - the scope to push
        Returns:
        The pushed scope.
      • pushIsolatedScope

        public IScope pushIsolatedScope​(IActivationContext activationCtx)
        Description copied from interface: ISymbolTable
        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.

        Specified by:
        pushIsolatedScope in interface ISymbolTable
        Parameters:
        activationCtx - The context for the activation record.
        Returns:
        The isolated scope (aka the activation record).
      • popScope

        public IScope popScope()
        Description copied from interface: ISymbolTable
        Pop a local scope context from the symbol table.

        See pushScope() for implementation suggestions.

        Specified by:
        popScope in interface ISymbolTable
        Returns:
        The popped scope.
      • copy

        public ISymbolTable copy()
        Description copied from interface: ISymbolTable
        Perform a semi-deep copy of this symbol table. Symbols need not be cloned.
        Specified by:
        copy in interface ISymbolTable
        Returns:
        A semi-deep copy of this symbol table.
      • defineCommonSymbols

        public void defineCommonSymbols()
        Description copied from interface: ISymbolTable
        Define symbols that are considered ubiquitous. There may be none.
        Specified by:
        defineCommonSymbols in interface ISymbolTable
      • isSymbolWithinScope

        public boolean isSymbolWithinScope​(ISymbol symToFind,
                                           IScope containingScope)
        Specified by:
        isSymbolWithinScope in interface ISymbolTable
        Returns:
        true if the given symbol is within the given scope
      • getNextStackIndex

        public int getNextStackIndex()
        For compile-time assignment of stack indexes.
        Specified by:
        getNextStackIndex in interface IStackProvider
      • getNextStackIndexForScopeIndex

        private int getNextStackIndexForScopeIndex​(int csr)
      • hasIsolatedScope

        public boolean hasIsolatedScope()
        Description copied from interface: IStackProvider
        For compile-time use. Returns true iff an isolated scope is visible.
        Specified by:
        hasIsolatedScope in interface IStackProvider
      • getSymbol

        private ISymbol getSymbol​(java.lang.CharSequence strName,
                                  int iStartIndex)
      • getGlobalSymbol

        private ISymbol getGlobalSymbol​(java.lang.CharSequence strName)
      • getPrivateGlobalSymbol

        private ISymbol getPrivateGlobalSymbol​(java.lang.CharSequence strName)
      • removeGlobalScope

        private void removeGlobalScope​(IScope globalScope)
      • getIndexOfGlobalScope

        private int getIndexOfGlobalScope​(IScope globalScope)
      • getInsertionIndexOfGlobalScope

        private int getInsertionIndexOfGlobalScope()
      • getSymbols

        private void getSymbols​(java.util.Map symbols,
                                int iStartIndex,
                                int iPrivateGlobalIndex)
      • getGlobalSymbols

        private void getGlobalSymbols​(java.util.Map symbols,
                                      int iPrivateGlobalIndex)
      • getPrivateGlobalSymbols

        private void getPrivateGlobalSymbols​(java.util.Map symbols,
                                             int iPrivateGlobalIndex)
      • ensureIsolatedScopeSizesCapacity

        private void ensureIsolatedScopeSizesCapacity()
      • toString

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