diff options
author | Lars Knoll <[email protected]> | 2013-08-29 13:24:38 +0200 |
---|---|---|
committer | The Qt Project <[email protected]> | 2013-09-02 17:27:36 +0200 |
commit | 3ad8b0f0e8193bb7b62ffee6b33588ef6b51459c (patch) | |
tree | a4c05097b9787efcb2749ed2d40590b1beb2d360 /src/qml/jsruntime/qv4internalclass.cpp | |
parent | 6c69cdb1af58dfb584615aa60d4f69b359b312cc (diff) |
Add the object's prototype to the InternalClass structure
Change-Id: Ifa97d3354a7a7afadf70f9ba540716bd5b1eef44
Reviewed-by: Simon Hausmann <[email protected]>
Diffstat (limited to 'src/qml/jsruntime/qv4internalclass.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4internalclass.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/qml/jsruntime/qv4internalclass.cpp b/src/qml/jsruntime/qv4internalclass.cpp index f4edc99545..50803db73d 100644 --- a/src/qml/jsruntime/qv4internalclass.cpp +++ b/src/qml/jsruntime/qv4internalclass.cpp @@ -126,6 +126,7 @@ uint PropertyHash::lookup(const Identifier *identifier) const InternalClass::InternalClass(const QV4::InternalClass &other) : engine(other.engine) + , prototype(other.prototype) , propertyTable(other.propertyTable) , nameMap(other.nameMap) , propertyData(other.propertyData) @@ -163,6 +164,25 @@ InternalClass *InternalClass::changeMember(String *string, PropertyAttributes da } +InternalClass *InternalClass::changePrototype(Object *proto) +{ + if (prototype == proto) + return this; + + Transition t; + t.prototype = proto; + t.flags = Transition::ProtoChange; + + QHash<Transition, InternalClass *>::const_iterator tit = transitions.constFind(t); + if (tit != transitions.constEnd()) + return tit.value(); + + // create a new class and add it to the tree + InternalClass *newClass = engine->newClass(*this); + newClass->prototype = proto; + return newClass; +} + InternalClass *InternalClass::addMember(String *string, PropertyAttributes data, uint *index) { // qDebug() << "InternalClass::addMember()" << string->toQString() << size << hex << (uint)data.m_all << data.type(); @@ -293,4 +313,12 @@ void InternalClass::destroy() transitions.clear(); } +void InternalClass::markObjects() +{ + prototype->mark(); + for (QHash<Transition, InternalClass *>::ConstIterator it = transitions.begin(), end = transitions.end(); + it != end; ++it) + it.value()->markObjects(); +} + QT_END_NAMESPACE |