| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 function SymbolValueOf() { | 61 function SymbolValueOf() { |
| 62 // NOTE: Both Symbol objects and values can enter here as | 62 // NOTE: Both Symbol objects and values can enter here as |
| 63 // 'this'. This is not as dictated by ECMA-262. | 63 // 'this'. This is not as dictated by ECMA-262. |
| 64 if (!IS_SYMBOL(this) && !IS_SYMBOL_WRAPPER(this)) { | 64 if (!IS_SYMBOL(this) && !IS_SYMBOL_WRAPPER(this)) { |
| 65 throw MakeTypeError( | 65 throw MakeTypeError( |
| 66 'incompatible_method_receiver', ["Symbol.prototype.valueOf", this]); | 66 'incompatible_method_receiver', ["Symbol.prototype.valueOf", this]); |
| 67 } | 67 } |
| 68 return %_ValueOf(this); | 68 return %_ValueOf(this); |
| 69 } | 69 } |
| 70 | 70 |
| 71 |
| 72 // ES6 19.1.2.8 |
| 73 function ObjectGetOwnPropertySymbols(obj) { |
| 74 if (!IS_SPEC_OBJECT(obj)) { |
| 75 throw MakeTypeError("called_on_non_object", |
| 76 ["Object.getOwnPropertySymbols"]); |
| 77 } |
| 78 |
| 79 // TODO(arv): Proxies use a shared trap for String and Symbol keys. |
| 80 |
| 81 return ObjectGetOwnPropertyKeys(obj, true); |
| 82 } |
| 83 |
| 84 |
| 71 //------------------------------------------------------------------- | 85 //------------------------------------------------------------------- |
| 72 | 86 |
| 73 function SetUpSymbol() { | 87 function SetUpSymbol() { |
| 74 %CheckIsBootstrapping(); | 88 %CheckIsBootstrapping(); |
| 75 | 89 |
| 76 %SetCode($Symbol, SymbolConstructor); | 90 %SetCode($Symbol, SymbolConstructor); |
| 77 %FunctionSetPrototype($Symbol, new $Symbol()); | 91 %FunctionSetPrototype($Symbol, new $Symbol()); |
| 78 %SetProperty($Symbol.prototype, "constructor", $Symbol, DONT_ENUM); | 92 %SetProperty($Symbol.prototype, "constructor", $Symbol, DONT_ENUM); |
| 79 | 93 |
| 80 InstallGetter($Symbol.prototype, "name", SymbolGetName); | 94 InstallGetter($Symbol.prototype, "name", SymbolGetName); |
| 81 InstallFunctions($Symbol.prototype, DONT_ENUM, $Array( | 95 InstallFunctions($Symbol.prototype, DONT_ENUM, $Array( |
| 82 "toString", SymbolToString, | 96 "toString", SymbolToString, |
| 83 "valueOf", SymbolValueOf | 97 "valueOf", SymbolValueOf |
| 84 )); | 98 )); |
| 85 } | 99 } |
| 86 | 100 |
| 87 SetUpSymbol(); | 101 SetUpSymbol(); |
| 102 |
| 103 |
| 104 function ExtendObject() { |
| 105 %CheckIsBootstrapping(); |
| 106 |
| 107 InstallFunctions($Object, DONT_ENUM, $Array( |
| 108 "getOwnPropertySymbols", ObjectGetOwnPropertySymbols |
| 109 )); |
| 110 } |
| 111 |
| 112 ExtendObject(); |
| OLD | NEW |