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

Side by Side Diff: src/collection.js

Issue 12456004: ES6 symbols: enable symbols as weak map keys (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 9 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 | « no previous file | src/runtime.cc » ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 return new $WeakMap(); 190 return new $WeakMap();
191 } 191 }
192 } 192 }
193 193
194 194
195 function WeakMapGet(key) { 195 function WeakMapGet(key) {
196 if (!IS_WEAKMAP(this)) { 196 if (!IS_WEAKMAP(this)) {
197 throw MakeTypeError('incompatible_method_receiver', 197 throw MakeTypeError('incompatible_method_receiver',
198 ['WeakMap.prototype.get', this]); 198 ['WeakMap.prototype.get', this]);
199 } 199 }
200 if (!IS_SPEC_OBJECT(key)) { 200 if (!(IS_SPEC_OBJECT(key) || IS_SYMBOL(key))) {
201 throw %MakeTypeError('invalid_weakmap_key', [this, key]); 201 throw %MakeTypeError('invalid_weakmap_key', [this, key]);
202 } 202 }
203 return %WeakMapGet(this, key); 203 return %WeakMapGet(this, key);
204 } 204 }
205 205
206 206
207 function WeakMapSet(key, value) { 207 function WeakMapSet(key, value) {
208 if (!IS_WEAKMAP(this)) { 208 if (!IS_WEAKMAP(this)) {
209 throw MakeTypeError('incompatible_method_receiver', 209 throw MakeTypeError('incompatible_method_receiver',
210 ['WeakMap.prototype.set', this]); 210 ['WeakMap.prototype.set', this]);
211 } 211 }
212 if (!IS_SPEC_OBJECT(key)) { 212 if (!(IS_SPEC_OBJECT(key) || IS_SYMBOL(key))) {
213 throw %MakeTypeError('invalid_weakmap_key', [this, key]); 213 throw %MakeTypeError('invalid_weakmap_key', [this, key]);
214 } 214 }
215 return %WeakMapSet(this, key, value); 215 return %WeakMapSet(this, key, value);
216 } 216 }
217 217
218 218
219 function WeakMapHas(key) { 219 function WeakMapHas(key) {
220 if (!IS_WEAKMAP(this)) { 220 if (!IS_WEAKMAP(this)) {
221 throw MakeTypeError('incompatible_method_receiver', 221 throw MakeTypeError('incompatible_method_receiver',
222 ['WeakMap.prototype.has', this]); 222 ['WeakMap.prototype.has', this]);
223 } 223 }
224 if (!IS_SPEC_OBJECT(key)) { 224 if (!(IS_SPEC_OBJECT(key) || IS_SYMBOL(key))) {
225 throw %MakeTypeError('invalid_weakmap_key', [this, key]); 225 throw %MakeTypeError('invalid_weakmap_key', [this, key]);
226 } 226 }
227 return %WeakMapHas(this, key); 227 return %WeakMapHas(this, key);
228 } 228 }
229 229
230 230
231 function WeakMapDelete(key) { 231 function WeakMapDelete(key) {
232 if (!IS_WEAKMAP(this)) { 232 if (!IS_WEAKMAP(this)) {
233 throw MakeTypeError('incompatible_method_receiver', 233 throw MakeTypeError('incompatible_method_receiver',
234 ['WeakMap.prototype.delete', this]); 234 ['WeakMap.prototype.delete', this]);
235 } 235 }
236 if (!IS_SPEC_OBJECT(key)) { 236 if (!(IS_SPEC_OBJECT(key) || IS_SYMBOL(key))) {
237 throw %MakeTypeError('invalid_weakmap_key', [this, key]); 237 throw %MakeTypeError('invalid_weakmap_key', [this, key]);
238 } 238 }
239 return %WeakMapDelete(this, key); 239 return %WeakMapDelete(this, key);
240 } 240 }
241 241
242 // ------------------------------------------------------------------- 242 // -------------------------------------------------------------------
243 243
244 (function () { 244 (function () {
245 %CheckIsBootstrapping(); 245 %CheckIsBootstrapping();
246 246
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 %SetProperty($WeakMap.prototype, "constructor", $WeakMap, DONT_ENUM); 278 %SetProperty($WeakMap.prototype, "constructor", $WeakMap, DONT_ENUM);
279 279
280 // Set up the non-enumerable functions on the WeakMap prototype object. 280 // Set up the non-enumerable functions on the WeakMap prototype object.
281 InstallFunctions($WeakMap.prototype, DONT_ENUM, $Array( 281 InstallFunctions($WeakMap.prototype, DONT_ENUM, $Array(
282 "get", WeakMapGet, 282 "get", WeakMapGet,
283 "set", WeakMapSet, 283 "set", WeakMapSet,
284 "has", WeakMapHas, 284 "has", WeakMapHas,
285 "delete", WeakMapDelete 285 "delete", WeakMapDelete
286 )); 286 ));
287 })(); 287 })();
OLDNEW
« no previous file with comments | « no previous file | src/runtime.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698