Qt 4.8
Public Types | Public Functions | Properties | List of all members
QPatternist::CallTemplate Class Reference

Implements xsl:call-template. More...

#include <qcalltemplate_p.h>

Inheritance diagram for QPatternist::CallTemplate:
QPatternist::TemplateInvoker QPatternist::CallSite QPatternist::UnlimitedContainer QPatternist::Expression QSharedData QPatternist::CppCastingHelper< Expression > QPatternist::SourceLocationReflection

Public Types

typedef QExplicitlySharedDataPointer< CallTemplatePtr
 
- Public Types inherited from QPatternist::UnlimitedContainer
enum  CardinalityComputation { ProductOfCardinality, UnionOfCardinality }
 
- Public Types inherited from QPatternist::Expression
typedef QExplicitlySharedDataPointer< const ExpressionConstPtr
 A smart pointer wrapping const Expression instances. More...
 
enum  ID {
  IDBooleanValue = 1, IDCountFN, IDEmptyFN, IDExistsFN,
  IDExpressionSequence, IDGeneralComparison, IDIfThenClause, IDIgnorableExpression,
  IDIntegerValue, IDPositionFN, IDStringValue, IDValueComparison,
  IDRangeVariableReference, IDContextItem, IDUserFunctionCallsite, IDExpressionVariableReference,
  IDAttributeConstructor, IDUpperCaseFN, IDLowerCaseFN, IDFirstItemPredicate,
  IDEmptySequence, IDReturnOrderBy, IDLetClause, IDForClause,
  IDPath, IDNamespaceConstructor, IDArgumentReference, IDGenericPredicate,
  IDAxisStep, IDFloat, IDCombineNodes, IDUnresolvedVariableReference,
  IDCardinalityVerifier
}
 
typedef QList< Expression::PtrList
 
typedef QFlags< PropertyProperties
 
enum  Property {
  UseContextItem = 1, DisableElimination = 1 << 1, IsEvaluated = 1 << 2, DisableTypingDeduction = 1 << 3,
  EmptynessFollowsChild = 1 << 4, RewriteToEmptyOnEmpty = 1 << 5, RequiresFocus = 1 << 6, AffectsOrderOnly = 1 << 7,
  RequiresContextItem = (1 << 8) | RequiresFocus, CreatesFocusForLast = 1 << 9, LastOperandIsCollation = 1 << 10, DependsOnLocalVariable = (1 << 11) | DisableElimination,
  EvaluationCacheRedundant = (1 << 12), IsNodeConstructor = 1 << 13, RequiresCurrentItem = 1 << 14
}
 
typedef QExplicitlySharedDataPointer< ExpressionPtr
 A smart pointer wrapping mutable Expression instances. More...
 
typedef ::QAbstractXmlForwardIterator< Expression::PtrQAbstractXmlForwardIterator
 
typedef QVector< Expression::PtrVector
 

Public Functions

virtual ExpressionVisitorResult::Ptr accept (const ExpressionVisitor::Ptr &visitor) const
 
virtual Expression::Ptr body () const
 Returns the body of the function/template/component that is being called. More...
 
virtual CallTargetDescription::Ptr callTargetDescription () const
 
 CallTemplate (const QXmlName &name, const WithParam::Hash &withParams)
 
virtual bool configureRecursion (const CallTargetDescription::Ptr &sign)
 
virtual Properties dependencies () const
 
virtual bool evaluateEBV (const DynamicContext::Ptr &context) const
 
virtual Item::Iterator::Ptr evaluateSequence (const DynamicContext::Ptr &context) const
 
virtual void evaluateToSequenceReceiver (const DynamicContext::Ptr &context) const
 
virtual Properties properties () const
 
void setTemplate (const Template::Ptr &templ)
 
virtual SequenceType::Ptr staticType () const
 
virtual Expression::Ptr typeCheck (const StaticContext::Ptr &context, const SequenceType::Ptr &reqType)
 
- Public Functions inherited from QPatternist::TemplateInvoker
virtual Expression::Ptr compress (const StaticContext::Ptr &context)
 
virtual SequenceType::List expectedOperandTypes () const
 
const WithParam::HashwithParams () const
 
- Public Functions inherited from QPatternist::CallSite
bool isRecursive () const
 
QXmlName name () const
 
void setIsRecursive (const bool value)
 
- Public Functions inherited from QPatternist::UnlimitedContainer
virtual bool compressOperands (const StaticContext::Ptr &)
 
virtual Expression::List operands () const
 
virtual void setOperands (const Expression::List &list)
 
 UnlimitedContainer (const Expression::List &operands=Expression::List())
 
- Public Functions inherited from QPatternist::Expression
virtual const SourceLocationReflectionactualReflection () const
 Returns this. More...
 
virtual void announceFocusType (const ItemType::Ptr &itemType)
 
Properties deepProperties () const
 Computes the union of properties for this Expression and all its descending children. More...
 
virtual QString description () const
 
virtual Item evaluateSingleton (const DynamicContext::Ptr &context) const
 
virtual ItemType::Ptr expectedContextItemType () const
 
 Expression ()
 
