Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(713)

Unified Diff: src/regexp.js

Issue 1149773003: Revert of Revert of Hook up more import/exports in natives. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/proxy.js ('k') | src/string.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/regexp.js
diff --git a/src/regexp.js b/src/regexp.js
index 6470f29ed9cbebcb350d8ea5858ca9146795f80b..a0d7094e026181f8071015658582319cdca6b0c9 100644
--- a/src/regexp.js
+++ b/src/regexp.js
@@ -2,9 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-var $regexpExec;
-var $regexpExecNoTests;
-var $regexpLastMatchInfo;
var $regexpLastMatchInfoOverride;
var harmony_regexps = false;
var harmony_unicode_regexps = false;
@@ -22,12 +19,12 @@
// -------------------------------------------------------------------
// Property of the builtins object for recording the result of the last
-// regexp match. The property $regexpLastMatchInfo includes the matchIndices
+// regexp match. The property RegExpLastMatchInfo includes the matchIndices
// array of the last successful regexp match (an array of start/end index
// pairs for the match and all the captured substrings), the invariant is
// that there are at least two capture indeces. The array also contains
// the subject string for the last successful match.
-$regexpLastMatchInfo = new InternalPackedArray(
+var RegExpLastMatchInfo = new InternalPackedArray(
2, // REGEXP_NUMBER_OF_CAPTURES
"", // Last subject.
UNDEFINED, // Last input - settable with RegExpSetInput.
@@ -104,7 +101,7 @@
function DoRegExpExec(regexp, string, index) {
- var result = %_RegExpExec(regexp, string, index, $regexpLastMatchInfo);
+ var result = %_RegExpExec(regexp, string, index, RegExpLastMatchInfo);
if (result !== null) $regexpLastMatchInfoOverride = null;
return result;
}
@@ -138,7 +135,7 @@
function RegExpExecNoTests(regexp, string, start) {
// Must be called with RegExp, string and positive integer as arguments.
- var matchInfo = %_RegExpExec(regexp, string, start, $regexpLastMatchInfo);
+ var matchInfo = %_RegExpExec(regexp, string, start, RegExpLastMatchInfo);
if (matchInfo !== null) {
$regexpLastMatchInfoOverride = null;
RETURN_NEW_RESULT_FROM_MATCH_INFO(matchInfo, string);
@@ -171,8 +168,8 @@
i = 0;
}
- // matchIndices is either null or the $regexpLastMatchInfo array.
- var matchIndices = %_RegExpExec(this, string, i, $regexpLastMatchInfo);
+ // matchIndices is either null or the RegExpLastMatchInfo array.
+ var matchIndices = %_RegExpExec(this, string, i, RegExpLastMatchInfo);
if (IS_NULL(matchIndices)) {
this.lastIndex = 0;
@@ -182,7 +179,7 @@
// Successful match.
$regexpLastMatchInfoOverride = null;
if (updateLastIndex) {
- this.lastIndex = $regexpLastMatchInfo[CAPTURE1];
+ this.lastIndex = RegExpLastMatchInfo[CAPTURE1];
}
RETURN_NEW_RESULT_FROM_MATCH_INFO(matchIndices, string);
}
@@ -214,14 +211,14 @@
this.lastIndex = 0;
return false;
}
- // matchIndices is either null or the $regexpLastMatchInfo array.
- var matchIndices = %_RegExpExec(this, string, i, $regexpLastMatchInfo);
+ // matchIndices is either null or the RegExpLastMatchInfo array.
+ var matchIndices = %_RegExpExec(this, string, i, RegExpLastMatchInfo);
if (IS_NULL(matchIndices)) {
this.lastIndex = 0;
return false;
}
$regexpLastMatchInfoOverride = null;
- this.lastIndex = $regexpLastMatchInfo[CAPTURE1];
+ this.lastIndex = RegExpLastMatchInfo[CAPTURE1];
return true;
} else {
// Non-global, non-sticky regexp.
@@ -235,8 +232,8 @@
%_StringCharCodeAt(regexp.source, 2) != 63) { // '?'
regexp = TrimRegExp(regexp);
}
- // matchIndices is either null or the $regexpLastMatchInfo array.
- var matchIndices = %_RegExpExec(regexp, string, 0, $regexpLastMatchInfo);
+ // matchIndices is either null or the RegExpLastMatchInfo array.
+ var matchIndices = %_RegExpExec(regexp, string, 0, RegExpLastMatchInfo);
if (IS_NULL(matchIndices)) {
this.lastIndex = 0;
return false;
@@ -281,10 +278,10 @@
if ($regexpLastMatchInfoOverride !== null) {
return OVERRIDE_MATCH($regexpLastMatchInfoOverride);
}
- var regExpSubject = LAST_SUBJECT($regexpLastMatchInfo);
+ var regExpSubject = LAST_SUBJECT(RegExpLastMatchInfo);
return %_SubString(regExpSubject,
- $regexpLastMatchInfo[CAPTURE0],
- $regexpLastMatchInfo[CAPTURE1]);
+ RegExpLastMatchInfo[CAPTURE0],
+ RegExpLastMatchInfo[CAPTURE1]);
}
@@ -294,14 +291,14 @@
if (override.length <= 3) return '';
return override[override.length - 3];
}
- var length = NUMBER_OF_CAPTURES($regexpLastMatchInfo);
+ var length = NUMBER_OF_CAPTURES(RegExpLastMatchInfo);
if (length <= 2) return ''; // There were no captures.
// We match the SpiderMonkey behavior: return the substring defined by the
// last pair (after the first pair) of elements of the capture array even if
// it is empty.
- var regExpSubject = LAST_SUBJECT($regexpLastMatchInfo);
- var start = $regexpLastMatchInfo[CAPTURE(length - 2)];
- var end = $regexpLastMatchInfo[CAPTURE(length - 1)];
+ var regExpSubject = LAST_SUBJECT(RegExpLastMatchInfo);
+ var start = RegExpLastMatchInfo[CAPTURE(length - 2)];
+ var end = RegExpLastMatchInfo[CAPTURE(length - 1)];
if (start != -1 && end != -1) {
return %_SubString(regExpSubject, start, end);
}
@@ -313,8 +310,8 @@
var start_index;
var subject;
if (!$regexpLastMatchInfoOverride) {
- start_index = $regexpLastMatchInfo[CAPTURE0];
- subject = LAST_SUBJECT($regexpLastMatchInfo);
+ start_index = RegExpLastMatchInfo[CAPTURE0];
+ subject = LAST_SUBJECT(RegExpLastMatchInfo);
} else {
var override = $regexpLastMatchInfoOverride;
start_index = OVERRIDE_POS(override);
@@ -328,8 +325,8 @@
var start_index;
var subject;
if (!$regexpLastMatchInfoOverride) {
- start_index = $regexpLastMatchInfo[CAPTURE1];
- subject = LAST_SUBJECT($regexpLastMatchInfo);
+ start_index = RegExpLastMatchInfo[CAPTURE1];
+ subject = LAST_SUBJECT(RegExpLastMatchInfo);
} else {
var override = $regexpLastMatchInfoOverride;
subject = OVERRIDE_SUBJECT(override);
@@ -352,11 +349,11 @@
return '';
}
var index = n * 2;
- if (index >= NUMBER_OF_CAPTURES($regexpLastMatchInfo)) return '';
- var matchStart = $regexpLastMatchInfo[CAPTURE(index)];
- var matchEnd = $regexpLastMatchInfo[CAPTURE(index + 1)];
+ if (index >= NUMBER_OF_CAPTURES(RegExpLastMatchInfo)) return '';
+ var matchStart = RegExpLastMatchInfo[CAPTURE(index)];
+ var matchEnd = RegExpLastMatchInfo[CAPTURE(index + 1)];
if (matchStart == -1 || matchEnd == -1) return '';
- return %_SubString(LAST_SUBJECT($regexpLastMatchInfo), matchStart, matchEnd);
+ return %_SubString(LAST_SUBJECT(RegExpLastMatchInfo), matchStart, matchEnd);
};
}
@@ -367,7 +364,7 @@
GlobalRegExp.prototype, 'constructor', GlobalRegExp, DONT_ENUM);
%SetCode(GlobalRegExp, RegExpConstructor);
-$installFunctions(GlobalRegExp.prototype, DONT_ENUM, [
+utils.InstallFunctions(GlobalRegExp.prototype, DONT_ENUM, [
"exec", RegExpExecJS,
"test", RegExpTest,
"toString", RegExpToString,
@@ -381,11 +378,11 @@
// value is set the value it is set to is coerced to a string.
// Getter and setter for the input.
var RegExpGetInput = function() {
- var regExpInput = LAST_INPUT($regexpLastMatchInfo);
+ var regExpInput = LAST_INPUT(RegExpLastMatchInfo);
return IS_UNDEFINED(regExpInput) ? "" : regExpInput;
};
var RegExpSetInput = function(string) {
- LAST_INPUT($regexpLastMatchInfo) = $toString(string);
+ LAST_INPUT(RegExpLastMatchInfo) = $toString(string);
};
%OptimizeObjectForAddingMultipleProperties(GlobalRegExp, 22);
@@ -443,7 +440,13 @@
}
%ToFastProperties(GlobalRegExp);
-$regexpExecNoTests = RegExpExecNoTests;
-$regexpExec = DoRegExpExec;
+// -------------------------------------------------------------------
+// Exports
+
+utils.Export(function(to) {
+ to.RegExpExec = DoRegExpExec;
+ to.RegExpExecNoTests = RegExpExecNoTests;
+ to.RegExpLastMatchInfo = RegExpLastMatchInfo;
+});
})
« no previous file with comments | « src/proxy.js ('k') | src/string.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698