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 IProbabilityFunctionFactory
iProbFuncFactory
protected static ProbfunctionFactory
probFuncFactory
protected static StoexFactory
stocFactory
protected StoexSerialiser
stoexSerialiser
protected 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 Object
caseBooleanOperatorExpression(BooleanOperatorExpression expr)
Performs logical operations (AND, OR).Object
caseBoolLiteral(BoolLiteral bl)
Creates a BoolPMF for the given BoolLiteral.Object
caseCompareExpression(CompareExpression expr)
Performs compare operations.Object
caseDoubleLiteral(DoubleLiteral dl)
Just returns the given double literal.Atom
caseFunctionLiteral(FunctionLiteral object)
Returns the result of interpreting the object as an instance of 'Function Literal'.Object
caseIfElseExpression(IfElseExpression expr)
Returns the result of interpreting the object as an instance of 'If Else Expression'.Object
caseIntLiteral(IntLiteral il)
Just returns the given int literal.Object
caseNotExpression(NotExpression notExpression)
Returns the result of interpreting the object as an instance of 'Not Expression'.Object
caseParenthesis(Parenthesis parenthesis)
Forwards the visitor to the inner expression within the parenthesis.Object
casePowerExpression(PowerExpression expr)
Performs a power operation (only for constants).Object
caseProbabilityFunctionLiteral(ProbabilityFunctionLiteral probFuncLit)
Just returns the given probfunction literal.Object
caseProductExpression(ProductExpression expr)
Performs product operations (MULT, DIV, MOD).Object
caseStringLiteral(StringLiteral object)
Returns the result of interpreting the object as an instance of 'String Literal'.Object
caseTermExpression(TermExpression expr)
Performs term operations (ADD, SUB)Object
caseVariable(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:
caseCompareExpression
in 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:
caseBooleanOperatorExpression
in 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:
caseTermExpression
in 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:
caseProductExpression
in 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: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 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:
caseParenthesis
in 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:
caseVariable
in 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:
caseBoolLiteral
in 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:
caseIntLiteral
in 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:
caseDoubleLiteral
in 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: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 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:
caseProbabilityFunctionLiteral
in 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:
casePowerExpression
in 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: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 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:
caseNotExpression
in 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.
-
-