Qt 4.8
|
Implements the path expression, containing two steps, such as in html/body
.
More...
#include <qpath_p.h>
Private Types | |
typedef QExplicitlySharedDataPointer< const Path > | ConstPtr |
Properties | |
bool | m_checkXPTY0018 |
bool | m_hasCreatedSorter |
bool | m_isLast |
const Kind | m_kind |
Additional Inherited Members | |
Static Public Functions inherited from QPatternist::Expression | |
static void | rewrite (Expression::Ptr &old, const Expression::Ptr &New, const StaticContext::Ptr &context) |
Public Variables inherited from QSharedData | |
QAtomicInt | ref |
Protected Functions inherited from QPatternist::PairContainer | |
PairContainer (const Expression::Ptr &operand1, const Expression::Ptr &operand2) | |
Protected Functions inherited from QPatternist::Expression | |
void | typeCheckOperands (const StaticContext::Ptr &context) |
Protected Functions inherited from QPatternist::CppCastingHelper< Expression > | |
CppCastingHelper () | |
Protected Variables inherited from QPatternist::PairContainer | |
Expression::Ptr | m_operand1 |
Expression::Ptr | m_operand2 |
Implements the path expression, containing two steps, such as in html/body
.
|
private |
Enumerator | |
---|---|
RegularPath | This Path is a plain old path expression as found in XPath. Sorting is performed, and atomics are disallowed as left operand. |
XSLTForEach | This Path emulates an |
ForApplyTemplate | This Path performs the iteration in an |
Path::Path | ( | const Expression::Ptr & | operand1, |
const Expression::Ptr & | operand2, | ||
const Kind | kind = RegularPath |
||
) |
Definition at line 56 of file qpath.cpp.
|
virtual |
Implements QPatternist::Expression.
|
virtual |
compress() is the last stage performs in compiling an expression, done after the initial AST build and calling typeCheck(). compress() performs crucial simplifications, either by having drastic performance implications or that some expressions depend on it for proper behavior.
The default implementation performs a sparse conditional constant propagation. In short, a recursive process is performed in the AST which examines if the Expression's operands are constant values, and if so, performs a const fold(AST rewrite) into the result of evaluating the expression in question. This default behavior can be disabled by letting properties() return DisableElimination.
This compress() stage can be relative effective due to the design of XPath, in part because intrinsic functions are heavily used. Many Expressions override compress() and do optimizations specific to what they do. Also, many Expressions performs optimizations in their typeCheck().
context | the static context. Supplies compile time information, and is the channel for communicating error messages. |
Reimplemented from QPatternist::Expression.
Definition at line 162 of file qpath.cpp.
|
virtual |
Evaluate this Expression by iterating over it. This is a central function for evaluating expressions.
Expressions must always always return a valid QAbstractXmlForwardIterator and may never return 0. If an empty result is of interest to be returned, the EmptyIterator should be returned.
The default implementation returns a SingletonIterator over the item returned from evaluateSingleton().
Reimplemented from QPatternist::Expression.
Definition at line 77 of file qpath.cpp.
|
virtual |
Reimplemented from QPatternist::Expression.
Definition at line 126 of file qpath.cpp.
|
virtual |
Evaluates this Expression by sending its output to DynamicContext::outputReceiver().
Reimplemented from QPatternist::Expression.
Definition at line 150 of file qpath.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 223 of file qpath.cpp.
|
virtual |
This property, which has no setter, returns an enum value that uniquely identifies this Expression. Patternist makes no use of C++'s dynamic_cast feature, but uses this polymorphic function instead.
Reimplemented from QPatternist::Expression.
|
inline |
|
inline |
Definition at line 66 of file qpath.cpp.
|
virtual |
Reimplemented from QPatternist::Expression.
Definition at line 261 of file qpath.cpp.
Referenced by typeCheck().
|
virtual |
The default implementation returns 0. Override and let the function return a different value, if that's of interest.
An important decision when re-implementing properties() is whether to OR in the properties() of ones operands. For instance, if an operand has RequiresFocus set, that flag nost likely applies to the apparent as well, since it depends on its operand.
Reimplemented from QPatternist::Expression.
Definition at line 256 of file qpath.cpp.
|
inline |
|
virtual |
Implements QPatternist::Expression.
Definition at line 241 of file qpath.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 179 of file qpath.cpp.
|
private |
Definition at line 162 of file qpath_p.h.
Referenced by compress(), and evaluateSequence().
|
private |
One might think this block exists for preventing multiple NodeSortExpressions to be created. However, that is not an issue, since NodeSortExpression optimizes this away anyway.
The real reason is to avoid infinite recursion. When our typeCheck() forwards on the type check to the just created NodeSortExpression, it in turn calls typeCheck() on its child, which is this Path. Rince and repeat.
We only create node sorts when we're a regular path expression, and not when standing in as a generic map expression.
Definition at line 154 of file qpath_p.h.
Referenced by typeCheck().
|
private |
Whether this path is the step. For instance, in a/b/c
, the last path has c
as the right operand.
Definition at line 160 of file qpath_p.h.
Referenced by compress(), and setLast().
|
private |
Definition at line 163 of file qpath_p.h.
Referenced by compress(), expectedOperandTypes(), kind(), and typeCheck().