diff options
author | Lars Knoll <lars.knoll@digia.com> | 2014-05-06 09:23:59 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@digia.com> | 2014-07-22 13:49:11 +0200 |
commit | 9744e8bd423d528165f5e78704c6e017852b8e9a (patch) | |
tree | b1210199c698d3b09d80b9267d9aaab2b12ac5ab /src/qml/jsruntime/qv4globalobject.cpp | |
parent | f3f31957b79c55f3e076473b0d4c41c8872535b3 (diff) |
Convert ExecutionContext to new storage scheme
Change-Id: I9fcc13da5360f37cef3149b114ed9263b9b74281
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/jsruntime/qv4globalobject.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4globalobject.cpp | 94 |
1 files changed, 47 insertions, 47 deletions
diff --git a/src/qml/jsruntime/qv4globalobject.cpp b/src/qml/jsruntime/qv4globalobject.cpp index e78b913302..1be9561193 100644 --- a/src/qml/jsruntime/qv4globalobject.cpp +++ b/src/qml/jsruntime/qv4globalobject.cpp @@ -347,10 +347,10 @@ static QString decode(const QString &input, DecodeMode decodeMode, bool *ok) DEFINE_OBJECT_VTABLE(EvalFunction); EvalFunction::EvalFunction(ExecutionContext *scope) - : FunctionObject(scope, scope->engine->id_eval) + : FunctionObject(scope, scope->d()->engine->id_eval) { setVTable(staticVTable()); - defineReadonlyProperty(scope->engine->id_length, Primitive::fromInt32(1)); + defineReadonlyProperty(scope->d()->engine->id_length, Primitive::fromInt32(1)); } ReturnedValue EvalFunction::evalCall(CallData *callData, bool directCall) @@ -363,16 +363,16 @@ ReturnedValue EvalFunction::evalCall(CallData *callData, bool directCall) ContextStateSaver(ExecutionContext *context) : savedContext(context) - , strictMode(context->strictMode) - , evalCode(context->currentEvalCode) - , compilationUnit(context->compilationUnit) + , strictMode(context->d()->strictMode) + , evalCode(context->d()->currentEvalCode) + , compilationUnit(context->d()->compilationUnit) {} ~ContextStateSaver() { - savedContext->strictMode = strictMode; - savedContext->currentEvalCode = evalCode; - savedContext->compilationUnit = compilationUnit; + savedContext->d()->strictMode = strictMode; + savedContext->d()->currentEvalCode = evalCode; + savedContext->d()->compilationUnit = compilationUnit; } }; @@ -396,10 +396,10 @@ ReturnedValue EvalFunction::evalCall(CallData *callData, bool directCall) return callData->args[0].asReturnedValue(); const QString code = callData->args[0].stringValue()->toQString(); - bool inheritContext = !ctx->strictMode; + bool inheritContext = !ctx->d()->strictMode; Script script(ctx, code, QStringLiteral("eval code")); - script.strictMode = (directCall && parentContext->strictMode); + script.strictMode = (directCall && parentContext->d()->strictMode); script.inheritContext = inheritContext; script.parse(); if (scope.engine->hasException) @@ -409,14 +409,14 @@ ReturnedValue EvalFunction::evalCall(CallData *callData, bool directCall) if (!function) return Encode::undefined(); - d()->strictMode = function->isStrict() || (ctx->strictMode); + d()->strictMode = function->isStrict() || (ctx->d()->strictMode); d()->needsActivation = function->needsActivation(); if (strictMode()) { ScopedFunctionObject e(scope, FunctionObject::createScriptFunction(ctx, function)); ScopedCallData callData(scope, 0); - callData->thisObject = ctx->callData->thisObject; + callData->thisObject = ctx->d()->callData->thisObject; return e->call(callData); } @@ -424,12 +424,12 @@ ReturnedValue EvalFunction::evalCall(CallData *callData, bool directCall) ExecutionContext::EvalCode evalCode; evalCode.function = function; - evalCode.next = ctx->currentEvalCode; - ctx->currentEvalCode = &evalCode; + evalCode.next = ctx->d()->currentEvalCode; + ctx->d()->currentEvalCode = &evalCode; // set the correct strict mode flag on the context - ctx->strictMode = strictMode(); - ctx->compilationUnit = function->compilationUnit; + ctx->d()->strictMode = strictMode(); + ctx->d()->compilationUnit = function->compilationUnit; return function->code(ctx, function->codeData); } @@ -470,7 +470,7 @@ ReturnedValue GlobalFunctions::method_parseInt(CallContext *ctx) String *inputString = string->toString(ctx); // 1 QString trimmed = inputString->toQString().trimmed(); // 2 - if (ctx->engine->hasException) + if (ctx->d()->engine->hasException) return Encode::undefined(); const QChar *pos = trimmed.constData(); @@ -574,117 +574,117 @@ ReturnedValue GlobalFunctions::method_parseFloat(CallContext *ctx) /// isNaN [15.1.2.4] ReturnedValue GlobalFunctions::method_isNaN(CallContext *ctx) { - if (!ctx->callData->argc) + if (!ctx->d()->callData->argc) // undefined gets converted to NaN return Encode(true); - if (ctx->callData->args[0].integerCompatible()) + if (ctx->d()->callData->args[0].integerCompatible()) return Encode(false); - double d = ctx->callData->args[0].toNumber(); + double d = ctx->d()->callData->args[0].toNumber(); return Encode((bool)std::isnan(d)); } /// isFinite [15.1.2.5] ReturnedValue GlobalFunctions::method_isFinite(CallContext *ctx) { - if (!ctx->callData->argc) + if (!ctx->d()->callData->argc) // undefined gets converted to NaN return Encode(false); - if (ctx->callData->args[0].integerCompatible()) + if (ctx->d()->callData->args[0].integerCompatible()) return Encode(true); - double d = ctx->callData->args[0].toNumber(); + double d = ctx->d()->callData->args[0].toNumber(); return Encode((bool)std::isfinite(d)); } /// decodeURI [15.1.3.1] ReturnedValue GlobalFunctions::method_decodeURI(CallContext *context) { - if (context->callData->argc == 0) + if (context->d()->callData->argc == 0) return Encode::undefined(); - QString uriString = context->callData->args[0].toString(context)->toQString(); + QString uriString = context->d()->callData->args[0].toString(context)->toQString(); bool ok; QString out = decode(uriString, DecodeNonReserved, &ok); if (!ok) { Scope scope(context); - ScopedString s(scope, context->engine->newString(QStringLiteral("malformed URI sequence"))); + ScopedString s(scope, context->d()->engine->newString(QStringLiteral("malformed URI sequence"))); return context->throwURIError(s); } - return context->engine->newString(out)->asReturnedValue(); + return context->d()->engine->newString(out)->asReturnedValue(); } /// decodeURIComponent [15.1.3.2] ReturnedValue GlobalFunctions::method_decodeURIComponent(CallContext *context) { - if (context->callData->argc == 0) + if (context->d()->callData->argc == 0) return Encode::undefined(); - QString uriString = context->callData->args[0].toString(context)->toQString(); + QString uriString = context->d()->callData->args[0].toString(context)->toQString(); bool ok; QString out = decode(uriString, DecodeAll, &ok); if (!ok) { Scope scope(context); - ScopedString s(scope, context->engine->newString(QStringLiteral("malformed URI sequence"))); + ScopedString s(scope, context->d()->engine->newString(QStringLiteral("malformed URI sequence"))); return context->throwURIError(s); } - return context->engine->newString(out)->asReturnedValue(); + return context->d()->engine->newString(out)->asReturnedValue(); } /// encodeURI [15.1.3.3] ReturnedValue GlobalFunctions::method_encodeURI(CallContext *context) { - if (context->callData->argc == 0) + if (context->d()->callData->argc == 0) return Encode::undefined(); - QString uriString = context->callData->args[0].toString(context)->toQString(); + QString uriString = context->d()->callData->args[0].toString(context)->toQString(); bool ok; QString out = encode(uriString, uriUnescapedReserved, &ok); if (!ok) { Scope scope(context); - ScopedString s(scope, context->engine->newString(QStringLiteral("malformed URI sequence"))); + ScopedString s(scope, context->d()->engine->newString(QStringLiteral("malformed URI sequence"))); return context->throwURIError(s); } - return context->engine->newString(out)->asReturnedValue(); + return context->d()->engine->newString(out)->asReturnedValue(); } /// encodeURIComponent [15.1.3.4] ReturnedValue GlobalFunctions::method_encodeURIComponent(CallContext *context) { - if (context->callData->argc == 0) + if (context->d()->callData->argc == 0) return Encode::undefined(); - QString uriString = context->callData->args[0].toString(context)->toQString(); + QString uriString = context->d()->callData->args[0].toString(context)->toQString(); bool ok; QString out = encode(uriString, uriUnescaped, &ok); if (!ok) { Scope scope(context); - ScopedString s(scope, context->engine->newString(QStringLiteral("malformed URI sequence"))); + ScopedString s(scope, context->d()->engine->newString(QStringLiteral("malformed URI sequence"))); return context->throwURIError(s); } - return context->engine->newString(out)->asReturnedValue(); + return context->d()->engine->newString(out)->asReturnedValue(); } ReturnedValue GlobalFunctions::method_escape(CallContext *context) { - if (!context->callData->argc) - return context->engine->newString(QStringLiteral("undefined"))->asReturnedValue(); + if (!context->d()->callData->argc) + return context->d()->engine->newString(QStringLiteral("undefined"))->asReturnedValue(); - QString str = context->callData->args[0].toString(context)->toQString(); - return context->engine->newString(escape(str))->asReturnedValue(); + QString str = context->d()->callData->args[0].toString(context)->toQString(); + return context->d()->engine->newString(escape(str))->asReturnedValue(); } ReturnedValue GlobalFunctions::method_unescape(CallContext *context) { - if (!context->callData->argc) - return context->engine->newString(QStringLiteral("undefined"))->asReturnedValue(); + if (!context->d()->callData->argc) + return context->d()->engine->newString(QStringLiteral("undefined"))->asReturnedValue(); - QString str = context->callData->args[0].toString(context)->toQString(); - return context->engine->newString(unescape(str))->asReturnedValue(); + QString str = context->d()->callData->args[0].toString(context)->toQString(); + return context->d()->engine->newString(unescape(str))->asReturnedValue(); } |