SourceForge.net Logo
StaticAnalysis.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2001, 2008,
3  * DecisionSoft Limited. All rights reserved.
4  * Copyright (c) 2004, 2015 Oracle and/or its affiliates. All rights reserved.
5  *
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 
20 #ifndef _STATICANALYSIS_HPP
21 #define _STATICANALYSIS_HPP
22 
23 #include <string>
24 
25 #include <xqilla/framework/XQillaExport.hpp>
27 
28 #include <vector>
29 
31 
35 class XQILLA_API StaticAnalysis
36 {
37 public:
38  static const int HASH_SIZE = 13;
39 
40  class XQILLA_API VarEntry
41  {
42  public:
43  VarEntry() : uri(0), name(0), hash(0), prev(0) {}
44  void set(const XMLCh *u, const XMLCh *n);
45  void set(const XMLCh *u, const XMLCh *n, size_t h);
46 
47  const XMLCh *uri, *name;
48  size_t hash;
50  };
51 
54 
55  void copy(const StaticAnalysis &o);
56  void release();
57 
59  void clear();
61 
64  void forceNoFolding(bool value);
65  bool isNoFoldingForced() const;
66 
67  void contextItemUsed(bool value);
68  void contextPositionUsed(bool value);
69  void contextSizeUsed(bool value);
70  bool isContextItemUsed() const;
71  bool isContextPositionUsed() const;
72  bool isContextSizeUsed() const;
74  bool areContextFlagsUsed() const;
75 
76  void currentTimeUsed(bool value);
77  void implicitTimezoneUsed(bool value);
78 
79  void availableDocumentsUsed(bool value);
80  void availableCollectionsUsed(bool value);
82 
83  void variableUsed(const XMLCh *namespaceURI, const XMLCh *name);
84  bool removeVariable(const XMLCh *namespaceURI, const XMLCh *name);
85  bool isVariableUsed(const XMLCh *namespaceURI, const XMLCh *name) const;
86  bool isVariableUsed() const;
88 
90  void add(const StaticAnalysis &o);
92  void addExceptVariable(const XMLCh *namespaceURI, const XMLCh *name, const StaticAnalysis &o);
93 
95  bool isUsed() const;
97 
98  void creative(bool value);
99  bool isCreative() const;
100 
101  void updating(bool value);
102  bool isUpdating() const;
103  void possiblyUpdating(bool value);
104  bool isPossiblyUpdating() const;
105 
110  enum Properties {
111  DOCORDER = 0x001,
112  PEER = 0x002,
113  SUBTREE = 0x004,
114  GROUPED = 0x008,
115  SAMEDOC = 0x010,
116  ONENODE = 0x020,
117  SELF = 0x040,
118  UNDEFINEDVAR = 0x080
119  };
120 
121  unsigned int getProperties() const;
122  void setProperties(unsigned int props);
123 
124  const StaticType &getStaticType() const;
126 
127  std::string toString() const;
128 
129 private:
130  StaticAnalysis(const StaticAnalysis &o);
131  StaticAnalysis &operator=(const StaticAnalysis &o);
132 
133  bool _contextItem;
134  bool _contextPosition;
135  bool _contextSize;
136  bool _currentTime;
137  bool _implicitTimezone;
138  bool _availableDocuments;
139  bool _availableCollections;
140  bool _forceNoFolding;
141  bool _creative;
142  bool _updating;
143  bool _possiblyUpdating;
144 
145  unsigned int _properties;
146  StaticType _staticType;
147 
148  VarEntry *_dynamicVariables[HASH_SIZE];
149  VarEntry *_recycle;
150  XPath2MemoryManager *_memMgr;
151 };
152 
153 #endif
StaticAnalysis::setProperties
void setProperties(unsigned int props)
StaticAnalysis::isNoFoldingForced
bool isNoFoldingForced() const
StaticAnalysis::availableCollectionsUsed
void availableCollectionsUsed(bool value)
StaticAnalysis::VarEntry::VarEntry
VarEntry()
Definition: StaticAnalysis.hpp:43
StaticAnalysis::isUpdating
bool isUpdating() const
StaticAnalysis::isContextPositionUsed
bool isContextPositionUsed() const
StaticAnalysis::currentTimeUsed
void currentTimeUsed(bool value)
StaticAnalysis::StaticAnalysis
StaticAnalysis(const StaticAnalysis &o, XPath2MemoryManager *memMgr)
StaticAnalysis::clearExceptType
void clearExceptType()
StaticAnalysis::isVariableUsed
bool isVariableUsed() const
StaticAnalysis::isContextSizeUsed
bool isContextSizeUsed() const
StaticAnalysis::VarEntry::set
void set(const XMLCh *u, const XMLCh *n, size_t h)
StaticAnalysis::VarEntry::hash
size_t hash
Definition: StaticAnalysis.hpp:48
StaticAnalysis::forceNoFolding
void forceNoFolding(bool value)
Overrides all the other flags, and never allows this sub-expression to be constant folded.
StaticAnalysis::VarEntry::set
void set(const XMLCh *u, const XMLCh *n)
StaticAnalysis::isCreative
bool isCreative() const
StaticAnalysis::creative
void creative(bool value)
StaticAnalysis::updating
void updating(bool value)
StaticAnalysis::areDocsOrCollectionsUsed
bool areDocsOrCollectionsUsed() const
StaticAnalysis::VarEntry::uri
const XMLCh * uri
Definition: StaticAnalysis.hpp:47
StaticAnalysis::Properties
Properties
Properties that allow optimisation regarding sorting or not.
Definition: StaticAnalysis.hpp:110
StaticAnalysis::getStaticType
StaticType & getStaticType()
StaticAnalysis::implicitTimezoneUsed
void implicitTimezoneUsed(bool value)
StaticAnalysis::variableUsed
void variableUsed(const XMLCh *namespaceURI, const XMLCh *name)
XPath2MemoryManager
Definition: XPath2MemoryManager.hpp:46
StaticAnalysis::removeVariable
bool removeVariable(const XMLCh *namespaceURI, const XMLCh *name)
StaticAnalysis::variablesUsed
VarEntry ** variablesUsed() const
StaticAnalysis::VarEntry
Definition: StaticAnalysis.hpp:41
StaticAnalysis::getProperties
unsigned int getProperties() const
StaticAnalysis::possiblyUpdating
void possiblyUpdating(bool value)
StaticAnalysis::VarEntry::prev
VarEntry * prev
Definition: StaticAnalysis.hpp:49
StaticAnalysis::StaticAnalysis
StaticAnalysis(XPath2MemoryManager *memMgr)
StaticType.hpp
StaticType
Class that represents the static type of an expression.
Definition: StaticType.hpp:33
StaticAnalysis::isUsed
bool isUsed() const
Returns true if flags are set, or variables have been used.
StaticAnalysis::clear
void clear()
Clears all the information in this StaticAnalysis.
StaticAnalysis::contextItemUsed
void contextItemUsed(bool value)
StaticAnalysis::toString
std::string toString() const
StaticAnalysis::isPossiblyUpdating
bool isPossiblyUpdating() const
StaticAnalysis::contextPositionUsed
void contextPositionUsed(bool value)
StaticAnalysis::addExceptContextFlags
void addExceptContextFlags(const StaticAnalysis &o)
StaticAnalysis::addExceptVariable
void addExceptVariable(const XMLCh *namespaceURI, const XMLCh *name, const StaticAnalysis &o)
StaticAnalysis::getStaticType
const StaticType & getStaticType() const
StaticAnalysis::release
void release()
StaticAnalysis::isContextItemUsed
bool isContextItemUsed() const
StaticAnalysis::contextSizeUsed
void contextSizeUsed(bool value)
StaticAnalysis::copy
void copy(const StaticAnalysis &o)
StaticAnalysis::isUsedExceptContextFlags
bool isUsedExceptContextFlags() const
StaticAnalysis::availableDocumentsUsed
void availableDocumentsUsed(bool value)
StaticAnalysis::isVariableUsed
bool isVariableUsed(const XMLCh *namespaceURI, const XMLCh *name) const
StaticAnalysis::areContextFlagsUsed
bool areContextFlagsUsed() const
Returns true if any of the context item flags have been used.
StaticAnalysis::add
void add(const StaticAnalysis &o)
Sets the members of this StaticAnalysis from the given StaticAnalysis.
StaticAnalysis
Records access to various parts of the context during static resolution.
Definition: StaticAnalysis.hpp:36