| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/qml/jsruntime/qv4lookup.cpp | 
| Source code | Switch to Preprocessed file | 
| Line | Source | Count | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | /**************************************************************************** | - | ||||||||||||||||||
| 2 | ** | - | ||||||||||||||||||
| 3 | ** Copyright (C) 2016 The Qt Company Ltd. | - | ||||||||||||||||||
| 4 | ** Contact: https://www.qt.io/licensing/ | - | ||||||||||||||||||
| 5 | ** | - | ||||||||||||||||||
| 6 | ** This file is part of the QtQml module of the Qt Toolkit. | - | ||||||||||||||||||
| 7 | ** | - | ||||||||||||||||||
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ | - | ||||||||||||||||||
| 9 | ** Commercial License Usage | - | ||||||||||||||||||
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||||||||||||||
| 11 | ** accordance with the commercial license agreement provided with the | - | ||||||||||||||||||
| 12 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||||||||||||||
| 13 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||||||||||||||
| 14 | ** and conditions see https://www.qt.io/terms-conditions. For further | - | ||||||||||||||||||
| 15 | ** information use the contact form at https://www.qt.io/contact-us. | - | ||||||||||||||||||
| 16 | ** | - | ||||||||||||||||||
| 17 | ** GNU Lesser General Public License Usage | - | ||||||||||||||||||
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||||||||||||||
| 19 | ** General Public License version 3 as published by the Free Software | - | ||||||||||||||||||
| 20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the | - | ||||||||||||||||||
| 21 | ** packaging of this file. Please review the following information to | - | ||||||||||||||||||
| 22 | ** ensure the GNU Lesser General Public License version 3 requirements | - | ||||||||||||||||||
| 23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. | - | ||||||||||||||||||
| 24 | ** | - | ||||||||||||||||||
| 25 | ** GNU General Public License Usage | - | ||||||||||||||||||
| 26 | ** Alternatively, this file may be used under the terms of the GNU | - | ||||||||||||||||||
| 27 | ** General Public License version 2.0 or (at your option) the GNU General | - | ||||||||||||||||||
| 28 | ** Public license version 3 or any later version approved by the KDE Free | - | ||||||||||||||||||
| 29 | ** Qt Foundation. The licenses are as published by the Free Software | - | ||||||||||||||||||
| 30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 | - | ||||||||||||||||||
| 31 | ** included in the packaging of this file. Please review the following | - | ||||||||||||||||||
| 32 | ** information to ensure the GNU General Public License requirements will | - | ||||||||||||||||||
| 33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and | - | ||||||||||||||||||
| 34 | ** https://www.gnu.org/licenses/gpl-3.0.html. | - | ||||||||||||||||||
| 35 | ** | - | ||||||||||||||||||
| 36 | ** $QT_END_LICENSE$ | - | ||||||||||||||||||
| 37 | ** | - | ||||||||||||||||||
| 38 | ****************************************************************************/ | - | ||||||||||||||||||
| 39 | #include "qv4lookup_p.h" | - | ||||||||||||||||||
| 40 | #include "qv4functionobject_p.h" | - | ||||||||||||||||||
| 41 | #include "qv4jscall_p.h" | - | ||||||||||||||||||
| 42 | #include "qv4string_p.h" | - | ||||||||||||||||||
| 43 | #include <private/qv4identifiertable_p.h> | - | ||||||||||||||||||
| 44 | - | |||||||||||||||||||
| 45 | QT_BEGIN_NAMESPACE | - | ||||||||||||||||||
| 46 | - | |||||||||||||||||||
| 47 | using namespace QV4; | - | ||||||||||||||||||
| 48 | - | |||||||||||||||||||
| 49 | - | |||||||||||||||||||
| 50 | void Lookup::resolveProtoGetter(PropertyKey name, const Heap::Object *proto) | - | ||||||||||||||||||
| 51 | { | - | ||||||||||||||||||
| 52 | while (proto) { 
 | 15065-1460102 | ||||||||||||||||||
| 53 | uint index = proto->internalClass->find(name); | - | ||||||||||||||||||
| 54 | if (index != UINT_MAX) { 
 | 40012-1421618 | ||||||||||||||||||
| 55 | PropertyAttributes attrs = proto->internalClass->propertyData.at(index); | - | ||||||||||||||||||
| 56 | protoLookup.data = proto->propertyData(index); | - | ||||||||||||||||||
| 57 | if (attrs.isData()) { 
 | 2394-1417795 | ||||||||||||||||||
| 58 | getter = getterProto; | - | ||||||||||||||||||
| 59 | } else { executed 1417740 times by 7 tests:  end of blockExecuted by: 
 | 1417740 | ||||||||||||||||||
| 60 | getter = getterProtoAccessor; | - | ||||||||||||||||||
| 61 | } executed 2394 times by 1 test:  end of blockExecuted by: 
 | 2394 | ||||||||||||||||||
| 62 | return; executed 1420239 times by 7 tests:  return;Executed by: 
 | 1420239 | ||||||||||||||||||
| 63 | } | - | ||||||||||||||||||
| 64 | proto = proto->prototype(); | - | ||||||||||||||||||
| 65 | } executed 40005 times by 3 tests:  end of blockExecuted by: 
 | 40005 | ||||||||||||||||||
| 66 | // ### put in a getterNotFound! | - | ||||||||||||||||||
| 67 | getter = getterFallback; | - | ||||||||||||||||||
| 68 | } executed 15065 times by 3 tests:  end of blockExecuted by: 
 | 15065 | ||||||||||||||||||
