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

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

Issue 1266013006: [stubs] Unify (and optimize) implementation of ToObject. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Add missing support for %_ToObject in TurboFan and Crankshaft. Created 5 years, 4 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 | « src/array.js ('k') | src/bootstrapper.cc » ('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 $arrayValues; 5 var $arrayValues;
6 6
7 (function(global, utils) { 7 (function(global, utils) {
8 8
9 "use strict"; 9 "use strict";
10 10
(...skipping 27 matching lines...) Expand all
38 function ArrayIterator() {} 38 function ArrayIterator() {}
39 39
40 40
41 // TODO(wingo): Update section numbers when ES6 has stabilized. The 41 // TODO(wingo): Update section numbers when ES6 has stabilized. The
42 // section numbers below are already out of date as of the May 2014 42 // section numbers below are already out of date as of the May 2014
43 // draft. 43 // draft.
44 44
45 45
46 // 15.4.5.1 CreateArrayIterator Abstract Operation 46 // 15.4.5.1 CreateArrayIterator Abstract Operation
47 function CreateArrayIterator(array, kind) { 47 function CreateArrayIterator(array, kind) {
48 var object = $toObject(array); 48 var object = TO_OBJECT(array);
49 var iterator = new ArrayIterator; 49 var iterator = new ArrayIterator;
50 SET_PRIVATE(iterator, arrayIteratorObjectSymbol, object); 50 SET_PRIVATE(iterator, arrayIteratorObjectSymbol, object);
51 SET_PRIVATE(iterator, arrayIteratorNextIndexSymbol, 0); 51 SET_PRIVATE(iterator, arrayIteratorNextIndexSymbol, 0);
52 SET_PRIVATE(iterator, arrayIterationKindSymbol, kind); 52 SET_PRIVATE(iterator, arrayIterationKindSymbol, kind);
53 return iterator; 53 return iterator;
54 } 54 }
55 55
56 56
57 // 15.19.4.3.4 CreateItrResultObject 57 // 15.19.4.3.4 CreateItrResultObject
58 function CreateIteratorResultObject(value, done) { 58 function CreateIteratorResultObject(value, done) {
59 return {value: value, done: done}; 59 return {value: value, done: done};
60 } 60 }
61 61
62 62
63 // 22.1.5.2.2 %ArrayIteratorPrototype%[@@iterator] 63 // 22.1.5.2.2 %ArrayIteratorPrototype%[@@iterator]
64 function ArrayIteratorIterator() { 64 function ArrayIteratorIterator() {
65 return this; 65 return this;
66 } 66 }
67 67
68 68
69 // 15.4.5.2.2 ArrayIterator.prototype.next( ) 69 // 15.4.5.2.2 ArrayIterator.prototype.next( )
70 function ArrayIteratorNext() { 70 function ArrayIteratorNext() {
71 var iterator = $toObject(this); 71 var iterator = TO_OBJECT(this);
72 72
73 if (!HAS_DEFINED_PRIVATE(iterator, arrayIteratorNextIndexSymbol)) { 73 if (!HAS_DEFINED_PRIVATE(iterator, arrayIteratorNextIndexSymbol)) {
74 throw MakeTypeError(kIncompatibleMethodReceiver, 74 throw MakeTypeError(kIncompatibleMethodReceiver,
75 'Array Iterator.prototype.next', this); 75 'Array Iterator.prototype.next', this);
76 } 76 }
77 77
78 var array = GET_PRIVATE(iterator, arrayIteratorObjectSymbol); 78 var array = GET_PRIVATE(iterator, arrayIteratorObjectSymbol);
79 if (IS_UNDEFINED(array)) { 79 if (IS_UNDEFINED(array)) {
80 return CreateIteratorResultObject(UNDEFINED, true); 80 return CreateIteratorResultObject(UNDEFINED, true);
81 } 81 }
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 // ------------------------------------------------------------------- 158 // -------------------------------------------------------------------
159 // Exports 159 // Exports
160 160
161 utils.Export(function(to) { 161 utils.Export(function(to) {
162 to.ArrayIteratorCreateResultObject = CreateIteratorResultObject; 162 to.ArrayIteratorCreateResultObject = CreateIteratorResultObject;
163 }); 163 });
164 164
165 $arrayValues = ArrayValues; 165 $arrayValues = ArrayValues;
166 166
167 }) 167 })
OLDNEW
« no previous file with comments | « src/array.js ('k') | src/bootstrapper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698