| 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 } |
| 88 | 88 |
| 89 | 89 |
| 90 function SetClearJS() { | 90 function SetClearJS() { |
| 91 if (!IS_SET(this)) { | 91 if (!IS_SET(this)) { |
| 92 throw MakeTypeError('incompatible_method_receiver', | 92 throw MakeTypeError('incompatible_method_receiver', |
| 93 ['Set.prototype.clear', this]); | 93 ['Set.prototype.clear', this]); |
| 94 } | 94 } |
| 95 %SetClear(this); | 95 %SetClear(this); |
| 96 } | 96 } |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 %_CallFunction(this, nextItem[0], nextItem[1], adder); | 186 %_CallFunction(this, nextItem[0], nextItem[1], adder); |
| 187 } | 187 } |
| 188 } | 188 } |
| 189 | 189 |
| 190 | 190 |
| 191 function MapGetJS(key) { | 191 function MapGetJS(key) { |
| 192 if (!IS_MAP(this)) { | 192 if (!IS_MAP(this)) { |
| 193 throw MakeTypeError('incompatible_method_receiver', | 193 throw MakeTypeError('incompatible_method_receiver', |
| 194 ['Map.prototype.get', this]); | 194 ['Map.prototype.get', this]); |
| 195 } | 195 } |
| 196 return %MapGet(this, key); | 196 return %_MapGet(this, key); |
| 197 } | 197 } |
| 198 | 198 |
| 199 | 199 |
| 200 function MapSetJS(key, value) { | 200 function MapSetJS(key, value) { |
| 201 if (!IS_MAP(this)) { | 201 if (!IS_MAP(this)) { |
| 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 } |
| 241 | 241 |
| 242 | 242 |
| 243 function MapClearJS() { | 243 function MapClearJS() { |
| 244 if (!IS_MAP(this)) { | 244 if (!IS_MAP(this)) { |
| 245 throw MakeTypeError('incompatible_method_receiver', | 245 throw MakeTypeError('incompatible_method_receiver', |
| 246 ['Map.prototype.clear', this]); | 246 ['Map.prototype.clear', this]); |
| 247 } | 247 } |
| 248 %MapClear(this); | 248 %MapClear(this); |
| 249 } | 249 } |
| (...skipping 45 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 |