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

Side by Side Diff: src/symbol.js

Issue 108083005: ES6: Add Object.getOwnPropertySymbols (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Comment and formatting based on code review Created 6 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 | Annotate | Revision Log
« no previous file with comments | « src/runtime.cc ('k') | src/v8natives.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 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
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 // ES6 19.1.2.8
72 function ObjectGetOwnPropertySymbols(obj) {
73 if (!IS_SPEC_OBJECT(obj)) {
74 throw MakeTypeError("called_on_non_object",
75 ["Object.getOwnPropertySymbols"]);
76 }
77
78 // TODO(arv): Proxies use a shared trap for String and Symbol keys.
79
80 return ObjectGetOwnPropertyKeys(obj, true);
81 }
82
83
71 //------------------------------------------------------------------- 84 //-------------------------------------------------------------------
72 85
73 function SetUpSymbol() { 86 function SetUpSymbol() {
74 %CheckIsBootstrapping(); 87 %CheckIsBootstrapping();
75 88
76 %SetCode($Symbol, SymbolConstructor); 89 %SetCode($Symbol, SymbolConstructor);
77 %FunctionSetPrototype($Symbol, new $Symbol()); 90 %FunctionSetPrototype($Symbol, new $Symbol());
78 %SetProperty($Symbol.prototype, "constructor", $Symbol, DONT_ENUM); 91 %SetProperty($Symbol.prototype, "constructor", $Symbol, DONT_ENUM);
79 92
80 InstallGetter($Symbol.prototype, "name", SymbolGetName); 93 InstallGetter($Symbol.prototype, "name", SymbolGetName);
81 InstallFunctions($Symbol.prototype, DONT_ENUM, $Array( 94 InstallFunctions($Symbol.prototype, DONT_ENUM, $Array(
82 "toString", SymbolToString, 95 "toString", SymbolToString,
83 "valueOf", SymbolValueOf 96 "valueOf", SymbolValueOf
84 )); 97 ));
85 } 98 }
86 99
87 SetUpSymbol(); 100 SetUpSymbol();
101
102 function ExtendObject() {
103 %CheckIsBootstrapping();
104
105 InstallFunctions($Object, DONT_ENUM, $Array(
106 "getOwnPropertySymbols", ObjectGetOwnPropertySymbols
107 ));
108 }
109
110 ExtendObject();
OLDNEW
« no previous file with comments | « src/runtime.cc ('k') | src/v8natives.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698