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

Unified Diff: src/string.js

Issue 14125004: Move global code for builtins into setup functions. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments by Andreas Rossberg. Created 7 years, 8 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/regexp.js ('k') | src/symbol.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/string.js
diff --git a/src/string.js b/src/string.js
index 2f8043c60917a444a77cab71e8af5fb28ca2fa81..bb439a99ac558cb8bac0aa99d6604b80ee3b5e10 100644
--- a/src/string.js
+++ b/src/string.js
@@ -25,24 +25,22 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
// This file relies on the fact that the following declaration has been made
// in runtime.js:
// var $String = global.String;
// var $NaN = 0/0;
+// -------------------------------------------------------------------
-// Set the String function and constructor.
-%SetCode($String, function(x) {
+function StringConstructor(x) {
var value = %_ArgumentsLength() == 0 ? '' : TO_STRING_INLINE(x);
if (%_IsConstructCall()) {
%_SetValueOf(this, value);
} else {
return value;
}
-});
+}
-%FunctionSetPrototype($String, new $String());
// ECMA-262 section 15.5.4.2
function StringToString() {
@@ -994,16 +992,19 @@ SetUpLockedPrototype(ReplaceResultBuilder,
function SetUpString() {
%CheckIsBootstrapping();
+
+ // Set the String function and constructor.
+ %SetCode($String, StringConstructor);
+ %FunctionSetPrototype($String, new $String());
+
// Set up the constructor property on the String prototype object.
%SetProperty($String.prototype, "constructor", $String, DONT_ENUM);
-
// Set up the non-enumerable functions on the String object.
InstallFunctions($String, DONT_ENUM, $Array(
"fromCharCode", StringFromCharCode
));
-
// Set up the non-enumerable functions on the String prototype object.
InstallFunctions($String.prototype, DONT_ENUM, $Array(
"valueOf", StringValueOf,
« no previous file with comments | « src/regexp.js ('k') | src/symbol.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698