Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(267)

Side by Side Diff: src/v8natives.js

Issue 7628021: Make function proxies work as constructors. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/runtime.js ('k') | src/x64/builtins-x64.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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();
OLDNEW
« no previous file with comments | « src/runtime.js ('k') | src/x64/builtins-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698