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

Side by Side Diff: src/js/runtime.js

Issue 1470193002: Array/TypedArray/ArrayBuffer method subclassing and @@species (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase Created 4 years, 11 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/js/regexp.js ('k') | src/js/typedarray.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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 // This files contains runtime support implemented in JavaScript. 5 // This files contains runtime support implemented in JavaScript.
6 6
7 // CAUTION: Some of the functions specified in this file are called 7 // CAUTION: Some of the functions specified in this file are called
8 // directly from compiled code. These are the functions with names in 8 // directly from compiled code. These are the functions with names in
9 // ALL CAPS. The compiled code passes the first argument in 'this'. 9 // ALL CAPS. The compiled code passes the first argument in 'this'.
10 10
11 11
12 // The following declarations are shared with other native JS files. 12 // The following declarations are shared with other native JS files.
13 // They are all declared at this one spot to avoid redeclaration errors. 13 // They are all declared at this one spot to avoid redeclaration errors.
14 14
15 (function(global, utils) { 15 (function(global, utils) {
16 16
17 %CheckIsBootstrapping(); 17 %CheckIsBootstrapping();
18 18
19 var FLAG_harmony_species;
19 var GlobalArray = global.Array; 20 var GlobalArray = global.Array;
20 var GlobalBoolean = global.Boolean; 21 var GlobalBoolean = global.Boolean;
21 var GlobalString = global.String; 22 var GlobalString = global.String;
22 var isConcatSpreadableSymbol =
23 utils.ImportNow("is_concat_spreadable_symbol");
24 var MakeRangeError; 23 var MakeRangeError;
24 var MakeTypeError;
25 var speciesSymbol;
25 26
26 utils.Import(function(from) { 27 utils.Import(function(from) {
27 MakeRangeError = from.MakeRangeError; 28 MakeRangeError = from.MakeRangeError;
29 MakeTypeError = from.MakeTypeError;
30 speciesSymbol = from.species_symbol;
31 });
32
33 utils.ImportFromExperimental(function(from) {
34 FLAG_harmony_species = from.FLAG_harmony_species;
28 }); 35 });
29 36
30 // ---------------------------------------------------------------------------- 37 // ----------------------------------------------------------------------------
31 38
32 /* ----------------------------- 39 /* -----------------------------
33 - - - H e l p e r s - - - 40 - - - H e l p e r s - - -
34 ----------------------------- 41 -----------------------------
35 */ 42 */
36 43
37 function CONCAT_ITERABLE_TO_ARRAY(iterable) { 44 function CONCAT_ITERABLE_TO_ARRAY(iterable) {
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 118
112 119
113 function MinSimple(a, b) { 120 function MinSimple(a, b) {
114 return a > b ? b : a; 121 return a > b ? b : a;
115 } 122 }
116 123
117 124
118 %SetForceInlineFlag(MaxSimple); 125 %SetForceInlineFlag(MaxSimple);
119 %SetForceInlineFlag(MinSimple); 126 %SetForceInlineFlag(MinSimple);
120 127
128
129 // ES2015 7.3.20
130 function SpeciesConstructor(object, defaultConstructor) {
131 if (FLAG_harmony_species) {
132 var constructor = object.constructor;
133 if (IS_UNDEFINED(constructor)) {
134 return defaultConstructor;
135 }
136 if (!IS_RECEIVER(constructor)) {
137 throw MakeTypeError(kSpeciesNotConstructor);
138 }
139 var species = constructor[speciesSymbol];
140 if (IS_NULL_OR_UNDEFINED(species)) {
141 return defaultConstructor;
142 }
143 if (%IsConstructor(species)) {
144 return species;
145 }
146 throw MakeTypeError(kSpeciesNotConstructor);
147 } else {
148 return defaultConstructor;
149 }
150 }
151
121 //---------------------------------------------------------------------------- 152 //----------------------------------------------------------------------------
122 153
123 // NOTE: Setting the prototype for Array must take place as early as 154 // NOTE: Setting the prototype for Array must take place as early as
124 // possible due to code generation for array literals. When 155 // possible due to code generation for array literals. When
125 // generating code for a array literal a boilerplate array is created 156 // generating code for a array literal a boilerplate array is created
126 // that is cloned when running the code. It is essential that the 157 // that is cloned when running the code. It is essential that the
127 // boilerplate gets the right prototype. 158 // boilerplate gets the right prototype.
128 %FunctionSetPrototype(GlobalArray, new GlobalArray(0)); 159 %FunctionSetPrototype(GlobalArray, new GlobalArray(0));
129 160
130 // ---------------------------------------------------------------------------- 161 // ----------------------------------------------------------------------------
131 // Exports 162 // Exports
132 163
133 utils.Export(function(to) { 164 utils.Export(function(to) {
134 to.AddIndexedProperty = AddIndexedProperty; 165 to.AddIndexedProperty = AddIndexedProperty;
135 to.MaxSimple = MaxSimple; 166 to.MaxSimple = MaxSimple;
136 to.MinSimple = MinSimple; 167 to.MinSimple = MinSimple;
137 to.SameValue = SameValue; 168 to.SameValue = SameValue;
138 to.SameValueZero = SameValueZero; 169 to.SameValueZero = SameValueZero;
139 to.ToPositiveInteger = ToPositiveInteger; 170 to.ToPositiveInteger = ToPositiveInteger;
171 to.SpeciesConstructor = SpeciesConstructor;
140 }); 172 });
141 173
142 %InstallToContext([ 174 %InstallToContext([
143 "concat_iterable_to_array_builtin", CONCAT_ITERABLE_TO_ARRAY, 175 "concat_iterable_to_array_builtin", CONCAT_ITERABLE_TO_ARRAY,
144 ]); 176 ]);
145 177
146 %InstallToContext([ 178 %InstallToContext([
147 "concat_iterable_to_array", ConcatIterableToArray, 179 "concat_iterable_to_array", ConcatIterableToArray,
148 ]); 180 ]);
149 181
150 }) 182 })
OLDNEW
« no previous file with comments | « src/js/regexp.js ('k') | src/js/typedarray.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698