summaryrefslogtreecommitdiffstats
path: root/src/declarative/qml/qdeclarativevme.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/declarative/qml/qdeclarativevme.cpp')
-rw-r--r--src/declarative/qml/qdeclarativevme.cpp72
1 files changed, 69 insertions, 3 deletions
diff --git a/src/declarative/qml/qdeclarativevme.cpp b/src/declarative/qml/qdeclarativevme.cpp
index 06aed98..a23f89d 100644
--- a/src/declarative/qml/qdeclarativevme.cpp
+++ b/src/declarative/qml/qdeclarativevme.cpp
@@ -74,6 +74,27 @@
QT_BEGIN_NAMESPACE
+// A simple stack wrapper around QVarLengthArray
+template<typename T>
+class QDeclarativeVMEStack : private QVarLengthArray<T, 128>
+{
+private:
+ typedef QVarLengthArray<T, 128> VLA;
+ int _index;
+
+public:
+ inline QDeclarativeVMEStack();
+ inline bool isEmpty() const;
+ inline const T &top() const;
+ inline void push(const T &o);
+ inline T pop();
+ inline int count() const;
+ inline const T &at(int index) const;
+};
+
+// We do this so we can forward declare the type in the qdeclarativevme_p.h header
+class QDeclarativeVMEObjectStack : public QDeclarativeVMEStack<QObject *> {};
+
QDeclarativeVME::QDeclarativeVME()
{
}
@@ -99,10 +120,12 @@ struct ListInstance
QDeclarativeListProperty<void> qListProperty;
};
+Q_DECLARE_TYPEINFO(ListInstance, Q_PRIMITIVE_TYPE | Q_MOVABLE_TYPE);
+
QObject *QDeclarativeVME::run(QDeclarativeContextData *ctxt, QDeclarativeCompiledData *comp,
int start, int count, const QBitField &bindingSkipList)
{
- QDeclarativeVMEStack<QObject *> stack;
+ QDeclarativeVMEObjectStack stack;
if (start == -1) start = 0;
if (count == -1) count = comp->bytecode.count();
@@ -121,7 +144,7 @@ void QDeclarativeVME::runDeferred(QObject *object)
QDeclarativeCompiledData *comp = data->deferredComponent;
int start = data->deferredIdx + 1;
int count = data->deferredComponent->bytecode.at(data->deferredIdx).defer.deferCount;
- QDeclarativeVMEStack<QObject *> stack;
+ QDeclarativeVMEObjectStack stack;
stack.push(object);
run(stack, ctxt, comp, start, count, QBitField());
@@ -143,7 +166,7 @@ static void removeBindingOnProperty(QObject *o, int index)
#define CLEAN_PROPERTY(o, index) if (fastHasBinding(o, index)) removeBindingOnProperty(o, index)
-QObject *QDeclarativeVME::run(QDeclarativeVMEStack<QObject *> &stack,
+QObject *QDeclarativeVME::run(QDeclarativeVMEObjectStack &stack,
QDeclarativeContextData *ctxt,
QDeclarativeCompiledData *comp,
int start, int count,
@@ -1054,5 +1077,48 @@ QDeclarativeCompiledData::TypeReference::createInstance(QDeclarativeContextData
}
}
+template<typename T>
+QDeclarativeVMEStack<T>::QDeclarativeVMEStack()
+: _index(-1)
+{
+}
+
+template<typename T>
+bool QDeclarativeVMEStack<T>::isEmpty() const {
+ return _index == -1;
+}
+
+template<typename T>
+const T &QDeclarativeVMEStack<T>::top() const {
+ return at(_index);
+}
+
+template<typename T>
+void QDeclarativeVMEStack<T>::push(const T &o) {
+ _index++;
+
+ Q_ASSERT(_index <= VLA::size());
+ if (_index == VLA::size())
+ VLA::append(o);
+ else
+ VLA::data()[_index] = o;
+}
+
+template<typename T>
+T QDeclarativeVMEStack<T>::pop() {
+ Q_ASSERT(_index >= 0);
+ --_index;
+ return VLA::data()[_index + 1];
+}
+
+template<typename T>
+int QDeclarativeVMEStack<T>::count() const {
+ return _index + 1;
+}
+
+template<typename T>
+const T &QDeclarativeVMEStack<T>::at(int index) const {
+ return VLA::data()[index];
+}
QT_END_NAMESPACE