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 Summary
Fields Modifier and Type Field Description protected static IProbabilityFunctionFactoryiProbFuncFactoryprotected static ProbfunctionFactoryprobFuncFactoryprotected static StoexFactorystocFactoryprotected StoexSerialiserstoexSerialiserprotected HashMap<Expression,TypeEnum>typeAnnotation-
Fields inherited from class de.uka.ipd.sdq.stoex.util.StoexSwitch
copyright, modelPackage
-
-
Constructor Summary
Constructors Constructor Description ExpressionSolveVisitor(HashMap<Expression,TypeEnum> typeAnn, StoexSerialiser stoexSerialiser)Constructor storing the evaluated type annotations.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ObjectcaseBooleanOperatorExpression(BooleanOperatorExpression expr)Performs logical operations (AND, OR).ObjectcaseBoolLiteral(BoolLiteral bl)Creates a BoolPMF for the given BoolLiteral.ObjectcaseCompareExpression(CompareExpression expr)Performs compare operations.ObjectcaseDoubleLiteral(DoubleLiteral dl)Just returns the given double literal.AtomcaseFunctionLiteral(FunctionLiteral object)Returns the result of interpreting the object as an instance of 'Function Literal'.ObjectcaseIfElseExpression(IfElseExpression expr)Returns the result of interpreting the object as an instance of 'If Else Expression'.ObjectcaseIntLiteral(IntLiteral il)Just returns the given int literal.ObjectcaseNotExpression(NotExpression notExpression)Returns the result of interpreting the object as an instance of 'Not Expression'.ObjectcaseParenthesis(Parenthesis parenthesis)Forwards the visitor to the inner expression within the parenthesis.ObjectcasePowerExpression(PowerExpression expr)Performs a power operation (only for constants).ObjectcaseProbabilityFunctionLiteral(ProbabilityFunctionLiteral probFuncLit)Just returns the given probfunction literal.ObjectcaseProductExpression(ProductExpression expr)Performs product operations (MULT, DIV, MOD).ObjectcaseStringLiteral(StringLiteral object)Returns the result of interpreting the object as an instance of 'String Literal'.ObjectcaseTermExpression(TermExpression expr)Performs term operations (ADD, SUB)ObjectcaseVariable(Variable var)Skips variables.-
Methods inherited from class de.uka.ipd.sdq.stoex.util.StoexSwitch
caseAbstractNamedReference, caseAtom, caseBooleanExpression, caseComparison, caseExpression, caseIfElse, caseNamespaceReference, caseNegativeExpression, caseNumericLiteral, casePower, caseProduct, caseRandomVariable, caseTerm, caseUnary, caseUnitCarryingElement, caseVariableReference, defaultCase, doSwitch, isSwitchFor
-
-
-
-
Field Detail
-
iProbFuncFactory
protected static final IProbabilityFunctionFactory iProbFuncFactory
-
probFuncFactory
protected static final ProbfunctionFactory probFuncFactory
-
stocFactory
protected static final StoexFactory stocFactory
-
stoexSerialiser
protected final StoexSerialiser stoexSerialiser
-
typeAnnotation
protected final HashMap<Expression,TypeEnum> typeAnnotation
-
-
Constructor Detail
-
ExpressionSolveVisitor
public ExpressionSolveVisitor(HashMap<Expression,TypeEnum> typeAnn, StoexSerialiser stoexSerialiser)
Constructor storing the evaluated type annotations.- Parameters:
typeAnn-
-
-
Method Detail
-
caseCompareExpression
public Object caseCompareExpression(CompareExpression expr)
Performs compare operations.- Overrides:
caseCompareExpressionin classStoexSwitch<Object>- Parameters:
expr- the target of the switch.- Returns:
- the result of interpreting the object as an instance of 'Compare Expression'.
- See Also:
doSwitch(EObject)
-
caseBooleanOperatorExpression
public Object caseBooleanOperatorExpression(BooleanOperatorExpression expr)
Performs logical operations (AND, OR).- Overrides:
caseBooleanOperatorExpressionin classStoexSwitch<Object>- Parameters:
expr- the target of the switch.- Returns:
- the result of interpreting the object as an instance of 'Boolean Operator Expression'.
- See Also:
doSwitch(EObject)
-
caseTermExpression
public Object caseTermExpression(TermExpression expr)
Performs term operations (ADD, SUB)- Overrides:
caseTermExpressionin classStoexSwitch<Object>- Parameters:
expr- the target of the switch.- Returns:
- the result of interpreting the object as an instance of 'Term Expression'.
- See Also:
doSwitch(EObject)
-
caseProductExpression
public Object caseProductExpression(ProductExpression expr)
Performs product operations (MULT, DIV, MOD).- Overrides:
caseProductExpressionin classStoexSwitch<Object>- Parameters:
expr- the target of the switch.- Returns:
- the result of interpreting the object as an instance of 'Product Expression'.
- See Also:
doSwitch(EObject)
-
caseIfElseExpression
public Object caseIfElseExpression(IfElseExpression expr)
Description copied from class:StoexSwitchReturns 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:
caseIfElseExpressionin classStoexSwitch<Object>- Parameters:
expr- the target of the switch.- Returns:
- the result of interpreting the object as an instance of 'If Else Expression'.
- See Also:
doSwitch(EObject)
-
caseParenthesis
public Object caseParenthesis(Parenthesis parenthesis)
Forwards the visitor to the inner expression within the parenthesis.- Overrides:
caseParenthesisin classStoexSwitch<Object>- Parameters:
parenthesis- the target of the switch.- Returns:
- the result of interpreting the object as an instance of 'Parenthesis'.
- See Also:
doSwitch(EObject)
-
caseVariable
public Object caseVariable(Variable var)
Skips variables. This visitor cannot handle variables. Use the PCM Solver to handle variables in stochastic expressions.- Overrides:
caseVariablein classStoexSwitch<Object>- Parameters:
var- the target of the switch.- Returns:
- the result of interpreting the object as an instance of 'Variable'.
- See Also:
doSwitch(EObject)
-
caseBoolLiteral
public Object caseBoolLiteral(BoolLiteral bl)
Creates a BoolPMF for the given BoolLiteral.- Overrides:
caseBoolLiteralin classStoexSwitch<Object>- Parameters:
bl- the target of the switch.- Returns:
- the result of interpreting the object as an instance of 'Bool Literal'.
- See Also:
doSwitch(EObject)
-
caseIntLiteral
public Object caseIntLiteral(IntLiteral il)
Just returns the given int literal.- Overrides:
caseIntLiteralin classStoexSwitch<Object>- Parameters:
il- the target of the switch.- Returns:
- the result of interpreting the object as an instance of 'Int Literal'.
- See Also:
doSwitch(EObject)
-
caseDoubleLiteral
public Object caseDoubleLiteral(DoubleLiteral dl)
Just returns the given double literal.- Overrides:
caseDoubleLiteralin classStoexSwitch<Object>- Parameters:
dl- the target of the switch.- Returns:
- the result of interpreting the object as an instance of 'Double Literal'.
- See Also:
doSwitch(EObject)
-
caseStringLiteral
public Object caseStringLiteral(StringLiteral object)
Description copied from class:StoexSwitchReturns 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:
caseStringLiteralin classStoexSwitch<Object>- Parameters:
object- the target of the switch.- Returns:
- the result of interpreting the object as an instance of 'String Literal'.
- See Also:
doSwitch(EObject)
-
caseProbabilityFunctionLiteral
public Object caseProbabilityFunctionLiteral(ProbabilityFunctionLiteral probFuncLit)
Just returns the given probfunction literal.- Overrides:
caseProbabilityFunctionLiteralin classStoexSwitch<Object>- Parameters:
probFuncLit- the target of the switch.- Returns:
- the result of interpreting the object as an instance of 'Probability Function Literal'.
- See Also:
doSwitch(EObject)
-
casePowerExpression
public Object casePowerExpression(PowerExpression expr)
Performs a power operation (only for constants).- Overrides:
casePowerExpressionin classStoexSwitch<Object>- Parameters:
expr- the target of the switch.- Returns:
- the result of interpreting the object as an instance of 'Power Expression'.
- See Also:
doSwitch(EObject)
-
caseFunctionLiteral
public Atom caseFunctionLiteral(FunctionLiteral object)
Description copied from class:StoexSwitchReturns 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:
caseFunctionLiteralin classStoexSwitch<Object>- Parameters:
object- the target of the switch.- Returns:
- the result of interpreting the object as an instance of 'Function Literal'.
- See Also:
doSwitch(EObject)
-
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:
caseNotExpressionin classStoexSwitch<Object>- Parameters:
notExpression- the target of the switch.- Returns:
- the result of interpreting the object as an instance of 'Not Expression'.
- See Also:
doSwitch(EObject)- Generated class or method.
-
-