Changeset 33038 in webkit for trunk/JavaScriptCore/kjs/regexp_object.cpp
- Timestamp:
- May 12, 2008, 12:12:31 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/regexp_object.cpp
r32807 r33038 52 52 : JSObject(objectPrototype) 53 53 { 54 putDirectFunction(new (exec)PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().compile, regExpProtoFuncCompile), DontEnum);55 putDirectFunction(new (exec)PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().exec, regExpProtoFuncExec), DontEnum);56 putDirectFunction(new (exec)PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().test, regExpProtoFuncTest), DontEnum);57 putDirectFunction(new (exec)PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().toString, regExpProtoFuncToString), DontEnum);54 putDirectFunction(new PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().compile, regExpProtoFuncCompile), DontEnum); 55 putDirectFunction(new PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().exec, regExpProtoFuncExec), DontEnum); 56 putDirectFunction(new PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().test, regExpProtoFuncTest), DontEnum); 57 putDirectFunction(new PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().toString, regExpProtoFuncToString), DontEnum); 58 58 } 59 59 … … 107 107 if (!thisObj->inherits(&RegExpImp::info)) { 108 108 if (thisObj->inherits(&RegExpPrototype::info)) 109 return jsString( exec,"//");109 return jsString("//"); 110 110 return throwError(exec, TypeError); 111 111 } … … 118 118 if (thisObj->get(exec, exec->propertyNames().multiline)->toBoolean(exec)) 119 119 result += "m"; 120 return jsString( exec,result);120 return jsString(result); 121 121 } 122 122 … … 151 151 } 152 152 153 JSValue* RegExpImp::getValueProperty(ExecState* exec, int token) const153 JSValue* RegExpImp::getValueProperty(ExecState*, int token) const 154 154 { 155 155 switch (token) { … … 161 161 return jsBoolean(m_regExp->multiline()); 162 162 case Source: 163 return jsString( exec,m_regExp->pattern());163 return jsString(m_regExp->pattern()); 164 164 case LastIndex: 165 return jsNumber( exec,m_lastIndex);165 return jsNumber(m_lastIndex); 166 166 } 167 167 … … 288 288 289 289 // no. of arguments for constructor 290 putDirect(exec->propertyNames().length, jsNumber( exec,2), ReadOnly | DontDelete | DontEnum);290 putDirect(exec->propertyNames().length, jsNumber(2), ReadOnly | DontDelete | DontEnum); 291 291 } 292 292 … … 318 318 { 319 319 unsigned lastNumSubpatterns = d->lastNumSubPatterns; 320 ArrayInstance* arr = new (exec)ArrayInstance(exec->lexicalGlobalObject()->arrayPrototype(), lastNumSubpatterns + 1);320 ArrayInstance* arr = new ArrayInstance(exec->lexicalGlobalObject()->arrayPrototype(), lastNumSubpatterns + 1); 321 321 for (unsigned i = 0; i <= lastNumSubpatterns; ++i) { 322 322 int start = d->lastOvector[2 * i]; 323 323 if (start >= 0) 324 arr->put(exec, i, jsString( exec,d->lastInput.substr(start, d->lastOvector[2 * i + 1] - start)));325 } 326 arr->put(exec, exec->propertyNames().index, jsNumber( exec,d->lastOvector[0]));327 arr->put(exec, exec->propertyNames().input, jsString( exec,d->lastInput));324 arr->put(exec, i, jsString(d->lastInput.substr(start, d->lastOvector[2 * i + 1] - start))); 325 } 326 arr->put(exec, exec->propertyNames().index, jsNumber(d->lastOvector[0])); 327 arr->put(exec, exec->propertyNames().input, jsString(d->lastInput)); 328 328 return arr; 329 329 } 330 330 331 JSValue* RegExpObjectImp::getBackref( ExecState* exec,unsigned i) const331 JSValue* RegExpObjectImp::getBackref(unsigned i) const 332 332 { 333 333 if (d->lastOvector && i <= d->lastNumSubPatterns) 334 return jsString( exec,d->lastInput.substr(d->lastOvector[2 * i], d->lastOvector[2 * i + 1] - d->lastOvector[2 * i]));335 return jsString( exec,"");336 } 337 338 JSValue* RegExpObjectImp::getLastParen( ExecState* exec) const334 return jsString(d->lastInput.substr(d->lastOvector[2 * i], d->lastOvector[2 * i + 1] - d->lastOvector[2 * i])); 335 return jsString(""); 336 } 337 338 JSValue* RegExpObjectImp::getLastParen() const 339 339 { 340 340 unsigned i = d->lastNumSubPatterns; 341 341 if (i > 0) { 342 342 ASSERT(d->lastOvector); 343 return jsString( exec,d->lastInput.substr(d->lastOvector[2 * i], d->lastOvector[2 * i + 1] - d->lastOvector[2 * i]));344 } 345 return jsString( exec,"");346 } 347 348 JSValue *RegExpObjectImp::getLeftContext( ExecState* exec) const343 return jsString(d->lastInput.substr(d->lastOvector[2 * i], d->lastOvector[2 * i + 1] - d->lastOvector[2 * i])); 344 } 345 return jsString(""); 346 } 347 348 JSValue *RegExpObjectImp::getLeftContext() const 349 349 { 350 350 if (d->lastOvector) 351 return jsString( exec,d->lastInput.substr(0, d->lastOvector[0]));352 return jsString( exec,"");353 } 354 355 JSValue *RegExpObjectImp::getRightContext( ExecState* exec) const351 return jsString(d->lastInput.substr(0, d->lastOvector[0])); 352 return jsString(""); 353 } 354 355 JSValue *RegExpObjectImp::getRightContext() const 356 356 { 357 357 if (d->lastOvector) { 358 358 UString s = d->lastInput; 359 return jsString( exec,s.substr(d->lastOvector[1], s.size() - d->lastOvector[1]));360 } 361 return jsString( exec,"");359 return jsString(s.substr(d->lastOvector[1], s.size() - d->lastOvector[1])); 360 } 361 return jsString(""); 362 362 } 363 363 … … 367 367 } 368 368 369 JSValue *RegExpObjectImp::getValueProperty(ExecState* exec, int token) const369 JSValue *RegExpObjectImp::getValueProperty(ExecState*, int token) const 370 370 { 371 371 switch (token) { 372 372 case Dollar1: 373 return getBackref( exec,1);373 return getBackref(1); 374 374 case Dollar2: 375 return getBackref( exec,2);375 return getBackref(2); 376 376 case Dollar3: 377 return getBackref( exec,3);377 return getBackref(3); 378 378 case Dollar4: 379 return getBackref( exec,4);379 return getBackref(4); 380 380 case Dollar5: 381 return getBackref( exec,5);381 return getBackref(5); 382 382 case Dollar6: 383 return getBackref( exec,6);383 return getBackref(6); 384 384 case Dollar7: 385 return getBackref( exec,7);385 return getBackref(7); 386 386 case Dollar8: 387 return getBackref( exec,8);387 return getBackref(8); 388 388 case Dollar9: 389 return getBackref( exec,9);389 return getBackref(9); 390 390 case Input: 391 return jsString( exec,d->lastInput);391 return jsString(d->lastInput); 392 392 case Multiline: 393 393 return jsBoolean(d->multiline); 394 394 case LastMatch: 395 return getBackref( exec,0);395 return getBackref(0); 396 396 case LastParen: 397 return getLastParen( exec);397 return getLastParen(); 398 398 case LeftContext: 399 return getLeftContext( exec);399 return getLeftContext(); 400 400 case RightContext: 401 return getRightContext( exec);401 return getRightContext(); 402 402 default: 403 403 ASSERT(0); 404 404 } 405 405 406 return jsString( exec,"");406 return jsString(""); 407 407 } 408 408 … … 452 452 { 453 453 return regExp->isValid() 454 ? new (exec)RegExpImp(static_cast<RegExpPrototype*>(exec->lexicalGlobalObject()->regExpPrototype()), regExp)454 ? new RegExpImp(static_cast<RegExpPrototype*>(exec->lexicalGlobalObject()->regExpPrototype()), regExp) 455 455 : throwError(exec, SyntaxError, UString("Invalid regular expression: ").append(regExp->errorMessage())); 456 456 }
Note:
See TracChangeset
for help on using the changeset viewer.