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

Side by Side Diff: src/array-iterator.js

Issue 1083013002: Revert of Revert of Wrap typed array implementations 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 unified diff | Download patch
« no previous file with comments | « no previous file | src/arraybuffer.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 var $iteratorCreateResultObject;
6 var $arrayValues;
7
8 (function() {
9
5 "use strict"; 10 "use strict";
6 11
12 %CheckIsBootstrapping();
7 13
8 // This file relies on the fact that the following declaration has been made 14 var GlobalArray = global.Array;
9 // in runtime.js: 15 var GlobalObject = global.Object;
10 // var $Array = global.Array;
11 16
17 macro TYPED_ARRAYS(FUNCTION)
18 FUNCTION(Uint8Array)
19 FUNCTION(Int8Array)
20 FUNCTION(Uint16Array)
21 FUNCTION(Int16Array)
22 FUNCTION(Uint32Array)
23 FUNCTION(Int32Array)
24 FUNCTION(Float32Array)
25 FUNCTION(Float64Array)
26 FUNCTION(Uint8ClampedArray)
27 endmacro
28
29 macro COPY_FROM_GLOBAL(NAME)
30 var GlobalNAME = global.NAME;
31 endmacro
32
33 TYPED_ARRAYS(COPY_FROM_GLOBAL)
12 34
13 var arrayIteratorObjectSymbol = GLOBAL_PRIVATE("ArrayIterator#object"); 35 var arrayIteratorObjectSymbol = GLOBAL_PRIVATE("ArrayIterator#object");
14 var arrayIteratorNextIndexSymbol = GLOBAL_PRIVATE("ArrayIterator#next"); 36 var arrayIteratorNextIndexSymbol = GLOBAL_PRIVATE("ArrayIterator#next");
15 var arrayIterationKindSymbol = GLOBAL_PRIVATE("ArrayIterator#kind"); 37 var arrayIterationKindSymbol = GLOBAL_PRIVATE("ArrayIterator#kind");
16 38
17 39
18 function ArrayIterator() {} 40 function ArrayIterator() {}
19 41
20 42
21 // TODO(wingo): Update section numbers when ES6 has stabilized. The 43 // TODO(wingo): Update section numbers when ES6 has stabilized. The
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 function ArrayValues() { 115 function ArrayValues() {
94 return CreateArrayIterator(this, ITERATOR_KIND_VALUES); 116 return CreateArrayIterator(this, ITERATOR_KIND_VALUES);
95 } 117 }
96 118
97 119
98 function ArrayKeys() { 120 function ArrayKeys() {
99 return CreateArrayIterator(this, ITERATOR_KIND_KEYS); 121 return CreateArrayIterator(this, ITERATOR_KIND_KEYS);
100 } 122 }
101 123
102 124
103 function SetUpArrayIterator() { 125 %FunctionSetPrototype(ArrayIterator, new GlobalObject());
104 %CheckIsBootstrapping(); 126 %FunctionSetInstanceClassName(ArrayIterator, 'Array Iterator');
105 127
106 %FunctionSetPrototype(ArrayIterator, new $Object()); 128 InstallFunctions(ArrayIterator.prototype, DONT_ENUM, [
107 %FunctionSetInstanceClassName(ArrayIterator, 'Array Iterator'); 129 'next', ArrayIteratorNext
130 ]);
131 %FunctionSetName(ArrayIteratorIterator, '[Symbol.iterator]');
132 %AddNamedProperty(ArrayIterator.prototype, symbolIterator,
133 ArrayIteratorIterator, DONT_ENUM);
134 %AddNamedProperty(ArrayIterator.prototype, symbolToStringTag,
135 "Array Iterator", READ_ONLY | DONT_ENUM);
108 136
109 InstallFunctions(ArrayIterator.prototype, DONT_ENUM, [ 137 InstallFunctions(GlobalArray.prototype, DONT_ENUM, [
110 'next', ArrayIteratorNext 138 // No 'values' since it breaks webcompat: http://crbug.com/409858
111 ]); 139 'entries', ArrayEntries,
112 %FunctionSetName(ArrayIteratorIterator, '[Symbol.iterator]'); 140 'keys', ArrayKeys
113 %AddNamedProperty(ArrayIterator.prototype, symbolIterator, 141 ]);
114 ArrayIteratorIterator, DONT_ENUM);
115 %AddNamedProperty(ArrayIterator.prototype, symbolToStringTag,
116 "Array Iterator", READ_ONLY | DONT_ENUM);
117 }
118 SetUpArrayIterator();
119 142
143 %AddNamedProperty(GlobalArray.prototype, symbolIterator, ArrayValues,
144 DONT_ENUM);
120 145
121 function ExtendArrayPrototype() { 146 macro EXTEND_TYPED_ARRAY(NAME)
122 %CheckIsBootstrapping(); 147 %AddNamedProperty(GlobalNAME.prototype, 'entries', ArrayEntries, DONT_ENUM);
123 148 %AddNamedProperty(GlobalNAME.prototype, 'values', ArrayValues, DONT_ENUM);
124 InstallFunctions($Array.prototype, DONT_ENUM, [ 149 %AddNamedProperty(GlobalNAME.prototype, 'keys', ArrayKeys, DONT_ENUM);
125 // No 'values' since it breaks webcompat: http://crbug.com/409858 150 %AddNamedProperty(GlobalNAME.prototype, symbolIterator, ArrayValues,
126 'entries', ArrayEntries, 151 DONT_ENUM);
127 'keys', ArrayKeys
128 ]);
129
130 %AddNamedProperty($Array.prototype, symbolIterator, ArrayValues, DONT_ENUM);
131 }
132 ExtendArrayPrototype();
133
134
135 function ExtendTypedArrayPrototypes() {
136 %CheckIsBootstrapping();
137
138 macro TYPED_ARRAYS(FUNCTION)
139 FUNCTION(Uint8Array)
140 FUNCTION(Int8Array)
141 FUNCTION(Uint16Array)
142 FUNCTION(Int16Array)
143 FUNCTION(Uint32Array)
144 FUNCTION(Int32Array)
145 FUNCTION(Float32Array)
146 FUNCTION(Float64Array)
147 FUNCTION(Uint8ClampedArray)
148 endmacro 152 endmacro
149 153
150 macro EXTEND_TYPED_ARRAY(NAME) 154 TYPED_ARRAYS(EXTEND_TYPED_ARRAY)
151 %AddNamedProperty($NAME.prototype, 'entries', ArrayEntries, DONT_ENUM);
152 %AddNamedProperty($NAME.prototype, 'values', ArrayValues, DONT_ENUM);
153 %AddNamedProperty($NAME.prototype, 'keys', ArrayKeys, DONT_ENUM);
154 %AddNamedProperty($NAME.prototype, symbolIterator, ArrayValues, DONT_ENUM);
155 endmacro
156 155
157 TYPED_ARRAYS(EXTEND_TYPED_ARRAY) 156 $iteratorCreateResultObject = CreateIteratorResultObject;
158 } 157 $arrayValues = ArrayValues;
159 ExtendTypedArrayPrototypes(); 158
159 })();
OLDNEW
« no previous file with comments | « no previous file | src/arraybuffer.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698