From cf8e87abaabd2f9aaf643d9563b526a662d3941d Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Wed, 1 Nov 2017 09:19:55 +0100 Subject: Convert methods of RegExp to new calling convention Change-Id: Ie364357b5e1ecf09eb264181e11b0247b07fad6c Reviewed-by: Erik Verbruggen --- src/qml/jsruntime/qv4regexpobject.cpp | 39 ++++++++++++++++------------------- 1 file changed, 18 insertions(+), 21 deletions(-) (limited to 'src/qml/jsruntime/qv4regexpobject.cpp') diff --git a/src/qml/jsruntime/qv4regexpobject.cpp b/src/qml/jsruntime/qv4regexpobject.cpp index 3ff5349e74..f95719b25f 100644 --- a/src/qml/jsruntime/qv4regexpobject.cpp +++ b/src/qml/jsruntime/qv4regexpobject.cpp @@ -311,13 +311,13 @@ void RegExpPrototype::init(ExecutionEngine *engine, Object *constructor) } /* used by String.match */ -ReturnedValue RegExpPrototype::execFirstMatch(const BuiltinFunction *b, CallData *callData) +ReturnedValue RegExpPrototype::execFirstMatch(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc) { Scope scope(b); - Scoped r(scope, callData->thisObject.as()); + Scoped r(scope, thisObject->as()); Q_ASSERT(r && r->global()); - ScopedString str(scope, callData->args[0]); + ScopedString str(scope, argc ? argv[0] : Primitive::undefinedValue()); Q_ASSERT(str); QString s = str->toQString(); @@ -356,14 +356,14 @@ ReturnedValue RegExpPrototype::execFirstMatch(const BuiltinFunction *b, CallData return retVal; } -ReturnedValue RegExpPrototype::method_exec(const BuiltinFunction *b, CallData *callData) +ReturnedValue RegExpPrototype::method_exec(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc) { Scope scope(b); - Scoped r(scope, callData->thisObject.as()); + Scoped r(scope, thisObject->as()); if (!r) return scope.engine->throwTypeError(); - ScopedValue arg(scope, callData->argument(0)); + ScopedValue arg(scope, argc ? argv[0]: Primitive::undefinedValue()); ScopedString str(scope, arg->toString(scope.engine)); if (scope.hasException()) RETURN_UNDEFINED(); @@ -413,40 +413,37 @@ ReturnedValue RegExpPrototype::method_exec(const BuiltinFunction *b, CallData *c return array.asReturnedValue(); } -ReturnedValue RegExpPrototype::method_test(const BuiltinFunction *b, CallData *callData) +ReturnedValue RegExpPrototype::method_test(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc) { - Value res = Value::fromReturnedValue(method_exec(b, callData)); + Value res = Value::fromReturnedValue(method_exec(b, thisObject, argv, argc)); return Encode(!res.isNull()); } -ReturnedValue RegExpPrototype::method_toString(const BuiltinFunction *b, CallData *callData) +ReturnedValue RegExpPrototype::method_toString(const FunctionObject *b, const Value *thisObject, const Value *, int) { ExecutionEngine *v4 = b->engine(); - RegExpObject *r = callData->thisObject.as(); + const RegExpObject *r = thisObject->as(); if (!r) return v4->throwTypeError(); return Encode(v4->newString(r->toString())); } -ReturnedValue RegExpPrototype::method_compile(const BuiltinFunction *b, CallData *callData) +ReturnedValue RegExpPrototype::method_compile(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc) { Scope scope(b); - Scoped r(scope, callData->thisObject.as()); + Scoped r(scope, thisObject->as()); if (!r) return scope.engine->throwTypeError(); - JSCallData jsCallData(scope, callData->argc()); - memcpy(jsCallData->args, callData->args, callData->argc()*sizeof(Value)); - - Scoped re(scope, scope.engine->regExpCtor()->callAsConstructor(jsCallData)); + Scoped re(scope, scope.engine->regExpCtor()->callAsConstructor(argv, argc)); r->d()->value.set(scope.engine, re->value()); return Encode::undefined(); } template -ReturnedValue RegExpPrototype::method_get_lastMatch_n(const BuiltinFunction *b, CallData *) +ReturnedValue RegExpPrototype::method_get_lastMatch_n(const FunctionObject *b, const Value *, const Value *, int) { Scope scope(b); ScopedArrayObject lastMatch(scope, static_cast(scope.engine->regExpCtor())->lastMatch()); @@ -456,7 +453,7 @@ ReturnedValue RegExpPrototype::method_get_lastMatch_n(const BuiltinFunction *b, return res->asReturnedValue(); } -ReturnedValue RegExpPrototype::method_get_lastParen(const BuiltinFunction *b, CallData *) +ReturnedValue RegExpPrototype::method_get_lastParen(const FunctionObject *b, const Value *, const Value *, int) { Scope scope(b); ScopedArrayObject lastMatch(scope, static_cast(scope.engine->regExpCtor())->lastMatch()); @@ -466,12 +463,12 @@ ReturnedValue RegExpPrototype::method_get_lastParen(const BuiltinFunction *b, Ca return res->asReturnedValue(); } -ReturnedValue RegExpPrototype::method_get_input(const BuiltinFunction *b, CallData *) +ReturnedValue RegExpPrototype::method_get_input(const FunctionObject *b, const Value *, const Value *, int) { return static_cast(b->engine()->regExpCtor())->lastInput()->asReturnedValue(); } -ReturnedValue RegExpPrototype::method_get_leftContext(const BuiltinFunction *b, CallData *) +ReturnedValue RegExpPrototype::method_get_leftContext(const FunctionObject *b, const Value *, const Value *, int) { Scope scope(b); Scoped regExpCtor(scope, scope.engine->regExpCtor()); @@ -479,7 +476,7 @@ ReturnedValue RegExpPrototype::method_get_leftContext(const BuiltinFunction *b, return Encode(scope.engine->newString(lastInput.left(regExpCtor->lastMatchStart()))); } -ReturnedValue RegExpPrototype::method_get_rightContext(const BuiltinFunction *b, CallData *) +ReturnedValue RegExpPrototype::method_get_rightContext(const FunctionObject *b, const Value *, const Value *, int) { Scope scope(b); Scoped regExpCtor(scope, scope.engine->regExpCtor()); -- cgit v1.2.1