diff --git a/src/qml/qml/v4vm/qv4isel_masm.cpp b/src/qml/qml/v4vm/qv4isel_masm.cpp index 4137f39061..b08355ae50 100644 --- a/src/qml/qml/v4vm/qv4isel_masm.cpp +++ b/src/qml/qml/v4vm/qv4isel_masm.cpp @@ -894,7 +894,7 @@ void InstructionSelection::setProperty(V4IR::Temp *source, V4IR::Temp *targetBas { if (useFastLookups) { QV4::String *s = identifier(targetName); - uint index = addLookup(s); + uint index = addSetterLookup(s); generateFunctionCall(Assembler::Void, __qmljs_set_property_lookup, Assembler::ContextRegister, Assembler::Reference(targetBase), Assembler::TrustedImm32(index), Assembler::Reference(source)); @@ -1234,7 +1234,21 @@ uint InstructionSelection::addLookup(QV4::String *name) { uint index = (uint)_lookups.size(); QV4::Lookup l; - l.lookupProperty = Lookup::lookupPropertyGeneric; + l.getter = Lookup::getterGeneric; + for (int i = 0; i < Lookup::Size; ++i) + l.classList[i] = 0; + l.level = -1; + l.index = UINT_MAX; + l.name = name; + _lookups.append(l); + return index; +} + +uint InstructionSelection::addSetterLookup(QV4::String *name) +{ + uint index = (uint)_lookups.size(); + QV4::Lookup l; + l.setter = Lookup::setterGeneric; for (int i = 0; i < Lookup::Size; ++i) l.classList[i] = 0; l.level = -1; @@ -1248,7 +1262,7 @@ uint InstructionSelection::addGlobalLookup(QV4::String *name) { uint index = (uint)_lookups.size(); QV4::Lookup l; - l.lookupGlobal = Lookup::lookupGlobalGeneric; + l.globalGetter = Lookup::globalGetterGeneric; for (int i = 0; i < Lookup::Size; ++i) l.classList[i] = 0; l.level = -1; diff --git a/src/qml/qml/v4vm/qv4isel_masm_p.h b/src/qml/qml/v4vm/qv4isel_masm_p.h index 3ce29bd72b..b1e17947ee 100644 --- a/src/qml/qml/v4vm/qv4isel_masm_p.h +++ b/src/qml/qml/v4vm/qv4isel_masm_p.h @@ -881,6 +881,7 @@ private: callRuntimeMethodImp(result, isel_stringIfy(function), function, __VA_ARGS__) uint addLookup(QV4::String *name); + uint addSetterLookup(QV4::String *name); uint addGlobalLookup(QV4::String *name); V4IR::BasicBlock *_block; diff --git a/src/qml/qml/v4vm/qv4lookup.cpp b/src/qml/qml/v4vm/qv4lookup.cpp index f8a265ec87..88a601f6a9 100644 --- a/src/qml/qml/v4vm/qv4lookup.cpp +++ b/src/qml/qml/v4vm/qv4lookup.cpp @@ -45,7 +45,48 @@ QT_BEGIN_NAMESPACE using namespace QV4; -void Lookup::lookupPropertyGeneric(QV4::Lookup *l, ExecutionContext *ctx, QV4::Value *result, const QV4::Value &object) +Property *Lookup::lookup(Object *obj, PropertyAttributes *attrs) +{ + int i = 0; + while (i < level && obj && obj->internalClass == classList[i]) { + obj = obj->prototype; + ++i; + } + + if (index != UINT_MAX && obj->internalClass == classList[i]) { + *attrs = obj->internalClass->propertyData.at(index); + return obj->memberData + index; + } + + while (i < Size && obj) { + classList[i] = obj->internalClass; + + index = obj->internalClass->find(name); + if (index != UINT_MAX) { + level = i; + *attrs = obj->internalClass->propertyData.at(index); + return obj->memberData + index; + } + + obj = obj->prototype; + ++i; + } + level = i; + + while (obj) { + index = obj->internalClass->find(name); + if (index != UINT_MAX) { + *attrs = obj->internalClass->propertyData.at(index); + return obj->memberData + index; + } + + obj = obj->prototype; + } + return 0; +} + + +void Lookup::getterGeneric(QV4::Lookup *l, ExecutionContext *ctx, QV4::Value *result, const QV4::Value &object) { if (Object *o = object.asObject()) { PropertyAttributes attrs; @@ -53,21 +94,21 @@ void Lookup::lookupPropertyGeneric(QV4::Lookup *l, ExecutionContext *ctx, QV4::V if (p) { if (attrs.isData()) { if (l->level == 0) - l->lookupProperty = lookupProperty0; + l->getter = getter0; else if (l->level == 1) - l->lookupProperty = lookupProperty1; + l->getter = getter1; else if (l->level == 2) - l->lookupProperty = lookupProperty2; + l->getter = getter2; if (result) *result = p->value; return; } else { if (l->level == 0) - l->lookupProperty = lookupPropertyAccessor0; + l->getter = getterAccessor0; else if (l->level == 1) - l->lookupProperty = lookupPropertyAccessor1; + l->getter = getterAccessor1; else if (l->level == 2) - l->lookupProperty = lookupPropertyAccessor2; + l->getter = getterAccessor2; if (result) *result = p->value; Value res = o->getValue(ctx, p, attrs); @@ -91,7 +132,7 @@ void Lookup::lookupPropertyGeneric(QV4::Lookup *l, ExecutionContext *ctx, QV4::V } } -void Lookup::lookupProperty0(Lookup *l, ExecutionContext *ctx, Value *result, const Value &object) +void Lookup::getter0(Lookup *l, ExecutionContext *ctx, Value *result, const Value &object) { if (Object *o = object.asObject()) { if (l->classList[0] == o->internalClass) { @@ -100,11 +141,11 @@ void Lookup::lookupProperty0(Lookup *l, ExecutionContext *ctx, Value *result, co return; } } - l->lookupProperty = lookupPropertyGeneric; - lookupPropertyGeneric(l, ctx, result, object); + l->getter = getterGeneric; + getterGeneric(l, ctx, result, object); } -void Lookup::lookupProperty1(Lookup *l, ExecutionContext *ctx, Value *result, const Value &object) +void Lookup::getter1(Lookup *l, ExecutionContext *ctx, Value *result, const Value &object) { if (Object *o = object.asObject()) { if (l->classList[0] == o->internalClass && @@ -114,11 +155,11 @@ void Lookup::lookupProperty1(Lookup *l, ExecutionContext *ctx, Value *result, co return; } } - l->lookupProperty = lookupPropertyGeneric; - lookupPropertyGeneric(l, ctx, result, object); + l->getter = getterGeneric; + getterGeneric(l, ctx, result, object); } -void Lookup::lookupProperty2(Lookup *l, ExecutionContext *ctx, Value *result, const Value &object) +void Lookup::getter2(Lookup *l, ExecutionContext *ctx, Value *result, const Value &object) { if (Object *o = object.asObject()) { if (l->classList[0] == o->internalClass) { @@ -133,11 +174,11 @@ void Lookup::lookupProperty2(Lookup *l, ExecutionContext *ctx, Value *result, co } } } - l->lookupProperty = lookupPropertyGeneric; - lookupPropertyGeneric(l, ctx, result, object); + l->getter = getterGeneric; + getterGeneric(l, ctx, result, object); } -void Lookup::lookupPropertyAccessor0(Lookup *l, ExecutionContext *ctx, Value *result, const Value &object) +void Lookup::getterAccessor0(Lookup *l, ExecutionContext *ctx, Value *result, const Value &object) { if (Object *o = object.asObject()) { if (l->classList[0] == o->internalClass) { @@ -152,11 +193,11 @@ void Lookup::lookupPropertyAccessor0(Lookup *l, ExecutionContext *ctx, Value *re return; } } - l->lookupProperty = lookupPropertyGeneric; - lookupPropertyGeneric(l, ctx, result, object); + l->getter = getterGeneric; + getterGeneric(l, ctx, result, object); } -void Lookup::lookupPropertyAccessor1(Lookup *l, ExecutionContext *ctx, Value *result, const Value &object) +void Lookup::getterAccessor1(Lookup *l, ExecutionContext *ctx, Value *result, const Value &object) { if (Object *o = object.asObject()) { if (l->classList[0] == o->internalClass && @@ -172,11 +213,11 @@ void Lookup::lookupPropertyAccessor1(Lookup *l, ExecutionContext *ctx, Value *re return; } } - l->lookupProperty = lookupPropertyGeneric; - lookupPropertyGeneric(l, ctx, result, object); + l->getter = getterGeneric; + getterGeneric(l, ctx, result, object); } -void Lookup::lookupPropertyAccessor2(Lookup *l, ExecutionContext *ctx, Value *result, const Value &object) +void Lookup::getterAccessor2(Lookup *l, ExecutionContext *ctx, Value *result, const Value &object) { if (Object *o = object.asObject()) { if (l->classList[0] == o->internalClass) { @@ -197,12 +238,12 @@ void Lookup::lookupPropertyAccessor2(Lookup *l, ExecutionContext *ctx, Value *re } } } - l->lookupProperty = lookupPropertyGeneric; - lookupPropertyGeneric(l, ctx, result, object); + l->getter = getterGeneric; + getterGeneric(l, ctx, result, object); } -void Lookup::lookupGlobalGeneric(Lookup *l, ExecutionContext *ctx, Value *result) +void Lookup::globalGetterGeneric(Lookup *l, ExecutionContext *ctx, Value *result) { Object *o = ctx->engine->globalObject; PropertyAttributes attrs; @@ -210,20 +251,20 @@ void Lookup::lookupGlobalGeneric(Lookup *l, ExecutionContext *ctx, Value *result if (p) { if (attrs.isData()) { if (l->level == 0) - l->lookupGlobal = lookupGlobal0; + l->globalGetter = globalGetter0; else if (l->level == 1) - l->lookupGlobal = lookupGlobal1; + l->globalGetter = globalGetter1; else if (l->level == 2) - l->lookupGlobal = lookupGlobal2; + l->globalGetter = globalGetter2; *result = p->value; return; } else { if (l->level == 0) - l->lookupGlobal = lookupGlobalAccessor0; + l->globalGetter = globalGetterAccessor0; else if (l->level == 1) - l->lookupGlobal = lookupGlobalAccessor1; + l->globalGetter = globalGetterAccessor1; else if (l->level == 2) - l->lookupGlobal = lookupGlobalAccessor2; + l->globalGetter = globalGetterAccessor2; Value res = o->getValue(ctx, p, attrs); if (result) *result = res; @@ -233,18 +274,18 @@ void Lookup::lookupGlobalGeneric(Lookup *l, ExecutionContext *ctx, Value *result ctx->throwReferenceError(Value::fromString(l->name)); } -void Lookup::lookupGlobal0(Lookup *l, ExecutionContext *ctx, Value *result) +void Lookup::globalGetter0(Lookup *l, ExecutionContext *ctx, Value *result) { Object *o = ctx->engine->globalObject; if (l->classList[0] == o->internalClass) { *result = o->memberData[l->index].value; return; } - l->lookupGlobal = lookupGlobalGeneric; - lookupGlobalGeneric(l, ctx, result); + l->globalGetter = globalGetterGeneric; + globalGetterGeneric(l, ctx, result); } -void Lookup::lookupGlobal1(Lookup *l, ExecutionContext *ctx, Value *result) +void Lookup::globalGetter1(Lookup *l, ExecutionContext *ctx, Value *result) { Object *o = ctx->engine->globalObject; if (l->classList[0] == o->internalClass && @@ -252,11 +293,11 @@ void Lookup::lookupGlobal1(Lookup *l, ExecutionContext *ctx, Value *result) *result = o->prototype->memberData[l->index].value; return; } - l->lookupGlobal = lookupGlobalGeneric; - lookupGlobalGeneric(l, ctx, result); + l->globalGetter = globalGetterGeneric; + globalGetterGeneric(l, ctx, result); } -void Lookup::lookupGlobal2(Lookup *l, ExecutionContext *ctx, Value *result) +void Lookup::globalGetter2(Lookup *l, ExecutionContext *ctx, Value *result) { Object *o = ctx->engine->globalObject; if (l->classList[0] == o->internalClass) { @@ -269,11 +310,11 @@ void Lookup::lookupGlobal2(Lookup *l, ExecutionContext *ctx, Value *result) } } } - l->lookupGlobal = lookupGlobalGeneric; - lookupGlobalGeneric(l, ctx, result); + l->globalGetter = globalGetterGeneric; + globalGetterGeneric(l, ctx, result); } -void Lookup::lookupGlobalAccessor0(Lookup *l, ExecutionContext *ctx, Value *result) +void Lookup::globalGetterAccessor0(Lookup *l, ExecutionContext *ctx, Value *result) { Object *o = ctx->engine->globalObject; if (l->classList[0] == o->internalClass) { @@ -284,11 +325,11 @@ void Lookup::lookupGlobalAccessor0(Lookup *l, ExecutionContext *ctx, Value *resu *result = getter->call(ctx, Value::undefinedValue(), 0, 0); return; } - l->lookupGlobal = lookupGlobalGeneric; - lookupGlobalGeneric(l, ctx, result); + l->globalGetter = globalGetterGeneric; + globalGetterGeneric(l, ctx, result); } -void Lookup::lookupGlobalAccessor1(Lookup *l, ExecutionContext *ctx, Value *result) +void Lookup::globalGetterAccessor1(Lookup *l, ExecutionContext *ctx, Value *result) { Object *o = ctx->engine->globalObject; if (l->classList[0] == o->internalClass && @@ -300,11 +341,11 @@ void Lookup::lookupGlobalAccessor1(Lookup *l, ExecutionContext *ctx, Value *resu *result = getter->call(ctx, Value::undefinedValue(), 0, 0); return; } - l->lookupGlobal = lookupGlobalGeneric; - lookupGlobalGeneric(l, ctx, result); + l->globalGetter = globalGetterGeneric; + globalGetterGeneric(l, ctx, result); } -void Lookup::lookupGlobalAccessor2(Lookup *l, ExecutionContext *ctx, Value *result) +void Lookup::globalGetterAccessor2(Lookup *l, ExecutionContext *ctx, Value *result) { Object *o = ctx->engine->globalObject; if (l->classList[0] == o->internalClass) { @@ -321,8 +362,35 @@ void Lookup::lookupGlobalAccessor2(Lookup *l, ExecutionContext *ctx, Value *resu } } } - l->lookupGlobal = lookupGlobalGeneric; - lookupGlobalGeneric(l, ctx, result); + l->globalGetter = globalGetterGeneric; + globalGetterGeneric(l, ctx, result); +} + +void Lookup::setterGeneric(Lookup *l, ExecutionContext *ctx, const Value &object, const Value &value) +{ + Object *o = object.toObject(ctx); + + if (o->internalClass == l->classList[0]) { + o->memberData[l->index].value = value; + return; + } + + uint idx = o->internalClass->find(l->name); + if (!o->isArrayObject() || idx != ArrayObject::LengthPropertyIndex) { + if (idx != UINT_MAX && o->internalClass->propertyData[idx].isData() && o->internalClass->propertyData[idx].isWritable()) { + l->classList[0] = o->internalClass; + l->index = idx; + o->memberData[idx].value = value; + return; + } + + if (idx != UINT_MAX) { + o->putValue(ctx, o->memberData + idx, o->internalClass->propertyData[idx], value); + return; + } + } + + o->put(ctx, l->name, value); } QT_END_NAMESPACE diff --git a/src/qml/qml/v4vm/qv4lookup_p.h b/src/qml/qml/v4vm/qv4lookup_p.h index 81f9655ef0..2ad5a53a4c 100644 --- a/src/qml/qml/v4vm/qv4lookup_p.h +++ b/src/qml/qml/v4vm/qv4lookup_p.h @@ -55,84 +55,35 @@ namespace QV4 { struct Lookup { enum { Size = 3 }; union { - void (*lookupProperty)(Lookup *l, ExecutionContext *ctx, Value *result, const Value &object); - void (*lookupGlobal)(Lookup *l, ExecutionContext *ctx, Value *result); + void (*getter)(Lookup *l, ExecutionContext *ctx, Value *result, const Value &object); + void (*globalGetter)(Lookup *l, ExecutionContext *ctx, Value *result); + void (*setter)(Lookup *l, ExecutionContext *ctx, const Value &object, const Value &v); }; InternalClass *classList[Size]; int level; uint index; String *name; - static void lookupPropertyGeneric(Lookup *l, ExecutionContext *ctx, Value *result, const Value &object); - static void lookupProperty0(Lookup *l, ExecutionContext *ctx, Value *result, const Value &object); - static void lookupProperty1(Lookup *l, ExecutionContext *ctx, Value *result, const Value &object); - static void lookupProperty2(Lookup *l, ExecutionContext *ctx, Value *result, const Value &object); - static void lookupPropertyAccessor0(Lookup *l, ExecutionContext *ctx, Value *result, const Value &object); - static void lookupPropertyAccessor1(Lookup *l, ExecutionContext *ctx, Value *result, const Value &object); - static void lookupPropertyAccessor2(Lookup *l, ExecutionContext *ctx, Value *result, const Value &object); + static void getterGeneric(Lookup *l, ExecutionContext *ctx, Value *result, const Value &object); + static void getter0(Lookup *l, ExecutionContext *ctx, Value *result, const Value &object); + static void getter1(Lookup *l, ExecutionContext *ctx, Value *result, const Value &object); + static void getter2(Lookup *l, ExecutionContext *ctx, Value *result, const Value &object); + static void getterAccessor0(Lookup *l, ExecutionContext *ctx, Value *result, const Value &object); + static void getterAccessor1(Lookup *l, ExecutionContext *ctx, Value *result, const Value &object); + static void getterAccessor2(Lookup *l, ExecutionContext *ctx, Value *result, const Value &object); - static void lookupGlobalGeneric(Lookup *l, ExecutionContext *ctx, Value *result); - static void lookupGlobal0(Lookup *l, ExecutionContext *ctx, Value *result); - static void lookupGlobal1(Lookup *l, ExecutionContext *ctx, Value *result); - static void lookupGlobal2(Lookup *l, ExecutionContext *ctx, Value *result); - static void lookupGlobalAccessor0(Lookup *l, ExecutionContext *ctx, Value *result); - static void lookupGlobalAccessor1(Lookup *l, ExecutionContext *ctx, Value *result); - static void lookupGlobalAccessor2(Lookup *l, ExecutionContext *ctx, Value *result); + static void globalGetterGeneric(Lookup *l, ExecutionContext *ctx, Value *result); + static void globalGetter0(Lookup *l, ExecutionContext *ctx, Value *result); + static void globalGetter1(Lookup *l, ExecutionContext *ctx, Value *result); + static void globalGetter2(Lookup *l, ExecutionContext *ctx, Value *result); + static void globalGetterAccessor0(Lookup *l, ExecutionContext *ctx, Value *result); + static void globalGetterAccessor1(Lookup *l, ExecutionContext *ctx, Value *result); + static void globalGetterAccessor2(Lookup *l, ExecutionContext *ctx, Value *result); - Property *lookup(Object *obj, PropertyAttributes *attrs) { - int i = 0; - while (i < level && obj && obj->internalClass == classList[i]) { - obj = obj->prototype; - ++i; - } + static void setterGeneric(Lookup *l, ExecutionContext *ctx, const Value &object, const Value &value); - if (index != UINT_MAX && obj->internalClass == classList[i]) { - *attrs = obj->internalClass->propertyData.at(index); - return obj->memberData + index; - } + Property *lookup(Object *obj, PropertyAttributes *attrs); - while (i < Size && obj) { - classList[i] = obj->internalClass; - - index = obj->internalClass->find(name); - if (index != UINT_MAX) { - level = i; - *attrs = obj->internalClass->propertyData.at(index); - return obj->memberData + index; - } - - obj = obj->prototype; - ++i; - } - level = i; - - while (obj) { - index = obj->internalClass->find(name); - if (index != UINT_MAX) { - *attrs = obj->internalClass->propertyData.at(index); - return obj->memberData + index; - } - - obj = obj->prototype; - } - return 0; - } - - Property *setterLookup(Object *o, PropertyAttributes *attrs) { - if (o->internalClass == classList[0]) { - *attrs = o->internalClass->propertyData[index]; - return o->memberData + index; - } - - uint idx = o->internalClass->find(name); - if (idx != UINT_MAX) { - classList[0] = o->internalClass; - index = idx; - *attrs = o->internalClass->propertyData[index]; - return o->memberData + index; - } - return 0; - } }; } diff --git a/src/qml/qml/v4vm/qv4runtime.cpp b/src/qml/qml/v4vm/qv4runtime.cpp index 4b6d3d22cf..eeb4b415b4 100644 --- a/src/qml/qml/v4vm/qv4runtime.cpp +++ b/src/qml/qml/v4vm/qv4runtime.cpp @@ -704,13 +704,13 @@ void __qmljs_get_activation_property(ExecutionContext *ctx, Value *result, Strin void __qmljs_get_global_lookup(ExecutionContext *ctx, Value *result, int lookupIndex) { Lookup *l = ctx->lookups + lookupIndex; - l->lookupGlobal(l, ctx, result); + l->globalGetter(l, ctx, result); } void __qmljs_get_property_lookup(ExecutionContext *ctx, Value *result, const Value &object, int lookupIndex) { Lookup *l = ctx->lookups + lookupIndex; - l->lookupProperty(l, ctx, result, object); + l->getter(l, ctx, result, object); } void __qmljs_set_property_lookup(ExecutionContext *ctx, const Value &object, int lookupIndex, const Value &value) @@ -718,14 +718,7 @@ void __qmljs_set_property_lookup(ExecutionContext *ctx, const Value &object, int Object *o = object.toObject(ctx); Lookup *l = ctx->lookups + lookupIndex; - PropertyAttributes attrs; - Property *p = l->setterLookup(o, &attrs); - if (p && (l->index != ArrayObject::LengthPropertyIndex || !o->isArrayObject())) { - o->putValue(ctx, p, attrs, value); - return; - } - - o->put(ctx, l->name, value); + l->setter(l, ctx, object, value); } @@ -806,7 +799,7 @@ void __qmljs_call_global_lookup(ExecutionContext *context, Value *result, uint i { Lookup *l = context->lookups + index; Value v; - l->lookupGlobal(l, context, &v); + l->globalGetter(l, context, &v); FunctionObject *o = v.asFunctionObject(); if (!o) context->throwTypeError(); @@ -923,7 +916,7 @@ void __qmljs_construct_global_lookup(ExecutionContext *context, Value *result, u { Lookup *l = context->lookups + index; Value func; - l->lookupGlobal(l, context, &func); + l->globalGetter(l, context, &func); if (Object *f = func.asObject()) { Value res = f->construct(context, args, argc); diff --git a/tools/v4/main.cpp b/tools/v4/main.cpp index 3a91e59291..525649f9a4 100644 --- a/tools/v4/main.cpp +++ b/tools/v4/main.cpp @@ -69,7 +69,7 @@ namespace builtins { -using namespace QQmlJS::VM; +using namespace QV4; struct Print: FunctionObject { @@ -116,16 +116,16 @@ DEFINE_MANAGED_VTABLE(GC); } // builtins -static void showException(QQmlJS::VM::ExecutionContext *ctx, const QQmlJS::VM::Value &exception) +static void showException(QV4::ExecutionContext *ctx, const QV4::Value &exception) { - QQmlJS::VM::ErrorObject *e = exception.asErrorObject(); + QV4::ErrorObject *e = exception.asErrorObject(); if (!e) { std::cerr << "Uncaught exception: " << qPrintable(exception.toString(ctx)->toQString()) << std::endl; return; } - if (QQmlJS::VM::SyntaxErrorObject *err = e->asSyntaxError()) { - QQmlJS::VM::DiagnosticMessage *msg = err->message(); + if (QV4::SyntaxErrorObject *err = e->asSyntaxError()) { + QV4::DiagnosticMessage *msg = err->message(); if (!msg) { std::cerr << "Uncaught exception: Syntax error" << std::endl; return; @@ -153,9 +153,9 @@ int executeLLVMCode(void *codePtr) VM::ExecutionContext *ctx = vm.rootContext; #if THIS_NEEDS_TO_BE_FIXED - QQmlJS::VM::Object *globalObject = vm.globalObject.objectValue(); + QV4::Object *globalObject = vm.globalObject.objectValue(); globalObject->__put__(ctx, vm.newIdentifier(QStringLiteral("print")), - QQmlJS::VM::Value::fromObject(new (ctx->engine->memoryManager) builtins::Print(ctx))); + QV4::Value::fromObject(new (ctx->engine->memoryManager) builtins::Print(ctx))); void * buf = __qmljs_create_exception_handler(ctx); if (setjmp(*(jmp_buf *)buf)) { @@ -198,12 +198,12 @@ int compile(const QString &fileName, const QString &source, QQmlJS::LLVMOutputTy class MyErrorHandler: public ErrorHandler { public: - virtual void syntaxError(QQmlJS::VM::DiagnosticMessage *message) { + virtual void syntaxError(QV4::DiagnosticMessage *message) { for (; message; message = message->next) { std::cerr << qPrintable(message->fileName) << ':' << message->startLine << ':' << message->startColumn << ": " - << (message->type == QQmlJS::VM::DiagnosticMessage::Error ? "error" : "warning") << ": " + << (message->type == QV4::DiagnosticMessage::Error ? "error" : "warning") << ": " << qPrintable(message->message) << std::endl; } } @@ -349,24 +349,24 @@ int main(int argc, char *argv[]) iSelFactory = new QQmlJS::MASM::ISelFactory; } - QQmlJS::VM::ExecutionEngine vm(iSelFactory); + QV4::ExecutionEngine vm(iSelFactory); QScopedPointer debugger; if (enableDebugging) debugger.reset(new QQmlJS::Debugging::Debugger(&vm)); vm.debugger = debugger.data(); - QQmlJS::VM::ExecutionContext *ctx = vm.rootContext; + QV4::ExecutionContext *ctx = vm.rootContext; - QQmlJS::VM::Object *globalObject = vm.globalObject; - QQmlJS::VM::Object *print = new (ctx->engine->memoryManager) builtins::Print(ctx); + QV4::Object *globalObject = vm.globalObject; + QV4::Object *print = new (ctx->engine->memoryManager) builtins::Print(ctx); print->prototype = ctx->engine->objectPrototype; globalObject->put(ctx, vm.newIdentifier(QStringLiteral("print")), - QQmlJS::VM::Value::fromObject(print)); - QQmlJS::VM::Object *gc = new (ctx->engine->memoryManager) builtins::GC(ctx); + QV4::Value::fromObject(print)); + QV4::Object *gc = new (ctx->engine->memoryManager) builtins::GC(ctx); gc->prototype = ctx->engine->objectPrototype; globalObject->put(ctx, vm.newIdentifier(QStringLiteral("gc")), - QQmlJS::VM::Value::fromObject(gc)); + QV4::Value::fromObject(gc)); foreach (const QString &fn, args) { QFile file(fn); @@ -375,16 +375,16 @@ int main(int argc, char *argv[]) file.close(); try { - QQmlJS::VM::Function *f = QQmlJS::VM::EvalFunction::parseSource(ctx, fn, code, QQmlJS::Codegen::GlobalCode, + QV4::Function *f = QV4::EvalFunction::parseSource(ctx, fn, code, QQmlJS::Codegen::GlobalCode, /*strictMode =*/ false, /*inheritContext =*/ false); if (!f) continue; - QQmlJS::VM::Value result = vm.run(f); + QV4::Value result = vm.run(f); if (!result.isUndefined()) { if (! qgetenv("SHOW_EXIT_VALUE").isEmpty()) std::cout << "exit value: " << qPrintable(result.toString(ctx)->toQString()) << std::endl; } - } catch (QQmlJS::VM::Exception& ex) { + } catch (QV4::Exception& ex) { ex.accept(ctx); showException(ctx, ex.value()); return EXIT_FAILURE;