Class Environment

    • Constructor Summary

      Constructors 
      Constructor Description
      Environment()  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      Environment bind​(java.lang.String name, Type type, java.lang.Object value)
      Creates an environment that is the same as a given environment, plus one more variable.
      private Environment bind​(Binding binding)  
      Environment bindAll​(java.lang.Iterable<Binding> bindings)
      Creates an environment that is the same as this, plus the given bindings.
      void forEachType​(java.util.function.BiConsumer<java.lang.String,​Type> consumer)
      Calls a consumer for each variable and its type.
      void forEachValue​(java.util.function.BiConsumer<java.lang.String,​java.lang.Object> consumer)
      Calls a consumer for each variable and its value.
      Binding get​(java.lang.String name)
      Returns the binding of name; throws if not.
      abstract Binding getOpt​(java.lang.String name)
      Returns the binding of name if bound, null if not.
      java.util.Map<java.lang.String,​Binding> getValueMap()
      Returns a map of the values and bindings.
      java.lang.String toString()  
      (package private) abstract void visit​(java.util.function.Consumer<Binding> consumer)
      Visits every variable binding in this environment.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • Environment

        public Environment()
    • Method Detail

      • visit

        abstract void visit​(java.util.function.Consumer<Binding> consumer)
        Visits every variable binding in this environment.

        Bindings that are obscured by more recent bindings of the same name are visited, but after the more obscuring bindings.

      • toString

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

        public abstract Binding getOpt​(java.lang.String name)
        Returns the binding of name if bound, null if not.
      • get

        public Binding get​(java.lang.String name)
        Returns the binding of name; throws if not.
      • bind

        public Environment bind​(java.lang.String name,
                                Type type,
                                java.lang.Object value)
        Creates an environment that is the same as a given environment, plus one more variable.
      • forEachType

        public void forEachType​(java.util.function.BiConsumer<java.lang.String,​Type> consumer)
        Calls a consumer for each variable and its type. Does not visit obscured bindings.
      • forEachValue

        public void forEachValue​(java.util.function.BiConsumer<java.lang.String,​java.lang.Object> consumer)
        Calls a consumer for each variable and its value. Does not visit obscured bindings, or bindings to Unit.INSTANCE.
      • getValueMap

        public final java.util.Map<java.lang.String,​Binding> getValueMap()
        Returns a map of the values and bindings.
      • bindAll

        public final Environment bindAll​(java.lang.Iterable<Binding> bindings)
        Creates an environment that is the same as this, plus the given bindings.