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

Creates a particular Expression instance identified by an Expression::ID. More...

#include <qoptimizerblocks_p.h>

Inheritance diagram for QPatternist::ByIDCreator:
QPatternist::ExpressionCreator QSharedData

Public Functions

 ByIDCreator (const Expression::ID id)
 
virtual Expression::Ptr create (const Expression::List &operands, const StaticContext::Ptr &context, const SourceLocationReflection *const r) const
 
- Public Functions inherited from QPatternist::ExpressionCreator
 ExpressionCreator ()
 
virtual ~ExpressionCreator ()
 
- 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...
 

Static Public Functions

static Expression::Ptr create (const Expression::ID id, const Expression::List &operands, const StaticContext::Ptr &context, const SourceLocationReflection *const r)
 

Properties

const Expression::ID m_id
 

Additional Inherited Members

- Public Types inherited from QPatternist::ExpressionCreator
typedef QExplicitlySharedDataPointer< ExpressionCreatorPtr
 
- Public Variables inherited from QSharedData
QAtomicInt ref
 

Detailed Description

Creates a particular Expression instance identified by an Expression::ID.

For example, if ByIDCreator() is passed Expression::IDCountFN, create() will return CountFN instances.

Author
Frans englich frans.nosp@m..eng.nosp@m.lich@.nosp@m.noki.nosp@m.a.com

Definition at line 197 of file qoptimizerblocks_p.h.

Constructors and Destructors

◆ ByIDCreator()

ByIDCreator::ByIDCreator ( const Expression::ID  id)

Creates a ByIDCreator that creates expressions of the type that id identifies.

Definition at line 128 of file qoptimizerblocks.cpp.

128  : m_id(id)
129 {
131 }
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
const Expression::ID m_id

Functions

◆ create() [1/2]

Expression::Ptr ByIDCreator::create ( const Expression::List operands,
const StaticContext::Ptr context,
const SourceLocationReflection *const  const 
) const
virtual

Creates an expression that has operands as operands.

The Expression that is returned is guaranteed, by the caller, to get a treatment identical to if the expression was created in an ordinary compilation(via the parser, and so forth). That is, Expression::typeCheck() and Expression::compress() stages will be carried out on the returned expression.

Returns
an Expression::Ptr that never is non null, valid pointer

Implements QPatternist::ExpressionCreator.

Definition at line 133 of file qoptimizerblocks.cpp.

Referenced by QPatternist::CountFN::typeCheck().

136 {
137  return create(m_id, operands, context, r);
138 }
virtual Expression::Ptr create(const Expression::List &operands, const StaticContext::Ptr &context, const SourceLocationReflection *const r) const
const Expression::ID m_id

◆ create() [2/2]

Expression::Ptr ByIDCreator::create ( const Expression::ID  id,
const Expression::List operands,
const StaticContext::Ptr context,
const SourceLocationReflection *const  r 
)
static

Creates an expression by id id with the arguments operands.

Definition at line 140 of file qoptimizerblocks.cpp.

144 {
145  Q_ASSERT(context);
146 
148 
149  switch(id)
150  {
152  {
154  break;
155  }
157  {
158  fnName = StandardLocalNames::empty;
159  break;
160  }
161  default:
162  {
163  Q_ASSERT_X(false, Q_FUNC_INFO,
164  "Cannot create an expression of requested type; m_id is wrong.");
165  return Expression::Ptr();
166  }
167  }
168 
169  /* The reason we don't simply do 'new ExistsFN()' ourselves, is that all FunctionCall
170  * instances needs their FunctionSignature in order to function, and the FunctionFactories
171  * sets that. */
172  const QXmlName qName(StandardNamespaces::fn, fnName);
173 
174  const Expression::Ptr result(context->functionSignatures()->createFunctionCall(qName, operands, context, r));
175  context->wrapExpressionWith(r, result);
176  return result;
177 }
NamespaceCode LocalNameCode
Definition: qxmlname.h:84
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
virtual QExplicitlySharedDataPointer< FunctionFactory > functionSignatures() const =0
QExplicitlySharedDataPointer< Expression > Ptr
A smart pointer wrapping mutable Expression instances.
#define Q_ASSERT_X(cond, where, what)
Definition: qglobal.h:1837
The QXmlName class represents the name of an XML node, in an efficient, namespace-aware way...
Definition: qxmlname.h:58
void wrapExpressionWith(const SourceLocationReflection *const existingNode, const QExplicitlySharedDataPointer< Expression > &newNode)
Ensures source locations are handled in such a manner that existingNode wraps newNode.
virtual Expression::Ptr createFunctionCall(const QXmlName name, const Expression::List &arguments, const StaticContext::Ptr &context, const SourceLocationReflection *const r)=0
#define Q_FUNC_INFO
Definition: qglobal.h:1871

Properties

◆ m_id

const Expression::ID QPatternist::ByIDCreator::m_id
private

Definition at line 218 of file qoptimizerblocks_p.h.

Referenced by create().


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