Class Scope<T>


  • public class Scope<T>
    extends Object
    Scope stores maps on a stack. Each map is a 'scope' of values uniquely identified by their map keys. Values from previous scopes may be retrieved with the lookup() and lookdown() methods.
    • Field Detail

      • parent

        public final Scope<T> parent
    • Constructor Detail

      • Scope

        public Scope()
      • Scope

        public Scope​(Scope<T> parent)
    • Method Detail

      • lookup

        public T lookup​(String key)
        Iterates the scopes from the bottom up (back to front), and returns the value of the first map containing the key.
        Parameters:
        key - Object key
        Returns:
        Object associated with the first match of key, or null if not found
      • lookdown

        public T lookdown​(String key)
        Iterates the scope from the top down (front to back), and returns the value of the first map containing the key.
        Parameters:
        key - Object key
        Returns:
        Object associated with the first match of key, or null if not found
      • look

        public T look​(String key)
        Looks only at the current scope and returns the value associated with the key.
        Parameters:
        key - Object key
        Returns:
        Object associated with the match of key, or null if not found
      • add

        public void add​(String key,
                        T value)
        Adds a value to the current scope (map).
        Parameters:
        key - Key associated with object
        value - Value associated with the key
      • getSymbols

        public Map<String,​T> getSymbols()