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 1027 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1038 } | 1038 } |
1039 | 1039 |
1040 | 1040 |
1041 // Harmony proxies. | 1041 // Harmony proxies. |
1042 function ProxyFix(obj) { | 1042 function ProxyFix(obj) { |
1043 var handler = %GetHandler(obj); | 1043 var handler = %GetHandler(obj); |
1044 var props = CallTrap0(handler, "fix", void 0); | 1044 var props = CallTrap0(handler, "fix", void 0); |
1045 if (IS_UNDEFINED(props)) { | 1045 if (IS_UNDEFINED(props)) { |
1046 throw MakeTypeError("handler_returned_undefined", [handler, "fix"]); | 1046 throw MakeTypeError("handler_returned_undefined", [handler, "fix"]); |
1047 } | 1047 } |
1048 | |
1049 if (IS_FUNCTION(obj)) { | 1048 if (IS_FUNCTION(obj)) { |
1050 var callTrap = %GetCallTrap(obj); | 1049 var callTrap = %GetCallTrap(obj); |
1051 var constructTrap = %GetConstructTrap(obj); | 1050 var constructTrap = %GetConstructTrap(obj); |
1052 var code = DelegateCallAndConstruct(callTrap, constructTrap); | 1051 var code = DelegateCallAndConstruct(callTrap, constructTrap); |
1053 %Fix(obj); // becomes a regular function | 1052 %Fix(obj); // becomes a regular function |
1054 %SetCode(obj, code); | 1053 %SetCode(obj, code); |
| 1054 // TODO(rossberg): What about length and other properties? Not specified. |
| 1055 // We just put in some half-reasonable defaults for now. |
| 1056 var prototype = new $Object(); |
| 1057 $Object.defineProperty(prototype, "constructor", |
| 1058 {value: obj, writable: true, enumerable: false, configrable: true}); |
| 1059 $Object.defineProperty(obj, "prototype", |
| 1060 {value: prototype, writable: true, enumerable: false, configrable: false}) |
| 1061 $Object.defineProperty(obj, "length", |
| 1062 {value: 0, writable: true, enumerable: false, configrable: false}); |
1055 } else { | 1063 } else { |
1056 %Fix(obj); | 1064 %Fix(obj); |
1057 } | 1065 } |
1058 ObjectDefineProperties(obj, props); | 1066 ObjectDefineProperties(obj, props); |
1059 } | 1067 } |
1060 | 1068 |
1061 | 1069 |
1062 // ES5 section 15.2.3.8. | 1070 // ES5 section 15.2.3.8. |
1063 function ObjectSeal(obj) { | 1071 function ObjectSeal(obj) { |
1064 if (!IS_SPEC_OBJECT(obj)) { | 1072 if (!IS_SPEC_OBJECT(obj)) { |
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1552 // ---------------------------------------------------------------------------- | 1560 // ---------------------------------------------------------------------------- |
1553 | 1561 |
1554 function SetupFunction() { | 1562 function SetupFunction() { |
1555 InstallFunctions($Function.prototype, DONT_ENUM, $Array( | 1563 InstallFunctions($Function.prototype, DONT_ENUM, $Array( |
1556 "bind", FunctionBind, | 1564 "bind", FunctionBind, |
1557 "toString", FunctionToString | 1565 "toString", FunctionToString |
1558 )); | 1566 )); |
1559 } | 1567 } |
1560 | 1568 |
1561 SetupFunction(); | 1569 SetupFunction(); |
OLD | NEW |