Interface ISymbolTable

    • Method Detail

      • getSymbol

        ISymbol getSymbol​(CharSequence name)
        Returns:
        The symbol mapped to the specified name.
      • putSymbol

        void putSymbol​(ISymbol symbol)
        Maps a name to a symbol in the table.
      • removeSymbol

        ISymbol removeSymbol​(CharSequence name)
        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

        Map getSymbols​(int iScopeIndex,
                       int iPrivateGlobalIndex)
        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:
        getSymbols(int,int)
      • 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:
        getSymbols(int,int)
      • pushScope

        IScope pushScope()
        Push a local scope context onto the symbol table.
        Returns:
        The pushed scope.
      • pushScope

        IScope pushScope​(IScope scope)
        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

        IScope peekScope​(int iPos)
      • pushIsolatedScope

        IScope pushIsolatedScope​(IActivationContext activationCtx)
        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

        void pushPrivateGlobalScope​(IScope scope)
        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 calling pushIsolatedScope() instead.

        See Also:
        pushScope(), pushIsolatedScope(IActivationContext)
      • popGlobalScope

        void popGlobalScope​(IScope scope)
        Pops a global scope previously pushed via pushGlobalScope( IScope ) or pushPrivateGlobalScope( IScope ).

        You probably shouldn't call this method.

        See Also:
        pushPrivateGlobalScope(IScope), popScope()
      • 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

        boolean isSymbolWithinScope​(ISymbol sym,
                                    IScope scope)
        Returns:
        true if the given symbol is within the given scope
      • peekIsolatedScope

        IScope peekIsolatedScope()
        Returns:
        the top-most isolated scope