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

Unified Diff: src/regexp.js

Issue 1154743003: 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 a0d7094e026181f8071015658582319cdca6b0c9..6470f29ed9cbebcb350d8ea5858ca9146795f80b 100644
--- a/src/regexp.js
+++ b/src/regexp.js
@@ -2,6 +2,9 @@
// 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;
@@ -19,12 +22,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.
-var RegExpLastMatchInfo = new InternalPackedArray(
+$regexpLastMatchInfo = new InternalPackedArray(
2, // REGEXP_NUMBER_OF_CAPTURES
"", // Last subject.
UNDEFINED, // Last input - settable with RegExpSetInput.
@@ -101,7 +104,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;
}
@@ -135,7 +138,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);
@@ -168,8 +171,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;
@@ -179,7 +182,7 @@
// Successful match.
$regexpLastMatchInfoOverride = null;
if (updateLastIndex) {
- this.lastIndex = RegExpLastMatchInfo[CAPTURE1];
+ this.lastIndex = $regexpLastMatchInfo[CAPTURE1];
}
RETURN_NEW_RESULT_FROM_MATCH_INFO(matchIndices, string);
}
@@ -211,14 +214,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.
@@ -232,8 +235,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;
@@ -278,10 +281,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]);
}
@@ -291,14 +294,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);
}
@@ -310,8 +313,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);
@@ -325,8 +328,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);
@@ -349,11 +352,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);
};
}
@@ -364,7 +367,7 @@
GlobalRegExp.prototype, 'constructor', GlobalRegExp, DONT_ENUM);
%SetCode(GlobalRegExp, RegExpConstructor);
-utils.InstallFunctions(GlobalRegExp.prototype, DONT_ENUM, [
+$installFunctions(GlobalRegExp.prototype, DONT_ENUM, [
"exec", RegExpExecJS,
"test", RegExpTest,
"toString", RegExpToString,
@@ -378,11 +381,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);
@@ -440,13 +443,7 @@
}
%ToFastProperties(GlobalRegExp);
-// -------------------------------------------------------------------
-// Exports
-
-utils.Export(function(to) {
- to.RegExpExec = DoRegExpExec;
- to.RegExpExecNoTests = RegExpExecNoTests;
- to.RegExpLastMatchInfo = RegExpLastMatchInfo;
-});
+$regexpExecNoTests = RegExpExecNoTests;
+$regexpExec = DoRegExpExec;
})
« 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