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 form net.ssehub.easy.varModel.model.values are intended to be constants and, thus, cannot contain arbitrary expressions.
Author:
Holger Eichelberger
  • Field Details

  • Constructor Details

    • CompoundInitializer

      public CompoundInitializer(Compound type, String[] slots, AbstractVariable[] slotDecls, ConstraintSyntaxTree[] expressions) throws CSTSemanticException
      Creates a new compound initializer.
      Parameters:
      type - the type of the compound
      slots - the names of the slots. Note that the index of the name denotes the slot related to the expression at the same index position in expressions.
      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 in expressions.
      expressions - the initializing expressions. Note that the index of the expression denotes the slot related to the name at the same index position in slots.
      Throws:
      CSTSemanticException - in case that the initialization fails
  • Method Details

    • 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:
      IndexOutOfBoundsException - if index < 0 || index >=getExpressionCount()
    • getSlot

      public 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:
      IndexOutOfBoundsException - if index < 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:
      IndexOutOfBoundsException - if index < 0 || index >=getSlotCount()
    • accept

      public void accept(IConstraintTreeVisitor visitor)
      Description copied from class: ConstraintSyntaxTree
      Visiting method for the visitor.
      This method is used for saving this model element.
      Specified by:
      accept in class ConstraintSyntaxTree
      Parameters:
      visitor - The visitor, which should save this model element.
    • inferDatatype

      public IDatatype inferDatatype() throws CSTSemanticException
      Description copied from class: ConstraintSyntaxTree
      Infers the datatype of the subtree represented by this object.
      Specified by:
      inferDatatype in class ConstraintSyntaxTree
      Returns:
      the data type
      Throws:
      CSTSemanticException - Will be thrown if parameters of (sub-) trees do not fit together.
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object