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 (function(global, shared, exports) { | 5 (function(global, shared, exports) { |
6 | 6 |
7 "use strict"; | 7 "use strict"; |
8 | 8 |
9 %CheckIsBootstrapping(); | 9 %CheckIsBootstrapping(); |
10 | 10 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 if (!IS_SPEC_OBJECT(key)) return UNDEFINED; | 45 if (!IS_SPEC_OBJECT(key)) return UNDEFINED; |
46 return %WeakCollectionGet(this, key); | 46 return %WeakCollectionGet(this, key); |
47 } | 47 } |
48 | 48 |
49 | 49 |
50 function WeakMapSet(key, value) { | 50 function WeakMapSet(key, value) { |
51 if (!IS_WEAKMAP(this)) { | 51 if (!IS_WEAKMAP(this)) { |
52 throw MakeTypeError(kIncompatibleMethodReceiver, | 52 throw MakeTypeError(kIncompatibleMethodReceiver, |
53 'WeakMap.prototype.set', this); | 53 'WeakMap.prototype.set', this); |
54 } | 54 } |
55 if (!IS_SPEC_OBJECT(key)) { | 55 if (!IS_SPEC_OBJECT(key)) throw MakeTypeError(kInvalidWeakMapKey); |
56 throw %MakeTypeError('invalid_weakmap_key', [this, key]); | |
57 } | |
58 return %WeakCollectionSet(this, key, value); | 56 return %WeakCollectionSet(this, key, value); |
59 } | 57 } |
60 | 58 |
61 | 59 |
62 function WeakMapHas(key) { | 60 function WeakMapHas(key) { |
63 if (!IS_WEAKMAP(this)) { | 61 if (!IS_WEAKMAP(this)) { |
64 throw MakeTypeError(kIncompatibleMethodReceiver, | 62 throw MakeTypeError(kIncompatibleMethodReceiver, |
65 'WeakMap.prototype.has', this); | 63 'WeakMap.prototype.has', this); |
66 } | 64 } |
67 if (!IS_SPEC_OBJECT(key)) return false; | 65 if (!IS_SPEC_OBJECT(key)) return false; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 } | 115 } |
118 } | 116 } |
119 } | 117 } |
120 | 118 |
121 | 119 |
122 function WeakSetAdd(value) { | 120 function WeakSetAdd(value) { |
123 if (!IS_WEAKSET(this)) { | 121 if (!IS_WEAKSET(this)) { |
124 throw MakeTypeError(kIncompatibleMethodReceiver, | 122 throw MakeTypeError(kIncompatibleMethodReceiver, |
125 'WeakSet.prototype.add', this); | 123 'WeakSet.prototype.add', this); |
126 } | 124 } |
127 if (!IS_SPEC_OBJECT(value)) { | 125 if (!IS_SPEC_OBJECT(value)) throw MakeTypeError(kInvalidWeakSetValue); |
128 throw %MakeTypeError('invalid_weakset_value', [this, value]); | |
129 } | |
130 return %WeakCollectionSet(this, value, true); | 126 return %WeakCollectionSet(this, value, true); |
131 } | 127 } |
132 | 128 |
133 | 129 |
134 function WeakSetHas(value) { | 130 function WeakSetHas(value) { |
135 if (!IS_WEAKSET(this)) { | 131 if (!IS_WEAKSET(this)) { |
136 throw MakeTypeError(kIncompatibleMethodReceiver, | 132 throw MakeTypeError(kIncompatibleMethodReceiver, |
137 'WeakSet.prototype.has', this); | 133 'WeakSet.prototype.has', this); |
138 } | 134 } |
139 if (!IS_SPEC_OBJECT(value)) return false; | 135 if (!IS_SPEC_OBJECT(value)) return false; |
(...skipping 22 matching lines...) Expand all Loading... |
162 DONT_ENUM | READ_ONLY); | 158 DONT_ENUM | READ_ONLY); |
163 | 159 |
164 // Set up the non-enumerable functions on the WeakSet prototype object. | 160 // Set up the non-enumerable functions on the WeakSet prototype object. |
165 $installFunctions(GlobalWeakSet.prototype, DONT_ENUM, [ | 161 $installFunctions(GlobalWeakSet.prototype, DONT_ENUM, [ |
166 "add", WeakSetAdd, | 162 "add", WeakSetAdd, |
167 "has", WeakSetHas, | 163 "has", WeakSetHas, |
168 "delete", WeakSetDelete | 164 "delete", WeakSetDelete |
169 ]); | 165 ]); |
170 | 166 |
171 }) | 167 }) |
OLD | NEW |