diff options
Diffstat (limited to 'src/libs/qmljs/qmljscontext.h')
-rw-r--r-- | src/libs/qmljs/qmljscontext.h | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/src/libs/qmljs/qmljscontext.h b/src/libs/qmljs/qmljscontext.h index bd5c4cf03d5..5d28c5872a9 100644 --- a/src/libs/qmljs/qmljscontext.h +++ b/src/libs/qmljs/qmljscontext.h @@ -45,9 +45,12 @@ class Snapshot; namespace Interpreter { +// shared among threads, completely threadsafe +// currently also safe to copy, but will be deprecated class QMLJS_EXPORT Context { public: + typedef QSharedPointer<Context> Ptr; typedef QHash<const Document *, QSharedPointer<const Imports> > ImportsPerDocument; // Context takes ownership of valueOwner @@ -57,12 +60,8 @@ public: ValueOwner *valueOwner() const; Snapshot snapshot() const; - const ScopeChain &scopeChain() const; - ScopeChain &scopeChain(); - const Imports *imports(const Document *doc) const; - const Value *lookup(const QString &name, const ObjectValue **foundInScope = 0) const; const ObjectValue *lookupType(const Document *doc, AST::UiQualifiedId *qmlTypeName, AST::UiQualifiedId *qmlTypeNameEnd = 0) const; const ObjectValue *lookupType(const Document *doc, const QStringList &qmlTypeName) const; @@ -71,19 +70,29 @@ public: QString defaultPropertyName(const ObjectValue *object) const; private: - typedef QHash<QString, const Value *> Properties; - Snapshot _snapshot; QSharedPointer<ValueOwner> _valueOwner; ImportsPerDocument _imports; - ScopeChain _scopeChain; - int _qmlScopeObjectIndex; - bool _qmlScopeObjectSet; +}; + +// for looking up references +class QMLJS_EXPORT ReferenceContext +{ +public: + // implicit conversion ok + ReferenceContext(const Context *context); + + const Value *lookupReference(const Value *value); + + const Context *context() const; + operator const Context *() const; - // for avoiding reference cycles during lookup - mutable QList<const Reference *> _referenceStack; +private: + const Context *m_context; + QList<const Reference *> m_references; }; + } // namespace Interpreter } // namespace QmlJS |