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
Definition: StaticAnalysis.hpp:41
void set(const XMLCh *u, const XMLCh *n)
VarEntry()
Definition: StaticAnalysis.hpp:43
void set(const XMLCh *u, const XMLCh *n, size_t h)
const XMLCh * name
Definition: StaticAnalysis.hpp:47
VarEntry * prev
Definition: StaticAnalysis.hpp:49
size_t hash
Definition: StaticAnalysis.hpp:48
Records access to various parts of the context during static resolution.
Definition: StaticAnalysis.hpp:36
std::string toString() const
void currentTimeUsed(bool value)
void updating(bool value)
bool isContextSizeUsed() const
void implicitTimezoneUsed(bool value)
StaticType & getStaticType()
bool isVariableUsed() const
VarEntry ** variablesUsed() const
void addExceptContextFlags(const StaticAnalysis &o)
bool removeVariable(const XMLCh *namespaceURI, const XMLCh *name)
bool isCreative() const
void contextPositionUsed(bool value)
void contextItemUsed(bool value)
void variableUsed(const XMLCh *namespaceURI, const XMLCh *name)
StaticAnalysis(XPath2MemoryManager *memMgr)
void clear()
Clears all the information in this StaticAnalysis.
bool isUsedExceptContextFlags() const
StaticAnalysis(const StaticAnalysis &o, XPath2MemoryManager *memMgr)
void possiblyUpdating(bool value)
bool areContextFlagsUsed() const
Returns true if any of the context item flags have been used.
void availableCollectionsUsed(bool value)
bool isUpdating() const
bool isVariableUsed(const XMLCh *namespaceURI, const XMLCh *name) const
unsigned int getProperties() const
const StaticType & getStaticType() const
bool isContextPositionUsed() const
bool isUsed() const
Returns true if flags are set, or variables have been used.
void creative(bool value)
bool isNoFoldingForced() const
void setProperties(unsigned int props)
void clearExceptType()
Properties
Properties that allow optimisation regarding sorting or not.
Definition: StaticAnalysis.hpp:110
void availableDocumentsUsed(bool value)
void add(const StaticAnalysis &o)
Sets the members of this StaticAnalysis from the given StaticAnalysis.
bool isPossiblyUpdating() const
void addExceptVariable(const XMLCh *namespaceURI, const XMLCh *name, const StaticAnalysis &o)
void copy(const StaticAnalysis &o)
bool isContextItemUsed() const
void forceNoFolding(bool value)
Overrides all the other flags, and never allows this sub-expression to be constant folded.
bool areDocsOrCollectionsUsed() const
void contextSizeUsed(bool value)
Class that represents the static type of an expression.
Definition: StaticType.hpp:33
Definition: XPath2MemoryManager.hpp:46