Qt 4.8
|
Performs a call to a UserFunction. More...
#include <quserfunctioncallsite_p.h>
Private Functions | |
DynamicContext::Ptr | bindVariables (const DynamicContext::Ptr &context) const |
Properties | |
const FunctionSignature::Arity | m_arity |
Expression::Ptr | m_body |
VariableSlotID | m_expressionSlotOffset |
UserFunction::Ptr | m_functionDeclaration |
Related Functions | |
(Note that these are not member functions.) | |
static QString | formatFunction (const UserFunctionCallsite::Ptr &func) |
Formats UserFunctionCallsite. More... | |
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::CallSite | |
CallSite (const QXmlName &name=QXmlName()) | |
Protected Functions inherited from QPatternist::UnlimitedContainer | |
template<CardinalityComputation suppliedCard> | |
SequenceType::Ptr | operandsUnionType () const |
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::UnlimitedContainer | |
Expression::List | m_operands |
Performs a call to a UserFunction.
UserFunctionCallsite is the call site to a function that has been declared in the query using declare function
. That is, it is never used for builtin functions such as fn:count()
.
Definition at line 78 of file quserfunctioncallsite_p.h.
Definition at line 82 of file quserfunctioncallsite_p.h.
Definition at line 81 of file quserfunctioncallsite_p.h.
UserFunctionCallsite::UserFunctionCallsite | ( | const QXmlName | name, |
const FunctionSignature::Arity | arity | ||
) |
Definition at line 52 of file quserfunctioncallsite.cpp.
|
virtual |
Implements QPatternist::Expression.
Definition at line 182 of file quserfunctioncallsite.cpp.
FunctionSignature::Arity UserFunctionCallsite::arity | ( | ) | const |
Definition at line 235 of file quserfunctioncallsite.cpp.
|
private |
Creates a new context sets the arguments, and returns it.
Definition at line 80 of file quserfunctioncallsite.cpp.
Referenced by body(), evaluateEBV(), evaluateSequence(), evaluateSingleton(), and evaluateToSequenceReceiver().
|
inlinevirtual |
Returns the body of the function/template/component that is being called.
Implements QPatternist::CallSite.
Definition at line 131 of file quserfunctioncallsite_p.h.
|
virtual |
Implements QPatternist::CallSite.
Definition at line 240 of file quserfunctioncallsite.cpp.
Referenced by body().
|
virtual |
We call compress on our body.
Reimplemented from QPatternist::Expression.
Definition at line 152 of file quserfunctioncallsite.cpp.
|
virtual |
Called in the earliest stages of the compilation process. sign
can be any function signature for a user declared function. If sign
matches this UserFunctionCallsite, it means the UserFunction represented by sign
is recursive and that this UserFunctionCallsite should take appropriate measures.
true
if is recursive, otherwise false
Implements QPatternist::CallSite.
Definition at line 201 of file quserfunctioncallsite.cpp.
Referenced by body().
|
virtual |
Determines the Effective Boolean Value of the expression.
The Effective Boolean Value of a value is not necessarily the same as converting the value to a new value of type xs:boolean.
Note that this function cannot return the empty sequence, evaluateSingleton() must be overridden in order to be able to do that.
The default implementation results in a type error. Hence, this function must be overridden if such behavior is not of interest.
Reimplemented from QPatternist::Expression.
Definition at line 70 of file quserfunctioncallsite.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 60 of file quserfunctioncallsite.cpp.
|
virtual |
Reimplemented from QPatternist::Expression.
Definition at line 65 of file quserfunctioncallsite.cpp.
|
virtual |
Evaluates this Expression by sending its output to DynamicContext::outputReceiver().
Reimplemented from QPatternist::Expression.
Definition at line 75 of file quserfunctioncallsite.cpp.
|
virtual |
Returns the types declared in the function declaration.
Implements QPatternist::Expression.
Definition at line 100 of file quserfunctioncallsite.cpp.
|
virtual |
Reimplemented from QPatternist::Expression.
Definition at line 187 of file quserfunctioncallsite.cpp.
bool UserFunctionCallsite::isSignatureValid | ( | const FunctionSignature::Ptr & | sign | ) | const |
true
, if a function definition with signature sign
would be valid to call from this callsite, otherwise false
. Definition at line 192 of file quserfunctioncallsite.cpp.
Referenced by configureRecursion().
|
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 160 of file quserfunctioncallsite.cpp.
void UserFunctionCallsite::setSource | ( | const UserFunction::Ptr & | userFunction, |
const VariableSlotID | cacheSlotOffset | ||
) |
If slotOffset
is -1, it means this function has no arguments.
Definition at line 209 of file quserfunctioncallsite.cpp.
|
virtual |
Implements QPatternist::Expression.
Definition at line 165 of file quserfunctioncallsite.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 119 of file quserfunctioncallsite.cpp.
|
related |
Formats UserFunctionCallsite.
Definition at line 166 of file quserfunctioncallsite_p.h.
|
private |
Definition at line 145 of file quserfunctioncallsite_p.h.
Referenced by arity(), and isSignatureValid().
|
private |
Definition at line 157 of file quserfunctioncallsite_p.h.
Referenced by body(), compress(), evaluateEBV(), evaluateSequence(), evaluateSingleton(), evaluateToSequenceReceiver(), setSource(), staticType(), and typeCheck().
|
private |
The reason this variable, as well as others, aren't const, is that the binding to the actual function, is resolved after this UserFunctionCallsite has been created.
Definition at line 151 of file quserfunctioncallsite_p.h.
Referenced by bindVariables(), and setSource().
|
private |
Definition at line 158 of file quserfunctioncallsite_p.h.
Referenced by callTargetDescription(), expectedOperandTypes(), setSource(), and typeCheck().