Package gnu.mapping

Class Environment

  • All Implemented Interfaces:
    Named
    Direct Known Subclasses:
    BuiltinEnvironment, SimpleEnvironment

    public abstract class Environment
    extends PropertySet
    A mapping from EnvironmentKey to Locations. An EnvironmentKey is either a Symbol or a (Symbol, property)-pair.
    • Field Detail

      • INDIRECT_DEFINES

        public static final int INDIRECT_DEFINES
        Newly defined locations are created in inherited parent environment.
        See Also:
        Constant Field Values
      • curEnvironment

        protected static final gnu.mapping.Environment.InheritedLocal curEnvironment
    • Constructor Detail

      • Environment

        public Environment()
    • Method Detail

      • setGlobal

        public static void setGlobal​(Environment env)
      • getFlags

        public int getFlags()
      • setFlag

        public void setFlag​(boolean setting,
                            int flag)
      • getCanDefine

        public boolean getCanDefine()
        True if new bindings (non-unbound Locations) can be added.
      • setCanDefine

        public void setCanDefine​(boolean canDefine)
      • getCanRedefine

        public boolean getCanRedefine()
        True if bindings can be removed or replaced by other kinds of Location.
      • setCanRedefine

        public void setCanRedefine​(boolean canRedefine)
      • isLocked

        public final boolean isLocked()
        True if this environment is locked - bindings cannot be added or removed.
      • setLocked

        public void setLocked()
      • setIndirectDefines

        public final void setIndirectDefines()
      • getLocation

        public final Location getLocation​(Symbol key,
                                          Object property)
        Return a location bound to (key, property). Create new unbound Location if no such Location exists.
      • getLocation

        public final Location getLocation​(Symbol key)
        Return a location bound to key (and null property). Create new unbound Location if no such Location exists.
      • lookup

        public final Location lookup​(Symbol key,
                                     Object property)
        Return a location bound to (key, property). Return null if no such Location exists.
      • getLocation

        public final Location getLocation​(Object key,
                                          boolean create)
      • isBound

        public boolean isBound​(Symbol key,
                               Object property)
      • isBound

        public final boolean isBound​(Symbol key)
      • containsKey

        public final boolean containsKey​(Object key)
      • getFunction

        public final Object getFunction​(Symbol sym)
      • get

        public final Object get​(Object key)
        Get the value bound to the given name. Returns null if the name has no binding (for compatibility with Java2 Collections framework).
        See Also:
        getChecked(String)
      • define

        public abstract void define​(Symbol key,
                                    Object property,
                                    Object newValue)
      • put

        public final void put​(Symbol key,
                              Object newValue)
      • putFunction

        public final void putFunction​(Symbol key,
                                      Object newValue)
      • unlink

        public Location unlink​(Symbol key,
                               Object property,
                               int hash)
        Remove Location from this Environment. Does not explicitly undefine the location itself.
      • remove

        public Object remove​(Symbol key,
                             Object property,
                             int hash)
        Remove Location from this Environment and undefine it.
      • remove

        public final Object remove​(EnvironmentKey key)
        Remove and undefine binding.
        Returns:
        Old value
      • remove

        public final void remove​(Symbol sym)
      • removeFunction

        public final void removeFunction​(Symbol sym)
      • defaultNamespace

        public Namespace defaultNamespace()
      • enumerateLocations

        public abstract LocationEnumeration enumerateLocations()
        Does not enumerate inherited Locations.
      • enumerateAllLocations

        public abstract LocationEnumeration enumerateAllLocations()
        Does enumerate inherited Locations.
      • setCurrent

        public static void setCurrent​(Environment env)
      • restoreCurrent

        public static void restoreCurrent​(Environment saved)
      • addLocation

        public final void addLocation​(NamedLocation loc)
      • toStringVerbose

        public String toStringVerbose()
        Overridden in sub-classes - useful for more verbose debug output.