OLD | NEW |
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 // value is set the value it is set to is coerced to a string. | 349 // value is set the value it is set to is coerced to a string. |
350 // Getter and setter for the input. | 350 // Getter and setter for the input. |
351 function RegExpGetInput() { | 351 function RegExpGetInput() { |
352 var regExpInput = LAST_INPUT(lastMatchInfo); | 352 var regExpInput = LAST_INPUT(lastMatchInfo); |
353 return IS_UNDEFINED(regExpInput) ? "" : regExpInput; | 353 return IS_UNDEFINED(regExpInput) ? "" : regExpInput; |
354 } | 354 } |
355 function RegExpSetInput(string) { | 355 function RegExpSetInput(string) { |
356 LAST_INPUT(lastMatchInfo) = ToString(string); | 356 LAST_INPUT(lastMatchInfo) = ToString(string); |
357 }; | 357 }; |
358 | 358 |
359 // All these accessors are set with the 'never_used' flag set to true. | |
360 // This is because at this point there can be no existing ics for setting | |
361 // these properties and so we don't have to bother clearing them. | |
362 %DefineAccessor($RegExp, 'input', GETTER, RegExpGetInput, DONT_DELETE); | 359 %DefineAccessor($RegExp, 'input', GETTER, RegExpGetInput, DONT_DELETE); |
363 %DefineAccessor($RegExp, 'input', SETTER, RegExpSetInput, DONT_DELETE, true); | 360 %DefineAccessor($RegExp, 'input', SETTER, RegExpSetInput, DONT_DELETE); |
364 %DefineAccessor($RegExp, '$_', GETTER, RegExpGetInput, DONT_ENUM | DONT_DELETE
); | 361 %DefineAccessor($RegExp, '$_', GETTER, RegExpGetInput, DONT_ENUM | DONT_DELETE
); |
365 %DefineAccessor($RegExp, '$_', SETTER, RegExpSetInput, DONT_ENUM | DONT_DELETE
, true); | 362 %DefineAccessor($RegExp, '$_', SETTER, RegExpSetInput, DONT_ENUM | DONT_DELETE
); |
366 %DefineAccessor($RegExp, '$input', GETTER, RegExpGetInput, DONT_ENUM | DONT_DE
LETE); | 363 %DefineAccessor($RegExp, '$input', GETTER, RegExpGetInput, DONT_ENUM | DONT_DE
LETE); |
367 %DefineAccessor($RegExp, '$input', SETTER, RegExpSetInput, DONT_ENUM | DONT_DE
LETE, true); | 364 %DefineAccessor($RegExp, '$input', SETTER, RegExpSetInput, DONT_ENUM | DONT_DE
LETE); |
368 | 365 |
369 // The properties multiline and $* are aliases for each other. When this | 366 // The properties multiline and $* are aliases for each other. When this |
370 // value is set in SpiderMonkey, the value it is set to is coerced to a | 367 // value is set in SpiderMonkey, the value it is set to is coerced to a |
371 // boolean. We mimic that behavior with a slight difference: in SpiderMonkey | 368 // boolean. We mimic that behavior with a slight difference: in SpiderMonkey |
372 // the value of the expression 'RegExp.multiline = null' (for instance) is the | 369 // the value of the expression 'RegExp.multiline = null' (for instance) is the |
373 // boolean false (ie, the value after coercion), while in V8 it is the value | 370 // boolean false (ie, the value after coercion), while in V8 it is the value |
374 // null (ie, the value before coercion). | 371 // null (ie, the value before coercion). |
375 | 372 |
376 // Getter and setter for multiline. | 373 // Getter and setter for multiline. |
377 var multiline = false; | 374 var multiline = false; |
378 function RegExpGetMultiline() { return multiline; }; | 375 function RegExpGetMultiline() { return multiline; }; |
379 function RegExpSetMultiline(flag) { multiline = flag ? true : false; }; | 376 function RegExpSetMultiline(flag) { multiline = flag ? true : false; }; |
380 | 377 |
381 %DefineAccessor($RegExp, 'multiline', GETTER, RegExpGetMultiline, DONT_DELETE)
; | 378 %DefineAccessor($RegExp, 'multiline', GETTER, RegExpGetMultiline, DONT_DELETE)
; |
382 %DefineAccessor($RegExp, 'multiline', SETTER, RegExpSetMultiline, DONT_DELETE,
true); | 379 %DefineAccessor($RegExp, 'multiline', SETTER, RegExpSetMultiline, DONT_DELETE)
; |
383 %DefineAccessor($RegExp, '$*', GETTER, RegExpGetMultiline, DONT_ENUM | DONT_DE
LETE); | 380 %DefineAccessor($RegExp, '$*', GETTER, RegExpGetMultiline, DONT_ENUM | DONT_DE
LETE); |
384 %DefineAccessor($RegExp, '$*', SETTER, RegExpSetMultiline, DONT_ENUM | DONT_DE
LETE, true); | 381 %DefineAccessor($RegExp, '$*', SETTER, RegExpSetMultiline, DONT_ENUM | DONT_DE
LETE); |
385 | 382 |
386 | 383 |
387 function NoOpSetter(ignored) {} | 384 function NoOpSetter(ignored) {} |
388 | 385 |
389 | 386 |
390 // Static properties set by a successful match. | 387 // Static properties set by a successful match. |
391 %DefineAccessor($RegExp, 'lastMatch', GETTER, RegExpGetLastMatch, DONT_DELETE)
; | 388 %DefineAccessor($RegExp, 'lastMatch', GETTER, RegExpGetLastMatch, DONT_DELETE)
; |
392 %DefineAccessor($RegExp, 'lastMatch', SETTER, NoOpSetter, DONT_DELETE, true); | 389 %DefineAccessor($RegExp, 'lastMatch', SETTER, NoOpSetter, DONT_DELETE); |
393 %DefineAccessor($RegExp, '$&', GETTER, RegExpGetLastMatch, DONT_ENUM | DONT_DE
LETE); | 390 %DefineAccessor($RegExp, '$&', GETTER, RegExpGetLastMatch, DONT_ENUM | DONT_DE
LETE); |
394 %DefineAccessor($RegExp, '$&', SETTER, NoOpSetter, DONT_ENUM | DONT_DELETE, tr
ue); | 391 %DefineAccessor($RegExp, '$&', SETTER, NoOpSetter, DONT_ENUM | DONT_DELETE); |
395 %DefineAccessor($RegExp, 'lastParen', GETTER, RegExpGetLastParen, DONT_DELETE)
; | 392 %DefineAccessor($RegExp, 'lastParen', GETTER, RegExpGetLastParen, DONT_DELETE)
; |
396 %DefineAccessor($RegExp, 'lastParen', SETTER, NoOpSetter, DONT_DELETE, true); | 393 %DefineAccessor($RegExp, 'lastParen', SETTER, NoOpSetter, DONT_DELETE); |
397 %DefineAccessor($RegExp, '$+', GETTER, RegExpGetLastParen, DONT_ENUM | DONT_DE
LETE); | 394 %DefineAccessor($RegExp, '$+', GETTER, RegExpGetLastParen, DONT_ENUM | DONT_DE
LETE); |
398 %DefineAccessor($RegExp, '$+', SETTER, NoOpSetter, DONT_ENUM | DONT_DELETE, tr
ue); | 395 %DefineAccessor($RegExp, '$+', SETTER, NoOpSetter, DONT_ENUM | DONT_DELETE); |
399 %DefineAccessor($RegExp, 'leftContext', GETTER, RegExpGetLeftContext, DONT_DEL
ETE); | 396 %DefineAccessor($RegExp, 'leftContext', GETTER, RegExpGetLeftContext, DONT_DEL
ETE); |
400 %DefineAccessor($RegExp, 'leftContext', SETTER, NoOpSetter, DONT_DELETE, true)
; | 397 %DefineAccessor($RegExp, 'leftContext', SETTER, NoOpSetter, DONT_DELETE); |
401 %DefineAccessor($RegExp, '$`', GETTER, RegExpGetLeftContext, DONT_ENUM | DONT_
DELETE); | 398 %DefineAccessor($RegExp, '$`', GETTER, RegExpGetLeftContext, DONT_ENUM | DONT_
DELETE); |
402 %DefineAccessor($RegExp, '$`', SETTER, NoOpSetter, DONT_ENUM | DONT_DELETE, tr
ue); | 399 %DefineAccessor($RegExp, '$`', SETTER, NoOpSetter, DONT_ENUM | DONT_DELETE); |
403 %DefineAccessor($RegExp, 'rightContext', GETTER, RegExpGetRightContext, DONT_D
ELETE); | 400 %DefineAccessor($RegExp, 'rightContext', GETTER, RegExpGetRightContext, DONT_D
ELETE); |
404 %DefineAccessor($RegExp, 'rightContext', SETTER, NoOpSetter, DONT_DELETE, true
); | 401 %DefineAccessor($RegExp, 'rightContext', SETTER, NoOpSetter, DONT_DELETE); |
405 %DefineAccessor($RegExp, "$'", GETTER, RegExpGetRightContext, DONT_ENUM | DONT
_DELETE); | 402 %DefineAccessor($RegExp, "$'", GETTER, RegExpGetRightContext, DONT_ENUM | DONT
_DELETE); |
406 %DefineAccessor($RegExp, "$'", SETTER, NoOpSetter, DONT_ENUM | DONT_DELETE, tr
ue); | 403 %DefineAccessor($RegExp, "$'", SETTER, NoOpSetter, DONT_ENUM | DONT_DELETE); |
407 | 404 |
408 for (var i = 1; i < 10; ++i) { | 405 for (var i = 1; i < 10; ++i) { |
409 %DefineAccessor($RegExp, '$' + i, GETTER, RegExpMakeCaptureGetter(i), DONT_D
ELETE); | 406 %DefineAccessor($RegExp, '$' + i, GETTER, RegExpMakeCaptureGetter(i), DONT_D
ELETE); |
410 %DefineAccessor($RegExp, '$' + i, SETTER, NoOpSetter, DONT_DELETE, true); | 407 %DefineAccessor($RegExp, '$' + i, SETTER, NoOpSetter, DONT_DELETE); |
411 } | 408 } |
412 } | 409 } |
413 | 410 |
414 | 411 |
415 SetupRegExp(); | 412 SetupRegExp(); |
OLD | NEW |