QmlJS: Avoid infinite loop with recursive prototypes.

This commit is contained in:
Christian Kamm
2010-11-12 14:53:00 +01:00
parent 443be8eea6
commit f7a077b1fa
8 changed files with 135 additions and 47 deletions

View File

@@ -397,6 +397,7 @@ public:
QString className() const;
void setClassName(const QString &className);
// not guaranteed to not recurse, use PrototypeIterator!
const ObjectValue *prototype(const Context *context) const;
void setPrototype(const Value *prototype);
@@ -422,6 +423,24 @@ private:
QString _className;
};
class QMLJS_EXPORT PrototypeIterator
{
public:
PrototypeIterator(const ObjectValue *start, const Context *context);
bool hasNext();
const ObjectValue *peekNext();
const ObjectValue *next();
QList<const ObjectValue *> all();
private:
const ObjectValue *m_current;
const ObjectValue *m_next;
QList<const ObjectValue *> m_prototypes;
const Context *m_context;
};
class QMLJS_EXPORT QmlObjectValue: public ObjectValue
{
public: