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

Unified Diff: src/runtime.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/proxy.js ('k') | src/v8natives.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime.js
diff --git a/src/runtime.js b/src/runtime.js
index ce6b4a3ccf347a65ab27eda9527cdfd3755d62bf..a76f3b6e81fc408721ed5e2777b8891a1aa7dbd1 100644
--- a/src/runtime.js
+++ b/src/runtime.js
@@ -405,11 +405,7 @@ function FILTER_KEY(key) {
function CALL_NON_FUNCTION() {
var delegate = %GetFunctionDelegate(this);
if (!IS_FUNCTION(delegate)) {
- if (%IsJSFunctionProxy(this)) {
- delegate = %GetCallTrap(this);
- } else {
- throw %MakeTypeError('called_non_callable', [typeof this]);
- }
+ throw %MakeTypeError('called_non_callable', [typeof this]);
}
return delegate.apply(this, arguments);
}
@@ -418,11 +414,7 @@ function CALL_NON_FUNCTION() {
function CALL_NON_FUNCTION_AS_CONSTRUCTOR() {
var delegate = %GetConstructorDelegate(this);
if (!IS_FUNCTION(delegate)) {
- if (%IsJSFunctionProxy(this)) {
- delegate = %GetConstructTrap(this);
- } else {
- throw %MakeTypeError('called_non_callable', [typeof this]);
- }
+ throw %MakeTypeError('called_non_callable', [typeof this]);
}
return delegate.apply(this, arguments);
}
@@ -434,25 +426,16 @@ function CALL_FUNCTION_PROXY() {
var trap = %GetCallTrap(proxy);
// TODO(rossberg): hm, shouldn't I be using $Function and friends?
// But how do I get it in a builtin?
- return global.Function.prototype.apply.call(
- trap, this, global.Array.prototype.slice.call(arguments, 0, arity));
+ return Function.prototype.apply.call(
+ trap, this, Array.prototype.slice.call(arguments, 0, arity));
}
-function CALL_FUNCTION_PROXY_AS_CONSTRUCTOR(proxy) {
+function CALL_FUNCTION_PROXY_AS_CONSTRUCTOR() {
+ var proxy = this;
var trap = %GetConstructTrap(proxy);
- var receiver = void 0;
- if (!IS_UNDEFINED(trap)) {
- trap = %GetCallTrap(proxy);
- var proto = proxy.prototype;
- if (!IS_SPEC_OBJECT(proto) && proto !== null) {
- throw MakeTypeError("proto_object_or_null", [proto]);
- }
- receiver = new global.Object();
- receiver.__proto__ = proto;
- }
- return global.Function.prototype.apply.call(
- trap, this, global.Array.prototype.shift.call(arguments));
+ // TODO(rossberg): should be using $Function or a builtin somehow.
+ return Function.prototype.apply.call(trap, this, arguments);
}
« no previous file with comments | « src/proxy.js ('k') | src/v8natives.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698