| Index: src/js/regexp.js
|
| diff --git a/src/js/regexp.js b/src/js/regexp.js
|
| index 584d4cdf41bdbe58c76cb3bd9ee22249f34f494a..e51a6d227a8d40ef2308cfeb1eed557c44656f4f 100644
|
| --- a/src/js/regexp.js
|
| +++ b/src/js/regexp.js
|
| @@ -68,6 +68,36 @@
|
| flags = IS_UNDEFINED(flags) ? '' : TO_STRING(flags);
|
| %RegExpInitializeAndCompile(object, pattern, flags);
|
| return object;
|
| +}
|
| +
|
| +
|
| +function PatternFlags(pattern) {
|
| + return (REGEXP_GLOBAL(pattern) ? 'g' : '') +
|
| + (REGEXP_IGNORE_CASE(pattern) ? 'i' : '') +
|
| + (REGEXP_MULTILINE(pattern) ? 'm' : '') +
|
| + (REGEXP_UNICODE(pattern) ? 'u' : '') +
|
| + (REGEXP_STICKY(pattern) ? 'y' : '');
|
| +}
|
| +
|
| +
|
| +// ES#sec-regexp.prototype.compile RegExp.prototype.compile (pattern, flags)
|
| +function RegExpCompileJS(pattern, flags) {
|
| + if (!IS_REGEXP(this)) {
|
| + throw %make_type_error(kIncompatibleMethodReceiver,
|
| + "RegExp.prototype.compile", this);
|
| + }
|
| +
|
| + if (IS_REGEXP(pattern)) {
|
| + if (!IS_UNDEFINED(flags)) throw %make_type_error(kRegExpFlags);
|
| +
|
| + flags = PatternFlags(pattern);
|
| + pattern = REGEXP_SOURCE(pattern);
|
| + }
|
| +
|
| + RegExpInitialize(this, pattern, flags);
|
| +
|
| + // Return undefined for compatibility with JSC.
|
| + // See http://crbug.com/585775 for web compat details.
|
| }
|
|
|
|
|
| @@ -302,6 +332,18 @@
|
| : REGEXP_MULTILINE(regexp) ? "m" : ""));
|
| }
|
| return regexp_val;
|
| +}
|
| +
|
| +
|
| +function RegExpToString() {
|
| + if (!IS_RECEIVER(this)) {
|
| + throw %make_type_error(
|
| + kIncompatibleMethodReceiver, 'RegExp.prototype.toString', this);
|
| + }
|
| + if (this === GlobalRegExp.prototype) {
|
| + %IncrementUseCounter(kRegExpPrototypeToString);
|
| + }
|
| + return '/' + TO_STRING(this.source) + '/' + TO_STRING(this.flags);
|
| }
|
|
|
|
|
| @@ -887,6 +929,8 @@
|
| utils.InstallFunctions(GlobalRegExp.prototype, DONT_ENUM, [
|
| "exec", RegExpSubclassExecJS,
|
| "test", RegExpSubclassTest,
|
| + "toString", RegExpToString,
|
| + "compile", RegExpCompileJS,
|
| matchSymbol, RegExpSubclassMatch,
|
| replaceSymbol, RegExpSubclassReplace,
|
| searchSymbol, RegExpSubclassSearch,
|
|
|