Class ExpressionSolveVisitor

java.lang.Object
org.eclipse.emf.ecore.util.Switch<T>
de.uka.ipd.sdq.stoex.util.StoexSwitch<Object>
de.uka.ipd.sdq.stoex.analyser.visitors.ExpressionSolveVisitor

public class ExpressionSolveVisitor extends StoexSwitch<Object>
A visitor for stochastic expressions, which evaluates the operations within a expression and returns the resulting expression, which does not contain any operation any more. For example, when a stochastic expression contains a division operation between a INT_PMF and a constant it returns an INT_PMF divided by the constant. The visitor is invoked as usual via the doSwitch(Expression toSolve) command. It returns the solved expression. This class uses the operations in de.uka.ipd.sdq.stoex.analyser.operations as an interface to the probability function package.
  • Field Details

  • Constructor Details

    • ExpressionSolveVisitor

      public ExpressionSolveVisitor(HashMap<Expression,TypeEnum> typeAnn, StoexSerialiser stoexSerialiser)
      Constructor storing the evaluated type annotations.
      Parameters:
      typeAnn -
  • Method Details

    • caseCompareExpression

      public Object caseCompareExpression(CompareExpression expr)
      Performs compare operations.
      Overrides:
      caseCompareExpression in class StoexSwitch<Object>
      Parameters:
      expr - the target of the switch.
      Returns:
      the result of interpreting the object as an instance of 'Compare Expression'.
      See Also:
    • caseBooleanOperatorExpression

      public Object caseBooleanOperatorExpression(BooleanOperatorExpression expr)
      Performs logical operations (AND, OR).
      Overrides:
      caseBooleanOperatorExpression in class StoexSwitch<Object>
      Parameters:
      expr - the target of the switch.
      Returns:
      the result of interpreting the object as an instance of 'Boolean Operator Expression'.
      See Also:
    • caseTermExpression

      public Object caseTermExpression(TermExpression expr)
      Performs term operations (ADD, SUB)
      Overrides:
      caseTermExpression in class StoexSwitch<Object>
      Parameters:
      expr - the target of the switch.
      Returns:
      the result of interpreting the object as an instance of 'Term Expression'.
      See Also:
    • caseProductExpression

      public Object caseProductExpression(ProductExpression expr)
      Performs product operations (MULT, DIV, MOD).
      Overrides:
      caseProductExpression in class StoexSwitch<Object>
      Parameters:
      expr - the target of the switch.
      Returns:
      the result of interpreting the object as an instance of 'Product Expression'.
      See Also:
    • caseIfElseExpression

      public Object caseIfElseExpression(IfElseExpression expr)
      Description copied from class: StoexSwitch
      Returns the result of interpreting the object as an instance of 'If Else Expression'. This implementation returns null; returning a non-null result will terminate the switch.
      Overrides:
      caseIfElseExpression in class StoexSwitch<Object>
      Parameters:
      expr - the target of the switch.
      Returns:
      the result of interpreting the object as an instance of 'If Else Expression'.
      See Also:
    • caseParenthesis

      public Object caseParenthesis(Parenthesis parenthesis)
      Forwards the visitor to the inner expression within the parenthesis.
      Overrides:
      caseParenthesis in class StoexSwitch<Object>
      Parameters:
      parenthesis - the target of the switch.
      Returns:
      the result of interpreting the object as an instance of 'Parenthesis'.
      See Also:
    • caseVariable

      public Object caseVariable(Variable var)
      Skips variables. This visitor cannot handle variables. Use the PCM Solver to handle variables in stochastic expressions.
      Overrides:
      caseVariable in class StoexSwitch<Object>
      Parameters:
      var - the target of the switch.
      Returns:
      the result of interpreting the object as an instance of 'Variable'.
      See Also:
    • caseBoolLiteral

      public Object caseBoolLiteral(BoolLiteral bl)
      Creates a BoolPMF for the given BoolLiteral.
      Overrides:
      caseBoolLiteral in class StoexSwitch<Object>
      Parameters:
      bl - the target of the switch.
      Returns:
      the result of interpreting the object as an instance of 'Bool Literal'.
      See Also:
    • caseIntLiteral

      public Object caseIntLiteral(IntLiteral il)
      Just returns the given int literal.
      Overrides:
      caseIntLiteral in class StoexSwitch<Object>
      Parameters:
      il - the target of the switch.
      Returns:
      the result of interpreting the object as an instance of 'Int Literal'.
      See Also:
    • caseDoubleLiteral

      public Object caseDoubleLiteral(DoubleLiteral dl)
      Just returns the given double literal.
      Overrides:
      caseDoubleLiteral in class StoexSwitch<Object>
      Parameters:
      dl - the target of the switch.
      Returns:
      the result of interpreting the object as an instance of 'Double Literal'.
      See Also:
    • caseStringLiteral

      public Object caseStringLiteral(StringLiteral object)
      Description copied from class: StoexSwitch
      Returns the result of interpreting the object as an instance of 'String Literal'. This implementation returns null; returning a non-null result will terminate the switch.
      Overrides:
      caseStringLiteral in class StoexSwitch<Object>
      Parameters:
      object - the target of the switch.
      Returns:
      the result of interpreting the object as an instance of 'String Literal'.
      See Also:
    • caseProbabilityFunctionLiteral

      public Object caseProbabilityFunctionLiteral(ProbabilityFunctionLiteral probFuncLit)
      Just returns the given probfunction literal.
      Overrides:
      caseProbabilityFunctionLiteral in class StoexSwitch<Object>
      Parameters:
      probFuncLit - the target of the switch.
      Returns:
      the result of interpreting the object as an instance of 'Probability Function Literal'.
      See Also:
    • casePowerExpression

      public Object casePowerExpression(PowerExpression expr)
      Performs a power operation (only for constants).
      Overrides:
      casePowerExpression in class StoexSwitch<Object>
      Parameters:
      expr - the target of the switch.
      Returns:
      the result of interpreting the object as an instance of 'Power Expression'.
      See Also:
    • caseFunctionLiteral

      public Atom caseFunctionLiteral(FunctionLiteral object)
      Description copied from class: StoexSwitch
      Returns the result of interpreting the object as an instance of 'Function Literal'. This implementation returns null; returning a non-null result will terminate the switch.
      Overrides:
      caseFunctionLiteral in class StoexSwitch<Object>
      Parameters:
      object - the target of the switch.
      Returns:
      the result of interpreting the object as an instance of 'Function Literal'.
      See Also:
    • caseNotExpression

      public Object caseNotExpression(NotExpression notExpression)
      Returns the result of interpreting the object as an instance of 'Not Expression'. This implementation casts the result of its inner expression to boolean and returns the resulting values. If it cannot be cast to Boolean or BoolPMF, an exception is thrown.
      Overrides:
      caseNotExpression in class StoexSwitch<Object>
      Parameters:
      notExpression - the target of the switch.
      Returns:
      the result of interpreting the object as an instance of 'Not Expression'.
      See Also:
      Generated class or method.