QmlJS: Find prototype resolution errors.

To avoid lots of follow-up errors where the root cause is a failed
prototype resolution or a prototype cycle.

Task-number: QTCREATORBUG-4952
Change-Id: Id474c8c6c152c993aca8c6c421b6d88eb1481676
Reviewed-on: http://codereview.qt.nokia.com/36
Reviewed-by: Thomas Hartmann <Thomas.Hartmann@nokia.com>
This commit is contained in:
Christian Kamm
2011-05-20 13:19:16 +02:00
committed by Thomas Hartmann
parent 044915b2c1
commit 0bf18d008b
3 changed files with 74 additions and 9 deletions

View File

@@ -332,7 +332,7 @@ public:
const Value *lookup(const QString &name, const ObjectValue **foundInScope = 0) const;
const ObjectValue *lookupType(const Document *doc, AST::UiQualifiedId *qmlTypeName) const;
const ObjectValue *lookupType(const Document *doc, const QStringList &qmlTypeName) const;
const Value *lookupReference(const Reference *reference) const;
const Value *lookupReference(const Value *value) const;
const Value *property(const ObjectValue *object, const QString &name) const;
void setProperty(const ObjectValue *object, const QString &name, const Value *value);
@@ -400,7 +400,9 @@ public:
QString className() const;
void setClassName(const QString &className);
// not guaranteed to not recurse, use PrototypeIterator!
// may return a reference, prototypes may form a cycle: use PrototypeIterator!
const Value *prototype() const;
// prototypes may form a cycle: use PrototypeIterator!
const ObjectValue *prototype(const Context *context) const;
void setPrototype(const Value *prototype);
@@ -433,11 +435,19 @@ protected:
class QMLJS_EXPORT PrototypeIterator
{
public:
enum Error
{
NoError,
ReferenceResolutionError,
CycleError
};
PrototypeIterator(const ObjectValue *start, const Context *context);
bool hasNext();
const ObjectValue *peekNext();
const ObjectValue *next();
Error error() const;
QList<const ObjectValue *> all();
@@ -446,6 +456,7 @@ private:
const ObjectValue *m_next;
QList<const ObjectValue *> m_prototypes;
const Context *m_context;
Error m_error;
};
// A ObjectValue based on a FakeMetaObject.