| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 file relies on the fact that the following declarations have been made | 5 // This file relies on the fact that the following declarations have been made |
| 6 // in runtime.js: | 6 // in runtime.js: |
| 7 // var $Object = global.Object; | 7 // var $Object = global.Object; |
| 8 // var $Boolean = global.Boolean; | 8 // var $Boolean = global.Boolean; |
| 9 // var $Number = global.Number; | 9 // var $Number = global.Number; |
| 10 // var $Function = global.Function; | 10 // var $Function = global.Function; |
| 11 // var $Array = global.Array; | 11 // var $Array = global.Array; |
| 12 | 12 |
| 13 var $isNaN = GlobalIsNaN; | 13 var $isNaN = GlobalIsNaN; |
| 14 var $isFinite = GlobalIsFinite; | 14 var $isFinite = GlobalIsFinite; |
| 15 | 15 |
| 16 // ---------------------------------------------------------------------------- | 16 // ---------------------------------------------------------------------------- |
| 17 | 17 |
| 18 // ES6 - 9.2.11 SetFunctionName |
| 19 function SetFunctionName(f, name, prefix) { |
| 20 if (IS_SYMBOL(name)) { |
| 21 name = "[" + %SymbolDescription(name) + "]"; |
| 22 } |
| 23 if (IS_UNDEFINED(prefix)) { |
| 24 %FunctionSetName(f, name); |
| 25 } else { |
| 26 %FunctionSetName(f, prefix + " " + name); |
| 27 } |
| 28 } |
| 29 |
| 30 |
| 18 // Helper function used to install functions on objects. | 31 // Helper function used to install functions on objects. |
| 19 function InstallFunctions(object, attributes, functions) { | 32 function InstallFunctions(object, attributes, functions) { |
| 20 %OptimizeObjectForAddingMultipleProperties(object, functions.length >> 1); | 33 %OptimizeObjectForAddingMultipleProperties(object, functions.length >> 1); |
| 21 for (var i = 0; i < functions.length; i += 2) { | 34 for (var i = 0; i < functions.length; i += 2) { |
| 22 var key = functions[i]; | 35 var key = functions[i]; |
| 23 var f = functions[i + 1]; | 36 var f = functions[i + 1]; |
| 24 %FunctionSetName(f, key); | 37 SetFunctionName(f, key); |
| 25 %FunctionRemovePrototype(f); | 38 %FunctionRemovePrototype(f); |
| 26 %AddNamedProperty(object, key, f, attributes); | 39 %AddNamedProperty(object, key, f, attributes); |
| 27 %SetNativeFlag(f); | 40 %SetNativeFlag(f); |
| 28 } | 41 } |
| 29 %ToFastProperties(object); | 42 %ToFastProperties(object); |
| 30 } | 43 } |
| 31 | 44 |
| 32 | 45 |
| 33 function OverrideFunction(object, name, f) { | 46 function OverrideFunction(object, name, f) { |
| 34 ObjectDefineProperty(object, name, { value: f, | 47 ObjectDefineProperty(object, name, { value: f, |
| 35 writeable: true, | 48 writeable: true, |
| 36 configurable: true, | 49 configurable: true, |
| 37 enumerable: false }); | 50 enumerable: false }); |
| 38 %FunctionSetName(f, name); | 51 SetFunctionName(f, name); |
| 39 %FunctionRemovePrototype(f); | 52 %FunctionRemovePrototype(f); |
| 40 %SetNativeFlag(f); | 53 %SetNativeFlag(f); |
| 41 } | 54 } |
| 42 | 55 |
| 43 | 56 |
| 44 // Helper function to install a getter-only accessor property. | 57 // Helper function to install a getter-only accessor property. |
| 45 function InstallGetter(object, name, getter, attributes) { | 58 function InstallGetter(object, name, getter, attributes) { |
| 46 if (typeof attributes == "undefined") { | 59 if (typeof attributes == "undefined") { |
| 47 attributes = DONT_ENUM; | 60 attributes = DONT_ENUM; |
| 48 } | 61 } |
| 49 %FunctionSetName(getter, name); | 62 SetFunctionName(getter, name, "get"); |
| 50 %FunctionRemovePrototype(getter); | 63 %FunctionRemovePrototype(getter); |
| 51 %DefineAccessorPropertyUnchecked(object, name, getter, null, attributes); | 64 %DefineAccessorPropertyUnchecked(object, name, getter, null, attributes); |
| 52 %SetNativeFlag(getter); | 65 %SetNativeFlag(getter); |
| 53 } | 66 } |
| 54 | 67 |
| 55 | 68 |
| 56 // Helper function to install a getter/setter accessor property. | 69 // Helper function to install a getter/setter accessor property. |
| 57 function InstallGetterSetter(object, name, getter, setter) { | 70 function InstallGetterSetter(object, name, getter, setter) { |
| 58 %FunctionSetName(getter, name); | 71 SetFunctionName(getter, name, "get"); |
| 59 %FunctionSetName(setter, name); | 72 SetFunctionName(setter, name, "set"); |
| 60 %FunctionRemovePrototype(getter); | 73 %FunctionRemovePrototype(getter); |
| 61 %FunctionRemovePrototype(setter); | 74 %FunctionRemovePrototype(setter); |
| 62 %DefineAccessorPropertyUnchecked(object, name, getter, setter, DONT_ENUM); | 75 %DefineAccessorPropertyUnchecked(object, name, getter, setter, DONT_ENUM); |
| 63 %SetNativeFlag(getter); | 76 %SetNativeFlag(getter); |
| 64 %SetNativeFlag(setter); | 77 %SetNativeFlag(setter); |
| 65 } | 78 } |
| 66 | 79 |
| 67 | 80 |
| 68 // Helper function for installing constant properties on objects. | 81 // Helper function for installing constant properties on objects. |
| 69 function InstallConstants(object, constants) { | 82 function InstallConstants(object, constants) { |
| (...skipping 1822 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1892 } | 1905 } |
| 1893 if (!IS_SPEC_FUNCTION(method)) { | 1906 if (!IS_SPEC_FUNCTION(method)) { |
| 1894 throw MakeTypeError(kNotIterable, obj); | 1907 throw MakeTypeError(kNotIterable, obj); |
| 1895 } | 1908 } |
| 1896 var iterator = %_CallFunction(obj, method); | 1909 var iterator = %_CallFunction(obj, method); |
| 1897 if (!IS_SPEC_OBJECT(iterator)) { | 1910 if (!IS_SPEC_OBJECT(iterator)) { |
| 1898 throw MakeTypeError(kNotAnIterator, iterator); | 1911 throw MakeTypeError(kNotAnIterator, iterator); |
| 1899 } | 1912 } |
| 1900 return iterator; | 1913 return iterator; |
| 1901 } | 1914 } |
| OLD | NEW |