QmlJS: Refactor LookupContext creation for speed.

* If possible, create LookupContexts through SemanticInfo; it caches the
  linked Context and will be faster.
* Contexts now own their Engine.

Reviewed-by: Lasse Holmstedt
This commit is contained in:
Christian Kamm
2010-08-26 10:50:00 +02:00
parent af46c3d947
commit 87e04df257
15 changed files with 141 additions and 96 deletions

View File

@@ -1419,8 +1419,8 @@ QList<const ObjectValue *> ScopeChain::all() const
}
Context::Context(Engine *engine)
: _engine(engine),
Context::Context()
: _engine(new Engine),
_qmlScopeObjectIndex(-1),
_qmlScopeObjectSet(false)
{
@@ -1430,9 +1430,10 @@ Context::~Context()
{
}
// the engine is only guaranteed to live as long as the context
Engine *Context::engine() const
{
return _engine;
return _engine.data();
}
const ScopeChain &Context::scopeChain() const
@@ -1530,7 +1531,7 @@ void Context::setProperty(const ObjectValue *object, const QString &name, const
_properties[object].insert(name, value);
}
QString Context::defaultPropertyName(const ObjectValue *object)
QString Context::defaultPropertyName(const ObjectValue *object) const
{
for (const ObjectValue *o = object; o; o = o->prototype(this)) {
if (const ASTObjectValue *astObjValue = dynamic_cast<const ASTObjectValue *>(o)) {
@@ -1544,16 +1545,6 @@ QString Context::defaultPropertyName(const ObjectValue *object)
return QString();
}
bool Context::documentImportsPlugins(const QmlJS::Document *doc) const
{
return _documentsImportingPlugins.contains(doc->fileName());
}
void Context::setDocumentImportsPlugins(const QmlJS::Document *doc)
{
_documentsImportingPlugins.insert(doc->fileName());
}
Reference::Reference(Engine *engine)
: _engine(engine)
{