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

Unified Diff: src/collection-iterator.js

Issue 1094563002: Wrap map and set implementation in functions. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 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/collection.js ('k') | src/mirror-debugger.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/collection-iterator.js
diff --git a/src/collection-iterator.js b/src/collection-iterator.js
index 6f944f3c4ab55aa5a538b03af05f931a0e63b2c5..e66b4434041a26318f4743bb450424ea109397fe 100644
--- a/src/collection-iterator.js
+++ b/src/collection-iterator.js
@@ -2,14 +2,22 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+var $mapEntries;
+var $mapIteratorNext;
+var $setIteratorNext;
+var $setValues;
+
+(function() {
+
"use strict";
+%CheckIsBootstrapping();
-// This file relies on the fact that the following declaration has been made
-// in runtime.js:
-// var $Set = global.Set;
-// var $Map = global.Map;
+var GlobalMap = global.Map;
+var GlobalObject = global.Object;
+var GlobalSet = global.Set;
+// -------------------------------------------------------------------
function SetIteratorConstructor(set, kind) {
%SetIteratorInitialize(this, set, kind);
@@ -63,42 +71,33 @@ function SetValues() {
return new SetIterator(this, ITERATOR_KIND_VALUES);
}
+// -------------------------------------------------------------------
-function SetUpSetIterator() {
- %CheckIsBootstrapping();
+%SetCode(SetIterator, SetIteratorConstructor);
+%FunctionSetPrototype(SetIterator, new GlobalObject());
+%FunctionSetInstanceClassName(SetIterator, 'Set Iterator');
+InstallFunctions(SetIterator.prototype, DONT_ENUM, [
+ 'next', SetIteratorNextJS
+]);
- %SetCode(SetIterator, SetIteratorConstructor);
- %FunctionSetPrototype(SetIterator, new $Object());
- %FunctionSetInstanceClassName(SetIterator, 'Set Iterator');
- InstallFunctions(SetIterator.prototype, DONT_ENUM, [
- 'next', SetIteratorNextJS
- ]);
-
- %FunctionSetName(SetIteratorSymbolIterator, '[Symbol.iterator]');
- %AddNamedProperty(SetIterator.prototype, symbolIterator,
- SetIteratorSymbolIterator, DONT_ENUM);
- %AddNamedProperty(SetIterator.prototype, symbolToStringTag,
- "Set Iterator", READ_ONLY | DONT_ENUM);
-}
+%FunctionSetName(SetIteratorSymbolIterator, '[Symbol.iterator]');
+%AddNamedProperty(SetIterator.prototype, symbolIterator,
+ SetIteratorSymbolIterator, DONT_ENUM);
+%AddNamedProperty(SetIterator.prototype, symbolToStringTag,
+ "Set Iterator", READ_ONLY | DONT_ENUM);
-SetUpSetIterator();
+InstallFunctions(GlobalSet.prototype, DONT_ENUM, [
+ 'entries', SetEntries,
+ 'keys', SetValues,
+ 'values', SetValues
+]);
+%AddNamedProperty(GlobalSet.prototype, symbolIterator, SetValues, DONT_ENUM);
-function ExtendSetPrototype() {
- %CheckIsBootstrapping();
-
- InstallFunctions($Set.prototype, DONT_ENUM, [
- 'entries', SetEntries,
- 'keys', SetValues,
- 'values', SetValues
- ]);
-
- %AddNamedProperty($Set.prototype, symbolIterator, SetValues, DONT_ENUM);
-}
-
-ExtendSetPrototype();
-
+$setIteratorNext = SetIteratorNextJS;
+$setValues = SetValues;
+// -------------------------------------------------------------------
function MapIteratorConstructor(map, kind) {
%MapIteratorInitialize(this, map, kind);
@@ -162,37 +161,31 @@ function MapValues() {
return new MapIterator(this, ITERATOR_KIND_VALUES);
}
+// -------------------------------------------------------------------
-function SetUpMapIterator() {
- %CheckIsBootstrapping();
-
- %SetCode(MapIterator, MapIteratorConstructor);
- %FunctionSetPrototype(MapIterator, new $Object());
- %FunctionSetInstanceClassName(MapIterator, 'Map Iterator');
- InstallFunctions(MapIterator.prototype, DONT_ENUM, [
- 'next', MapIteratorNextJS
- ]);
+%SetCode(MapIterator, MapIteratorConstructor);
+%FunctionSetPrototype(MapIterator, new GlobalObject());
+%FunctionSetInstanceClassName(MapIterator, 'Map Iterator');
+InstallFunctions(MapIterator.prototype, DONT_ENUM, [
+ 'next', MapIteratorNextJS
+]);
- %FunctionSetName(MapIteratorSymbolIterator, '[Symbol.iterator]');
- %AddNamedProperty(MapIterator.prototype, symbolIterator,
- MapIteratorSymbolIterator, DONT_ENUM);
- %AddNamedProperty(MapIterator.prototype, symbolToStringTag,
- "Map Iterator", READ_ONLY | DONT_ENUM);
-}
-
-SetUpMapIterator();
+%FunctionSetName(MapIteratorSymbolIterator, '[Symbol.iterator]');
+%AddNamedProperty(MapIterator.prototype, symbolIterator,
+ MapIteratorSymbolIterator, DONT_ENUM);
+%AddNamedProperty(MapIterator.prototype, symbolToStringTag,
+ "Map Iterator", READ_ONLY | DONT_ENUM);
-function ExtendMapPrototype() {
- %CheckIsBootstrapping();
+InstallFunctions(GlobalMap.prototype, DONT_ENUM, [
+ 'entries', MapEntries,
+ 'keys', MapKeys,
+ 'values', MapValues
+]);
- InstallFunctions($Map.prototype, DONT_ENUM, [
- 'entries', MapEntries,
- 'keys', MapKeys,
- 'values', MapValues
- ]);
+%AddNamedProperty(GlobalMap.prototype, symbolIterator, MapEntries, DONT_ENUM);
- %AddNamedProperty($Map.prototype, symbolIterator, MapEntries, DONT_ENUM);
-}
+$mapEntries = MapEntries;
+$mapIteratorNext = MapIteratorNextJS;
-ExtendMapPrototype();
+})();
« no previous file with comments | « src/collection.js ('k') | src/mirror-debugger.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698