bool has (const Property prop) const
 
bool hasDependency (const Property prop) const
 
virtual ID id () const
 
bool is (const ID id) const
 
bool isEvaluated () const
 
virtual ItemType::Ptr newFocusType () const
 
virtual QList< QExplicitlySharedDataPointer< OptimizationPass > > optimizationPasses () const
 
virtual PatternPriority patternPriority () const
 
const Expression::Ptrrewrite (const Expression::Ptr &to, const StaticContext::Ptr &context) const
 Rewrites this Expression to to, and return to. More...
 
virtual ~Expression ()
 
- Public Functions inherited from QSharedData
 QSharedData ()
 Constructs a QSharedData object with a reference count of 0. More...
 
 QSharedData (const QSharedData &)
 Constructs a QSharedData object with reference count 0. More...
 
- Public Functions inherited from QPatternist::CppCastingHelper< Expression >
const TCastTarget * as () const
 
TCastTarget * as ()
 
- Public Functions inherited from QPatternist::SourceLocationReflection
virtual QSourceLocation sourceLocation () const
 
 SourceLocationReflection ()
 
virtual ~SourceLocationReflection ()
 

Properties

Template::Ptr m_template
 

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 QPatternist::TemplateInvoker
WithParam::Hash m_withParams
 
- Public Variables inherited from QSharedData
QAtomicInt ref
 
- Protected Functions inherited from QPatternist::TemplateInvoker
 TemplateInvoker (const WithParam::Hash &withParams, const QXmlName &name=QXmlName())
 
- 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
 

Detailed Description

Implements xsl:call-template.

Since
4.5
Author
Frans Englich frans.nosp@m..eng.nosp@m.lich@.nosp@m.noki.nosp@m.a.com

Definition at line 71 of file qcalltemplate_p.h.

Typedefs

◆ Ptr

Definition at line 74 of file qcalltemplate_p.h.

Constructors and Destructors

◆ CallTemplate()

CallTemplate::CallTemplate ( const QXmlName name,
const WithParam::Hash withParams 
)

Definition at line 50 of file qcalltemplate.cpp.

51  : TemplateInvoker(withParams, name)
52 {
53 }
TemplateInvoker(const WithParam::Hash &withParams, const QXmlName &name=QXmlName())

Functions

◆ accept()

ExpressionVisitorResult::Ptr CallTemplate::accept ( const ExpressionVisitor::Ptr visitor) const
virtual

Implements QPatternist::Expression.

Definition at line 132 of file qcalltemplate.cpp.

133 {
134  return visitor->visit(this);
135 }

◆ body()

Expression::Ptr CallTemplate::body ( ) const
virtual

Returns the body of the function/template/component that is being called.

Implements QPatternist::CallSite.

Definition at line 143 of file qcalltemplate.cpp.

Referenced by setTemplate().

144 {
145  return m_template->body;
146 }
Expression::Ptr body
Definition: qtemplate_p.h:98

◆ callTargetDescription()

CallTargetDescription::Ptr CallTemplate::callTargetDescription ( ) const
virtual

Implements QPatternist::CallSite.

Definition at line 148 of file qcalltemplate.cpp.

Referenced by setTemplate().

149 {
151 }
QExplicitlySharedDataPointer< CallTargetDescription > Ptr

◆ configureRecursion()

bool CallTemplate::configureRecursion ( const CallTargetDescription::Ptr sign)
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.

Returns
true if is recursive, otherwise false

Implements QPatternist::CallSite.

Definition at line 137 of file qcalltemplate.cpp.

Referenced by setTemplate().

138 {
139  Q_UNUSED(sign);
140  return false;
141 }
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ dependencies()

Expression::Properties CallTemplate::dependencies ( ) const
virtual

Recursively computes through all descendants until a Property is encount

Reimplemented from QPatternist::Expression.

Definition at line 119 of file qcalltemplate.cpp.

120 {
121  if(m_template && !isRecursive())
122  return m_template->dependencies();
123  else
124  return Properties();
125 }
Expression::Properties dependencies() const
Definition: qtemplate.cpp:213
bool isRecursive() const
Definition: qcallsite.cpp:58
QFlags< Property > Properties

◆ evaluateEBV()

bool CallTemplate::evaluateEBV ( const DynamicContext::Ptr context) const
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.

See also
XML Path Language (XPath) 2.0, 2.4.3 Effective Boolean Value

Reimplemented from QPatternist::Expression.

Definition at line 61 of file qcalltemplate.cpp.

62 {
64  return m_template->body->evaluateEBV(m_template->createContext(this, context, true));
65 }
virtual bool evaluateEBV(const DynamicContext::Ptr &context) const
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
Expression::Ptr body
Definition: qtemplate_p.h:98
DynamicContext::Ptr createContext(const TemplateInvoker *const invoker, const DynamicContext::Ptr &context, const bool isCallTemplate) const
Definition: qtemplate.cpp:81

◆ evaluateSequence()

Item::Iterator::Ptr CallTemplate::evaluateSequence ( const DynamicContext::Ptr context) const
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().

