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

Implements the context item, the dot: .. More...

#include <qcontextitem_p.h>

Inheritance diagram for QPatternist::ContextItem:
QPatternist::EmptyContainer QPatternist::Expression QSharedData QPatternist::CppCastingHelper< Expression > QPatternist::SourceLocationReflection

Public Functions

virtual ExpressionVisitorResult::Ptr accept (const ExpressionVisitor::Ptr &visitor) const
 
virtual const SourceLocationReflectionactualReflection () const
 Returns this. More...
 
virtual void announceFocusType (const ItemType::Ptr &type)
 
virtual Expression::Ptr compress (const StaticContext::Ptr &context)
 
 ContextItem (const Expression::Ptr &expr=Expression::Ptr())
 
virtual Item evaluateSingleton (const DynamicContext::Ptr &context) const
 
virtual ItemType::Ptr expectedContextItemType () const
 
virtual ID id () const
 
virtual Expression::Properties properties () const
 
virtual SequenceType::Ptr staticType () const
 
virtual Expression::Ptr typeCheck (const StaticContext::Ptr &context, const SequenceType::Ptr &reqType)
 
- Public Functions inherited from QPatternist::EmptyContainer
virtual Expression::List operands () const
 
virtual void setOperands (const Expression::List &)
 
- Public Functions inherited from QPatternist::Expression
Properties deepProperties () const
 Computes the union of properties for this Expression and all its descending children. More...
 
virtual Properties dependencies () const
 
virtual QString description () 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
 
 Expression ()
 
bool has (const Property prop) const
 
bool hasDependency (const Property prop) 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

const Expression::Ptr m_expr
 
ItemType::Ptr m_itemType
 

Additional Inherited Members

- 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
 
- 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::EmptyContainer
virtual bool compressOperands (const StaticContext::Ptr &context)
 
virtual SequenceType::List expectedOperandTypes () const
 
- Protected Functions inherited from QPatternist::Expression
void typeCheckOperands (const StaticContext::Ptr &context)
 
- Protected Functions inherited from QPatternist::CppCastingHelper< Expression >
 CppCastingHelper ()
 

Detailed Description

Implements the context item, the dot: ..

See also
XML Path Language (XPath) 2.0, 3.1.4 Context Item Expression
Author
Frans Englich frans.nosp@m..eng.nosp@m.lich@.nosp@m.noki.nosp@m.a.com

Definition at line 71 of file qcontextitem_p.h.

Constructors and Destructors

◆ ContextItem()

QPatternist::ContextItem::ContextItem ( const Expression::Ptr expr = Expression::Ptr())
inline

expr is possibly used for error reporting. If this context item has been created implicitly, such as for the expression fn:string(), expr should be passed a valid pointer to the Expression that this context item is generated for.

Definition at line 80 of file qcontextitem_p.h.

80  : m_expr(expr)
81  {
82  }
const Expression::Ptr m_expr

Functions

◆ accept()

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

Implements QPatternist::Expression.

Definition at line 85 of file qcontextitem.cpp.

Referenced by ContextItem().

86 {
87  return visitor->visit(this);
88 }

◆ actualReflection()

const SourceLocationReflection * ContextItem::actualReflection ( ) const
virtual

Returns this.

Reimplemented from QPatternist::Expression.

Definition at line 100 of file qcontextitem.cpp.

Referenced by ContextItem().

101 {
102  if(m_expr)
103  return m_expr.data();
104  else
105  return this;
106 }
const Expression::Ptr m_expr
T * data() const
Returns a pointer to the shared data object.
Definition: qshareddata.h:145

◆ announceFocusType()

void ContextItem::announceFocusType ( const ItemType::Ptr itemType)
virtual

When this function is called, it signals that the parent will create a focus of type itemType.

This type can also be retrieved through StaticContext::contextItemType() when inside typeCheck(), but in some cases this is too late. For instance, a parent needs to have the static type of its child properly reported before it calls its typeCheck()(and the child's type is inferred from the focus).

The default implementation delegates the call on to the children.

This function may be called at arbitrary times, in arbitrary amounts.

If the AST node overriding this call has children, it should be considered whether the default implementation should be called, such that they type is announced to them too.

The caller guarantees that itemType is not null.

Reimplemented from QPatternist::Expression.

Definition at line 108 of file qcontextitem.cpp.

Referenced by ContextItem().

109 {
110  Q_ASSERT(type);
111  m_itemType = type;
112 }
int type
Definition: qmetatype.cpp:239
#define Q_ASSERT(cond)
Definition: qglobal.h:1823

◆ compress()

Expression::Ptr ContextItem::compress ( const StaticContext::Ptr context)
virtual

Overridden to store a pointer to StaticContext::contextItemType().

Reimplemented from QPatternist::Expression.

Definition at line 57 of file qcontextitem.cpp.

Referenced by ContextItem().

58 {
59  m_itemType = context->contextItemType();
60  return EmptyContainer::compress(context);
61 }
virtual Expression::Ptr compress(const StaticContext::Ptr &context)
virtual ItemType::Ptr contextItemType() const =0
The static type of the context item.

◆ evaluateSingleton()

Item ContextItem::evaluateSingleton ( const DynamicContext::Ptr context) const
virtual

Reimplemented from QPatternist::Expression.

Definition at line 52 of file qcontextitem.cpp.

Referenced by ContextItem().

53 {
54  return context->contextItem();
55 }
virtual Item contextItem() const =0

◆ expectedContextItemType()

ItemType::Ptr ContextItem::expectedContextItemType ( ) const
virtual
Returns
always BuiltinTypes::item;

Reimplemented from QPatternist::Expression.

Definition at line 95 of file qcontextitem.cpp.

Referenced by ContextItem().

96 {
97  return BuiltinTypes::item;
98 }
static const ItemType::Ptr item

◆ id()

Expression::ID ContextItem::id ( ) const
virtual
Returns
always IDContextItem

Reimplemented from QPatternist::Expression.

Definition at line 90 of file qcontextitem.cpp.

Referenced by ContextItem().

◆ properties()

Expression::Properties ContextItem::properties ( ) const
virtual

◆ staticType()

SequenceType::Ptr ContextItem::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 70 of file qcontextitem.cpp.

Referenced by ContextItem().

71 {
72  /* We test m_itemType here because Patternist View calls staticType() before the typeCheck()
73  * stage. */
74  if(m_itemType)
75  return makeGenericSequenceType(m_itemType, Cardinality::exactlyOne());
76  else
78 }
static const SequenceType::Ptr ExactlyOneItem
static Cardinality exactlyOne()

◆ typeCheck()

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

Overridden to store a pointer to StaticContext::contextItemType().

Reimplemented from QPatternist::Expression.

Definition at line 63 of file qcontextitem.cpp.

Referenced by ContextItem().

65 {
66  m_itemType = context->contextItemType();
67  return EmptyContainer::typeCheck(context, reqType);
68 }
virtual Expression::Ptr typeCheck(const StaticContext::Ptr &context, const SequenceType::Ptr &reqType)
Definition: qexpression.cpp:70
virtual ItemType::Ptr contextItemType() const =0
The static type of the context item.

Properties

◆ m_expr

const Expression::Ptr QPatternist::ContextItem::m_expr
private

Definition at line 120 of file qcontextitem_p.h.

Referenced by actualReflection().

◆ m_itemType

ItemType::Ptr QPatternist::ContextItem::m_itemType
private

Definition at line 119 of file qcontextitem_p.h.

Referenced by announceFocusType(), compress(), staticType(), and typeCheck().


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