aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/compiler
diff options
context:
space:
mode:
authorErik Verbruggen <erik.verbruggen@digia.com>2015-06-05 12:54:36 +0200
committerJani Heikkinen <jani.heikkinen@theqtcompany.com>2015-06-08 08:22:02 +0000
commitd6723686961bebe97eac002bdb3e276a75256121 (patch)
tree261fb563aacf49224a7c786524efab69996931cd /src/qml/compiler
parent515cef3937c4e3b6f3b7908ff79bfef3c935a360 (diff)
Add a version of BitVector that uses QBitArray.
Some C++ STL libraries are unable to ship a bug-free std::vector<bool>, and/or a bug-free specialization of std::find for std::vector<bool>. So, for those platforms there now is a slow version of BitVector, which relies on QBitArray, which we can fix if we find bugs. Change-Id: I5ddfb18cabe82049a7ede6083fe6ba142bca068b Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
Diffstat (limited to 'src/qml/compiler')
-rw-r--r--src/qml/compiler/qv4ssa.cpp54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/qml/compiler/qv4ssa.cpp b/src/qml/compiler/qv4ssa.cpp
index 5829e1c813..e61a602e64 100644
--- a/src/qml/compiler/qv4ssa.cpp
+++ b/src/qml/compiler/qv4ssa.cpp
@@ -81,6 +81,8 @@ static void showMeTheCode(IR::Function *function, const char *marker)
}
}
+#if !defined(BROKEN_STD_VECTOR_BOOL_OR_BROKEN_STD_FIND)
+// Sanity:
class BitVector
{
std::vector<bool> bits;
@@ -140,6 +142,58 @@ public:
void clearBit(int idx)
{ bits[idx] = false; }
};
+#else // Insanity:
+class BitVector
+{
+ QBitArray bits;
+
+public:
+ BitVector(int size = 0, bool value = false)
+ : bits(size, value)
+ {}
+
+ void reserve(int size)
+ { Q_UNUSED(size); }
+
+ int size() const
+ { return bits.size(); }
+
+ void resize(int newSize)
+ { bits.resize(newSize); }
+
+ void assign(int newSize, bool value)
+ {
+ bits.resize(newSize);
+ bits.fill(value);
+ }
+
+ int findNext(int start, bool value, bool wrapAround) const
+ {
+ for (int i = start, ei = size(); i < ei; ++i) {
+ if (at(i) == value)
+ return i;
+ }
+
+ if (wrapAround) {
+ for (int i = 0, ei = start; i < ei; ++i) {
+ if (at(i) == value)
+ return i;
+ }
+ }
+
+ return size();
+ }
+
+ bool at(int idx) const
+ { return bits.at(idx); }
+
+ void setBit(int idx)
+ { bits[idx] = true; }
+
+ void clearBit(int idx)
+ { bits[idx] = false; }
+};
+#endif
class ProcessedBlocks
{