| OLD | NEW |
| 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 29 matching lines...) Expand all Loading... |
| 40 // supported internally but required for Harmony sets and maps. | 40 // supported internally but required for Harmony sets and maps. |
| 41 var undefined_sentinel = {}; | 41 var undefined_sentinel = {}; |
| 42 | 42 |
| 43 // ------------------------------------------------------------------- | 43 // ------------------------------------------------------------------- |
| 44 // Harmony Set | 44 // Harmony Set |
| 45 | 45 |
| 46 function SetConstructor() { | 46 function SetConstructor() { |
| 47 if (%_IsConstructCall()) { | 47 if (%_IsConstructCall()) { |
| 48 %SetInitialize(this); | 48 %SetInitialize(this); |
| 49 } else { | 49 } else { |
| 50 return new $Set(); | 50 throw MakeTypeError('constructor_not_function', ['Set']); |
| 51 } | 51 } |
| 52 } | 52 } |
| 53 | 53 |
| 54 | 54 |
| 55 function SetAdd(key) { | 55 function SetAdd(key) { |
| 56 if (!IS_SET(this)) { | 56 if (!IS_SET(this)) { |
| 57 throw MakeTypeError('incompatible_method_receiver', | 57 throw MakeTypeError('incompatible_method_receiver', |
| 58 ['Set.prototype.add', this]); | 58 ['Set.prototype.add', this]); |
| 59 } | 59 } |
| 60 if (IS_UNDEFINED(key)) { | 60 if (IS_UNDEFINED(key)) { |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 SetUpSet(); | 134 SetUpSet(); |
| 135 | 135 |
| 136 | 136 |
| 137 // ------------------------------------------------------------------- | 137 // ------------------------------------------------------------------- |
| 138 // Harmony Map | 138 // Harmony Map |
| 139 | 139 |
| 140 function MapConstructor() { | 140 function MapConstructor() { |
| 141 if (%_IsConstructCall()) { | 141 if (%_IsConstructCall()) { |
| 142 %MapInitialize(this); | 142 %MapInitialize(this); |
| 143 } else { | 143 } else { |
| 144 return new $Map(); | 144 throw MakeTypeError('constructor_not_function', ['Map']); |
| 145 } | 145 } |
| 146 } | 146 } |
| 147 | 147 |
| 148 | 148 |
| 149 function MapGet(key) { | 149 function MapGet(key) { |
| 150 if (!IS_MAP(this)) { | 150 if (!IS_MAP(this)) { |
| 151 throw MakeTypeError('incompatible_method_receiver', | 151 throw MakeTypeError('incompatible_method_receiver', |
| 152 ['Map.prototype.get', this]); | 152 ['Map.prototype.get', this]); |
| 153 } | 153 } |
| 154 if (IS_UNDEFINED(key)) { | 154 if (IS_UNDEFINED(key)) { |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 SetUpMap(); | 236 SetUpMap(); |
| 237 | 237 |
| 238 | 238 |
| 239 // ------------------------------------------------------------------- | 239 // ------------------------------------------------------------------- |
| 240 // Harmony WeakMap | 240 // Harmony WeakMap |
| 241 | 241 |
| 242 function WeakMapConstructor() { | 242 function WeakMapConstructor() { |
| 243 if (%_IsConstructCall()) { | 243 if (%_IsConstructCall()) { |
| 244 %WeakCollectionInitialize(this); | 244 %WeakCollectionInitialize(this); |
| 245 } else { | 245 } else { |
| 246 return new $WeakMap(); | 246 throw MakeTypeError('constructor_not_function', ['WeakMap']); |
| 247 } | 247 } |
| 248 } | 248 } |
| 249 | 249 |
| 250 | 250 |
| 251 function WeakMapGet(key) { | 251 function WeakMapGet(key) { |
| 252 if (!IS_WEAKMAP(this)) { | 252 if (!IS_WEAKMAP(this)) { |
| 253 throw MakeTypeError('incompatible_method_receiver', | 253 throw MakeTypeError('incompatible_method_receiver', |
| 254 ['WeakMap.prototype.get', this]); | 254 ['WeakMap.prototype.get', this]); |
| 255 } | 255 } |
| 256 if (!(IS_SPEC_OBJECT(key) || IS_SYMBOL(key))) { | 256 if (!(IS_SPEC_OBJECT(key) || IS_SYMBOL(key))) { |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 SetUpWeakMap(); | 328 SetUpWeakMap(); |
| 329 | 329 |
| 330 | 330 |
| 331 // ------------------------------------------------------------------- | 331 // ------------------------------------------------------------------- |
| 332 // Harmony WeakSet | 332 // Harmony WeakSet |
| 333 | 333 |
| 334 function WeakSetConstructor() { | 334 function WeakSetConstructor() { |
| 335 if (%_IsConstructCall()) { | 335 if (%_IsConstructCall()) { |
| 336 %WeakCollectionInitialize(this); | 336 %WeakCollectionInitialize(this); |
| 337 } else { | 337 } else { |
| 338 return new $WeakSet(); | 338 throw MakeTypeError('constructor_not_function', ['WeakSet']); |
| 339 } | 339 } |
| 340 } | 340 } |
| 341 | 341 |
| 342 | 342 |
| 343 function WeakSetAdd(value) { | 343 function WeakSetAdd(value) { |
| 344 if (!IS_WEAKSET(this)) { | 344 if (!IS_WEAKSET(this)) { |
| 345 throw MakeTypeError('incompatible_method_receiver', | 345 throw MakeTypeError('incompatible_method_receiver', |
| 346 ['WeakSet.prototype.add', this]); | 346 ['WeakSet.prototype.add', this]); |
| 347 } | 347 } |
| 348 if (!(IS_SPEC_OBJECT(value) || IS_SYMBOL(value))) { | 348 if (!(IS_SPEC_OBJECT(value) || IS_SYMBOL(value))) { |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 // Set up the non-enumerable functions on the WeakSet prototype object. | 398 // Set up the non-enumerable functions on the WeakSet prototype object. |
| 399 InstallFunctions($WeakSet.prototype, DONT_ENUM, $Array( | 399 InstallFunctions($WeakSet.prototype, DONT_ENUM, $Array( |
| 400 "add", WeakSetAdd, | 400 "add", WeakSetAdd, |
| 401 "has", WeakSetHas, | 401 "has", WeakSetHas, |
| 402 "delete", WeakSetDelete, | 402 "delete", WeakSetDelete, |
| 403 "clear", WeakSetClear | 403 "clear", WeakSetClear |
| 404 )); | 404 )); |
| 405 } | 405 } |
| 406 | 406 |
| 407 SetUpWeakSet(); | 407 SetUpWeakSet(); |
| OLD | NEW |