Package net.ssehub.easy.varModel.cst
Class CompoundInitializer
- java.lang.Object
-
- net.ssehub.easy.varModel.cst.ConstraintSyntaxTree
-
- net.ssehub.easy.varModel.cst.CompoundInitializer
-
- All Implemented Interfaces:
IAttributeAccess
public class CompoundInitializer extends ConstraintSyntaxTree
Represents a typed initializer for compounds. This initializer may contain expressions for initializing compound slots. IVML:Type{slot=expression, ...}. We need a special constraint tree node for this purpose as values formnet.ssehub.easy.varModel.model.valuesare intended to be constants and, thus, cannot contain arbitrary expressions.- Author:
- Holger Eichelberger
-
-
Field Summary
Fields Modifier and Type Field Description private ConstraintSyntaxTree[]expressionsprivate AbstractVariable[]slotDeclsprivate java.lang.String[]slotsprivate Compoundtype
-
Constructor Summary
Constructors Constructor Description CompoundInitializer(Compound type, java.lang.String[] slots, AbstractVariable[] slotDecls, ConstraintSyntaxTree[] expressions)Creates a new compound initializer.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaccept(IConstraintTreeVisitor visitor)Visiting method for the visitor.booleanequals(java.lang.Object obj)ConstraintSyntaxTreegetExpression(int index)Returns the specified expression.intgetExpressionCount()Returns the number of expressions / slots.java.lang.StringgetSlot(int index)Returns the specified slot name.intgetSlotCount()Returns the number of expressions / slots.AbstractVariablegetSlotDeclaration(int index)Returns the declaration of the specified slot.CompoundgetType()Returns the type of the container.inthashCode()IDatatypeinferDatatype()Infers the datatype of the subtree represented by this object.-
Methods inherited from class net.ssehub.easy.varModel.cst.ConstraintSyntaxTree
getAttribute, getAttribute, getAttributesCount, getContainedType, getName, getParent, isSemanticallyEqual
-
-
-
-
Field Detail
-
type
private Compound type
-
expressions
private ConstraintSyntaxTree[] expressions
-
slots
private java.lang.String[] slots
-
slotDecls
private AbstractVariable[] slotDecls
-
-
Constructor Detail
-
CompoundInitializer
public CompoundInitializer(Compound type, java.lang.String[] slots, AbstractVariable[] slotDecls, ConstraintSyntaxTree[] expressions) throws CSTSemanticException
Creates a new compound initializer.- Parameters:
type- the type of the compoundslots- the names of the slots. Note that the index of the name denotes the slot related to the expression at the same index position inexpressions.slotDecls- the declarations of the slots. Note that the index of the name denotes the slot related to the expression at the same index position inexpressions.expressions- the initializing expressions. Note that the index of the expression denotes the slot related to the name at the same index position inslots.- Throws:
CSTSemanticException- in case that the initialization fails
-
-
Method Detail
-
getType
public Compound getType()
Returns the type of the container.- Returns:
- the type of the container
-
getSlotCount
public int getSlotCount()
Returns the number of expressions / slots.- Returns:
- the number of expressions / slots
-
getExpressionCount
public int getExpressionCount()
Returns the number of expressions / slots.- Returns:
- the number of expressions / slots
-
getExpression
public ConstraintSyntaxTree getExpression(int index)
Returns the specified expression.- Parameters:
index- the index of the expression to be returned- Returns:
- the specified expression
- Throws:
java.lang.IndexOutOfBoundsException- ifindex < 0 || index >=getExpressionCount()
-
getSlot
public java.lang.String getSlot(int index)
Returns the specified slot name.- Parameters:
index- the index of the expression to be returned- Returns:
- the specified slot name
- Throws:
java.lang.IndexOutOfBoundsException- ifindex < 0 || index >=getSlotCount()
-
getSlotDeclaration
public AbstractVariable getSlotDeclaration(int index)
Returns the declaration of the specified slot.- Parameters:
index- the index of the expression to be returned- Returns:
- the specified slot declaration
- Throws:
java.lang.IndexOutOfBoundsException- ifindex < 0 || index >=getSlotCount()
-
accept
public void accept(IConstraintTreeVisitor visitor)
Description copied from class:ConstraintSyntaxTreeVisiting method for the visitor.
This method is used for saving this model element.- Specified by:
acceptin classConstraintSyntaxTree- Parameters:
visitor- The visitor, which should save this model element.
-
inferDatatype
public IDatatype inferDatatype() throws CSTSemanticException
Description copied from class:ConstraintSyntaxTreeInfers the datatype of the subtree represented by this object.- Specified by:
inferDatatypein classConstraintSyntaxTree- Returns:
- the data type
- Throws:
CSTSemanticException- Will be thrown if parameters of (sub-) trees do not fit together.
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
-