Qt 4.8
Static Public Functions | Private Functions | List of all members
QPatternist::OptimizationPasses::Coordinator Class Reference

#include <qoptimizationpasses_p.h>

Static Public Functions

static void init ()
 

Private Functions

 Coordinator ()
 

Detailed Description

Initializes the data members in the OptimizationPasses namespace.

This class is not supposed to be instantiated, but to be used via its init() function. In fact, this class cannot be instantiated.

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

Definition at line 124 of file qoptimizationpasses_p.h.

Constructors and Destructors

◆ Coordinator()

QPatternist::OptimizationPasses::Coordinator::Coordinator ( )
inlineprivate

Functions

◆ init()

void OptimizationPasses::Coordinator::init ( )
static

Initializes the members in the OptimizationPasses namespace.

Definition at line 56 of file qoptimizationpasses.cpp.

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

57 {
58  static bool isInitialized = false; // STATIC DATA
59 
60  if(isInitialized)
61  return;
62 
63  isInitialized = true;
64 
65  /* Note, below is many of the building blocks re-used in several passes
66  * in order to reduce memory use. Thus, when changing one building block
67  * it potentially affects many passes. */
68 
69  /* ****************************************************** */
70  /* Rewrite "count(<expr>) ge 1" into "exists(<expr>)" */
71  OptimizationPass::ExpressionMarker firstFirstChild;
72  firstFirstChild.append(0);
73  firstFirstChild.append(0);
74 
77  geOpIDs.append(countFN);
79 
80  QVector<Expression::ID> geMatcher;
83 
84  const ExpressionIdentifier::Ptr ge(new ComparisonIdentifier(geMatcher,
86 
88  const OptimizationPass::Ptr geToExists(new OptimizationPass(ge, geOpIDs, firstFirstChild, existsFN));
89  comparisonPasses.append(geToExists);
90  /* ****************************************************** */
91 
92  /* ****************************************************** */
93  /* Rewrite "count(<expr>) gt 0" into "exists(<expr>)" */
94  ExpressionIdentifier::List countAndIntZero;
95  countAndIntZero.append(countFN);
96  const ExpressionIdentifier::Ptr zeroInteger(new IntegerIdentifier(0));
97  countAndIntZero.append(zeroInteger);
98 
99  const ExpressionIdentifier::Ptr gt(new ComparisonIdentifier(geMatcher,
101 
102  const OptimizationPass::Ptr gtToExists(new OptimizationPass(gt, countAndIntZero,
103  firstFirstChild, existsFN));
104  comparisonPasses.append(gtToExists);
105  /* ****************************************************** */
106 
107  /* ****************************************************** */
108  /* Rewrite "count(<expr>) ne 0" into "exists(<expr>)" */
109 
110  const ExpressionIdentifier::Ptr ne(new ComparisonIdentifier(geMatcher,
112  const OptimizationPass::Ptr neToExists(new OptimizationPass(ne, countAndIntZero, firstFirstChild,
113  existsFN,
115  comparisonPasses.append(neToExists);
116  /* ****************************************************** */
117 
118  /* ****************************************************** */
119  /* Rewrite "count(<expr>) eq 0" into "empty(<expr>)" */
121  eqOpIDs.append(countFN);
122  eqOpIDs.append(zeroInteger);
124  const ExpressionIdentifier::Ptr eq(new ComparisonIdentifier(geMatcher,
126  const OptimizationPass::Ptr eqToEmpty(new OptimizationPass(eq, eqOpIDs, firstFirstChild,
127  emptyFN,
129  comparisonPasses.append(eqToEmpty);
130 
131  /* ****************************************************** */
132 
133  /* ****************************************************** */
134  /* Rewrite "for $var in <expr> return $var" into "<expr>" */
137  firstChild.append(0);
138 
141  const OptimizationPass::Ptr simplifyFor(new OptimizationPass(ExpressionIdentifier::Ptr(), forOps,
142  firstChild, ExpressionCreator::Ptr()));
143  forPasses.append(simplifyFor);
144  /* ****************************************************** */
145 
146  /* ****************************************************** */
147  /* Rewrite "if(<expr>) then true() else false()" to "<expr>" */
149  marker.append(0);
150 
156 
157  const OptimizationPass::Ptr pass(new OptimizationPass(ExpressionIdentifier::Ptr(), opIDs, marker));
158  ifThenPasses.append(pass);
159  /* ****************************************************** */
160 
161  /* ****************************************************** */
162  /* Rewrite "not(exists(X))" into "empty(X)" */
163  ExpressionIdentifier::List idExistsFN;
165 
167  idExistsFN,
168  firstFirstChild,
169  emptyFN)));
170 
171  /* Rewrite "not(empty(X))" into "exists(X)" */
172  ExpressionIdentifier::List idEmptyFN;
174 
176  idEmptyFN,
177  firstFirstChild,
178  existsFN)));
179  /* ****************************************************** */
180 }
Describes how a particular optimization pass should be carried out.
Creates a particular Expression instance identified by an Expression::ID.
The QExplicitlySharedDataPointer class represents a pointer to an explicitly shared object...
Definition: qshareddata.h:136
Matches numeric literals that are of type xs:integer and has a specific value.
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
OptimizationPass::List comparisonPasses
void append(const T &t)
Inserts value at the end of the vector.
Definition: qvector.h:573
Identifies Expression instances based on their static type.
Matches boolean literals.
static const SequenceType::Ptr ExactlyOneBoolean
Determines whether an Expression is a value or general comparison or both, with a certain operator...
Identifies Expression instances by their Expression::id().
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

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