Note
This function may raise an exception when calling, not only when QAbstractXmlForwardIterator::next() is called on the return value. This is because in some cases evaluateSingleton() is called directly.

Reimplemented from QPatternist::Expression.

Definition at line 55 of file qcalltemplate.cpp.

56 {
58  return m_template->body->evaluateSequence(m_template->createContext(this, context, true));
59 }
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
Expression::Ptr body
Definition: qtemplate_p.h:98
DynamicContext::Ptr createContext(const TemplateInvoker *const invoker, const DynamicContext::Ptr &context, const bool isCallTemplate) const
Definition: qtemplate.cpp:81
virtual Item::Iterator::Ptr evaluateSequence(const DynamicContext::Ptr &context) const

◆ evaluateToSequenceReceiver()

void CallTemplate::evaluateToSequenceReceiver ( const DynamicContext::Ptr context) const
virtual

Evaluates this Expression by sending its output to DynamicContext::outputReceiver().

Reimplemented from QPatternist::Expression.

Definition at line 67 of file qcalltemplate.cpp.

68 {
71 }
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
Expression::Ptr body
Definition: qtemplate_p.h:98
DynamicContext::Ptr createContext(const TemplateInvoker *const invoker, const DynamicContext::Ptr &context, const bool isCallTemplate) const
Definition: qtemplate.cpp:81
virtual void evaluateToSequenceReceiver(const DynamicContext::Ptr &context) const

◆ properties()

Expression::Properties CallTemplate::properties ( ) const
virtual
Returns
a bitwise OR'd value of properties, describing the characteristics of the expression. These properties affects how this Expression is treated in for example type checking stages.

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.

See also
deepProperties()
Returns
Expression::None, meaning no special properties

Reimplemented from QPatternist::Expression.

Definition at line 105 of file qcalltemplate.cpp.

106 {
108 
109  /* We may be called before our m_template is resolved, namely when we're
110  * the body of a variable. In that case querytransformparser.ypp will
111  * manually call TypeChecker::applyFunctionConversion(), which is before
112  * ExpressionFactory::createExpression() has resolved us. */
113  if(m_template && !isRecursive())
114  return m_template->properties();
115  else
116  return Properties();
117 }
Expression::Properties properties() const
Definition: qtemplate.cpp:193
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
Expression::Ptr body
Definition: qtemplate_p.h:98
bool isRecursive() const
Definition: qcallsite.cpp:58
QFlags< Property > Properties

◆ setTemplate()

void QPatternist::CallTemplate::setTemplate ( const Template::Ptr templ)
inline

Definition at line 101 of file qcalltemplate_p.h.

Referenced by QPatternist::ExpressionFactory::createExpression().

102  {
103  m_template = templ;
104  }

◆ staticType()

SequenceType::Ptr CallTemplate::staticType ( ) const
virtual
Returns
the static type of this Expression. For example, an 'and' expression have as static type xs:boolean

Implements QPatternist::Expression.

Definition at line 127 of file qcalltemplate.cpp.

128 {
130 }
static const SequenceType::Ptr ZeroOrMoreItems

◆ typeCheck()

Expression::Ptr CallTemplate::typeCheck ( const StaticContext::Ptr context,
const SequenceType::Ptr reqType 
)
virtual

This is a bit complicated by that we have two required types, one specified by xsl:param in the template declaration, and one on xsl:with-param.

See also
UserFunctionCallsite::expectedOperandTypes()
XSL Transformations (XSLT) Version 2.0, 10.1.1 Passing Parameters to Templates

Reimplemented from QPatternist::Expression.

Definition at line 73 of file qcalltemplate.cpp.

75 {
76  /* Check XTSE0680, that every @c xsl:with-param has a corresponding @c
77  * xsl:param declaration. */
78  {
80 
82  it != end;
83  ++it)
84  {
86  Template::raiseXTSE0680(context, it.value()->name(), this);
87  }
88  }
89 
90  const Expression::Ptr me(TemplateInvoker::typeCheck(context, reqType));
91 
93  const VariableDeclaration::List::const_iterator end(args.constEnd());
95 
96  for(; it != end; ++it)
97  {
98  // TODO
99  Q_ASSERT((*it)->sequenceType);
100  }
101 
102  return me;
103 }
#define it(className, varName)
static void raiseXTSE0680(const ReportContext::Ptr &context, const QXmlName &name, const SourceLocationReflection *const reflection)
Definition: qtemplate.cpp:70
virtual Expression::Ptr typeCheck(const StaticContext::Ptr &context, const SequenceType::Ptr &reqType)
Definition: qexpression.cpp:70
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
static bool contains(const VariableDeclaration::List &list, const QXmlName &lookup)
Returns true if list contains lookup.
VariableDeclaration::List templateParameters
Definition: qtemplate_p.h:107
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the hash.
Definition: qhash.h:466
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the hash...
Definition: qhash.h:469
static const KeyPair *const end
friend class const_iterator
Definition: qhash.h:461

Properties

◆ m_template

Template::Ptr QPatternist::CallTemplate::m_template
private

The documentation for this class was generated from the following files: