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
Environment that keeps bindings in a map.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final com.google.common.collect.ImmutableMultimap<Core.IdPat, Binding> private final Map<Core.NamedPat, Binding> private final Environment -
Constructor Summary
ConstructorsConstructorDescriptionMapEnvironment(Environment parent, com.google.common.collect.ImmutableMap<Core.NamedPat, Binding> map, com.google.common.collect.ImmutableMultimap<Core.IdPat, Binding> instanceMap) -
Method Summary
Modifier and TypeMethodDescriptionvoidcollect(Core.NamedPat id, Consumer<Binding> consumer) Calls a consumer for all bindings ofid.(package private) intdistance(int soFar, Core.NamedPat id) private <E> int@Nullable BindinggetOpt(Core.NamedPat id) Returns the binding ofidif bound, null if not.@Nullable BindinggetOpt2(Core.NamedPat id) Alternative version ofEnvironment.getOpt(Core.NamedPat).@Nullable BindingReturns the top binding ofname.(package private) EnvironmentIf this environment only defines bindings in the given set, returns its parent.(package private) voidVisits every variable binding in this environment.Methods inherited from class net.hydromatic.morel.compile.Environment
asString, bind, bind, bindAll, forEachType, forEachValue, getOpt, getOverloads, getValueMap, hasOverloaded, plus, renumber
-
Field Details
-
parent
-
map
-
instanceMap
-
-
Constructor Details
-
MapEnvironment
MapEnvironment(Environment parent, com.google.common.collect.ImmutableMap<Core.NamedPat, Binding> map, com.google.common.collect.ImmutableMultimap<Core.IdPat, Binding> instanceMap)
-
-
Method Details
-
visit
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
-
getTop
Description copied from class:EnvironmentReturns the top binding ofname.If the top binding is overloaded, there may be other bindings. But at least it gives you a
Core.NamedPatwith which to callEnvironment.collect(Core.NamedPat, Consumer).- Specified by:
getTopin classEnvironment
-
getOpt
Description copied from class:EnvironmentReturns the binding ofidif bound, null if not.- Specified by:
getOptin classEnvironment
-
getOpt2
Description copied from class:EnvironmentAlternative version ofEnvironment.getOpt(Core.NamedPat).- Specified by:
getOpt2in classEnvironment
-
collect
Description copied from class:EnvironmentCalls a consumer for all bindings ofid.- Specified by:
collectin classEnvironment
-
nearestAncestorNotObscuredBy
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
- Specified by:
distancein classEnvironment
-
find
-