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 "use strict"; | 5 "use strict"; |
6 | 6 |
7 // This file relies on the fact that the following declaration has been made | 7 // This file relies on the fact that the following declaration has been made |
8 // in runtime.js: | 8 // in runtime.js: |
9 // var $Array = global.Array; | 9 // var $Array = global.Array; |
10 | 10 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 throw MakeTypeError('incompatible_method_receiver', | 49 throw MakeTypeError('incompatible_method_receiver', |
50 ['Set.prototype.add', this]); | 50 ['Set.prototype.add', this]); |
51 } | 51 } |
52 // Normalize -0 to +0 as required by the spec. | 52 // Normalize -0 to +0 as required by the spec. |
53 // Even though we use SameValueZero as the comparison for the keys we don't | 53 // Even though we use SameValueZero as the comparison for the keys we don't |
54 // want to ever store -0 as the key since the key is directly exposed when | 54 // want to ever store -0 as the key since the key is directly exposed when |
55 // doing iteration. | 55 // doing iteration. |
56 if (key === 0) { | 56 if (key === 0) { |
57 key = 0; | 57 key = 0; |
58 } | 58 } |
59 return %_SetAdd(this, key); | 59 return %SetAdd(this, key); |
60 } | 60 } |
61 | 61 |
62 | 62 |
63 function SetHasJS(key) { | 63 function SetHasJS(key) { |
64 if (!IS_SET(this)) { | 64 if (!IS_SET(this)) { |
65 throw MakeTypeError('incompatible_method_receiver', | 65 throw MakeTypeError('incompatible_method_receiver', |
66 ['Set.prototype.has', this]); | 66 ['Set.prototype.has', this]); |
67 } | 67 } |
68 return %_SetHas(this, key); | 68 return %_SetHas(this, key); |
69 } | 69 } |
70 | 70 |
71 | 71 |
72 function SetDeleteJS(key) { | 72 function SetDeleteJS(key) { |
73 if (!IS_SET(this)) { | 73 if (!IS_SET(this)) { |
74 throw MakeTypeError('incompatible_method_receiver', | 74 throw MakeTypeError('incompatible_method_receiver', |
75 ['Set.prototype.delete', this]); | 75 ['Set.prototype.delete', this]); |
76 } | 76 } |
77 return %_SetDelete(this, key); | 77 return %SetDelete(this, key); |
78 } | 78 } |
79 | 79 |
80 | 80 |
81 function SetGetSizeJS() { | 81 function SetGetSizeJS() { |
82 if (!IS_SET(this)) { | 82 if (!IS_SET(this)) { |
83 throw MakeTypeError('incompatible_method_receiver', | 83 throw MakeTypeError('incompatible_method_receiver', |
84 ['Set.prototype.size', this]); | 84 ['Set.prototype.size', this]); |
85 } | 85 } |
86 return %_SetGetSize(this); | 86 return %_SetGetSize(this); |
87 } | 87 } |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 throw MakeTypeError('incompatible_method_receiver', | 202 throw MakeTypeError('incompatible_method_receiver', |
203 ['Map.prototype.set', this]); | 203 ['Map.prototype.set', this]); |
204 } | 204 } |
205 // Normalize -0 to +0 as required by the spec. | 205 // Normalize -0 to +0 as required by the spec. |
206 // Even though we use SameValueZero as the comparison for the keys we don't | 206 // Even though we use SameValueZero as the comparison for the keys we don't |
207 // want to ever store -0 as the key since the key is directly exposed when | 207 // want to ever store -0 as the key since the key is directly exposed when |
208 // doing iteration. | 208 // doing iteration. |
209 if (key === 0) { | 209 if (key === 0) { |
210 key = 0; | 210 key = 0; |
211 } | 211 } |
212 return %_MapSet(this, key, value); | 212 return %MapSet(this, key, value); |
213 } | 213 } |
214 | 214 |
215 | 215 |
216 function MapHasJS(key) { | 216 function MapHasJS(key) { |
217 if (!IS_MAP(this)) { | 217 if (!IS_MAP(this)) { |
218 throw MakeTypeError('incompatible_method_receiver', | 218 throw MakeTypeError('incompatible_method_receiver', |
219 ['Map.prototype.has', this]); | 219 ['Map.prototype.has', this]); |
220 } | 220 } |
221 return %_MapHas(this, key); | 221 return %_MapHas(this, key); |
222 } | 222 } |
223 | 223 |
224 | 224 |
225 function MapDeleteJS(key) { | 225 function MapDeleteJS(key) { |
226 if (!IS_MAP(this)) { | 226 if (!IS_MAP(this)) { |
227 throw MakeTypeError('incompatible_method_receiver', | 227 throw MakeTypeError('incompatible_method_receiver', |
228 ['Map.prototype.delete', this]); | 228 ['Map.prototype.delete', this]); |
229 } | 229 } |
230 return %_MapDelete(this, key); | 230 return %MapDelete(this, key); |
231 } | 231 } |
232 | 232 |
233 | 233 |
234 function MapGetSizeJS() { | 234 function MapGetSizeJS() { |
235 if (!IS_MAP(this)) { | 235 if (!IS_MAP(this)) { |
236 throw MakeTypeError('incompatible_method_receiver', | 236 throw MakeTypeError('incompatible_method_receiver', |
237 ['Map.prototype.size', this]); | 237 ['Map.prototype.size', this]); |
238 } | 238 } |
239 return %_MapGetSize(this); | 239 return %_MapGetSize(this); |
240 } | 240 } |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 "get", MapGetJS, | 295 "get", MapGetJS, |
296 "set", MapSetJS, | 296 "set", MapSetJS, |
297 "has", MapHasJS, | 297 "has", MapHasJS, |
298 "delete", MapDeleteJS, | 298 "delete", MapDeleteJS, |
299 "clear", MapClearJS, | 299 "clear", MapClearJS, |
300 "forEach", MapForEach | 300 "forEach", MapForEach |
301 )); | 301 )); |
302 } | 302 } |
303 | 303 |
304 SetUpMap(); | 304 SetUpMap(); |
OLD | NEW |