Package org.eclipse.xsemantics.runtime
Class RuleEnvironment
- java.lang.Object
-
- org.eclipse.xsemantics.runtime.RuleEnvironment
-
public class RuleEnvironment extends java.lang.ObjectImplements the environment for a typing judgment- Author:
- Lorenzo Bettini
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Map<java.lang.Object,java.lang.Object>environmentprotected RuleEnvironmentnext
-
Constructor Summary
Constructors Constructor Description RuleEnvironment()RuleEnvironment(RuleEnvironment e)RuleEnvironment(RuleEnvironmentEntry environmentEntry)RuleEnvironment(RuleEnvironment firstComponent, RuleEnvironment secondComponent)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(java.lang.Object o1, java.lang.Object o2)booleanadd(java.lang.Object o1, java.lang.Object o2, boolean checkExist)If checkExist is true, before inserting, also checks that there is no other statement in the environment with left equal to the passed typingStatement left (otherwise returns false=voidadd(RuleEnvironmentEntry runtimeEnvironmentEntry)voidclear()voiddecrement(java.lang.Object o1)Remove the mapping with the passed object as keyvoiddecrement(RuleEnvironment ruleEnvironment)Removes all the mapping that have as keys the keys of the passed environment.java.util.Set<java.util.Map.Entry<java.lang.Object,java.lang.Object>>entrySet()booleanequals(java.lang.Object o)If the passed object is a RuleEnvironment then returns equals on the twoMapcontained objects.java.lang.Objectget(java.lang.Object key)If the key is not found in this environment tries recursively with the next onejava.util.Map<java.lang.Object,java.lang.Object>getEnvironment()RuleEnvironmentgetNext()inthashCode()voidincrement(java.lang.Object o1, java.lang.Object o2)Same as addvoidincrement(RuleEnvironment ruleEnvironment)Adds all the entries of the passed environment to this one (existing mappings for the same key will be overwritten).voidincrement(RuleEnvironmentEntry runtimeEnvironmentEntry)Same as addbooleanisEmpty()java.util.Set<java.lang.Object>keySet()voidsetNext(RuleEnvironment next)voidsetNext(RuleEnvironmentEntry runtimeEnvironmentEntry)intsize()java.lang.StringtoString()booleanunion(java.lang.Object o1, java.lang.Object o2)booleanunion(RuleEnvironment ruleEnvironment)Adds all the entries of the passed environment, but it returns false if there are mappings in the passed environment with the same key of the current environment; the current environment is NOT restored to its original state in case of failure.booleanunion(RuleEnvironmentEntry runtimeEnvironmentEntry)java.util.Collection<java.lang.Object>values()
-
-
-
Field Detail
-
environment
protected java.util.Map<java.lang.Object,java.lang.Object> environment
-
next
protected RuleEnvironment next
-
-
Constructor Detail
-
RuleEnvironment
public RuleEnvironment(RuleEnvironment e)
-
RuleEnvironment
public RuleEnvironment()
-
RuleEnvironment
public RuleEnvironment(RuleEnvironmentEntry environmentEntry)
-
RuleEnvironment
public RuleEnvironment(RuleEnvironment firstComponent, RuleEnvironment secondComponent)
-
-
Method Detail
-
getEnvironment
public java.util.Map<java.lang.Object,java.lang.Object> getEnvironment()
-
getNext
public RuleEnvironment getNext()
-
setNext
public void setNext(RuleEnvironment next)
-
setNext
public void setNext(RuleEnvironmentEntry runtimeEnvironmentEntry)
-
add
public void add(RuleEnvironmentEntry runtimeEnvironmentEntry)
-
add
public boolean add(java.lang.Object o1, java.lang.Object o2)
-
add
public boolean add(java.lang.Object o1, java.lang.Object o2, boolean checkExist)If checkExist is true, before inserting, also checks that there is no other statement in the environment with left equal to the passed typingStatement left (otherwise returns false=- Parameters:
typingStatement-checkExist-- Returns:
-
get
public java.lang.Object get(java.lang.Object key)
If the key is not found in this environment tries recursively with the next one- Parameters:
key-- Returns:
-
increment
public void increment(RuleEnvironment ruleEnvironment)
Adds all the entries of the passed environment to this one (existing mappings for the same key will be overwritten).- Parameters:
ruleEnvironment-
-
increment
public void increment(RuleEnvironmentEntry runtimeEnvironmentEntry)
Same as add- Parameters:
runtimeEnvironmentEntry-
-
increment
public void increment(java.lang.Object o1, java.lang.Object o2)Same as add- Parameters:
o1-o2-
-
decrement
public void decrement(RuleEnvironment ruleEnvironment)
Removes all the mapping that have as keys the keys of the passed environment.- Parameters:
ruleEnvironment-
-
decrement
public void decrement(java.lang.Object o1)
Remove the mapping with the passed object as key- Parameters:
o1-
-
union
public boolean union(RuleEnvironment ruleEnvironment)
Adds all the entries of the passed environment, but it returns false if there are mappings in the passed environment with the same key of the current environment; the current environment is NOT restored to its original state in case of failure.- Parameters:
ruleEnvironment- if null it's succeeds- Returns:
-
union
public boolean union(RuleEnvironmentEntry runtimeEnvironmentEntry)
-
union
public boolean union(java.lang.Object o1, java.lang.Object o2)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
isEmpty
public boolean isEmpty()
- Since:
- 1.5
-
size
public int size()
- Since:
- 1.5
-
clear
public void clear()
- Since:
- 1.5
-
keySet
public java.util.Set<java.lang.Object> keySet()
- Since:
- 1.5
-
values
public java.util.Collection<java.lang.Object> values()
- Since:
- 1.5
-
entrySet
public java.util.Set<java.util.Map.Entry<java.lang.Object,java.lang.Object>> entrySet()
- Since:
- 1.5
-
equals
public boolean equals(java.lang.Object o)
If the passed object is a RuleEnvironment then returns equals on the twoMapcontained objects.- Overrides:
equalsin classjava.lang.Object- Since:
- 1.5
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object- Since:
- 1.5
-
-