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

Side by Side Diff: src/weakmap.js

Issue 7572013: Additional functions to Harmony weak maps API. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix how undefined is used. Created 9 years, 4 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 | test/mjsunit/harmony/weakmaps.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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 } 51 }
52 52
53 53
54 function WeakMapSet(key, value) { 54 function WeakMapSet(key, value) {
55 if (!IS_SPEC_OBJECT(key)) { 55 if (!IS_SPEC_OBJECT(key)) {
56 throw %MakeTypeError('invalid_weakmap_key', [this, key]); 56 throw %MakeTypeError('invalid_weakmap_key', [this, key]);
57 } 57 }
58 return %WeakMapSet(this, key, value); 58 return %WeakMapSet(this, key, value);
59 } 59 }
60 60
61
62 function WeakMapHas(key) {
63 if (!IS_SPEC_OBJECT(key)) {
64 throw %MakeTypeError('invalid_weakmap_key', [this, key]);
65 }
66 return !IS_UNDEFINED(%WeakMapGet(this, key));
67 }
68
69
70 function WeakMapDelete(key) {
71 if (!IS_SPEC_OBJECT(key)) {
72 throw %MakeTypeError('invalid_weakmap_key', [this, key]);
73 }
74 if (!IS_UNDEFINED(%WeakMapGet(this, key))) {
75 %WeakMapSet(this, key, void 0);
76 return true;
77 } else {
78 return false;
79 }
80 }
81
61 // ------------------------------------------------------------------- 82 // -------------------------------------------------------------------
62 83
63 function SetupWeakMap() { 84 function SetupWeakMap() {
64 // Setup the non-enumerable functions on the WeakMap prototype object. 85 // Setup the non-enumerable functions on the WeakMap prototype object.
65 InstallFunctionsOnHiddenPrototype($WeakMap.prototype, DONT_ENUM, $Array( 86 InstallFunctionsOnHiddenPrototype($WeakMap.prototype, DONT_ENUM, $Array(
66 "get", WeakMapGet, 87 "get", WeakMapGet,
67 "set", WeakMapSet 88 "set", WeakMapSet,
89 "has", WeakMapHas,
90 "delete", WeakMapDelete
68 )); 91 ));
69 } 92 }
70 93
71 94
72 SetupWeakMap(); 95 SetupWeakMap();
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/harmony/weakmaps.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698