Changeset 34754 in webkit for trunk/JavaScriptCore/kjs/RegExpObject.cpp
- Timestamp:
- Jun 23, 2008, 10:23:17 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/RegExpObject.cpp
r34659 r34754 39 39 // ------------------------------ RegExpPrototype --------------------------- 40 40 41 static JSValue* regExpProtoFuncTest(ExecState*, JSObject*, const ArgList&);42 static JSValue* regExpProtoFuncExec(ExecState*, JSObject*, const ArgList&);43 static JSValue* regExpProtoFuncCompile(ExecState*, JSObject*, const ArgList&);44 static JSValue* regExpProtoFuncToString(ExecState*, JSObject*, const ArgList&);41 static JSValue* regExpProtoFuncTest(ExecState*, JSObject*, JSValue*, const ArgList&); 42 static JSValue* regExpProtoFuncExec(ExecState*, JSObject*, JSValue*, const ArgList&); 43 static JSValue* regExpProtoFuncCompile(ExecState*, JSObject*, JSValue*, const ArgList&); 44 static JSValue* regExpProtoFuncToString(ExecState*, JSObject*, JSValue*, const ArgList&); 45 45 46 46 // ECMA 15.10.5 … … 59 59 // ------------------------------ Functions --------------------------- 60 60 61 JSValue* regExpProtoFuncTest(ExecState* exec, JSObject* thisObj, const ArgList& args)62 { 63 if (!this Obj->inherits(&RegExpObject::info))61 JSValue* regExpProtoFuncTest(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args) 62 { 63 if (!thisValue->isObject(&RegExpObject::info)) 64 64 return throwError(exec, TypeError); 65 66 return static_cast<RegExpObject*>(thisObj)->test(exec, args); 67 } 68 69 JSValue* regExpProtoFuncExec(ExecState* exec, JSObject* thisObj, const ArgList& args) 70 { 71 if (!thisObj->inherits(&RegExpObject::info)) 65 return static_cast<RegExpObject*>(thisValue)->test(exec, args); 66 } 67 68 JSValue* regExpProtoFuncExec(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args) 69 { 70 if (!thisValue->isObject(&RegExpObject::info)) 72 71 return throwError(exec, TypeError); 73 74 return static_cast<RegExpObject*>(thisObj)->exec(exec, args); 75 } 76 77 JSValue* regExpProtoFuncCompile(ExecState* exec, JSObject* thisObj, const ArgList& args) 78 { 79 if (!thisObj->inherits(&RegExpObject::info)) 72 return static_cast<RegExpObject*>(thisValue)->exec(exec, args); 73 } 74 75 JSValue* regExpProtoFuncCompile(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args) 76 { 77 if (!thisValue->isObject(&RegExpObject::info)) 80 78 return throwError(exec, TypeError); 81 79 … … 97 95 return throwError(exec, SyntaxError, UString("Invalid regular expression: ").append(regExp->errorMessage())); 98 96 99 static_cast<RegExpObject*>(this Obj)->setRegExp(regExp.release());100 static_cast<RegExpObject*>(this Obj)->setLastIndex(0);97 static_cast<RegExpObject*>(thisValue)->setRegExp(regExp.release()); 98 static_cast<RegExpObject*>(thisValue)->setLastIndex(0); 101 99 return jsUndefined(); 102 100 } 103 101 104 JSValue* regExpProtoFuncToString(ExecState* exec, JSObject* thisObj, const ArgList&)105 { 106 if (!this Obj->inherits(&RegExpObject::info)) {107 if (this Obj->inherits(&RegExpPrototype::info))102 JSValue* regExpProtoFuncToString(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&) 103 { 104 if (!thisValue->isObject(&RegExpObject::info)) { 105 if (thisValue->isObject(&RegExpPrototype::info)) 108 106 return jsString(exec, "//"); 109 107 return throwError(exec, TypeError); 110 108 } 111 109 112 UString result = "/" + thisObj->get(exec, exec->propertyNames().source)->toString(exec) + "/";113 if ( thisObj->get(exec, exec->propertyNames().global)->toBoolean(exec))110 UString result = "/" + static_cast<RegExpObject*>(thisValue)->get(exec, exec->propertyNames().source)->toString(exec) + "/"; 111 if (static_cast<RegExpObject*>(thisValue)->get(exec, exec->propertyNames().global)->toBoolean(exec)) 114 112 result += "g"; 115 if ( thisObj->get(exec, exec->propertyNames().ignoreCase)->toBoolean(exec))113 if (static_cast<RegExpObject*>(thisValue)->get(exec, exec->propertyNames().ignoreCase)->toBoolean(exec)) 116 114 result += "i"; 117 if ( thisObj->get(exec, exec->propertyNames().multiline)->toBoolean(exec))115 if (static_cast<RegExpObject*>(thisValue)->get(exec, exec->propertyNames().multiline)->toBoolean(exec)) 118 116 result += "m"; 119 117 return jsString(exec, result); … … 125 123 126 124 /* Source for RegExpObject.lut.h 127 @begin regExpTable 5125 @begin regExpTable 128 126 global RegExpObject::Global DontDelete|ReadOnly|DontEnum 129 127 ignoreCase RegExpObject::IgnoreCase DontDelete|ReadOnly|DontEnum … … 230 228 } 231 229 232 CallType RegExpObject::getCallData(CallData&) 233 { 230 static JSValue* callRegExpObject(ExecState* exec, JSObject* function, JSValue*, const ArgList& args) 231 { 232 return static_cast<RegExpObject*>(function)->exec(exec, args); 233 } 234 235 CallType RegExpObject::getCallData(CallData& callData) 236 { 237 callData.native.function = callRegExpObject; 234 238 return CallTypeNative; 235 239 } 236 240 237 JSValue* RegExpObject::callAsFunction(ExecState* exec, JSObject*, const ArgList& args)238 {239 return RegExpObject::exec(exec, args);240 }241 242 241 // ------------------------------ RegExpConstructor ------------------------------ 243 242 … … 245 244 246 245 /* Source for RegExpObject.lut.h 247 @begin regExpConstructorTable 21246 @begin regExpConstructorTable 248 247 input RegExpConstructor::Input None 249 248 $_ RegExpConstructor::Input DontEnum … … 317 316 public: 318 317 RegExpMatchesArray(ExecState*, RegExpConstructorPrivate*); 319 320 318 virtual ~RegExpMatchesArray(); 321 319 320 private: 322 321 virtual bool getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) { if (lazyCreationData()) fillArrayInstance(exec); return JSArray::getOwnPropertySlot(exec, propertyName, slot); } 323 322 virtual bool getOwnPropertySlot(ExecState* exec, unsigned propertyName, PropertySlot& slot) { if (lazyCreationData()) fillArrayInstance(exec); return JSArray::getOwnPropertySlot(exec, propertyName, slot); } … … 328 327 virtual void getPropertyNames(ExecState* exec, PropertyNameArray& arr) { if (lazyCreationData()) fillArrayInstance(exec); JSArray::getPropertyNames(exec, arr); } 329 328 330 private:331 329 void fillArrayInstance(ExecState*); 332 330 }; … … 472 470 } 473 471 474 ConstructType RegExpConstructor::getConstructData(ConstructData&)475 {476 return ConstructTypeNative;477 }478 479 472 // ECMA 15.10.4 480 JSObject *RegExpConstructor::construct(ExecState *exec, const ArgList &args)473 static JSObject* constructRegExp(ExecState* exec, const ArgList& args) 481 474 { 482 475 JSValue* arg0 = args[0]; … … 498 491 } 499 492 493 static JSObject* constructWithRegExpConstructor(ExecState* exec, JSObject*, const ArgList& args) 494 { 495 return constructRegExp(exec, args); 496 } 497 498 ConstructType RegExpConstructor::getConstructData(ConstructData& constructData) 499 { 500 constructData.native.function = constructWithRegExpConstructor; 501 return ConstructTypeNative; 502 } 503 500 504 // ECMA 15.10.3 501 JSValue *RegExpConstructor::callAsFunction(ExecState *exec, JSObject * /*thisObj*/, const ArgList &args) 502 { 503 return construct(exec, args); 505 static JSValue* callRegExpConstructor(ExecState* exec, JSObject*, JSValue*, const ArgList& args) 506 { 507 return constructRegExp(exec, args); 508 } 509 510 CallType RegExpConstructor::getCallData(CallData& callData) 511 { 512 callData.native.function = callRegExpConstructor; 513 return CallTypeNative; 504 514 } 505 515
Note:
See TracChangeset
for help on using the changeset viewer.