| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/qml/jsruntime/qv4generatorobject.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||
| 2 | using namespace QV4; | - | ||||||||||||
| 3 | - | |||||||||||||
| 4 | const QV4::VTable GeneratorFunctionCtor::static_vtbl = { (std::is_same<GeneratorFunctionCtor::SuperClass, Object>::value) ? nullptr : &GeneratorFunctionCtor::SuperClass::static_vtbl, (sizeof(GeneratorFunctionCtor::Data) + sizeof(QV4::Value) - 1)/sizeof(QV4::Value), (sizeof(GeneratorFunctionCtor::Data) + (GeneratorFunctionCtor::NInlineProperties*sizeof(QV4::Value)) + QV4::Chunk::SlotSize - 1)/QV4::Chunk::SlotSize*QV4::Chunk::SlotSize/sizeof(QV4::Value) - (sizeof(GeneratorFunctionCtor::Data) + sizeof(QV4::Value) - 1)/sizeof(QV4::Value), GeneratorFunctionCtor::IsExecutionContext, GeneratorFunctionCtor::IsString, GeneratorFunctionCtor::IsObject, GeneratorFunctionCtor::IsFunctionObject, GeneratorFunctionCtor::IsErrorObject, GeneratorFunctionCtor::IsArrayData, GeneratorFunctionCtor::IsStringOrSymbol, GeneratorFunctionCtor::MyType, { 0, 0, 0, 0 }, "GeneratorFunctionCtor", GeneratorFunctionCtor::virtualDestroy, GeneratorFunctionCtor::Data::markObjects, GeneratorFunctionCtor::virtualIsEqualTo, GeneratorFunctionCtor::virtualGet, GeneratorFunctionCtor::virtualPut, GeneratorFunctionCtor::virtualDeleteProperty, GeneratorFunctionCtor::virtualHasProperty, GeneratorFunctionCtor::virtualGetOwnProperty, GeneratorFunctionCtor::virtualDefineOwnProperty, GeneratorFunctionCtor::virtualIsExtensible, GeneratorFunctionCtor::virtualPreventExtensions, GeneratorFunctionCtor::virtualGetPrototypeOf, GeneratorFunctionCtor::virtualSetPrototypeOf, GeneratorFunctionCtor::virtualGetLength, GeneratorFunctionCtor::virtualAdvanceIterator, GeneratorFunctionCtor::virtualInstanceOf, GeneratorFunctionCtor::virtualCall, GeneratorFunctionCtor::virtualCallAsConstructor, }; | - | ||||||||||||
| 5 | const QV4::VTable GeneratorFunction::static_vtbl = { (std::is_same<GeneratorFunction::SuperClass, Object>::value) ? nullptr : &GeneratorFunction::SuperClass::static_vtbl, (sizeof(GeneratorFunction::Data) + sizeof(QV4::Value) - 1)/sizeof(QV4::Value), (sizeof(GeneratorFunction::Data) + (GeneratorFunction::NInlineProperties*sizeof(QV4::Value)) + QV4::Chunk::SlotSize - 1)/QV4::Chunk::SlotSize*QV4::Chunk::SlotSize/sizeof(QV4::Value) - (sizeof(GeneratorFunction::Data) + sizeof(QV4::Value) - 1)/sizeof(QV4::Value), GeneratorFunction::IsExecutionContext, GeneratorFunction::IsString, GeneratorFunction::IsObject, GeneratorFunction::IsFunctionObject, GeneratorFunction::IsErrorObject, GeneratorFunction::IsArrayData, GeneratorFunction::IsStringOrSymbol, GeneratorFunction::MyType, { 0, 0, 0, 0 }, "GeneratorFunction", GeneratorFunction::virtualDestroy, GeneratorFunction::Data::markObjects, GeneratorFunction::virtualIsEqualTo, GeneratorFunction::virtualGet, GeneratorFunction::virtualPut, GeneratorFunction::virtualDeleteProperty, GeneratorFunction::virtualHasProperty, GeneratorFunction::virtualGetOwnProperty, GeneratorFunction::virtualDefineOwnProperty, GeneratorFunction::virtualIsExtensible, GeneratorFunction::virtualPreventExtensions, GeneratorFunction::virtualGetPrototypeOf, GeneratorFunction::virtualSetPrototypeOf, GeneratorFunction::virtualGetLength, GeneratorFunction::virtualAdvanceIterator, GeneratorFunction::virtualInstanceOf, GeneratorFunction::virtualCall, GeneratorFunction::virtualCallAsConstructor, }; | - | ||||||||||||
| 6 | const QV4::VTable GeneratorObject::static_vtbl = { (std::is_same<GeneratorObject::SuperClass, Object>::value) ? nullptr : &GeneratorObject::SuperClass::static_vtbl, (sizeof(GeneratorObject::Data) + sizeof(QV4::Value) - 1)/sizeof(QV4::Value), (sizeof(GeneratorObject::Data) + (GeneratorObject::NInlineProperties*sizeof(QV4::Value)) + QV4::Chunk::SlotSize - 1)/QV4::Chunk::SlotSize*QV4::Chunk::SlotSize/sizeof(QV4::Value) - (sizeof(GeneratorObject::Data) + sizeof(QV4::Value) - 1)/sizeof(QV4::Value), GeneratorObject::IsExecutionContext, GeneratorObject::IsString, GeneratorObject::IsObject, GeneratorObject::IsFunctionObject, GeneratorObject::IsErrorObject, GeneratorObject::IsArrayData, GeneratorObject::IsStringOrSymbol, GeneratorObject::MyType, { 0, 0, 0, 0 }, "GeneratorObject", GeneratorObject::virtualDestroy, GeneratorObject::Data::markObjects, GeneratorObject::virtualIsEqualTo, GeneratorObject::virtualGet, GeneratorObject::virtualPut, GeneratorObject::virtualDeleteProperty, GeneratorObject::virtualHasProperty, GeneratorObject::virtualGetOwnProperty, GeneratorObject::virtualDefineOwnProperty, GeneratorObject::virtualIsExtensible, GeneratorObject::virtualPreventExtensions, GeneratorObject::virtualGetPrototypeOf, GeneratorObject::virtualSetPrototypeOf, GeneratorObject::virtualGetLength, GeneratorObject::virtualAdvanceIterator, GeneratorObject::virtualInstanceOf, GeneratorObject::virtualCall, GeneratorObject::virtualCallAsConstructor, }; | - | ||||||||||||
| 7 | - | |||||||||||||
| 8 | void Heap::GeneratorFunctionCtor::init(QV4::ExecutionContext *scope) | - | ||||||||||||
| 9 | { | - | ||||||||||||
| 10 | Heap::FunctionObject::init(scope, ([]() noexcept -> QString { enum { Size = sizeof(u"" "GeneratorFunction")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "GeneratorFunction" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return executed 98596 times by 153 tests: qstring_literal_temp;return qstring_literal_temp;Executed by:
executed 98596 times by 153 tests: }()));return qstring_literal_temp;Executed by:
| 98596 | ||||||||||||
| 11 | } executed 99150 times by 153 tests: end of blockExecuted by:
| 99150 | ||||||||||||
| 12 | - | |||||||||||||
| 13 | ReturnedValue GeneratorFunctionCtor::virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *) | - | ||||||||||||
| 14 | { | - | ||||||||||||
| 15 | ExecutionEngine *engine = f->engine(); | - | ||||||||||||
| 16 | - | |||||||||||||
| 17 | QQmlRefPointer<CompiledData::CompilationUnit> compilationUnit = parse(engine, argv, argc, Type_Generator); | - | ||||||||||||
| 18 | if (engine->hasException
| 8-111 | ||||||||||||
| 19 | return executed 8 times by 1 test: Encode::undefined();return Encode::undefined();Executed by:
executed 8 times by 1 test: return Encode::undefined();Executed by:
| 8 | ||||||||||||
| 20 | - | |||||||||||||
| 21 | Function *vmf = compilationUnit->linkToEngine(engine); | - | ||||||||||||
| 22 | ExecutionContext *global = engine->scriptContext(); | - | ||||||||||||
| 23 | return executed 111 times by 1 test: Encode(GeneratorFunction::create(global, vmf));return Encode(GeneratorFunction::create(global, vmf));Executed by:
executed 111 times by 1 test: return Encode(GeneratorFunction::create(global, vmf));Executed by:
| 111 | ||||||||||||
| 24 | } | - | ||||||||||||
| 25 | - | |||||||||||||
| 26 | - | |||||||||||||
| 27 | ReturnedValue GeneratorFunctionCtor::virtualCall(const FunctionObject *f, const Value *, const Value *argv, int argc) | - | ||||||||||||
| 28 | { | - | ||||||||||||
| 29 | return executed 92 times by 1 test: virtualCallAsConstructor(f, argv, argc, f);return virtualCallAsConstructor(f, argv, argc, f);Executed by:
executed 92 times by 1 test: return virtualCallAsConstructor(f, argv, argc, f);Executed by:
| 92 | ||||||||||||
| 30 | } | - | ||||||||||||
| 31 | - | |||||||||||||
| 32 | Heap::FunctionObject *GeneratorFunction::create(ExecutionContext *context, Function *function) | - | ||||||||||||
| 33 | { | - | ||||||||||||
| 34 | Scope scope(context); | - | ||||||||||||
| 35 | Scoped<GeneratorFunction> g(scope, context->engine()->memoryManager->allocate<GeneratorFunction>(context, function)); | - | ||||||||||||
| 36 | ScopedObject proto(scope, scope.engine->newObject()); | - | ||||||||||||
| 37 | proto->setPrototypeOf(scope.engine->generatorPrototype()); | - | ||||||||||||
| 38 | g->defineDefaultProperty(scope.engine->id_prototype(), proto, Attr_NotConfigurable|Attr_NotEnumerable); | - | ||||||||||||
| 39 | g->setPrototypeOf(ScopedObject(scope, scope.engine->generatorFunctionCtor()->get(scope.engine->id_prototype()))); | - | ||||||||||||
| 40 | return executed 6223 times by 1 test: g->d();return g->d();Executed by:
executed 6223 times by 1 test: return g->d();Executed by:
| 6223 | ||||||||||||
| 41 | } | - | ||||||||||||
| 42 | - | |||||||||||||
| 43 | ReturnedValue GeneratorFunction::virtualCallAsConstructor(const FunctionObject *f, const Value *, int, const Value *) | - | ||||||||||||
| 44 | { | - | ||||||||||||
| 45 | return executed 16 times by 1 test: f->engine()->throwTypeError();return f->engine()->throwTypeError();Executed by:
executed 16 times by 1 test: return f->engine()->throwTypeError();Executed by:
| 16 | ||||||||||||
| 46 | } | - | ||||||||||||
| 47 | - | |||||||||||||
| 48 | ReturnedValue GeneratorFunction::virtualCall(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc) | - | ||||||||||||
| 49 | { | - | ||||||||||||
| 50 | const GeneratorFunction *gf = static_cast<const GeneratorFunction *>(f); | - | ||||||||||||
| 51 | Function *function = gf->function(); | - | ||||||||||||
| 52 | ExecutionEngine *engine = gf->engine(); | - | ||||||||||||
| 53 | - | |||||||||||||
| 54 | - | |||||||||||||
| 55 | uint stackSize = argc | - | ||||||||||||
| 56 | + CppStackFrame::requiredJSStackFrameSize(function); | - | ||||||||||||
| 57 | - | |||||||||||||
| 58 | size_t requiredMemory = sizeof(GeneratorObject::Data) - sizeof(Value) + sizeof(Value) * stackSize; | - | ||||||||||||
| 59 | - | |||||||||||||
| 60 | Scope scope(gf); | - | ||||||||||||
| 61 | Scoped<GeneratorObject> g(scope, scope.engine->memoryManager->allocManaged<GeneratorObject>(requiredMemory, scope.engine->classes[EngineBase::Class_GeneratorObject])); | - | ||||||||||||
| 62 | g->setPrototypeOf(ScopedObject(scope, gf->get(scope.engine->id_prototype()))); | - | ||||||||||||
| 63 | - | |||||||||||||
| 64 | Heap::GeneratorObject *gp = g->d(); | - | ||||||||||||
| 65 | gp->stack.size = stackSize; | - | ||||||||||||
| 66 | gp->stack.alloc = stackSize; | - | ||||||||||||
| 67 | - | |||||||||||||
| 68 | - | |||||||||||||
| 69 | memcpy(gp->stack.values, argv, argc*sizeof(Value)); | - | ||||||||||||
| 70 | gp->cppFrame.init(engine, function, gp->stack.values, argc); | - | ||||||||||||
| 71 | gp->cppFrame.setupJSFrame(&gp->stack.values[argc], *gf, gf->scope(), | - | ||||||||||||
| 72 | thisObject ? *thisObject : Primitive::undefinedValue(), | - | ||||||||||||
| 73 | Primitive::undefinedValue()); | - | ||||||||||||
| 74 | - | |||||||||||||
| 75 | gp->cppFrame.push(); | - | ||||||||||||
| 76 | - | |||||||||||||
| 77 | Moth::VME::interpret(&gp->cppFrame, engine, function->codeData); | - | ||||||||||||
| 78 | gp->state = GeneratorState::SuspendedStart; | - | ||||||||||||
| 79 | - | |||||||||||||
| 80 | gp->cppFrame.pop(); | - | ||||||||||||
| 81 | return executed 7777 times by 1 test: g->asReturnedValue();return g->asReturnedValue();Executed by:
executed 7777 times by 1 test: return g->asReturnedValue();Executed by:
| 7777 | ||||||||||||
| 82 | } | - | ||||||||||||
| 83 | - | |||||||||||||
| 84 | - | |||||||||||||
| 85 | void Heap::GeneratorPrototype::init() | - | ||||||||||||
| 86 | { | - | ||||||||||||
| 87 | Heap::FunctionObject::init(); | - | ||||||||||||
| 88 | } never executed: end of block | 0 | ||||||||||||
| 89 | - | |||||||||||||
| 90 | - | |||||||||||||
| 91 | void GeneratorPrototype::init(ExecutionEngine *engine, Object *ctor) | - | ||||||||||||
| 92 | { | - | ||||||||||||
| 93 | Scope scope(engine); | - | ||||||||||||
| 94 | ScopedValue v(scope); | - | ||||||||||||
| 95 | - | |||||||||||||
| 96 | ScopedObject ctorProto(scope, engine->newObject(engine->newInternalClass(Object::staticVTable(), engine->functionPrototype()))); | - | ||||||||||||
| 97 | - | |||||||||||||
| 98 | ctor->defineReadonlyConfigurableProperty(engine->id_length(), Primitive::fromInt32(1)); | - | ||||||||||||
| 99 | ctor->defineReadonlyProperty(engine->id_prototype(), ctorProto); | - | ||||||||||||
| 100 | - | |||||||||||||
| 101 | ctorProto->defineDefaultProperty(([]() noexcept -> QString { enum { Size = sizeof(u"" "constructor")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "constructor" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return executed 98715 times by 153 tests: qstring_literal_temp;return qstring_literal_temp;Executed by:
executed 98715 times by 153 tests: }()), (v = ctor), Attr_ReadOnly_ButConfigurable);return qstring_literal_temp;Executed by:
| 98715 | ||||||||||||
| 102 | ctorProto->defineDefaultProperty(engine->symbol_toStringTag(), (v = engine->newIdentifier(([]() noexcept -> QString { enum { Size = sizeof(u"" "GeneratorFunction")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "GeneratorFunction" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return executed 98995 times by 153 tests: qstring_literal_temp;return qstring_literal_temp;Executed by:
executed 98995 times by 153 tests: }()))), Attr_ReadOnly_ButConfigurable);return qstring_literal_temp;Executed by:
| 98995 | ||||||||||||
| 103 | ctorProto->defineDefaultProperty(engine->id_prototype(), (v = this), Attr_ReadOnly_ButConfigurable); | - | ||||||||||||
| 104 | - | |||||||||||||
| 105 | setPrototypeOf(engine->iteratorPrototype()); | - | ||||||||||||
| 106 | defineDefaultProperty(([]() noexcept -> QString { enum { Size = sizeof(u"" "constructor")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "constructor" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return executed 99072 times by 153 tests: qstring_literal_temp;return qstring_literal_temp;Executed by:
executed 99072 times by 153 tests: }()), ctorProto, Attr_ReadOnly_ButConfigurable);return qstring_literal_temp;Executed by:
| 99072 | ||||||||||||
| 107 | defineDefaultProperty(([]() noexcept -> QString { enum { Size = sizeof(u"" "next")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "next" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return executed 99096 times by 153 tests: qstring_literal_temp;return qstring_literal_temp;Executed by:
executed 99096 times by 153 tests: }()), method_next, 1);return qstring_literal_temp;Executed by:
| 99096 | ||||||||||||
| 108 | defineDefaultProperty(([]() noexcept -> QString { enum { Size = sizeof(u"" "return")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "return" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return executed 99107 times by 153 tests: qstring_literal_temp;return qstring_literal_temp;Executed by:
executed 99107 times by 153 tests: }()), method_return, 1);return qstring_literal_temp;Executed by:
| 99107 | ||||||||||||
| 109 | defineDefaultProperty(([]() noexcept -> QString { enum { Size = sizeof(u"" "throw")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "throw" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return executed 99095 times by 153 tests: qstring_literal_temp;return qstring_literal_temp;Executed by:
executed 99095 times by 153 tests: }()), method_throw, 1);return qstring_literal_temp;Executed by:
| 99095 | ||||||||||||
| 110 | defineDefaultProperty(engine->symbol_toStringTag(), (v = engine->newString(([]() noexcept -> QString { enum { Size = sizeof(u"" "Generator")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "Generator" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return executed 99061 times by 153 tests: qstring_literal_temp;return qstring_literal_temp;Executed by:
executed 99061 times by 153 tests: }()))), Attr_ReadOnly_ButConfigurable);return qstring_literal_temp;Executed by:
| 99061 | ||||||||||||
| 111 | } executed 99017 times by 153 tests: end of blockExecuted by:
| 99017 | ||||||||||||
| 112 | - | |||||||||||||
| 113 | ReturnedValue GeneratorPrototype::method_next(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc) | - | ||||||||||||
| 114 | { | - | ||||||||||||
| 115 | ExecutionEngine *engine = f->engine(); | - | ||||||||||||
| 116 | const GeneratorObject *g = thisObject->as<GeneratorObject>(); | - | ||||||||||||
| 117 | if (!g
| 8-7766 | ||||||||||||
| 118 | return executed 88 times by 1 test: engine->throwTypeError();return engine->throwTypeError();Executed by:
executed 88 times by 1 test: return engine->throwTypeError();Executed by:
| 88 | ||||||||||||
| 119 | Heap::GeneratorObject *gp = g->d(); | - | ||||||||||||
| 120 | - | |||||||||||||
| 121 | if (gp->state == GeneratorState::Completed
| 716-7045 | ||||||||||||
| 122 | return executed 716 times by 1 test: IteratorPrototype::createIterResultObject(engine, Primitive::undefinedValue(), true);return IteratorPrototype::createIterResultObject(engine, Primitive::undefinedValue(), true);Executed by:
executed 716 times by 1 test: return IteratorPrototype::createIterResultObject(engine, Primitive::undefinedValue(), true);Executed by:
| 716 | ||||||||||||
| 123 | - | |||||||||||||
| 124 | return executed 7043 times by 1 test: g->resume(engine, argc ? argv[0] : Primitive::undefinedValue());return g->resume(engine, argc ? argv[0] : Primitive::undefinedValue());Executed by:
executed 7043 times by 1 test: return g->resume(engine, argc ? argv[0] : Primitive::undefinedValue());Executed by:
| 7043 | ||||||||||||
| 125 | } | - | ||||||||||||
| 126 | - | |||||||||||||
| 127 | ReturnedValue GeneratorPrototype::method_return(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc) | - | ||||||||||||
| 128 | { | - | ||||||||||||
| 129 | ExecutionEngine *engine = f->engine(); | - | ||||||||||||
| 130 | const GeneratorObject *g = thisObject->as<GeneratorObject>(); | - | ||||||||||||
| 131 | if (!g
| 4-500 | ||||||||||||
| 132 | return executed 84 times by 1 test: engine->throwTypeError();return engine->throwTypeError();Executed by:
executed 84 times by 1 test: return engine->throwTypeError();Executed by:
| 84 | ||||||||||||
| 133 | - | |||||||||||||
| 134 | Heap::GeneratorObject *gp = g->d(); | - | ||||||||||||
| 135 | - | |||||||||||||
| 136 | if (gp->state == GeneratorState::SuspendedStart
| 4-492 | ||||||||||||
| 137 | gp->state = GeneratorState::Completed; executed 4 times by 1 test: gp->state = GeneratorState::Completed;Executed by:
| 4 | ||||||||||||
| 138 | - | |||||||||||||
| 139 | if (gp->state == GeneratorState::Completed
| 8-488 | ||||||||||||
| 140 | return executed 8 times by 1 test: IteratorPrototype::createIterResultObject(engine, argc ? argv[0] : Primitive::undefinedValue(), true);return IteratorPrototype::createIterResultObject(engine, argc ? argv[0] : Primitive::undefinedValue(), true);Executed by:
executed 8 times by 1 test: return IteratorPrototype::createIterResultObject(engine, argc ? argv[0] : Primitive::undefinedValue(), true);Executed by:
| 8 | ||||||||||||
| 141 | - | |||||||||||||
| 142 | - | |||||||||||||
| 143 | - | |||||||||||||
| 144 | engine->throwError(Primitive::emptyValue()); | - | ||||||||||||
| 145 | - | |||||||||||||
| 146 | return executed 488 times by 1 test: g->resume(engine, argc ? argv[0]: Primitive::undefinedValue());return g->resume(engine, argc ? argv[0]: Primitive::undefinedValue());Executed by:
executed 488 times by 1 test: return g->resume(engine, argc ? argv[0]: Primitive::undefinedValue());Executed by:
| 488 | ||||||||||||
| 147 | } | - | ||||||||||||
| 148 | - | |||||||||||||
| 149 | ReturnedValue GeneratorPrototype::method_throw(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc) | - | ||||||||||||
| 150 | { | - | ||||||||||||
| 151 | ExecutionEngine *engine = f->engine(); | - | ||||||||||||
| 152 | const GeneratorObject *g = thisObject->as<GeneratorObject>(); | - | ||||||||||||
| 153 | if (!g
| 4-80 | ||||||||||||
| 154 | return executed 84 times by 1 test: engine->throwTypeError();return engine->throwTypeError();Executed by:
executed 84 times by 1 test: return engine->throwTypeError();Executed by:
| 84 | ||||||||||||
| 155 | - | |||||||||||||
| 156 | Heap::GeneratorObject *gp = g->d(); | - | ||||||||||||
| 157 | - | |||||||||||||
| 158 | engine->throwError(argc ? argv[0]: Primitive::undefinedValue()); | - | ||||||||||||
| 159 | - | |||||||||||||
| 160 | if (gp->state == GeneratorState::SuspendedStart
| 4-56 | ||||||||||||
| 161 | gp->state = GeneratorState::Completed; | - | ||||||||||||
| 162 | return executed 8 times by 1 test: Encode::undefined();return Encode::undefined();Executed by:
executed 8 times by 1 test: return Encode::undefined();Executed by:
| 8 | ||||||||||||
| 163 | } | - | ||||||||||||
| 164 | - | |||||||||||||
| 165 | return executed 52 times by 1 test: g->resume(engine, Primitive::undefinedValue());return g->resume(engine, Primitive::undefinedValue());Executed by:
executed 52 times by 1 test: return g->resume(engine, Primitive::undefinedValue());Executed by:
| 52 | ||||||||||||
| 166 | } | - | ||||||||||||
| 167 | - | |||||||||||||
| 168 | ReturnedValue GeneratorObject::resume(ExecutionEngine *engine, const Value &arg) const | - | ||||||||||||
| 169 | { | - | ||||||||||||
| 170 | Heap::GeneratorObject *gp = d(); | - | ||||||||||||
| 171 | gp->state = GeneratorState::Executing; | - | ||||||||||||
| 172 | gp->cppFrame.parent = engine->currentStackFrame; | - | ||||||||||||
| 173 | engine->currentStackFrame = &gp->cppFrame; | - | ||||||||||||
| 174 | - | |||||||||||||
| 175 | ((gp->cppFrame.yield != nullptr) ? static_cast<void>(0) : qt_assert("gp->cppFrame.yield != nullptr", __FILE__, 219)); | - | ||||||||||||
| 176 | const char *code = gp->cppFrame.yield; | - | ||||||||||||
| 177 | gp->cppFrame.yield = nullptr; | - | ||||||||||||
| 178 | gp->cppFrame.jsFrame->accumulator = arg; | - | ||||||||||||
| 179 | - | |||||||||||||
| 180 | Scope scope(engine); | - | ||||||||||||
| 181 | ScopedValue result(scope, Moth::VME::interpret(&gp->cppFrame, engine, code)); | - | ||||||||||||
| 182 | - | |||||||||||||
| 183 | engine->currentStackFrame = gp->cppFrame.parent; | - | ||||||||||||
| 184 | - | |||||||||||||
| 185 | bool done = (gp->cppFrame.yield == nullptr); | - | ||||||||||||
| 186 | gp->state = done
| 1834-5756 | ||||||||||||
| 187 | if (engine->hasException
| 612-6985 | ||||||||||||
| 188 | return executed 612 times by 1 test: Encode::undefined();return Encode::undefined();Executed by:
executed 612 times by 1 test: return Encode::undefined();Executed by:
| 612 | ||||||||||||
| 189 | return executed 6985 times by 1 test: IteratorPrototype::createIterResultObject(engine, result, done);return IteratorPrototype::createIterResultObject(engine, result, done);Executed by:
executed 6985 times by 1 test: return IteratorPrototype::createIterResultObject(engine, result, done);Executed by:
| 6985 | ||||||||||||
| 190 | } | - | ||||||||||||
| 191 | - | |||||||||||||
| 192 | const QV4::VTable MemberGeneratorFunction::static_vtbl = { (std::is_same<MemberGeneratorFunction::SuperClass, Object>::value) ? nullptr : &MemberGeneratorFunction::SuperClass::static_vtbl, (sizeof(MemberGeneratorFunction::Data) + sizeof(QV4::Value) - 1)/sizeof(QV4::Value), (sizeof(MemberGeneratorFunction::Data) + (MemberGeneratorFunction::NInlineProperties*sizeof(QV4::Value)) + QV4::Chunk::SlotSize - 1)/QV4::Chunk::SlotSize*QV4::Chunk::SlotSize/sizeof(QV4::Value) - (sizeof(MemberGeneratorFunction::Data) + sizeof(QV4::Value) - 1)/sizeof(QV4::Value), MemberGeneratorFunction::IsExecutionContext, MemberGeneratorFunction::IsString, MemberGeneratorFunction::IsObject, MemberGeneratorFunction::IsFunctionObject, MemberGeneratorFunction::IsErrorObject, MemberGeneratorFunction::IsArrayData, MemberGeneratorFunction::IsStringOrSymbol, MemberGeneratorFunction::MyType, { 0, 0, 0, 0 }, "MemberGeneratorFunction", MemberGeneratorFunction::virtualDestroy, MemberGeneratorFunction::Data::markObjects, MemberGeneratorFunction::virtualIsEqualTo, MemberGeneratorFunction::virtualGet, MemberGeneratorFunction::virtualPut, MemberGeneratorFunction::virtualDeleteProperty, MemberGeneratorFunction::virtualHasProperty, MemberGeneratorFunction::virtualGetOwnProperty, MemberGeneratorFunction::virtualDefineOwnProperty, MemberGeneratorFunction::virtualIsExtensible, MemberGeneratorFunction::virtualPreventExtensions, MemberGeneratorFunction::virtualGetPrototypeOf, MemberGeneratorFunction::virtualSetPrototypeOf, MemberGeneratorFunction::virtualGetLength, MemberGeneratorFunction::virtualAdvanceIterator, MemberGeneratorFunction::virtualInstanceOf, MemberGeneratorFunction::virtualCall, MemberGeneratorFunction::virtualCallAsConstructor, }; | - | ||||||||||||
| 193 | - | |||||||||||||
| 194 | Heap::FunctionObject *MemberGeneratorFunction::create(ExecutionContext *context, Function *function) | - | ||||||||||||
| 195 | { | - | ||||||||||||
| 196 | Scope scope(context); | - | ||||||||||||
| 197 | Scoped<GeneratorFunction> g(scope, context->engine()->memoryManager->allocate<MemberGeneratorFunction>(context, function)); | - | ||||||||||||
| 198 | ScopedObject proto(scope, scope.engine->newObject()); | - | ||||||||||||
| 199 | proto->setPrototypeOf(scope.engine->generatorPrototype()); | - | ||||||||||||
| 200 | g->defineDefaultProperty(scope.engine->id_prototype(), proto, Attr_NotConfigurable|Attr_NotEnumerable); | - | ||||||||||||
| 201 | g->setPrototypeOf(ScopedObject(scope, scope.engine->generatorFunctionCtor()->get(scope.engine->id_prototype()))); | - | ||||||||||||
| 202 | return executed 3044 times by 1 test: g->d();return g->d();Executed by:
executed 3044 times by 1 test: return g->d();Executed by:
| 3044 | ||||||||||||
| 203 | } | - | ||||||||||||
| 204 | - | |||||||||||||
| 205 | ReturnedValue MemberGeneratorFunction::virtualCallAsConstructor(const FunctionObject *f, const Value *, int, const Value *) | - | ||||||||||||
| 206 | { | - | ||||||||||||
| 207 | return never executed: f->engine()->throwTypeError(([]() noexcept -> QString { enum { Size = sizeof(u"" "Function is not a constructor.")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "Function is not a constructor." }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); returnreturn f->engine()->throwTypeError(([]() noexcept -> QString { enum { Size = sizeof(u"" "Function is not a constructor.")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "Function is not a constructor." }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }()));never executed: qstring_literal_temp;return qstring_literal_temp;never executed: }()));return qstring_literal_temp;never executed: return f->engine()->throwTypeError(([]() noexcept -> QString { enum { Size = sizeof(u"" "Function is not a constructor.")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "Function is not a constructor." }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }())); | 0 | ||||||||||||
| 208 | } | - | ||||||||||||
| Switch to Source code | Preprocessed file |