diff options
author | Fedor Indutny <fedor@indutny.com> | 2014-10-10 14:49:02 +0400 |
---|---|---|
committer | Fedor Indutny <fedor@indutny.com> | 2014-10-10 14:49:02 +0400 |
commit | 6bcea4ff932144a5fd02affefd45164fbf471e67 (patch) | |
tree | a8e078c679b12f0daebe10ed254239cb0d79e146 /deps/v8/src/regexp.js | |
parent | 4fae2356d105e394115188a814097c4a95ae0c5d (diff) | |
download | node-new-6bcea4ff932144a5fd02affefd45164fbf471e67.tar.gz |
deps: update v8 to 3.29.93.1
Diffstat (limited to 'deps/v8/src/regexp.js')
-rw-r--r-- | deps/v8/src/regexp.js | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/deps/v8/src/regexp.js b/deps/v8/src/regexp.js index d7883fb693..0f3dbb630e 100644 --- a/deps/v8/src/regexp.js +++ b/deps/v8/src/regexp.js @@ -22,6 +22,8 @@ function DoConstructRegExp(object, pattern, flags) { flags = (pattern.global ? 'g' : '') + (pattern.ignoreCase ? 'i' : '') + (pattern.multiline ? 'm' : ''); + if (harmony_regexps) + flags += (pattern.sticky ? 'y' : ''); pattern = pattern.source; } @@ -31,6 +33,7 @@ function DoConstructRegExp(object, pattern, flags) { var global = false; var ignoreCase = false; var multiline = false; + var sticky = false; for (var i = 0; i < flags.length; i++) { var c = %_CallFunction(flags, i, StringCharAt); switch (c) { @@ -52,12 +55,18 @@ function DoConstructRegExp(object, pattern, flags) { } multiline = true; break; + case 'y': + if (!harmony_regexps || sticky) { + throw MakeSyntaxError("invalid_regexp_flags", [flags]); + } + sticky = true; + break; default: throw MakeSyntaxError("invalid_regexp_flags", [flags]); } } - %RegExpInitializeObject(object, pattern, global, ignoreCase, multiline); + %RegExpInitializeObject(object, pattern, global, ignoreCase, multiline, sticky); // Call internal function to compile the pattern. %RegExpCompile(object, pattern, flags); @@ -159,8 +168,8 @@ function RegExpExec(string) { // algorithm, step 5) even if the value is discarded for non-global RegExps. var i = TO_INTEGER(lastIndex); - var global = this.global; - if (global) { + var updateLastIndex = this.global || (harmony_regexps && this.sticky); + if (updateLastIndex) { if (i < 0 || i > string.length) { this.lastIndex = 0; return null; @@ -179,7 +188,7 @@ function RegExpExec(string) { // Successful match. lastMatchInfoOverride = null; - if (global) { + if (updateLastIndex) { this.lastIndex = lastMatchInfo[CAPTURE1]; } RETURN_NEW_RESULT_FROM_MATCH_INFO(matchIndices, string); @@ -207,7 +216,7 @@ function RegExpTest(string) { // algorithm, step 5) even if the value is discarded for non-global RegExps. var i = TO_INTEGER(lastIndex); - if (this.global) { + if (this.global || (harmony_regexps && this.sticky)) { if (i < 0 || i > string.length) { this.lastIndex = 0; return false; @@ -222,12 +231,13 @@ function RegExpTest(string) { this.lastIndex = lastMatchInfo[CAPTURE1]; return true; } else { - // Non-global regexp. - // Remove irrelevant preceeding '.*' in a non-global test regexp. - // The expression checks whether this.source starts with '.*' and - // that the third char is not a '?'. + // Non-global, non-sticky regexp. + // Remove irrelevant preceeding '.*' in a test regexp. The expression + // checks whether this.source starts with '.*' and that the third char is + // not a '?'. But see https://code.google.com/p/v8/issues/detail?id=3560 var regexp = this; - if (%_StringCharCodeAt(regexp.source, 0) == 46 && // '.' + if (regexp.source.length >= 3 && + %_StringCharCodeAt(regexp.source, 0) == 46 && // '.' %_StringCharCodeAt(regexp.source, 1) == 42 && // '*' %_StringCharCodeAt(regexp.source, 2) != 63) { // '?' regexp = TrimRegExp(regexp); @@ -264,6 +274,7 @@ function RegExpToString() { if (this.global) result += 'g'; if (this.ignoreCase) result += 'i'; if (this.multiline) result += 'm'; + if (harmony_regexps && this.sticky) result += 'y'; return result; } @@ -394,7 +405,7 @@ function SetUpRegExp() { // The length of compile is 1 in SpiderMonkey. %FunctionSetLength($RegExp.prototype.compile, 1); - // The properties input, $input, and $_ are aliases for each other. When this + // The properties `input` and `$_` are aliases for each other. When this // value is set the value it is set to is coerced to a string. // Getter and setter for the input. var RegExpGetInput = function() { @@ -410,8 +421,6 @@ function SetUpRegExp() { RegExpSetInput, DONT_DELETE); %DefineAccessorPropertyUnchecked($RegExp, '$_', RegExpGetInput, RegExpSetInput, DONT_ENUM | DONT_DELETE); - %DefineAccessorPropertyUnchecked($RegExp, '$input', RegExpGetInput, - RegExpSetInput, DONT_ENUM | DONT_DELETE); // The properties multiline and $* are aliases for each other. When this // value is set in SpiderMonkey, the value it is set to is coerced to a |