Class TypeCache.Entry
- java.lang.Object
-
- net.ssehub.easy.reasoning.sseReasoner.model.TypeCache.Entry
-
- Enclosing class:
- TypeCache
public class TypeCache.Entry extends java.lang.ObjectImplements a type cache entry. Variables in an entry are relative to#var, which must be substituted finally with the actual top-level variable.- Author:
- Holger Eichelberger
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<TypeCache.ConstraintTemplate>constraintsprivate java.util.Map<java.lang.String,ConstraintSyntaxTree>nameMapprivate AbstractVariableorigvarprivate java.util.List<TypeCache.Entry>parentsprivate java.util.Map<AbstractVariable,ConstraintSyntaxTree>varMap
-
Constructor Summary
Constructors Modifier Constructor Description privateEntry(AbstractVariable var)Creates a type cache entry.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddConstraint(ConstraintList target, boolean first, Constraint constraint, boolean register)Adds a constraint to this type cache entry.voidaddParent(TypeCache.Entry entry, TypeCache.IConstraintTarget target, IDecisionVariable register, AbstractVariable var)Adds a parent to this entry and causes constraint transfer.booleancontainsMapping(AbstractVariable var)Returns whether the current context contains a mapping forvar.ConstraintSyntaxTreegetLocalMapping(java.lang.String name, AbstractVariable self)Returns the local mapping for the given variablenamejust from the current context.ConstraintSyntaxTreegetMapping(AbstractVariable var, AbstractVariable self)Returns the mapped access expression forvartaking into account all current contexts of the stack starting with the current top-most one.booleanhasMapping()Returns whether this cache entry has a variable-accessor mapping.private ConstraintSyntaxTreeinstantiate(ConstraintSyntaxTree cst, AbstractVariable var)Instantiates a the given constraint.java.lang.StringtoString()private booleantransferConstraints(TypeCache.IConstraintTarget target, IDecisionVariable register, AbstractVariable var)Transfers constraints.
-
-
-
Field Detail
-
origvar
private AbstractVariable origvar
-
constraints
private java.util.List<TypeCache.ConstraintTemplate> constraints
-
parents
private java.util.List<TypeCache.Entry> parents
-
varMap
private java.util.Map<AbstractVariable,ConstraintSyntaxTree> varMap
-
nameMap
private java.util.Map<java.lang.String,ConstraintSyntaxTree> nameMap
-
-
Constructor Detail
-
Entry
private Entry(AbstractVariable var)
Creates a type cache entry.- Parameters:
var- the variable the constraint are bound to
-
-
Method Detail
-
addConstraint
public void addConstraint(ConstraintList target, boolean first, Constraint constraint, boolean register)
Adds a constraint to this type cache entry.- Parameters:
target- the target listfirst- whether the constraint shall be added to front or backconstraint- the constraintregister- shall the constraint be registered inVariablesMap
-
hasMapping
public boolean hasMapping()
Returns whether this cache entry has a variable-accessor mapping. Such mappings are only present if additional constraint translations for this type are needed, e.g., to cope with changing constraint variables.- Returns:
truefor mapping,falseelse
-
containsMapping
public boolean containsMapping(AbstractVariable var)
Returns whether the current context contains a mapping forvar.- Parameters:
var- the variable to look for- Returns:
trueif there is a mapping,falseelse
-
instantiate
private ConstraintSyntaxTree instantiate(ConstraintSyntaxTree cst, AbstractVariable var)
Instantiates a the given constraint.- Parameters:
cst- the constraintvar- the replacing variable- Returns:
- the instantiated constraint
-
getMapping
public ConstraintSyntaxTree getMapping(AbstractVariable var, AbstractVariable self)
Returns the mapped access expression forvartaking into account all current contexts of the stack starting with the current top-most one. IfvarMapis present, performs an on-the-fly instantiation of the mapped accessor. Intended for dynamically building up the mapping in the context stack.- Parameters:
var- the variable to return the mapping forself- the variable to instantiate the stored mapping for- Returns:
- the mapped access expression or null if there is no registered mapping
-
getLocalMapping
public ConstraintSyntaxTree getLocalMapping(java.lang.String name, AbstractVariable self)
Returns the local mapping for the given variablenamejust from the current context. Names are registered once, to the most local (non-shadowed) variable. IfvarMapis present, performs an on-the-fly instantiation of the mapped accessor. Intended for dynamically building up the mapping in the context stack.- Parameters:
name- the name of the variableself- the variable to instantiate the stored mapping for- Returns:
- the mapped access expression or null if there is no registered mapping
-
addParent
public void addParent(TypeCache.Entry entry, TypeCache.IConstraintTarget target, IDecisionVariable register, AbstractVariable var)
Adds a parent to this entry and causes constraint transfer. Shall be applied only to type-compatible types such as refined compounds or derived types.- Parameters:
entry- the entrytarget- the constraint targetregister- the variable to register againstvar- the replacing variable
-
transferConstraints
private boolean transferConstraints(TypeCache.IConstraintTarget target, IDecisionVariable register, AbstractVariable var)
Transfers constraints.- Parameters:
target- the constraint targetregister- the variable to register againstvar- the replacing variable- Returns:
- whether the transfer was done
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-