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

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

Issue 2222893002: Move family of MakeError functions to C++ (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix in prologue.js Created 4 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
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 (function(global, utils) { 5 (function(global, utils) {
6 6
7 "use strict"; 7 "use strict";
8 8
9 %CheckIsBootstrapping(); 9 %CheckIsBootstrapping();
10 10
11 // ----------------------------------------------------------------------- 11 // -----------------------------------------------------------------------
12 // Imports 12 // Imports
13 13
14 var arrayIterationKindSymbol = 14 var arrayIterationKindSymbol =
15 utils.ImportNow("array_iteration_kind_symbol"); 15 utils.ImportNow("array_iteration_kind_symbol");
16 var arrayIteratorNextIndexSymbol = 16 var arrayIteratorNextIndexSymbol =
17 utils.ImportNow("array_iterator_next_symbol"); 17 utils.ImportNow("array_iterator_next_symbol");
18 var arrayIteratorObjectSymbol = 18 var arrayIteratorObjectSymbol =
19 utils.ImportNow("array_iterator_object_symbol"); 19 utils.ImportNow("array_iterator_object_symbol");
20 var GlobalArray = global.Array; 20 var GlobalArray = global.Array;
21 var IteratorPrototype = utils.ImportNow("IteratorPrototype"); 21 var IteratorPrototype = utils.ImportNow("IteratorPrototype");
22 var iteratorSymbol = utils.ImportNow("iterator_symbol"); 22 var iteratorSymbol = utils.ImportNow("iterator_symbol");
23 var MakeTypeError;
24 var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol"); 23 var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol");
25 var GlobalTypedArray = %object_get_prototype_of(global.Uint8Array); 24 var GlobalTypedArray = %object_get_prototype_of(global.Uint8Array);
26 25
27 utils.Import(function(from) {
28 MakeTypeError = from.MakeTypeError;
29 })
30
31 // ----------------------------------------------------------------------- 26 // -----------------------------------------------------------------------
32 27
33 function ArrayIterator() {} 28 function ArrayIterator() {}
34 29
35 30
36 // TODO(wingo): Update section numbers when ES6 has stabilized. The 31 // TODO(wingo): Update section numbers when ES6 has stabilized. The
37 // section numbers below are already out of date as of the May 2014 32 // section numbers below are already out of date as of the May 2014
38 // draft. 33 // draft.
39 34
40 35
(...skipping 15 matching lines...) Expand all
56 51
57 52
58 // ES6 section 22.1.5.2.1 %ArrayIteratorPrototype%.next( ) 53 // ES6 section 22.1.5.2.1 %ArrayIteratorPrototype%.next( )
59 function ArrayIteratorNext() { 54 function ArrayIteratorNext() {
60 var iterator = this; 55 var iterator = this;
61 var value = UNDEFINED; 56 var value = UNDEFINED;
62 var done = true; 57 var done = true;
63 58
64 if (!IS_RECEIVER(iterator) || 59 if (!IS_RECEIVER(iterator) ||
65 !HAS_DEFINED_PRIVATE(iterator, arrayIteratorNextIndexSymbol)) { 60 !HAS_DEFINED_PRIVATE(iterator, arrayIteratorNextIndexSymbol)) {
66 throw MakeTypeError(kIncompatibleMethodReceiver, 61 throw %make_type_error(kIncompatibleMethodReceiver,
67 'Array Iterator.prototype.next', this); 62 'Array Iterator.prototype.next', this);
68 } 63 }
69 64
70 var array = GET_PRIVATE(iterator, arrayIteratorObjectSymbol); 65 var array = GET_PRIVATE(iterator, arrayIteratorObjectSymbol);
71 if (!IS_UNDEFINED(array)) { 66 if (!IS_UNDEFINED(array)) {
72 var index = GET_PRIVATE(iterator, arrayIteratorNextIndexSymbol); 67 var index = GET_PRIVATE(iterator, arrayIteratorNextIndexSymbol);
73 var itemKind = GET_PRIVATE(iterator, arrayIterationKindSymbol); 68 var itemKind = GET_PRIVATE(iterator, arrayIterationKindSymbol);
74 var length = TO_UINT32(array.length); 69 var length = TO_UINT32(array.length);
75 70
76 // "sparse" is never used. 71 // "sparse" is never used.
(...skipping 27 matching lines...) Expand all
104 return CreateArrayIterator(this, ITERATOR_KIND_VALUES); 99 return CreateArrayIterator(this, ITERATOR_KIND_VALUES);
105 } 100 }
106 101
107 102
108 function ArrayKeys() { 103 function ArrayKeys() {
109 return CreateArrayIterator(this, ITERATOR_KIND_KEYS); 104 return CreateArrayIterator(this, ITERATOR_KIND_KEYS);
110 } 105 }
111 106
112 // TODO(littledan): Check for detached TypedArray in these three methods 107 // TODO(littledan): Check for detached TypedArray in these three methods
113 function TypedArrayEntries() { 108 function TypedArrayEntries() {
114 if (!IS_TYPEDARRAY(this)) throw MakeTypeError(kNotTypedArray); 109 if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray);
115 return %_Call(ArrayEntries, this); 110 return %_Call(ArrayEntries, this);
116 } 111 }
117 112
118 113
119 function TypedArrayValues() { 114 function TypedArrayValues() {
120 if (!IS_TYPEDARRAY(this)) throw MakeTypeError(kNotTypedArray); 115 if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray);
121 return %_Call(ArrayValues, this); 116 return %_Call(ArrayValues, this);
122 } 117 }
123 118
124 119
125 function TypedArrayKeys() { 120 function TypedArrayKeys() {
126 if (!IS_TYPEDARRAY(this)) throw MakeTypeError(kNotTypedArray); 121 if (!IS_TYPEDARRAY(this)) throw %make_type_error(kNotTypedArray);
127 return %_Call(ArrayKeys, this); 122 return %_Call(ArrayKeys, this);
128 } 123 }
129 124
130 125
131 %FunctionSetPrototype(ArrayIterator, {__proto__: IteratorPrototype}); 126 %FunctionSetPrototype(ArrayIterator, {__proto__: IteratorPrototype});
132 %FunctionSetInstanceClassName(ArrayIterator, 'Array Iterator'); 127 %FunctionSetInstanceClassName(ArrayIterator, 'Array Iterator');
133 128
134 utils.InstallFunctions(ArrayIterator.prototype, DONT_ENUM, [ 129 utils.InstallFunctions(ArrayIterator.prototype, DONT_ENUM, [
135 'next', ArrayIteratorNext 130 'next', ArrayIteratorNext
136 ]); 131 ]);
(...skipping 27 matching lines...) Expand all
164 // ------------------------------------------------------------------- 159 // -------------------------------------------------------------------
165 // Exports 160 // Exports
166 161
167 utils.Export(function(to) { 162 utils.Export(function(to) {
168 to.ArrayValues = ArrayValues; 163 to.ArrayValues = ArrayValues;
169 }); 164 });
170 165
171 %InstallToContext(["array_values_iterator", ArrayValues]); 166 %InstallToContext(["array_values_iterator", ArrayValues]);
172 167
173 }) 168 })
OLDNEW
« src/bootstrapper.cc ('K') | « src/js/array.js ('k') | src/js/arraybuffer.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698