OLD | NEW |
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 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 | 347 |
348 | 348 |
349 function IsInconsistentDescriptor(desc) { | 349 function IsInconsistentDescriptor(desc) { |
350 return IsAccessorDescriptor(desc) && IsDataDescriptor(desc); | 350 return IsAccessorDescriptor(desc) && IsDataDescriptor(desc); |
351 } | 351 } |
352 | 352 |
353 | 353 |
354 // ES5 8.10.4 | 354 // ES5 8.10.4 |
355 function FromPropertyDescriptor(desc) { | 355 function FromPropertyDescriptor(desc) { |
356 if (IS_UNDEFINED(desc)) return desc; | 356 if (IS_UNDEFINED(desc)) return desc; |
357 var obj = new $Object(); | 357 |
358 if (IsDataDescriptor(desc)) { | 358 if (IsDataDescriptor(desc)) { |
359 obj.value = desc.getValue(); | 359 return { value: desc.getValue(), |
360 obj.writable = desc.isWritable(); | 360 writable: desc.isWritable(), |
| 361 enumerable: desc.isEnumerable(), |
| 362 configurable: desc.isConfigurable() }; |
361 } | 363 } |
362 if (IsAccessorDescriptor(desc)) { | 364 // Must be an AccessorDescriptor then. We never return a generic descriptor. |
363 obj.get = desc.getGet(); | 365 return { get: desc.getGet(), |
364 obj.set = desc.getSet(); | 366 set: desc.getSet(), |
365 } | 367 enumerable: desc.isEnumerable(), |
366 obj.enumerable = desc.isEnumerable(); | 368 configurable: desc.isConfigurable() }; |
367 obj.configurable = desc.isConfigurable(); | |
368 return obj; | |
369 } | 369 } |
370 | 370 |
| 371 |
371 // Harmony Proxies | 372 // Harmony Proxies |
372 function FromGenericPropertyDescriptor(desc) { | 373 function FromGenericPropertyDescriptor(desc) { |
373 if (IS_UNDEFINED(desc)) return desc; | 374 if (IS_UNDEFINED(desc)) return desc; |
374 var obj = new $Object(); | 375 var obj = new $Object(); |
375 if (desc.hasValue()) obj.value = desc.getValue(); | 376 |
376 if (desc.hasWritable()) obj.writable = desc.isWritable(); | 377 if (desc.hasValue()) { |
377 if (desc.hasGetter()) obj.get = desc.getGet(); | 378 %IgnoreAttributesAndSetProperty(obj, "value", desc.getValue(), NONE); |
378 if (desc.hasSetter()) obj.set = desc.getSet(); | 379 } |
379 if (desc.hasEnumerable()) obj.enumerable = desc.isEnumerable(); | 380 if (desc.hasWritable()) { |
380 if (desc.hasConfigurable()) obj.configurable = desc.isConfigurable(); | 381 %IgnoreAttributesAndSetProperty(obj, "writable", desc.isWritable(), NONE); |
| 382 } |
| 383 if (desc.hasGetter()) { |
| 384 %IgnoreAttributesAndSetProperty(obj, "get", desc.getGet(), NONE); |
| 385 } |
| 386 if (desc.hasSetter()) { |
| 387 %IgnoreAttributesAndSetProperty(obj, "set", desc.getSet(), NONE); |
| 388 } |
| 389 if (desc.hasEnumerable()) { |
| 390 %IgnoreAttributesAndSetProperty(obj, "enumerable", |
| 391 desc.isEnumerable(), NONE); |
| 392 } |
| 393 if (desc.hasConfigurable()) { |
| 394 %IgnoreAttributesAndSetProperty(obj, "configurable", |
| 395 desc.isConfigurable(), NONE); |
| 396 } |
381 return obj; | 397 return obj; |
382 } | 398 } |
383 | 399 |
| 400 |
384 // ES5 8.10.5. | 401 // ES5 8.10.5. |
385 function ToPropertyDescriptor(obj) { | 402 function ToPropertyDescriptor(obj) { |
386 if (!IS_SPEC_OBJECT(obj)) { | 403 if (!IS_SPEC_OBJECT(obj)) { |
387 throw MakeTypeError("property_desc_object", [obj]); | 404 throw MakeTypeError("property_desc_object", [obj]); |
388 } | 405 } |
389 var desc = new PropertyDescriptor(); | 406 var desc = new PropertyDescriptor(); |
390 | 407 |
391 if ("enumerable" in obj) { | 408 if ("enumerable" in obj) { |
392 desc.setEnumerable(ToBoolean(obj.enumerable)); | 409 desc.setEnumerable(ToBoolean(obj.enumerable)); |
393 } | 410 } |
(...skipping 1144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1538 // ---------------------------------------------------------------------------- | 1555 // ---------------------------------------------------------------------------- |
1539 | 1556 |
1540 function SetupFunction() { | 1557 function SetupFunction() { |
1541 InstallFunctions($Function.prototype, DONT_ENUM, $Array( | 1558 InstallFunctions($Function.prototype, DONT_ENUM, $Array( |
1542 "bind", FunctionBind, | 1559 "bind", FunctionBind, |
1543 "toString", FunctionToString | 1560 "toString", FunctionToString |
1544 )); | 1561 )); |
1545 } | 1562 } |
1546 | 1563 |
1547 SetupFunction(); | 1564 SetupFunction(); |
OLD | NEW |