| 69 | - | |||||||||||||||||||
| 70 | ReturnedValue Lookup::resolveGetter(ExecutionEngine *engine, const Object *object) | - | ||||||||||||||||||
| 71 | { | - | ||||||||||||||||||
| 72 | Heap::Object *obj = object->d(); | - | ||||||||||||||||||
| 73 | PropertyKey name = engine->identifierTable->asPropertyKey(engine->currentStackFrame->v4Function->compilationUnit->runtimeStrings[nameIndex]); | - | ||||||||||||||||||
| 74 | if (name.isArrayIndex()) { 
 | 679-680405 | ||||||||||||||||||
| 75 | indexedLookup.index = name.asArrayIndex(); | - | ||||||||||||||||||
| 76 | getter = getterIndexed; | - | ||||||||||||||||||
| 77 | return getter(this, engine, *object); executed 680 times by 1 test:  return getter(this, engine, *object);Executed by: 
 | 680 | ||||||||||||||||||
| 78 | } | - | ||||||||||||||||||
| 79 | - | |||||||||||||||||||
| 80 | uint index = obj->internalClass->find(name); | - | ||||||||||||||||||
| 81 | if (index != UINT_MAX) { 
 | 101618-579213 | ||||||||||||||||||
| 82 | PropertyAttributes attrs = obj->internalClass->propertyData.at(index); | - | ||||||||||||||||||
| 83 | uint nInline = obj->vtable()->nInlineProperties; | - | ||||||||||||||||||
| 84 | if (attrs.isData()) { 
 | 1561-577918 | ||||||||||||||||||
| 85 | if (index < obj->vtable()->nInlineProperties) { 
 | 279143-298779 | ||||||||||||||||||
| 86 | index += obj->vtable()->inlinePropertyOffset; | - | ||||||||||||||||||
| 87 | getter = getter0Inline; | - | ||||||||||||||||||
| 88 | } else { executed 279168 times by 7 tests:  end of blockExecuted by: 
 | 279168 | ||||||||||||||||||
| 89 | index -= nInline; | - | ||||||||||||||||||
| 90 | getter = getter0MemberData; | - | ||||||||||||||||||
| 91 | } executed 298799 times by 2 tests:  end of blockExecuted by: 
 | 298799 | ||||||||||||||||||
| 92 | } else { | - | ||||||||||||||||||
| 93 | getter = getterAccessor; | - | ||||||||||||||||||
| 94 | } executed 1561 times by 1 test:  end of blockExecuted by: 
 | 1561 | ||||||||||||||||||
| 95 | objectLookup.ic = obj->internalClass; | - | ||||||||||||||||||
| 96 | objectLookup.offset = index; | - | ||||||||||||||||||
| 97 | return getter(this, engine, *object); executed 579315 times by 7 tests:  return getter(this, engine, *object);Executed by: 
 | 579315 | ||||||||||||||||||
| 98 | } | - | ||||||||||||||||||
| 99 | - | |||||||||||||||||||
| 100 | protoLookup.protoId = obj->internalClass->protoId; | - | ||||||||||||||||||
| 101 | resolveProtoGetter(name, obj->prototype()); | - | ||||||||||||||||||
| 102 | return getter(this, engine, *object); executed 101576 times by 2 tests:  return getter(this, engine, *object);Executed by: 
 | 101576 | ||||||||||||||||||
| 103 | } | - | ||||||||||||||||||
| 104 | - | |||||||||||||||||||
| 105 | ReturnedValue Lookup::resolvePrimitiveGetter(ExecutionEngine *engine, const Value &object) | - | ||||||||||||||||||
| 106 | { | - | ||||||||||||||||||
| 107 | primitiveLookup.type = object.type(); | - | ||||||||||||||||||
| 108 | switch (primitiveLookup.type) { | - | ||||||||||||||||||
| 109 | case Value::Undefined_Type: executed 2407 times by 1 test:  case Value::Undefined_Type:Executed by: 
 | 2407 | ||||||||||||||||||
| 110 | case Value::Null_Type: executed 344 times by 1 test:  case Value::Null_Type:Executed by: 
 | 344 | ||||||||||||||||||
| 111 | return engine->throwTypeError(); executed 2750 times by 1 test:  return engine->throwTypeError();Executed by: 
 | 2750 | ||||||||||||||||||
| 112 | case Value::Boolean_Type: executed 56 times by 1 test:  case Value::Boolean_Type:Executed by: 
 | 56 | ||||||||||||||||||
| 113 | primitiveLookup.proto = engine->booleanPrototype()->d(); | - | ||||||||||||||||||
| 114 | break; executed 56 times by 1 test:  break;Executed by: 
 | 56 | ||||||||||||||||||
| 115 | case Value::Managed_Type: { executed 8134 times by 1 test:  case Value::Managed_Type:Executed by: 
 | 8134 | ||||||||||||||||||
| 116 | // ### Should move this over to the Object path, as strings also have an internalClass | - | ||||||||||||||||||
| 117 | Q_ASSERT(object.isStringOrSymbol()); | - | ||||||||||||||||||
| 118 | primitiveLookup.proto = static_cast<const Managed &>(object).internalClass()->prototype; | - | ||||||||||||||||||
| 119 | Q_ASSERT(primitiveLookup.proto); | - | ||||||||||||||||||
| 120 | Scope scope(engine); | - | ||||||||||||||||||
| 121 | ScopedString name(scope, engine->currentStackFrame->v4Function->compilationUnit->runtimeStrings[nameIndex]); | - | ||||||||||||||||||
| 122 | if (object.isString() && name->equals(engine->id_length())) { 
 
 | 54-8087 | ||||||||||||||||||
| 123 | // special case, as the property is on the object itself | - | ||||||||||||||||||
| 124 | getter = stringLengthGetter; | - | ||||||||||||||||||
| 125 | return stringLengthGetter(this, engine, object); executed 280 times by 1 test:  return stringLengthGetter(this, engine, object);Executed by: 
 | 280 | ||||||||||||||||||
| 126 | } | - | ||||||||||||||||||
| 127 | break; executed 7864 times by 1 test:  break;Executed by: 
 | 7864 | ||||||||||||||||||
| 128 | } | - | ||||||||||||||||||
| 129 | case Value::Integer_Type: executed 400 times by 1 test:  case Value::Integer_Type:Executed by: 
 | 400 | ||||||||||||||||||
| 130 | default: // Number executed 624 times by 1 test:  default:Executed by: 
 | 624 | ||||||||||||||||||
| 131 | primitiveLookup.proto = engine->numberPrototype()->d(); | - | ||||||||||||||||||
| 132 | } executed 1024 times by 1 test:  end of blockExecuted by: 
 | 1024 | ||||||||||||||||||
| 133 | - | |||||||||||||||||||
| 134 | PropertyKey name = engine->identifierTable->asPropertyKey(engine->currentStackFrame->v4Function->compilationUnit->runtimeStrings[nameIndex]); | - | ||||||||||||||||||
| 135 | protoLookup.protoId = primitiveLookup.proto->internalClass->protoId; | - | ||||||||||||||||||
| 136 | resolveProtoGetter(name, primitiveLookup.proto); | - | ||||||||||||||||||
| 137 | - | |||||||||||||||||||
| 138 | if (getter == getterProto) 
 | 174-8780 | ||||||||||||||||||
| 139 | getter = primitiveGetterProto; executed 8780 times by 1 test:  getter = primitiveGetterProto;Executed by: 
 | 8780 | ||||||||||||||||||
| 140 | else if (getter == getterProtoAccessor) 
 | 16-158 | ||||||||||||||||||
| 141 | getter = primitiveGetterAccessor; executed 16 times by 1 test:  getter = primitiveGetterAccessor;Executed by: 
 | 16 | ||||||||||||||||||
| 142 | return getter(this, engine, object); executed 8954 times by 1 test:  return getter(this, engine, object);Executed by: 
 | 8954 | ||||||||||||||||||
| 143 | } | - | ||||||||||||||||||
| 144 | - | |||||||||||||||||||
| 145 | ReturnedValue Lookup::resolveGlobalGetter(ExecutionEngine *engine) | - | ||||||||||||||||||
| 146 | { | - | ||||||||||||||||||
| 147 | Object *o = engine->globalObject; | - | ||||||||||||||||||
| 148 | PropertyKey name = engine->identifierTable->asPropertyKey(engine->currentStackFrame->v4Function->compilationUnit->runtimeStrings[nameIndex]); | - | ||||||||||||||||||
| 149 | protoLookup.protoId = o->internalClass()->protoId; | - | ||||||||||||||||||
| 150 | resolveProtoGetter(name, o->d()); | - | ||||||||||||||||||
| 151 | - | |||||||||||||||||||
| 152 | if (getter == getterProto) 
 | 7031-1318625 | ||||||||||||||||||
| 153 | globalGetter = globalGetterProto; executed 1317597 times by 7 tests:  globalGetter = globalGetterProto;Executed by: 
 | 1317597 | ||||||||||||||||||
| 154 | else if (getter == getterProtoAccessor) 
 | 60-6971 | ||||||||||||||||||
| 155 | globalGetter = globalGetterProtoAccessor; executed 60 times by 1 test:  globalGetter = globalGetterProtoAccessor;Executed by: 
 | 60 | ||||||||||||||||||
| 156 | else { | - | ||||||||||||||||||
| 157 | globalGetter = globalGetterGeneric; | - | ||||||||||||||||||
| 158 | Scope scope(engine); | - | ||||||||||||||||||
| 159 | ScopedString n(scope, engine->currentStackFrame->v4Function->compilationUnit->runtimeStrings[nameIndex]); | - | ||||||||||||||||||
| 160 | return engine->throwReferenceError(n); executed 6962 times by 2 tests:  return engine->throwReferenceError(n);Executed by: 
 | 6962 | ||||||||||||||||||
| 161 | } | - | ||||||||||||||||||
| 162 | return globalGetter(this, engine); executed 1317890 times by 7 tests:  return globalGetter(this, engine);Executed by: 
 | 1317890 | ||||||||||||||||||
| 163 | } | - | ||||||||||||||||||
| 164 | - | |||||||||||||||||||
| 165 | ReturnedValue Lookup::getterGeneric(Lookup *l, ExecutionEngine *engine, const Value &object) | - | ||||||||||||||||||
| 166 | { | - | ||||||||||||||||||
| 167 | if (const Object *o = object.as<Object>()) 
 | 11977-678473 | ||||||||||||||||||
| 168 | return l->resolveGetter(engine, o); executed 678495 times by 7 tests:  return l->resolveGetter(engine, o);Executed by: 
 | 678495 | ||||||||||||||||||
| 169 | return l->resolvePrimitiveGetter(engine, object); executed 11972 times by 1 test:  return l->resolvePrimitiveGetter(engine, object);Executed by: 
 | 11972 | ||||||||||||||||||
| 170 | } | - | ||||||||||||||||||
| 171 | - | |||||||||||||||||||
| 172 | ReturnedValue Lookup::getterTwoClasses(Lookup *l, ExecutionEngine *engine, const Value &object) | - | ||||||||||||||||||
| 173 | { | - | ||||||||||||||||||
| 174 | if (const Object *o = object.as<Object>()) { 
 | 0-1884 | ||||||||||||||||||
| 175 | Lookup first = *l; | - | ||||||||||||||||||
| 176 | Lookup second = *l; | - | ||||||||||||||||||
| 177 | - | |||||||||||||||||||
| 178 | ReturnedValue result = second.resolveGetter(engine, o); | - | ||||||||||||||||||
| 179 | - | |||||||||||||||||||
| 180 | if (first.getter == getter0Inline && (second.getter == getter0Inline || second.getter == getter0MemberData)) { 
 
 
 | 0-1663 | ||||||||||||||||||
| 181 | l->objectLookupTwoClasses.ic = first.objectLookup.ic; | - | ||||||||||||||||||
| 182 | l->objectLookupTwoClasses.ic2 = second.objectLookup.ic; | - | ||||||||||||||||||
| 183 | l->objectLookupTwoClasses.offset = first.objectLookup.offset; | - | ||||||||||||||||||
| 184 | l->objectLookupTwoClasses.offset2 = second.objectLookup.offset; | - | ||||||||||||||||||
| 185 | l->getter = second.getter == getter0Inline ? getter0Inlinegetter0Inline : getter0Inlinegetter0MemberData; 
 | 0-188 | ||||||||||||||||||
| 186 | return result; executed 188 times by 2 tests:  return result;Executed by: 
 | 188 | ||||||||||||||||||
| 187 | } | - | ||||||||||||||||||
| 188 | if (first.getter == getter0MemberData && (second.getter == getter0Inline || second.getter == getter0MemberData)) { 
 
 
 | 0-1697 | ||||||||||||||||||
| 189 | l->objectLookupTwoClasses.ic = second.objectLookup.ic; | - | ||||||||||||||||||
| 190 | l->objectLookupTwoClasses.ic2 = first.objectLookup.ic; | - | ||||||||||||||||||
| 191 | l->objectLookupTwoClasses.offset = second.objectLookup.offset; | - | ||||||||||||||||||
| 192 | l->objectLookupTwoClasses.offset2 = first.objectLookup.offset; | - | ||||||||||||||||||
| 193 | l->getter = second.getter == getter0Inline ? getter0Inlinegetter0MemberData : getter0MemberDatagetter0MemberData; 
 | 0 | ||||||||||||||||||
| 194 | return result; never executed:  return result; | 0 | ||||||||||||||||||
| 195 | } | - | ||||||||||||||||||
| 196 | if (first.getter == getterProto && second.getter == getterProto) { 
 
 | 0-1203 | ||||||||||||||||||
| 197 | l->protoLookupTwoClasses.protoId = first.protoLookup.protoId; | - | ||||||||||||||||||
| 198 | l->protoLookupTwoClasses.protoId2 = second.protoLookup.protoId; | - | ||||||||||||||||||
| 199 | l->protoLookupTwoClasses.data = first.protoLookup.data; | - | ||||||||||||||||||
| 200 | l->protoLookupTwoClasses.data2 = second.protoLookup.data; | - | ||||||||||||||||||
| 201 | l->getter = getterProtoTwoClasses; | - | ||||||||||||||||||
| 202 | return result; executed 1202 times by 1 test:  return result;Executed by: 
 | 1202 | ||||||||||||||||||
| 203 | } | - | ||||||||||||||||||
| 204 | if (first.getter == getterProtoAccessor && second.getter == getterProtoAccessor) { 
 
 | 0-460 | ||||||||||||||||||
| 205 | l->protoLookupTwoClasses.protoId = first.protoLookup.protoId; | - | ||||||||||||||||||
| 206 | l->protoLookupTwoClasses.protoId2 = second.protoLookup.protoId; | - | ||||||||||||||||||
| 207 | l->protoLookupTwoClasses.data = first.protoLookup.data; | - | ||||||||||||||||||
| 208 | l->protoLookupTwoClasses.data2 = second.protoLookup.data; | - | ||||||||||||||||||
| 209 | l->getter = getterProtoAccessorTwoClasses; | - | ||||||||||||||||||
| 210 | return result; executed 460 times by 1 test:  return result;Executed by: 
 | 460 | ||||||||||||||||||
| 211 | } | - | ||||||||||||||||||
| 212 | - | |||||||||||||||||||
| 213 | } executed 34 times by 2 tests:  end of blockExecuted by: 
 | 34 | ||||||||||||||||||
| 214 | - | |||||||||||||||||||
| 215 | l->getter = getterFallback; | - | ||||||||||||||||||
| 216 | return getterFallback(l, engine, object); executed 34 times by 2 tests:  return getterFallback(l, engine, object);Executed by: 
 | 34 | ||||||||||||||||||
| 217 | } | - | ||||||||||||||||||
| 218 | - | |||||||||||||||||||
| 219 | ReturnedValue Lookup::getterFallback(Lookup *l, ExecutionEngine *engine, const Value &object) | - | ||||||||||||||||||
| 220 | { | - | ||||||||||||||||||
| 221 | QV4::Scope scope(engine); | - | ||||||||||||||||||
| 222 | QV4::ScopedObject o(scope, object.toObject(scope.engine)); | - | ||||||||||||||||||
| 223 | if (!o) 
 | 0-44582 | ||||||||||||||||||
| 224 | return Encode::undefined(); never executed:  return Encode::undefined(); | 0 | ||||||||||||||||||
| 225 | ScopedString name(scope, engine->currentStackFrame->v4Function->compilationUnit->runtimeStrings[l->nameIndex]); | - | ||||||||||||||||||
| 226 | return o->get(name); executed 44589 times by 3 tests:  return o->get(name);Executed by: 
 | 44589 | ||||||||||||||||||
| 227 | } | - | ||||||||||||||||||
| 228 | - | |||||||||||||||||||
| 229 | ReturnedValue Lookup::getter0MemberData(Lookup *l, ExecutionEngine *engine, const Value &object) | - | ||||||||||||||||||
| 230 | { | - | ||||||||||||||||||
| 231 | // we can safely cast to a QV4::Object here. If object is actually a string, | - | ||||||||||||||||||
| 232 | // the internal class won't match | - | ||||||||||||||||||
| 233 | Heap::Object *o = static_cast<Heap::Object *>(object.heapObject()); | - | ||||||||||||||||||
| 234 | if (o) { 
 | 0-22363577 | ||||||||||||||||||
| 235 | if (l->objectLookup.ic == o->internalClass) 
 | 0-22471102 | ||||||||||||||||||
| 236 | return o->memberData->values.data()[l->objectLookup.offset].asReturnedValue(); executed 22470852 times by 2 tests:  return o->memberData->values.data()[l->objectLookup.offset].asReturnedValue();Executed by: 
 | 22470852 | ||||||||||||||||||
| 237 | } never executed:  end of block | 0 | ||||||||||||||||||
| 238 | return getterTwoClasses(l, engine, object); never executed:  return getterTwoClasses(l, engine, object); | 0 | ||||||||||||||||||
| 239 | } | - | ||||||||||||||||||
| 240 | - | |||||||||||||||||||
| 241 | ReturnedValue Lookup::getter0Inline(Lookup *l, ExecutionEngine *engine, const Value &object) | - | ||||||||||||||||||
| 242 | { | - | ||||||||||||||||||
| 243 | // we can safely cast to a QV4::Object here. If object is actually a string, | - | ||||||||||||||||||
| 244 | // the internal class won't match | - | ||||||||||||||||||
| 245 | Heap::Object *o = static_cast<Heap::Object *>(object.heapObject()); | - | ||||||||||||||||||
| 246 | if (o) { 
 | 0-2703476 | ||||||||||||||||||
| 247 | if (l->objectLookup.ic == o->internalClass) 
 | 222-2703887 | ||||||||||||||||||
| 248 | return o->inlinePropertyDataWithOffset(l->objectLookup.offset)->asReturnedValue(); executed 2703409 times by 7 tests:  return o->inlinePropertyDataWithOffset(l->objectLookup.offset)->asReturnedValue();Executed by: 
 | 2703409 | ||||||||||||||||||
| 249 | } executed 222 times by 3 tests:  end of blockExecuted by: 
 | 222 | ||||||||||||||||||
| 250 | return getterTwoClasses(l, engine, object); executed 222 times by 3 tests:  return getterTwoClasses(l, engine, object);Executed by: 
 | 222 | ||||||||||||||||||
| 251 | } | - | ||||||||||||||||||
| 252 | - | |||||||||||||||||||
| 253 | ReturnedValue Lookup::getterProto(Lookup *l, ExecutionEngine *engine, const Value &object) | - | ||||||||||||||||||
| 254 | { | - | ||||||||||||||||||
| 255 | // we can safely cast to a QV4::Object here. If object is actually a string, | - | ||||||||||||||||||
| 256 | // the internal class won't match | - | ||||||||||||||||||
| 257 | Heap::Object *o = static_cast<Heap::Object *>(object.heapObject()); | - | ||||||||||||||||||
| 258 | if (o) { 
 | 0-127837 | ||||||||||||||||||
| 259 | if (l->protoLookup.protoId == o->internalClass->protoId) 
 | 1204-126767 | ||||||||||||||||||
| 260 | return l->protoLookup.data->asReturnedValue(); executed 126710 times by 1 test:  return l->protoLookup.data->asReturnedValue();Executed by: 
 | 126710 | ||||||||||||||||||
| 261 | } executed 1203 times by 1 test:  end of blockExecuted by: 
 | 1203 | ||||||||||||||||||
| 262 | return getterTwoClasses(l, engine, object); executed 1203 times by 1 test:  return getterTwoClasses(l, engine, object);Executed by: 
 | 1203 | ||||||||||||||||||
| 263 | } | - | ||||||||||||||||||
| 264 | - | |||||||||||||||||||
| 265 | ReturnedValue Lookup::getter0Inlinegetter0Inline(Lookup *l, ExecutionEngine *engine, const Value &object) | - | ||||||||||||||||||
| 266 | { | - | ||||||||||||||||||
| 267 | // we can safely cast to a QV4::Object here. If object is actually a string, | - | ||||||||||||||||||
| 268 | // the internal class won't match | - | ||||||||||||||||||
| 269 | Heap::Object *o = static_cast<Heap::Object *>(object.heapObject()); | - | ||||||||||||||||||
| 270 | if (o) { 
 | 0-196 | ||||||||||||||||||
| 271 | if (l->objectLookupTwoClasses.ic == o->internalClass) 
 | 32-164 | ||||||||||||||||||
| 272 | return o->inlinePropertyDataWithOffset(l->objectLookupTwoClasses.offset)->asReturnedValue(); executed 32 times by 1 test:  return o->inlinePropertyDataWithOffset(l->objectLookupTwoClasses.offset)->asReturnedValue();Executed by: 
 | 32 | ||||||||||||||||||
| 273 | if (l->objectLookupTwoClasses.ic2 == o->internalClass) 
 | 32-132 | ||||||||||||||||||
| 274 | return o->inlinePropertyDataWithOffset(l->objectLookupTwoClasses.offset2)->asReturnedValue(); executed 32 times by 1 test:  return o->inlinePropertyDataWithOffset(l->objectLookupTwoClasses.offset2)->asReturnedValue();Executed by: 
 | 32 | ||||||||||||||||||
| 275 | } executed 132 times by 2 tests:  end of blockExecuted by: 
 | 132 | ||||||||||||||||||
| 276 | l->getter = getterFallback; | - | ||||||||||||||||||
| 277 | return getterFallback(l, engine, object); executed 132 times by 2 tests:  return getterFallback(l, engine, object);Executed by: 
 | 132 | ||||||||||||||||||
| 278 | } | - | ||||||||||||||||||
| 279 | - | |||||||||||||||||||
| 280 | ReturnedValue Lookup::getter0Inlinegetter0MemberData(Lookup *l, ExecutionEngine *engine, const Value &object) | - | ||||||||||||||||||
| 281 | { | - | ||||||||||||||||||
| 282 | // we can safely cast to a QV4::Object here. If object is actually a string, | - | ||||||||||||||||||
| 283 | // the internal class won't match | - | ||||||||||||||||||
| 284 | Heap::Object *o = static_cast<Heap::Object *>(object.heapObject()); | - | ||||||||||||||||||
| 285 | if (o) { 
 | 0 | ||||||||||||||||||
| 286 | if (l->objectLookupTwoClasses.ic == o->internalClass) 
 | 0 | ||||||||||||||||||
| 287 | return o->inlinePropertyDataWithOffset(l->objectLookupTwoClasses.offset)->asReturnedValue(); never executed:  return o->inlinePropertyDataWithOffset(l->objectLookupTwoClasses.offset)->asReturnedValue(); | 0 | ||||||||||||||||||
| 288 | if (l->objectLookupTwoClasses.ic2 == o->internalClass) 
 | 0 | ||||||||||||||||||
| 289 | return o->memberData->values.data()[l->objectLookupTwoClasses.offset2].asReturnedValue(); never executed:  return o->memberData->values.data()[l->objectLookupTwoClasses.offset2].asReturnedValue(); | 0 | ||||||||||||||||||
| 290 | } never executed:  end of block | 0 | ||||||||||||||||||
| 291 | l->getter = getterFallback; | - | ||||||||||||||||||
| 292 | return getterFallback(l, engine, object); never executed:  return getterFallback(l, engine, object); | 0 | ||||||||||||||||||
| 293 | } | - | ||||||||||||||||||
| 294 | - | |||||||||||||||||||
| 295 | ReturnedValue Lookup::getter0MemberDatagetter0MemberData(Lookup *l, ExecutionEngine *engine, const Value &object) | - | ||||||||||||||||||
| 296 | { | - | ||||||||||||||||||
| 297 | // we can safely cast to a QV4::Object here. If object is actually a string, | - | ||||||||||||||||||
| 298 | // the internal class won't match | - | ||||||||||||||||||
| 299 | Heap::Object *o = static_cast<Heap::Object *>(object.heapObject()); | - | ||||||||||||||||||
| 300 | if (o) { 
 | 0 | ||||||||||||||||||
| 301 | if (l->objectLookupTwoClasses.ic == o->internalClass) 
 | 0 | ||||||||||||||||||
| 302 | return o->memberData->values.data()[l->objectLookupTwoClasses.offset].asReturnedValue(); never executed:  return o->memberData->values.data()[l->objectLookupTwoClasses.offset].asReturnedValue(); | 0 | ||||||||||||||||||
| 303 | if (l->objectLookupTwoClasses.ic2 == o->internalClass) 
 | 0 | ||||||||||||||||||
| 304 | return o->memberData->values.data()[l->objectLookupTwoClasses.offset2].asReturnedValue(); never executed:  return o->memberData->values.data()[l->objectLookupTwoClasses.offset2].asReturnedValue(); | 0 | ||||||||||||||||||
| 305 | } never executed:  end of block | 0 | ||||||||||||||||||
| 306 | l->getter = getterFallback; | - | ||||||||||||||||||
| 307 | return getterFallback(l, engine, object); never executed:  return getterFallback(l, engine, object); | 0 | ||||||||||||||||||
| 308 | } | - | ||||||||||||||||||
| 309 | - | |||||||||||||||||||
| 310 | ReturnedValue Lookup::getterProtoTwoClasses(Lookup *l, ExecutionEngine *engine, const Value &object) | - | ||||||||||||||||||
| 311 | { | - | ||||||||||||||||||
| 312 | // we can safely cast to a QV4::Object here. If object is actually a string, | - | ||||||||||||||||||
| 313 | // the internal class won't match | - | ||||||||||||||||||
| 314 | Heap::Object *o = static_cast<Heap::Object *>(object.heapObject()); | - | ||||||||||||||||||
| 315 | if (o) { 
 | 0-11282 | ||||||||||||||||||
| 316 | if (l->protoLookupTwoClasses.protoId == o->internalClass->protoId) 
 | 16-11269 | ||||||||||||||||||
| 317 | return l->protoLookupTwoClasses.data->asReturnedValue(); executed 16 times by 1 test:  return l->protoLookupTwoClasses.data->asReturnedValue();Executed by: 
 | 16 | ||||||||||||||||||
| 318 | if (l->protoLookupTwoClasses.protoId2 == o->internalClass->protoId) 
 | 628-10646 | ||||||||||||||||||
| 319 | return l->protoLookupTwoClasses.data2->asReturnedValue(); executed 628 times by 1 test:  return l->protoLookupTwoClasses.data2->asReturnedValue();Executed by: 
 | 628 | ||||||||||||||||||
| 320 | return getterFallback(l, engine, object); executed 10646 times by 1 test:  return getterFallback(l, engine, object);Executed by: 
 | 10646 | ||||||||||||||||||
| 321 | } | - | ||||||||||||||||||
| 322 | l->getter = getterFallback; | - | ||||||||||||||||||
| 323 | return getterFallback(l, engine, object); never executed:  return getterFallback(l, engine, object); | 0 | ||||||||||||||||||
| 324 | } | - | ||||||||||||||||||
| 325 | - | |||||||||||||||||||
| 326 | ReturnedValue Lookup::getterAccessor(Lookup *l, ExecutionEngine *engine, const Value &object) | - | ||||||||||||||||||
| 327 | { | - | ||||||||||||||||||
| 328 | // we can safely cast to a QV4::Object here. If object is actually a string, | - | ||||||||||||||||||
| 329 | // the internal class won't match | - | ||||||||||||||||||
| 330 | Heap::Object *o = static_cast<Heap::Object *>(object.heapObject()); | - | ||||||||||||||||||
| 331 | if (o) { 
 | 0-1639 | ||||||||||||||||||
| 332 | if (l->objectLookup.ic == o->internalClass) { 
 | 12-1631 | ||||||||||||||||||
| 333 | const Value *getter = o->propertyData(l->objectLookup.offset); | - | ||||||||||||||||||
| 334 | if (!getter->isFunctionObject()) // ### catch at resolve time 
 | 156-1474 | ||||||||||||||||||
| 335 | return Encode::undefined(); executed 156 times by 1 test:  return Encode::undefined();Executed by: 
 | 156 | ||||||||||||||||||
| 336 | - | |||||||||||||||||||
| 337 | return static_cast<const FunctionObject *>(getter)->call(&object, nullptr, 0); executed 1472 times by 1 test:  return static_cast<const FunctionObject *>(getter)->call(&object, nullptr, 0);Executed by: 
 | 1472 | ||||||||||||||||||
| 338 | } | - | ||||||||||||||||||
| 339 | } executed 12 times by 1 test:  end of blockExecuted by: 
 | 12 | ||||||||||||||||||
| 340 | l->getter = getterFallback; | - | ||||||||||||||||||
| 341 | return getterFallback(l, engine, object); executed 12 times by 1 test:  return getterFallback(l, engine, object);Executed by: 
 | 12 | ||||||||||||||||||
| 342 | } | - | ||||||||||||||||||
| 343 | - | |||||||||||||||||||
| 344 | ReturnedValue Lookup::getterProtoAccessor(Lookup *l, ExecutionEngine *engine, const Value &object) | - | ||||||||||||||||||
| 345 | { | - | ||||||||||||||||||
| 346 | // we can safely cast to a QV4::Object here. If object is actually a string, | - | ||||||||||||||||||
| 347 | // the internal class won't match | - | ||||||||||||||||||
| 348 | Heap::Object *o = static_cast<Heap::Object *>(object.heapObject()); | - | ||||||||||||||||||
| 349 | if (o && l->protoLookup.protoId == o->internalClass->protoId) { 
 
 | 0-6050 | ||||||||||||||||||
| 350 | const Value *getter = l->protoLookup.data; | - | ||||||||||||||||||
| 351 | if (!getter->isFunctionObject()) // ### catch at resolve time 
 | 4-5587 | ||||||||||||||||||
| 352 | return Encode::undefined(); executed 4 times by 1 test:  return Encode::undefined();Executed by: 
 | 4 | ||||||||||||||||||
| 353 | - | |||||||||||||||||||
| 354 | return static_cast<const FunctionObject *>(getter)->call(&object, nullptr, 0); executed 5587 times by 1 test:  return static_cast<const FunctionObject *>(getter)->call(&object, nullptr, 0);Executed by: 
 | 5587 | ||||||||||||||||||
| 355 | } | - | ||||||||||||||||||
| 356 | return getterTwoClasses(l, engine, object); executed 459 times by 1 test:  return getterTwoClasses(l, engine, object);Executed by: 
 | 459 | ||||||||||||||||||
| 357 | } | - | ||||||||||||||||||
| 358 | - | |||||||||||||||||||
| 359 | ReturnedValue Lookup::getterProtoAccessorTwoClasses(Lookup *l, ExecutionEngine *engine, const Value &object) | - | ||||||||||||||||||
| 360 | { | - | ||||||||||||||||||
| 361 | // we can safely cast to a QV4::Object here. If object is actually a string, | - | ||||||||||||||||||
| 362 | // the internal class won't match | - | ||||||||||||||||||
| 363 | Heap::Object *o = static_cast<Heap::Object *>(object.heapObject()); | - | ||||||||||||||||||
| 364 | if (o) { 
 | 0-2837 | ||||||||||||||||||
| 365 | const Value *getter = nullptr; | - | ||||||||||||||||||
| 366 | if (l->protoLookupTwoClasses.protoId == o->internalClass->protoId) 
 | 64-2774 | ||||||||||||||||||
| 367 | getter = l->protoLookupTwoClasses.data; executed 64 times by 1 test:  getter = l->protoLookupTwoClasses.data;Executed by: 
 | 64 | ||||||||||||||||||
| 368 | else if (l->protoLookupTwoClasses.protoId2 == o->internalClass->protoId) 
 | 420-2355 | ||||||||||||||||||
| 369 | getter = l->protoLookupTwoClasses.data2; executed 2356 times by 1 test:  getter = l->protoLookupTwoClasses.data2;Executed by: 
 | 2356 | ||||||||||||||||||
| 370 | if (getter) { 
 | 419-2417 | ||||||||||||||||||
| 371 | if (!getter->isFunctionObject()) // ### catch at resolve time 
 | 0-2419 | ||||||||||||||||||
| 372 | return Encode::undefined(); never executed:  return Encode::undefined(); | 0 | ||||||||||||||||||
| 373 | - | |||||||||||||||||||
| 374 | return static_cast<const FunctionObject *>(getter)->call(&object, nullptr, 0); executed 2418 times by 1 test:  return static_cast<const FunctionObject *>(getter)->call(&object, nullptr, 0);Executed by: 
 | 2418 | ||||||||||||||||||
| 375 | } | - | ||||||||||||||||||
| 376 | } executed 419 times by 1 test:  end of blockExecuted by: 
 | 419 | ||||||||||||||||||
| 377 | l->getter = getterFallback; | - | ||||||||||||||||||
| 378 | return getterFallback(l, engine, object); executed 419 times by 1 test:  return getterFallback(l, engine, object);Executed by: 
 | 419 | ||||||||||||||||||
| 379 | } | - | ||||||||||||||||||
| 380 | - | |||||||||||||||||||
| 381 | ReturnedValue Lookup::getterIndexed(Lookup *l, ExecutionEngine *engine, const Value &object) | - | ||||||||||||||||||
| 382 | { | - | ||||||||||||||||||
| 383 | Object *o = object.objectValue(); | - | ||||||||||||||||||
| 384 | if (o) { 
 | 0-679 | ||||||||||||||||||
| 385 | Heap::Object *ho = o->d(); | - | ||||||||||||||||||
| 386 | if (ho->arrayData && ho->arrayData->type == Heap::ArrayData::Simple) { 
 | 0-680 | ||||||||||||||||||
| 387 | Heap::SimpleArrayData *s = ho->arrayData.cast<Heap::SimpleArrayData>(); | - | ||||||||||||||||||
| 388 | if (l->indexedLookup.index < s->values.size) 
 | 168-511 | ||||||||||||||||||
| 389 | if (!s->data(l->indexedLookup.index).isEmpty()) 
 | 0-512 | ||||||||||||||||||
| 390 | return s->data(l->indexedLookup.index).asReturnedValue(); executed 512 times by 1 test:  return s->data(l->indexedLookup.index).asReturnedValue();Executed by: 
 | 512 | ||||||||||||||||||
| 391 | } executed 168 times by 1 test:  end of blockExecuted by: 
 | 168 | ||||||||||||||||||
| 392 | return o->get(l->indexedLookup.index); executed 168 times by 1 test:  return o->get(l->indexedLookup.index);Executed by: 
 | 168 | ||||||||||||||||||
| 393 | } | - | ||||||||||||||||||
| 394 | l->getter = getterFallback; | - | ||||||||||||||||||
| 395 | return getterFallback(l, engine, object); never executed:  return getterFallback(l, engine, object); | 0 | ||||||||||||||||||
| 396 | - | |||||||||||||||||||
| 397 | } | - | ||||||||||||||||||
| 398 | - | |||||||||||||||||||
| 399 | ReturnedValue Lookup::primitiveGetterProto(Lookup *l, ExecutionEngine *engine, const Value &object) | - | ||||||||||||||||||
| 400 | { | - | ||||||||||||||||||
| 401 | if (object.type() == l->primitiveLookup.type) { 
 | 0-1613308 | ||||||||||||||||||
| 402 | Heap::Object *o = l->primitiveLookup.proto; | - | ||||||||||||||||||
| 403 | if (l->primitiveLookup.protoId == o->internalClass->protoId) 
 | 0-1614000 | ||||||||||||||||||
| 404 | return l->primitiveLookup.data->asReturnedValue(); executed 1614101 times by 1 test:  return l->primitiveLookup.data->asReturnedValue();Executed by: 
 | 1614101 | ||||||||||||||||||
| 405 | } never executed:  end of block | 0 | ||||||||||||||||||
| 406 | l->getter = getterGeneric; | - | ||||||||||||||||||
| 407 | return getterGeneric(l, engine, object); never executed:  return getterGeneric(l, engine, object); | 0 | ||||||||||||||||||
| 408 | } | - | ||||||||||||||||||
| 409 | - | |||||||||||||||||||
| 410 | ReturnedValue Lookup::primitiveGetterAccessor(Lookup *l, ExecutionEngine *engine, const Value &object) | - | ||||||||||||||||||
| 411 | { | - | ||||||||||||||||||
| 412 | if (object.type() == l->primitiveLookup.type) { 
 | 0-16 | ||||||||||||||||||
| 413 | Heap::Object *o = l->primitiveLookup.proto; | - | ||||||||||||||||||
| 414 | if (l->primitiveLookup.protoId == o->internalClass->protoId) { 
 | 0-16 | ||||||||||||||||||
| 415 | const Value *getter = l->primitiveLookup.data; | - | ||||||||||||||||||
| 416 | if (!getter->isFunctionObject()) // ### catch at resolve time 
 | 0-16 | ||||||||||||||||||
| 417 | return Encode::undefined(); never executed:  return Encode::undefined(); | 0 | ||||||||||||||||||
| 418 | - | |||||||||||||||||||
| 419 | return static_cast<const FunctionObject *>(getter)->call(&object, nullptr, 0); executed 16 times by 1 test:  return static_cast<const FunctionObject *>(getter)->call(&object, nullptr, 0);Executed by: 
 | 16 | ||||||||||||||||||
| 420 | } | - | ||||||||||||||||||
| 421 | } never executed:  end of block | 0 | ||||||||||||||||||
| 422 | l->getter = getterGeneric; | - | ||||||||||||||||||
| 423 | return getterGeneric(l, engine, object); never executed:  return getterGeneric(l, engine, object); | 0 | ||||||||||||||||||
| 424 | } | - | ||||||||||||||||||
| 425 | - | |||||||||||||||||||
| 426 | ReturnedValue Lookup::stringLengthGetter(Lookup *l, ExecutionEngine *engine, const Value &object) | - | ||||||||||||||||||
| 427 | { | - | ||||||||||||||||||
| 428 | if (const String *s = object.as<String>()) 
 | 0-1205284 | ||||||||||||||||||
| 429 | return Encode(s->d()->length()); executed 1205228 times by 1 test:  return Encode(s->d()->length());Executed by: 
 | 1205228 | ||||||||||||||||||
| 430 | - | |||||||||||||||||||
| 431 | l->getter = getterGeneric; | - | ||||||||||||||||||
| 432 | return getterGeneric(l, engine, object); never executed:  return getterGeneric(l, engine, object); | 0 | ||||||||||||||||||
| 433 | } | - | ||||||||||||||||||
| 434 | - | |||||||||||||||||||
| 435 | ReturnedValue Lookup::globalGetterGeneric(Lookup *l, ExecutionEngine *engine) | - | ||||||||||||||||||
| 436 | { | - | ||||||||||||||||||
| 437 | return l->resolveGlobalGetter(engine); executed 1324348 times by 7 tests:  return l->resolveGlobalGetter(engine);Executed by: 
 | 1324348 | ||||||||||||||||||
| 438 | } | - | ||||||||||||||||||
| 439 | - | |||||||||||||||||||
| 440 | ReturnedValue Lookup::globalGetterProto(Lookup *l, ExecutionEngine *engine) | - | ||||||||||||||||||
| 441 | { | - | ||||||||||||||||||
| 442 | Heap::Object *o = engine->globalObject->d(); | - | ||||||||||||||||||
| 443 | if (l->protoLookup.protoId == o->internalClass->protoId) 
 | 112-243663389 | ||||||||||||||||||
| 444 | return l->protoLookup.data->asReturnedValue(); executed 243702438 times by 7 tests:  return l->protoLookup.data->asReturnedValue();Executed by: 
 | 243702438 | ||||||||||||||||||
| 445 | l->globalGetter = globalGetterGeneric; | - | ||||||||||||||||||
| 446 | return globalGetterGeneric(l, engine); executed 112 times by 1 test:  return globalGetterGeneric(l, engine);Executed by: 
 | 112 | ||||||||||||||||||
| 447 | } | - | ||||||||||||||||||
| 448 | - | |||||||||||||||||||
| 449 | ReturnedValue Lookup::globalGetterProtoAccessor(Lookup *l, ExecutionEngine *engine) | - | ||||||||||||||||||
| 450 | { | - | ||||||||||||||||||
| 451 | Heap::Object *o = engine->globalObject->d(); | - | ||||||||||||||||||
| 452 | if (l->protoLookup.protoId == o->internalClass->protoId) { 
 | 0-60 | ||||||||||||||||||
| 453 | const Value *getter = l->protoLookup.data; | - | ||||||||||||||||||
| 454 | if (!getter->isFunctionObject()) // ### catch at resolve time 
 | 0-60 | ||||||||||||||||||
| 455 | return Encode::undefined(); never executed:  return Encode::undefined(); | 0 | ||||||||||||||||||
| 456 | - | |||||||||||||||||||
| 457 | return static_cast<const FunctionObject *>(getter)->call(engine->globalObject, nullptr, 0); executed 60 times by 1 test:  return static_cast<const FunctionObject *>(getter)->call(engine->globalObject, nullptr, 0);Executed by: 
 | 60 | ||||||||||||||||||
| 458 | } | - | ||||||||||||||||||
| 459 | l->globalGetter = globalGetterGeneric; | - | ||||||||||||||||||
| 460 | return globalGetterGeneric(l, engine); never executed:  return globalGetterGeneric(l, engine); | 0 | ||||||||||||||||||
| 461 | } | - | ||||||||||||||||||
| 462 | - | |||||||||||||||||||
| 463 | bool Lookup::resolveSetter(ExecutionEngine *engine, Object *object, const Value &value) | - | ||||||||||||||||||
| 464 | { | - | ||||||||||||||||||
| 465 | Scope scope(engine); | - | ||||||||||||||||||
| 466 | ScopedString name(scope, scope.engine->currentStackFrame->v4Function->compilationUnit->runtimeStrings[nameIndex]); | - | ||||||||||||||||||
| 467 | - | |||||||||||||||||||
| 468 | Heap::InternalClass *c = object->internalClass(); | - | ||||||||||||||||||
| 469 | PropertyKey key = name->toPropertyKey(); | - | ||||||||||||||||||
| 470 | uint idx = c->find(key); | - | ||||||||||||||||||
| 471 | if (idx != UINT_MAX) { 
 | 7130-511786 | ||||||||||||||||||
| 472 | if (object->isArrayObject() && idx == Heap::ArrayObject::LengthPropertyIndex) { 
 
 | 124-6452 | ||||||||||||||||||
| 473 | setter = arrayLengthSetter; | - | ||||||||||||||||||
| 474 | return setter(this, engine, *object, value); executed 541 times by 1 test:  return setter(this, engine, *object, value);Executed by: 
 | 541 | ||||||||||||||||||
| 475 | } else if (object->internalClass()->propertyData[idx].isData() && object->internalClass()->propertyData[idx].isWritable()) { 
 
 | 49-5719 | ||||||||||||||||||
| 476 | objectLookup.ic = object->internalClass(); | - | ||||||||||||||||||
| 477 | objectLookup.offset = idx; | - | ||||||||||||||||||
| 478 | setter = idx < object->d()->vtable()->nInlineProperties ? Lookup::setter0Inline : Lookup::setter0; 
 | 1665-3996 | ||||||||||||||||||
| 479 | return setter(this, engine, *object, value); executed 5661 times by 1 test:  return setter(this, engine, *object, value);Executed by: 
 | 5661 | ||||||||||||||||||
| 480 | } else { | - | ||||||||||||||||||
| 481 | // ### handle setter | - | ||||||||||||||||||
| 482 | setter = setterFallback; | - | ||||||||||||||||||
| 483 | } executed 909 times by 1 test:  end of blockExecuted by: 
 | 909 | ||||||||||||||||||
| 484 | return setter(this, engine, *object, value); executed 910 times by 1 test:  return setter(this, engine, *object, value);Executed by: 
 | 910 | ||||||||||||||||||
| 485 | } | - | ||||||||||||||||||
| 486 | - | |||||||||||||||||||
| 487 | insertionLookup.protoId = c->protoId; | - | ||||||||||||||||||
| 488 | if (!object->put(key, value)) { 
 | 205-511615 | ||||||||||||||||||
| 489 | setter = Lookup::setterFallback; | - | ||||||||||||||||||
| 490 | return false; executed 205 times by 1 test:  return false;Executed by: 
 | 205 | ||||||||||||||||||
| 491 | } | - | ||||||||||||||||||
| 492 | - | |||||||||||||||||||
| 493 | if (object->internalClass() == c) { 
 | 84-511675 | ||||||||||||||||||
| 494 | // ### setter in the prototype, should handle this | - | ||||||||||||||||||
| 495 | setter = setterFallback; | - | ||||||||||||||||||
| 496 | return true; executed 84 times by 1 test:  return true;Executed by: 
 | 84 | ||||||||||||||||||
| 497 | } | - | ||||||||||||||||||
| 498 | idx = object->internalClass()->find(key); | - | ||||||||||||||||||
| 499 | if (idx == UINT_MAX) { // ### can this even happen? 
 | 0-511550 | ||||||||||||||||||
| 500 | setter = setterFallback; | - | ||||||||||||||||||
| 501 | return false; never executed:  return false; | 0 | ||||||||||||||||||
| 502 | } | - | ||||||||||||||||||
| 503 | insertionLookup.newClass = object->internalClass(); | - | ||||||||||||||||||
| 504 | insertionLookup.offset = idx; | - | ||||||||||||||||||
| 505 | setter = setterInsert; | - | ||||||||||||||||||
| 506 | return true; executed 511521 times by 1 test:  return true;Executed by: 
 | 511521 | ||||||||||||||||||
| 507 | } | - | ||||||||||||||||||
| 508 | - | |||||||||||||||||||
| 509 | bool Lookup::setterGeneric(Lookup *l, ExecutionEngine *engine, Value &object, const Value &value) | - | ||||||||||||||||||
| 510 | { | - | ||||||||||||||||||
| 511 | if (object.isObject()) 
 | 20-517921 | ||||||||||||||||||
| 512 | return l->resolveSetter(engine, static_cast<Object *>(&object), value); executed 517876 times by 1 test:  return l->resolveSetter(engine, static_cast<Object *>(&object), value);Executed by: 
 | 517876 | ||||||||||||||||||
| 513 | - | |||||||||||||||||||
| 514 | Scope scope(engine); | - | ||||||||||||||||||
| 515 | ScopedObject o(scope, RuntimeHelpers::convertToObject(scope.engine, object)); | - | ||||||||||||||||||
| 516 | if (!o) // type error 
 | 4-16 | ||||||||||||||||||
| 517 | return false; executed 4 times by 1 test:  return false;Executed by: 
 | 4 | ||||||||||||||||||
| 518 | ScopedString name(scope, engine->currentStackFrame->v4Function->compilationUnit->runtimeStrings[l->nameIndex]); | - | ||||||||||||||||||
| 519 | return o->put(name, value); executed 16 times by 1 test:  return o->put(name, value);Executed by: 
 | 16 | ||||||||||||||||||
| 520 | } | - | ||||||||||||||||||
| 521 | - | |||||||||||||||||||
| 522 | bool Lookup::setterTwoClasses(Lookup *l, ExecutionEngine *engine, Value &object, const Value &value) | - | ||||||||||||||||||
| 523 | { | - | ||||||||||||||||||
| 524 | Lookup first = *l; | - | ||||||||||||||||||
| 525 | Lookup second = *l; | - | ||||||||||||||||||
| 526 | - | |||||||||||||||||||
| 527 | if (object.isObject()) { 
 | 0-60 | ||||||||||||||||||
| 528 | if (!l->resolveSetter(engine, static_cast<Object *>(&object), value)) { 
 | 0-60 | ||||||||||||||||||
| 529 | l->setter = setterFallback; | - | ||||||||||||||||||
| 530 | return false; never executed:  return false; | 0 | ||||||||||||||||||
| 531 | } | - | ||||||||||||||||||
| 532 | - | |||||||||||||||||||
| 533 | if (l->setter == Lookup::setter0 || l->setter == Lookup::setter0Inline) { 
 
 | 0-60 | ||||||||||||||||||
| 534 | l->objectLookupTwoClasses.ic = first.objectLookup.ic; | - | ||||||||||||||||||
| 535 | l->objectLookupTwoClasses.ic2 = second.objectLookup.ic; | - | ||||||||||||||||||
| 536 | l->objectLookupTwoClasses.offset = first.objectLookup.offset; | - | ||||||||||||||||||
| 537 | l->objectLookupTwoClasses.offset2 = second.objectLookup.offset; | - | ||||||||||||||||||
| 538 | l->setter = setter0setter0; | - | ||||||||||||||||||
| 539 | return true; executed 60 times by 1 test:  return true;Executed by: 
 | 60 | ||||||||||||||||||
| 540 | } | - | ||||||||||||||||||
| 541 | } never executed:  end of block | 0 | ||||||||||||||||||
| 542 | - | |||||||||||||||||||
| 543 | l->setter = setterFallback; | - | ||||||||||||||||||
| 544 | return setterFallback(l, engine, object, value); never executed:  return setterFallback(l, engine, object, value); | 0 | ||||||||||||||||||
| 545 | } | - | ||||||||||||||||||
| 546 | - | |||||||||||||||||||
| 547 | bool Lookup::setterFallback(Lookup *l, ExecutionEngine *engine, Value &object, const Value &value) | - | ||||||||||||||||||
| 548 | { | - | ||||||||||||||||||
| 549 | QV4::Scope scope(engine); | - | ||||||||||||||||||
| 550 | QV4::ScopedObject o(scope, object.toObject(scope.engine)); | - | ||||||||||||||||||
| 551 | if (!o) 
 | 0-2452 | ||||||||||||||||||
| 552 | return false; never executed:  return false; | 0 | ||||||||||||||||||
| 553 | - | |||||||||||||||||||
| 554 | ScopedString name(scope, engine->currentStackFrame->v4Function->compilationUnit->runtimeStrings[l->nameIndex]); | - | ||||||||||||||||||
| 555 | return o->put(name, value); executed 2454 times by 1 test:  return o->put(name, value);Executed by: 
 | 2454 | ||||||||||||||||||
| 556 | } | - | ||||||||||||||||||
| 557 | - | |||||||||||||||||||
| 558 | bool Lookup::setter0(Lookup *l, ExecutionEngine *engine, Value &object, const Value &value) | - | ||||||||||||||||||
| 559 | { | - | ||||||||||||||||||
| 560 | Heap::Object *o = static_cast<Heap::Object *>(object.heapObject()); | - | ||||||||||||||||||
| 561 | if (o && o->internalClass == l->objectLookup.ic) { 
 
 | 0-1716 | ||||||||||||||||||
| 562 | o->setProperty(engine, l->objectLookup.offset, value); | - | ||||||||||||||||||
| 563 | return true; executed 1709 times by 1 test:  return true;Executed by: 
 | 1709 | ||||||||||||||||||
| 564 | } | - | ||||||||||||||||||
| 565 | - | |||||||||||||||||||
| 566 | return setterTwoClasses(l, engine, object, value); never executed:  return setterTwoClasses(l, engine, object, value); | 0 | ||||||||||||||||||
| 567 | } | - | ||||||||||||||||||
| 568 | - | |||||||||||||||||||
| 569 | bool Lookup::setter0Inline(Lookup *l, ExecutionEngine *engine, Value &object, const Value &value) | - | ||||||||||||||||||
| 570 | { | - | ||||||||||||||||||
| 571 | Heap::Object *o = static_cast<Heap::Object *>(object.heapObject()); | - | ||||||||||||||||||
| 572 | if (o && o->internalClass == l->objectLookup.ic) { 
 
 | 0-4298 | ||||||||||||||||||
| 573 | o->setInlineProperty(engine, l->objectLookup.offset, value); | - | ||||||||||||||||||
| 574 | return true; executed 4232 times by 1 test:  return true;Executed by: 
 | 4232 | ||||||||||||||||||
| 575 | } | - | ||||||||||||||||||
| 576 | - | |||||||||||||||||||
| 577 | return setterTwoClasses(l, engine, object, value); executed 60 times by 1 test:  return setterTwoClasses(l, engine, object, value);Executed by: 
 | 60 | ||||||||||||||||||
| 578 | } | - | ||||||||||||||||||
| 579 | - | |||||||||||||||||||
| 580 | bool Lookup::setter0setter0(Lookup *l, ExecutionEngine *engine, Value &object, const Value &value) | - | ||||||||||||||||||
| 581 | { | - | ||||||||||||||||||
| 582 | Heap::Object *o = static_cast<Heap::Object *>(object.heapObject()); | - | ||||||||||||||||||
| 583 | if (o) { 
 | 0-60 | ||||||||||||||||||
| 584 | if (o->internalClass == l->objectLookupTwoClasses.ic) { 
 | 0-60 | ||||||||||||||||||
| 585 | o->setProperty(engine, l->objectLookupTwoClasses.offset, value); | - | ||||||||||||||||||
| 586 | return true; never executed:  return true; | 0 | ||||||||||||||||||
| 587 | } | - | ||||||||||||||||||
| 588 | if (o->internalClass == l->objectLookupTwoClasses.ic2) { 
 | 0-60 | ||||||||||||||||||
| 589 | o->setProperty(engine, l->objectLookupTwoClasses.offset2, value); | - | ||||||||||||||||||
| 590 | return true; never executed:  return true; | 0 | ||||||||||||||||||
| 591 | } | - | ||||||||||||||||||
| 592 | } executed 60 times by 1 test:  end of blockExecuted by: 
 | 60 | ||||||||||||||||||
| 593 | - | |||||||||||||||||||
| 594 | l->setter = setterFallback; | - | ||||||||||||||||||
| 595 | return setterFallback(l, engine, object, value); executed 60 times by 1 test:  return setterFallback(l, engine, object, value);Executed by: 
 | 60 | ||||||||||||||||||
| 596 | } | - | ||||||||||||||||||
| 597 | - | |||||||||||||||||||
| 598 | bool Lookup::setterInsert(Lookup *l, ExecutionEngine *engine, Value &object, const Value &value) | - | ||||||||||||||||||
| 599 | { | - | ||||||||||||||||||
| 600 | Object *o = static_cast<Object *>(object.managed()); | - | ||||||||||||||||||
| 601 | if (o && o->internalClass()->protoId == l->insertionLookup.protoId) { 
 
 | 0-4599 | ||||||||||||||||||
| 602 | o->setInternalClass(l->insertionLookup.newClass); | - | ||||||||||||||||||
| 603 | o->d()->setProperty(engine, l->insertionLookup.offset, value); | - | ||||||||||||||||||
| 604 | return true; executed 4082 times by 1 test:  return true;Executed by: 
 | 4082 | ||||||||||||||||||
| 605 | } | - | ||||||||||||||||||
| 606 | - | |||||||||||||||||||
| 607 | l->setter = setterFallback; | - | ||||||||||||||||||
| 608 | return setterFallback(l, engine, object, value); executed 520 times by 1 test:  return setterFallback(l, engine, object, value);Executed by: 
 | 520 | ||||||||||||||||||
| 609 | } | - | ||||||||||||||||||
| 610 | - | |||||||||||||||||||
| 611 | bool Lookup::arrayLengthSetter(Lookup *, ExecutionEngine *engine, Value &object, const Value &value) | - | ||||||||||||||||||
| 612 | { | - | ||||||||||||||||||
| 613 | Q_ASSERT(object.isObject() && static_cast<Object &>(object).isArrayObject()); | - | ||||||||||||||||||
| 614 | bool ok; | - | ||||||||||||||||||
| 615 | uint len = value.asArrayLength(&ok); | - | ||||||||||||||||||
| 616 | if (!ok) { 
 | 40-540 | ||||||||||||||||||
| 617 | engine->throwRangeError(value); | - | ||||||||||||||||||
| 618 | return false; executed 40 times by 1 test:  return false;Executed by: 
 | 40 | ||||||||||||||||||
| 619 | } | - | ||||||||||||||||||
| 620 | ok = static_cast<Object &>(object).setArrayLength(len); | - | ||||||||||||||||||
| 621 | if (!ok) 
 | 22-519 | ||||||||||||||||||
| 622 | return false; executed 22 times by 1 test:  return false;Executed by: 
 | 22 | ||||||||||||||||||
| 623 | return true; executed 519 times by 1 test:  return true;Executed by: 
 | 519 | ||||||||||||||||||
| 624 | } | - | ||||||||||||||||||
| 625 | - | |||||||||||||||||||
| 626 | QT_END_NAMESPACE | - | ||||||||||||||||||
| Source code | Switch to Preprocessed file |