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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/runtime.js ('k') | src/x64/builtins-x64.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/v8natives.js
diff --git a/src/v8natives.js b/src/v8natives.js
index 10cd4affbba9b19e0d6a1e90d3c0ae360caaaa40..13a3e9ed379d3064831342a68a2383d21e6d2561 100644
--- a/src/v8natives.js
+++ b/src/v8natives.js
@@ -1045,13 +1045,21 @@ function ProxyFix(obj) {
if (IS_UNDEFINED(props)) {
throw MakeTypeError("handler_returned_undefined", [handler, "fix"]);
}
-
if (IS_FUNCTION(obj)) {
var callTrap = %GetCallTrap(obj);
var constructTrap = %GetConstructTrap(obj);
var code = DelegateCallAndConstruct(callTrap, constructTrap);
%Fix(obj); // becomes a regular function
%SetCode(obj, code);
+ // TODO(rossberg): What about length and other properties? Not specified.
+ // We just put in some half-reasonable defaults for now.
+ var prototype = new $Object();
+ $Object.defineProperty(prototype, "constructor",
+ {value: obj, writable: true, enumerable: false, configrable: true});
+ $Object.defineProperty(obj, "prototype",
+ {value: prototype, writable: true, enumerable: false, configrable: false})
+ $Object.defineProperty(obj, "length",
+ {value: 0, writable: true, enumerable: false, configrable: false});
} else {
%Fix(obj);
}
« 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