diff options
Diffstat (limited to 'JavaScriptCore/runtime/RegExpObject.cpp')
| -rw-r--r-- | JavaScriptCore/runtime/RegExpObject.cpp | 60 |
1 files changed, 32 insertions, 28 deletions
diff --git a/JavaScriptCore/runtime/RegExpObject.cpp b/JavaScriptCore/runtime/RegExpObject.cpp index 42bfcef..7fda5b1 100644 --- a/JavaScriptCore/runtime/RegExpObject.cpp +++ b/JavaScriptCore/runtime/RegExpObject.cpp @@ -22,19 +22,23 @@ #include "RegExpObject.h" #include "Error.h" +#include "ExceptionHelpers.h" #include "JSArray.h" #include "JSGlobalObject.h" #include "JSString.h" +#include "Lookup.h" #include "RegExpConstructor.h" #include "RegExpPrototype.h" +#include "UStringConcatenate.h" +#include <wtf/PassOwnPtr.h> namespace JSC { -static JSValue regExpObjectGlobal(ExecState*, const Identifier&, const PropertySlot&); -static JSValue regExpObjectIgnoreCase(ExecState*, const Identifier&, const PropertySlot&); -static JSValue regExpObjectMultiline(ExecState*, const Identifier&, const PropertySlot&); -static JSValue regExpObjectSource(ExecState*, const Identifier&, const PropertySlot&); -static JSValue regExpObjectLastIndex(ExecState*, const Identifier&, const PropertySlot&); +static JSValue regExpObjectGlobal(ExecState*, JSValue, const Identifier&); +static JSValue regExpObjectIgnoreCase(ExecState*, JSValue, const Identifier&); +static JSValue regExpObjectMultiline(ExecState*, JSValue, const Identifier&); +static JSValue regExpObjectSource(ExecState*, JSValue, const Identifier&); +static JSValue regExpObjectLastIndex(ExecState*, JSValue, const Identifier&); static void setRegExpObjectLastIndex(ExecState*, JSObject*, JSValue); } // namespace JSC @@ -57,9 +61,9 @@ const ClassInfo RegExpObject::info = { "RegExp", 0, 0, ExecState::regExpTable }; @end */ -RegExpObject::RegExpObject(NonNullPassRefPtr<Structure> structure, NonNullPassRefPtr<RegExp> regExp) - : JSObject(structure) - , d(new RegExpObjectData(regExp, 0)) +RegExpObject::RegExpObject(JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure, NonNullPassRefPtr<RegExp> regExp) + : JSObjectWithGlobalObject(globalObject, structure) + , d(adoptPtr(new RegExpObjectData(regExp, 0))) { } @@ -77,29 +81,29 @@ bool RegExpObject::getOwnPropertyDescriptor(ExecState* exec, const Identifier& p return getStaticValueDescriptor<RegExpObject, JSObject>(exec, ExecState::regExpTable(exec), this, propertyName, descriptor); } -JSValue regExpObjectGlobal(ExecState*, const Identifier&, const PropertySlot& slot) +JSValue regExpObjectGlobal(ExecState*, JSValue slotBase, const Identifier&) { - return jsBoolean(asRegExpObject(slot.slotBase())->regExp()->global()); + return jsBoolean(asRegExpObject(slotBase)->regExp()->global()); } -JSValue regExpObjectIgnoreCase(ExecState*, const Identifier&, const PropertySlot& slot) +JSValue regExpObjectIgnoreCase(ExecState*, JSValue slotBase, const Identifier&) { - return jsBoolean(asRegExpObject(slot.slotBase())->regExp()->ignoreCase()); + return jsBoolean(asRegExpObject(slotBase)->regExp()->ignoreCase()); } -JSValue regExpObjectMultiline(ExecState*, const Identifier&, const PropertySlot& slot) +JSValue regExpObjectMultiline(ExecState*, JSValue slotBase, const Identifier&) { - return jsBoolean(asRegExpObject(slot.slotBase())->regExp()->multiline()); + return jsBoolean(asRegExpObject(slotBase)->regExp()->multiline()); } -JSValue regExpObjectSource(ExecState* exec, const Identifier&, const PropertySlot& slot) +JSValue regExpObjectSource(ExecState* exec, JSValue slotBase, const Identifier&) { - return jsString(exec, asRegExpObject(slot.slotBase())->regExp()->pattern()); + return jsString(exec, asRegExpObject(slotBase)->regExp()->pattern()); } -JSValue regExpObjectLastIndex(ExecState* exec, const Identifier&, const PropertySlot& slot) +JSValue regExpObjectLastIndex(ExecState*, JSValue slotBase, const Identifier&) { - return jsNumber(exec, asRegExpObject(slot.slotBase())->lastIndex()); + return jsNumber(asRegExpObject(slotBase)->lastIndex()); } void RegExpObject::put(ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot) @@ -112,21 +116,21 @@ void setRegExpObjectLastIndex(ExecState* exec, JSObject* baseObject, JSValue val asRegExpObject(baseObject)->setLastIndex(value.toInteger(exec)); } -JSValue RegExpObject::test(ExecState* exec, const ArgList& args) +JSValue RegExpObject::test(ExecState* exec) { - return jsBoolean(match(exec, args)); + return jsBoolean(match(exec)); } -JSValue RegExpObject::exec(ExecState* exec, const ArgList& args) +JSValue RegExpObject::exec(ExecState* exec) { - if (match(exec, args)) + if (match(exec)) return exec->lexicalGlobalObject()->regExpConstructor()->arrayOfMatches(exec); return jsNull(); } -static JSValue JSC_HOST_CALL callRegExpObject(ExecState* exec, JSObject* function, JSValue, const ArgList& args) +static EncodedJSValue JSC_HOST_CALL callRegExpObject(ExecState* exec) { - return asRegExpObject(function)->exec(exec, args); + return JSValue::encode(asRegExpObject(exec->callee())->exec(exec)); } CallType RegExpObject::getCallData(CallData& callData) @@ -136,13 +140,13 @@ CallType RegExpObject::getCallData(CallData& callData) } // Shared implementation used by test and exec. -bool RegExpObject::match(ExecState* exec, const ArgList& args) +bool RegExpObject::match(ExecState* exec) { RegExpConstructor* regExpConstructor = exec->lexicalGlobalObject()->regExpConstructor(); - UString input = args.isEmpty() ? regExpConstructor->input() : args.at(0).toString(exec); + UString input = !exec->argumentCount() ? regExpConstructor->input() : exec->argument(0).toString(exec); if (input.isNull()) { - throwError(exec, GeneralError, makeString("No input to ", toString(exec), ".")); + throwError(exec, createError(exec, makeUString("No input to ", toString(exec), "."))); return false; } @@ -153,7 +157,7 @@ bool RegExpObject::match(ExecState* exec, const ArgList& args) return position >= 0; } - if (d->lastIndex < 0 || d->lastIndex > input.size()) { + if (d->lastIndex < 0 || d->lastIndex > input.length()) { d->lastIndex = 0; return false; } |
