} else if (v->type == Value::SignalExpression) {
- BindingContext ctxt = compileState->signalExpressions.value(v);
-
QDeclarativeInstruction store;
store.setType(QDeclarativeInstruction::StoreSignal);
store.storeSignal.signalIndex = prop->index;
store.storeSignal.value =
output->indexForString(v->value.asScript().trimmed());
- store.storeSignal.context = ctxt.stack;
+ store.storeSignal.context = v->signalExpressionContextStack;
store.storeSignal.name = output->indexForByteArray(prop->name().toUtf8());
store.storeSignal.line = v->location.start.line;
output->addInstruction(store);
QString idVal = idProp->values.first()->primitive();
- if (compileState->ids.contains(idVal))
+ if (compileState->ids.value(idVal))
COMPILE_EXCEPTION(idProp, tr("id is not unique"));
obj->id = idVal;
if (script.isEmpty())
COMPILE_EXCEPTION(prop, tr("Empty signal assignment"));
- compileState->signalExpressions.insert(prop->values.first(), ctxt);
+ prop->values.first()->signalExpressionContextStack = ctxt.stack;
}
}
COMPILE_CHECK(checkValidId(idValue, val));
- if (compileState->ids.contains(val))
+ if (compileState->ids.value(val))
COMPILE_EXCEPTION(prop, tr("id is not unique"));
prop->values.first()->type = Value::Id;
void QDeclarativeCompiler::addId(const QString &id, QDeclarativeParser::Object *obj)
{
- Q_ASSERT(!compileState->ids.contains(id));
+ Q_ASSERT(!compileState->ids.value(id));
Q_ASSERT(obj->id == id);
obj->idIndex = compileState->ids.count();
- compileState->ids.insert(id, obj);
+ compileState->ids.append(obj);
}
void QDeclarativeCompiler::addBindingReference(BindingReference *ref)
obj->metadata = builder.toRelocatableData();
builder.fromRelocatableData(&obj->extObject, obj->metatype, obj->metadata);
- if (mode == IgnoreAliases && hasAlias)
- compileState->aliasingObjects << obj;
+ if (mode == IgnoreAliases && hasAlias)
+ compileState->aliasingObjects.append(obj);
obj->synthdata = dynamicData;
if (alias.count() < 1 || alias.count() > 3)
COMPILE_EXCEPTION(prop.defaultValue, tr("Invalid alias reference. An alias reference must be specified as <id>, <id>.<property> or <id>.<value property>.<property>"));
- if (!compileState->ids.contains(alias.at(0)))
+ QDeclarativeParser::Object *idObject = compileState->ids.value(alias.at(0));
+ if (!idObject)
COMPILE_EXCEPTION(prop.defaultValue, tr("Invalid alias reference. Unable to find id \"%1\"").arg(alias.at(0)));
- QDeclarativeParser::Object *idObject = compileState->ids[alias.at(0)];
-
QByteArray typeName;
int propIdx = -1;
return -1;
QDeclarativeIntegerCache *cache = new QDeclarativeIntegerCache();
-
- for (QHash<QString, QDeclarativeParser::Object *>::ConstIterator iter = compileState->ids.begin();
- iter != compileState->ids.end();
- ++iter)
- cache->add(iter.key(), (*iter)->idIndex);
+ cache->reserve(compileState->ids.count());
+ for (Object *o = compileState->ids.first(); o; o = compileState->ids.next(o))
+ cache->add(o->id, o->idIndex);
output->contextCaches.append(cache);
return output->contextCaches.count() - 1;
if (componentStats)
componentStats->componentStat.ids = compileState->ids.count();
- for (int ii = 0; ii < compileState->aliasingObjects.count(); ++ii) {
- QDeclarativeParser::Object *aliasObject = compileState->aliasingObjects.at(ii);
+ for (Object *aliasObject = compileState->aliasingObjects.first(); aliasObject;
+ aliasObject = compileState->aliasingObjects.next(aliasObject))
COMPILE_CHECK(buildDynamicMeta(aliasObject, ResolveAliases));
- }
QDeclarativeV4Compiler::Expression expr;
expr.component = compileState->root;
- expr.ids = compileState->ids;
+ expr.ids = &compileState->ids;
expr.importCache = output->importCache;
expr.imports = unit->imports();
BindingReference *nextReference;
};
+ struct IdList : public QFieldList<QDeclarativeParser::Object,
+ &QDeclarativeParser::Object::nextIdObject>
+ {
+ QDeclarativeParser::Object *value(const QString &id) const {
+ for (QDeclarativeParser::Object *o = first(); o; o = next(o)) {
+ if (o->id == id)
+ return o;
+ }
+ return 0;
+ }
+ };
+
// Contains all the incremental compiler state about a component. As
// a single QML file can have multiple components defined, there may be
// more than one of these for each compile
struct ComponentCompileState : public QDeclarativePool::Class
{
ComponentCompileState()
- : parserStatusCount(0), pushedProperties(0), nested(false), v8BindingProgramLine(-1), root(0) {}
- QHash<QString, QDeclarativeParser::Object *> ids;
+ : parserStatusCount(0), pushedProperties(0), nested(false), v8BindingProgramLine(-1), root(0) {}
+
+ IdList ids;
int parserStatusCount;
int pushedProperties;
bool nested;
int v8BindingProgramLine;
int v8BindingProgramIndex;
- struct BindingReferenceList {
- BindingReferenceList() : _count(0), _first(0) {}
- QDeclarativeCompilerTypes::BindingReference *first() const { return _first; }
- void prepend(QDeclarativeCompilerTypes::BindingReference *ref) {
- Q_ASSERT(ref);
- Q_ASSERT(0 == ref->nextReference);
- ref->nextReference = _first;
- _first = ref;
- ++_count;
- }
- int count() const { return _count; }
- private:
- int _count;
- QDeclarativeCompilerTypes::BindingReference *_first;
- };
-
+ typedef QDeclarativeCompilerTypes::BindingReference B;
+ typedef QFieldList<B, &B::nextReference> BindingReferenceList;
BindingReferenceList bindings;
- QHash<QDeclarativeParser::Value *, QDeclarativeCompilerTypes::BindingContext> signalExpressions;
- QList<QDeclarativeParser::Object *> aliasingObjects;
+ typedef QDeclarativeParser::Object O;
+ typedef QFieldList<O, &O::nextAliasingObject> AliasingObjectsList;
+ AliasingObjectsList aliasingObjects;
QDeclarativeParser::Object *root;
};
};
return QString();
}
+void QDeclarativeIntegerCache::reserve(int size)
+{
+ stringCache.reserve(size);
+}
+
void QDeclarativeIntegerCache::add(const QString &id, int value)
{
Q_ASSERT(!stringCache.contains(id));
inline int count() const;
void add(const QString &, int);
+ void reserve(int);
int value(const QString &);
inline int value(const QHashedV8String &);
QDeclarativeParser::Object::Object()
: type(-1), idIndex(-1), metatype(0), synthCache(0), defaultProperty(0), parserStatusCast(-1),
- componentCompileState(0)
+ componentCompileState(0), nextAliasingObject(0), nextIdObject(0)
{
}
}
QDeclarativeParser::Value::Value()
-: type(Unknown), object(0), bindingReference(0), nextValue(0)
+: type(Unknown), object(0), bindingReference(0), signalExpressionContextStack(0), nextValue(0)
{
}
// Used by compiler
QDeclarativeCompilerTypes::BindingReference *bindingReference;
+ int signalExpressionContextStack;
// Used in Property::ValueList lists
Value *nextValue;
// Used by compiler
QDeclarativeCompilerTypes::ComponentCompileState *componentCompileState;
+
+ // Used by ComponentCompileState::AliasingObjectsList
+ Object *nextAliasingObject;
+ // Used by ComponentComppileState::IdList
+ Object *nextIdObject;
};
}
// We mean it.
//
-#include "private/qdeclarativeexpression_p.h"
-#include "private/qdeclarativebinding_p.h"
+#include <private/qdeclarativeexpression_p.h>
+#include <private/qdeclarativebinding_p.h>
+#include <private/qdeclarativecompiler_p.h>
QT_BEGIN_HEADER
QDeclarativeParser::Object *context;
QDeclarativeParser::Property *property;
QDeclarativeParser::Variant expression;
- QHash<QString, QDeclarativeParser::Object *> ids;
+ QDeclarativeCompilerTypes::IdList *ids;
QDeclarativeTypeNameCache *importCache;
QDeclarativeImports imports;
};
} else if (m_engine->v8engine()->illegalNames().contains(name) ) {
if (qmlVerboseCompiler()) qWarning() << "*** illegal symbol:" << name;
return false;
- } else if (const QDeclarativeParser::Object *obj = m_expression->ids.value(name)) {
+ } else if (const QDeclarativeParser::Object *obj = m_expression->ids->value(name)) {
IR::Name *code = _block->ID_OBJECT(name, obj, line, column);
if (obj == m_expression->component)
code->storage = IR::Name::RootStorage;