Package net.hydromatic.morel.compile
Class Environments.MapEnvironment
- java.lang.Object
-
- net.hydromatic.morel.compile.Environment
-
- net.hydromatic.morel.compile.Environments.MapEnvironment
-
- Enclosing class:
- Environments
static class Environments.MapEnvironment extends Environment
Environment that keeps bindings in a map.
-
-
Field Summary
Fields Modifier and Type Field Description private Map<Core.NamedPat,Binding>mapprivate Environmentparent
-
Constructor Summary
Constructors Constructor Description MapEnvironment(Environment parent, com.google.common.collect.ImmutableMap<Core.NamedPat,Binding> map)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) intdistance(int soFar, Core.NamedPat id)private <E> intfind(Iterable<E> iterable, E e)@Nullable BindinggetOpt(String name)Returns the binding ofnameif bound, null if not.@Nullable BindinggetOpt(Core.NamedPat id)Returns the binding ofidif bound, null if not.(package private) EnvironmentnearestAncestorNotObscuredBy(Set<Core.NamedPat> names)If this environment only defines bindings in the given set, returns its parent.(package private) voidvisit(Consumer<Binding> consumer)Visits every variable binding in this environment.-
Methods inherited from class net.hydromatic.morel.compile.Environment
asString, bind, bind, bindAll, forEachType, forEachValue, getValueMap, plus
-
-
-
-
Field Detail
-
parent
private final Environment parent
-
map
private final Map<Core.NamedPat,Binding> map
-
-
Constructor Detail
-
MapEnvironment
MapEnvironment(Environment parent, com.google.common.collect.ImmutableMap<Core.NamedPat,Binding> map)
-
-
Method Detail
-
visit
void visit(Consumer<Binding> consumer)
Description copied from class:EnvironmentVisits 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.
- Specified by:
visitin classEnvironment
-
getOpt
public @Nullable Binding getOpt(String name)
Description copied from class:EnvironmentReturns the binding ofnameif bound, null if not.- Specified by:
getOptin classEnvironment
-
getOpt
public @Nullable Binding getOpt(Core.NamedPat id)
Description copied from class:EnvironmentReturns the binding ofidif bound, null if not.- Specified by:
getOptin classEnvironment
-
nearestAncestorNotObscuredBy
Environment nearestAncestorNotObscuredBy(Set<Core.NamedPat> names)
Description copied from class:EnvironmentIf this environment only defines bindings in the given set, returns its parent. Never returns null. The empty environment returns itself.- Specified by:
nearestAncestorNotObscuredByin classEnvironment
-
distance
int distance(int soFar, Core.NamedPat id)- Specified by:
distancein classEnvironment
-
find
private <E> int find(Iterable<E> iterable, E e)
-
-