| OLD | NEW |
| 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 AddIndexedProperty; | 14 var AddIndexedProperty; |
| 15 var ArrayToString; | 15 // array.js has to come before typedarray.js for this to work |
| 16 var ArrayToString = utils.ImportNow("ArrayToString"); |
| 16 var ArrayValues; | 17 var ArrayValues; |
| 17 var GetIterator; | 18 var GetIterator; |
| 18 var GetMethod; | 19 var GetMethod; |
| 19 var GlobalArray = global.Array; | 20 var GlobalArray = global.Array; |
| 20 var GlobalArrayBuffer = global.ArrayBuffer; | 21 var GlobalArrayBuffer = global.ArrayBuffer; |
| 21 var GlobalArrayBufferPrototype = GlobalArrayBuffer.prototype; | 22 var GlobalArrayBufferPrototype = GlobalArrayBuffer.prototype; |
| 22 var GlobalDataView = global.DataView; | 23 var GlobalDataView = global.DataView; |
| 23 var GlobalObject = global.Object; | 24 var GlobalObject = global.Object; |
| 24 var InternalArray = utils.InternalArray; | 25 var InternalArray = utils.InternalArray; |
| 25 var InnerArrayCopyWithin; | 26 var InnerArrayCopyWithin; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 endmacro | 65 endmacro |
| 65 | 66 |
| 66 macro DECLARE_GLOBALS(INDEX, NAME, SIZE) | 67 macro DECLARE_GLOBALS(INDEX, NAME, SIZE) |
| 67 var GlobalNAME = global.NAME; | 68 var GlobalNAME = global.NAME; |
| 68 endmacro | 69 endmacro |
| 69 | 70 |
| 70 TYPED_ARRAYS(DECLARE_GLOBALS) | 71 TYPED_ARRAYS(DECLARE_GLOBALS) |
| 71 | 72 |
| 72 utils.Import(function(from) { | 73 utils.Import(function(from) { |
| 73 AddIndexedProperty = from.AddIndexedProperty; | 74 AddIndexedProperty = from.AddIndexedProperty; |
| 74 ArrayToString = from.ArrayToString; | |
| 75 ArrayValues = from.ArrayValues; | 75 ArrayValues = from.ArrayValues; |
| 76 GetIterator = from.GetIterator; | 76 GetIterator = from.GetIterator; |
| 77 GetMethod = from.GetMethod; | 77 GetMethod = from.GetMethod; |
| 78 InnerArrayCopyWithin = from.InnerArrayCopyWithin; | 78 InnerArrayCopyWithin = from.InnerArrayCopyWithin; |
| 79 InnerArrayEvery = from.InnerArrayEvery; | 79 InnerArrayEvery = from.InnerArrayEvery; |
| 80 InnerArrayFill = from.InnerArrayFill; | 80 InnerArrayFill = from.InnerArrayFill; |
| 81 InnerArrayFilter = from.InnerArrayFilter; | 81 InnerArrayFilter = from.InnerArrayFilter; |
| 82 InnerArrayFind = from.InnerArrayFind; | 82 InnerArrayFind = from.InnerArrayFind; |
| 83 InnerArrayFindIndex = from.InnerArrayFindIndex; | 83 InnerArrayFindIndex = from.InnerArrayFindIndex; |
| 84 InnerArrayForEach = from.InnerArrayForEach; | 84 InnerArrayForEach = from.InnerArrayForEach; |
| (...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 677 // ES6 section 22.2.3.27 | 677 // ES6 section 22.2.3.27 |
| 678 function TypedArrayToLocaleString() { | 678 function TypedArrayToLocaleString() { |
| 679 if (!IS_TYPEDARRAY(this)) throw MakeTypeError(kNotTypedArray); | 679 if (!IS_TYPEDARRAY(this)) throw MakeTypeError(kNotTypedArray); |
| 680 | 680 |
| 681 var length = %_TypedArrayGetLength(this); | 681 var length = %_TypedArrayGetLength(this); |
| 682 | 682 |
| 683 return InnerArrayToLocaleString(this, length); | 683 return InnerArrayToLocaleString(this, length); |
| 684 } | 684 } |
| 685 | 685 |
| 686 | 686 |
| 687 // ES6 section 22.2.3.28 | |
| 688 function TypedArrayToString() { | |
| 689 return %_Call(ArrayToString, this); | |
| 690 } | |
| 691 | |
| 692 | |
| 693 // ES6 section 22.2.3.14 | 687 // ES6 section 22.2.3.14 |
| 694 function TypedArrayJoin(separator) { | 688 function TypedArrayJoin(separator) { |
| 695 if (!IS_TYPEDARRAY(this)) throw MakeTypeError(kNotTypedArray); | 689 if (!IS_TYPEDARRAY(this)) throw MakeTypeError(kNotTypedArray); |
| 696 | 690 |
| 697 var length = %_TypedArrayGetLength(this); | 691 var length = %_TypedArrayGetLength(this); |
| 698 | 692 |
| 699 return InnerArrayJoin(separator, this, length); | 693 return InnerArrayJoin(separator, this, length); |
| 700 } | 694 } |
| 701 | 695 |
| 702 | 696 |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 875 "join", TypedArrayJoin, | 869 "join", TypedArrayJoin, |
| 876 "lastIndexOf", TypedArrayLastIndexOf, | 870 "lastIndexOf", TypedArrayLastIndexOf, |
| 877 "forEach", TypedArrayForEach, | 871 "forEach", TypedArrayForEach, |
| 878 "map", TypedArrayMap, | 872 "map", TypedArrayMap, |
| 879 "reduce", TypedArrayReduce, | 873 "reduce", TypedArrayReduce, |
| 880 "reduceRight", TypedArrayReduceRight, | 874 "reduceRight", TypedArrayReduceRight, |
| 881 "reverse", TypedArrayReverse, | 875 "reverse", TypedArrayReverse, |
| 882 "slice", TypedArraySlice, | 876 "slice", TypedArraySlice, |
| 883 "some", TypedArraySome, | 877 "some", TypedArraySome, |
| 884 "sort", TypedArraySort, | 878 "sort", TypedArraySort, |
| 885 "toString", TypedArrayToString, | |
| 886 "toLocaleString", TypedArrayToLocaleString | 879 "toLocaleString", TypedArrayToLocaleString |
| 887 ]); | 880 ]); |
| 888 | 881 |
| 882 %AddNamedProperty(TypedArray.prototype, "toString", ArrayToString, |
| 883 DONT_ENUM); |
| 884 |
| 889 | 885 |
| 890 macro SETUP_TYPED_ARRAY(ARRAY_ID, NAME, ELEMENT_SIZE) | 886 macro SETUP_TYPED_ARRAY(ARRAY_ID, NAME, ELEMENT_SIZE) |
| 891 %SetCode(GlobalNAME, NAMEConstructor); | 887 %SetCode(GlobalNAME, NAMEConstructor); |
| 892 %FunctionSetPrototype(GlobalNAME, new GlobalObject()); | 888 %FunctionSetPrototype(GlobalNAME, new GlobalObject()); |
| 893 %InternalSetPrototype(GlobalNAME, TypedArray); | 889 %InternalSetPrototype(GlobalNAME, TypedArray); |
| 894 %InternalSetPrototype(GlobalNAME.prototype, TypedArray.prototype); | 890 %InternalSetPrototype(GlobalNAME.prototype, TypedArray.prototype); |
| 895 | 891 |
| 896 %AddNamedProperty(GlobalNAME, "BYTES_PER_ELEMENT", ELEMENT_SIZE, | 892 %AddNamedProperty(GlobalNAME, "BYTES_PER_ELEMENT", ELEMENT_SIZE, |
| 897 READ_ONLY | DONT_ENUM | DONT_DELETE); | 893 READ_ONLY | DONT_ENUM | DONT_DELETE); |
| 898 | 894 |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1006 "setUint32", DataViewSetUint32JS, | 1002 "setUint32", DataViewSetUint32JS, |
| 1007 | 1003 |
| 1008 "getFloat32", DataViewGetFloat32JS, | 1004 "getFloat32", DataViewGetFloat32JS, |
| 1009 "setFloat32", DataViewSetFloat32JS, | 1005 "setFloat32", DataViewSetFloat32JS, |
| 1010 | 1006 |
| 1011 "getFloat64", DataViewGetFloat64JS, | 1007 "getFloat64", DataViewGetFloat64JS, |
| 1012 "setFloat64", DataViewSetFloat64JS | 1008 "setFloat64", DataViewSetFloat64JS |
| 1013 ]); | 1009 ]); |
| 1014 | 1010 |
| 1015 }) | 1011 }) |
| OLD | NEW |