Qt 4.8
|
Implements arithmetics, such as multiplication and subtraction. More...
#include <qarithmeticexpression_p.h>
Static Public Functions | |
static AtomicMathematician::Ptr | fetchMathematician (Expression::Ptr &t1, Expression::Ptr &t2, const AtomicMathematician::Operator op, const bool issueError, const ReportContext::Ptr &context, const SourceLocationReflection *const reflection, const ReportContext::ErrorCode code=ReportContext::XPTY0004, const bool isCompat=false) |
static Item | flexiblyCalculate (const Item &op1, const AtomicMathematician::Operator op, const Item &op2, const AtomicMathematician::Ptr &mather, const DynamicContext::Ptr &context, const SourceLocationReflection *const reflection, const ReportContext::ErrorCode code=ReportContext::XPTY0004, const bool isCompat=false) |
Static Public Functions inherited from QPatternist::Expression | |
static void | rewrite (Expression::Ptr &old, const Expression::Ptr &New, const StaticContext::Ptr &context) |
Properties | |
bool | m_isCompat |
AtomicMathematician::Ptr | m_mather |
const AtomicMathematician::Operator | m_op |
Implements arithmetics, such as multiplication and subtraction.
Optimizations: there's some operator/value combos that are no ops. For instance, 0 +
, which is the case of unary plus. We can't compile those away early due to that type checks needs to be done but one can check for them in compress().
Definition at line 78 of file qarithmeticexpression_p.h.
ArithmeticExpression::ArithmeticExpression | ( | const Expression::Ptr & | operand1, |
const AtomicMathematician::Operator | op, | ||
const Expression::Ptr & | operand2 | ||
) |
Definition at line 58 of file qarithmeticexpression.cpp.
|
virtual |
Implements QPatternist::Expression.
Definition at line 358 of file qarithmeticexpression.cpp.
Referenced by fetchMathematician().
|
virtual |
Reimplemented from QPatternist::Expression.
Reimplemented in QPatternist::UnaryExpression.
Definition at line 66 of file qarithmeticexpression.cpp.
|
virtual |
Returns a list of Sequence Types, describing the type of each of the expression's operands. Hence, this function has a relationship to the operands() function:
- The lengths of the lists returned by expectedOperandTypes() and operands() should always be equal in length, since one cannot describe the type of a non-existent operand(and all operands must have type information). - A significant difference between the two functions is that while the type of objects in the list returned by operands() may vary between compilations/static context, simply because the particular Expression is part of different XPath expressions, the types in the list returned by expectedOperandTypes is always the same since the function/operator signature never changes.
This function should not be confused with staticType(), which returns the static type of the expression itself, not its operands. The function call is an expression where this is clear: the type of the return value is not the same as the arguments' types. The static type of the operands supplied to the expression can be determined via the staticType() function of the instances returned by operands().
If the expression has no operands, an empty list should be returned.
Implements QPatternist::Expression.
Definition at line 350 of file qarithmeticexpression.cpp.
|
static |
Definition at line 169 of file qarithmeticexpression.cpp.
Referenced by flexiblyCalculate(), typeCheck(), QPatternist::AddingAggregate::typeCheck(), and QPatternist::AvgFN::typeCheck().
|
static |
Definition at line 112 of file qarithmeticexpression.cpp.
Referenced by evaluateSingleton(), QPatternist::AvgFN::evaluateSingleton(), and QPatternist::SumFN::evaluateSingleton().
|
inline |
Definition at line 122 of file qarithmeticexpression_p.h.
Referenced by QPatternist::UnaryExpression::evaluateSingleton().
|
virtual |
Implements QPatternist::Expression.
Definition at line 233 of file qarithmeticexpression.cpp.
|
virtual |
This implementation guarantees to never rewrite away this Expression, but at most rewrite it as a child of another expression(that presumably have a type checking role). It is therefore always safe to override this function and call this implementation and not worry about that this Expression becomes deleted.
Many Expressions override typeCheck() and performs optimizations, as opposed to doing it in the compress() stage. This is due to that the design of those Expressions often are tied to that certain simplifications are done at the typeCheck() stage of the compilation process or that it in some other way is related to what the typeCheck() do. Also, the earlier the AST can be simplified, the better the chances are for subsequent optimizations.
It is important that the super class's typeCheck() is called before doing any custom type checking, since the call can change the children(notably, the childrens' static types). For example, if the Expression, MyExpression in the example, does not match the required type, typeCheck returns the Expression wrapped in for example ItemVerifier, CardinalityVerifier, or both.
typeCheck() may be called many times. typeCheck() must either raise an error if this Expression is an invalid expression. Thus, it is guaranteed that an Expression is valid after typeCheck() is called.
context | supplies information, such as namespace bindings and available function signatures, that can be needed at compilation time. context is guaranteed by the caller to never null. |
reqType | the static type that this Expression must match when evaluated. reqType is guaranteed by the caller to never null. |
reqType
Reimplemented from QPatternist::Expression.
Definition at line 136 of file qarithmeticexpression.cpp.
|
private |
Definition at line 119 of file qarithmeticexpression_p.h.
Referenced by evaluateSingleton(), staticType(), and typeCheck().
|
private |
Definition at line 118 of file qarithmeticexpression_p.h.
Referenced by evaluateSingleton(), and typeCheck().
|
private |
Definition at line 117 of file qarithmeticexpression_p.h.
Referenced by evaluateSingleton(), staticType(), and typeCheck().