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

Unified Diff: src/string-iterator.js

Issue 1000063002: Hide RegExp and String initialization in a closure. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: address comments Created 5 years, 9 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/string.js ('k') | src/third_party/fdlibm/fdlibm.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/string-iterator.js
diff --git a/src/string-iterator.js b/src/string-iterator.js
index f5eef37716ba98180774ec228cf80115b633a603..df31c130b8c8a7ecb994c0efd958194814f1b4fb 100644
--- a/src/string-iterator.js
+++ b/src/string-iterator.js
@@ -2,13 +2,17 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+(function() {
+
"use strict";
+%CheckIsBootstrapping();
-// This file relies on the fact that the following declaration has been made
-// in runtime.js:
-// var $String = global.String;
+var GlobalArray = global.Array;
+var GlobalObject = global.Object;
+var GlobalString = global.String;
+//-------------------------------------------------------------------
var stringIteratorIteratedStringSymbol =
GLOBAL_PRIVATE("StringIterator#iteratedString");
@@ -75,35 +79,27 @@ function StringIteratorNext() {
}
-function SetUpStringIterator() {
- %CheckIsBootstrapping();
-
- %FunctionSetPrototype(StringIterator, new $Object());
- %FunctionSetInstanceClassName(StringIterator, 'String Iterator');
-
- InstallFunctions(StringIterator.prototype, DONT_ENUM, $Array(
- 'next', StringIteratorNext
- ));
- %FunctionSetName(StringIteratorIterator, '[Symbol.iterator]');
- %AddNamedProperty(StringIterator.prototype, symbolIterator,
- StringIteratorIterator, DONT_ENUM);
- %AddNamedProperty(StringIterator.prototype, symbolToStringTag,
- "String Iterator", READ_ONLY | DONT_ENUM);
-}
-SetUpStringIterator();
-
-
// 21.1.3.27 String.prototype [ @@iterator ]( )
function StringPrototypeIterator() {
return CreateStringIterator(this);
}
+//-------------------------------------------------------------------
-function ExtendStringPrototypeWithIterator() {
- %CheckIsBootstrapping();
+%FunctionSetPrototype(StringIterator, new GlobalObject());
+%FunctionSetInstanceClassName(StringIterator, 'String Iterator');
- %FunctionSetName(StringPrototypeIterator, '[Symbol.iterator]');
- %AddNamedProperty($String.prototype, symbolIterator,
- StringPrototypeIterator, DONT_ENUM);
-}
-ExtendStringPrototypeWithIterator();
+InstallFunctions(StringIterator.prototype, DONT_ENUM, GlobalArray(
+ 'next', StringIteratorNext
+));
+%FunctionSetName(StringIteratorIterator, '[Symbol.iterator]');
+%AddNamedProperty(StringIterator.prototype, symbolIterator,
+ StringIteratorIterator, DONT_ENUM);
+%AddNamedProperty(StringIterator.prototype, symbolToStringTag,
+ "String Iterator", READ_ONLY | DONT_ENUM);
+
+%FunctionSetName(StringPrototypeIterator, '[Symbol.iterator]');
+%AddNamedProperty(GlobalString.prototype, symbolIterator,
+ StringPrototypeIterator, DONT_ENUM);
+
+})();
« no previous file with comments | « src/string.js ('k') | src/third_party/fdlibm/fdlibm.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698