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

Unified Diff: src/proxy.js

Issue 7623011: Implement function proxies (except for their use as constructors). (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed second round of comments. Created 9 years, 3 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/objects-visiting.cc ('k') | src/runtime.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/proxy.js
diff --git a/src/proxy.js b/src/proxy.js
index 28391595631e8877e39bae9fcefd62181b35433a..4e44cd4ef3d069709d4ad8855803e1765b40ce5e 100644
--- a/src/proxy.js
+++ b/src/proxy.js
@@ -29,36 +29,6 @@ global.Proxy = new $Object();
var $Proxy = global.Proxy
-var fundamentalTraps = [
- "getOwnPropertyDescriptor",
- "getPropertyDescriptor",
- "getOwnPropertyNames",
- "getPropertyNames",
- "defineProperty",
- "delete",
- "fix",
-]
-
-var derivedTraps = [
- "has",
- "hasOwn",
- "get",
- "set",
- "enumerate",
- "keys",
-]
-
-var functionTraps = [
- "callTrap",
- "constructTrap",
-]
-
-$Proxy.createFunction = function(handler, callTrap, constructTrap) {
- handler.callTrap = callTrap
- handler.constructTrap = constructTrap
- $Proxy.create(handler)
-}
-
$Proxy.create = function(handler, proto) {
if (!IS_SPEC_OBJECT(handler))
throw MakeTypeError("handler_non_object", ["create"])
@@ -66,6 +36,20 @@ $Proxy.create = function(handler, proto) {
return %CreateJSProxy(handler, proto)
}
+$Proxy.createFunction = function(handler, callTrap, constructTrap) {
+ if (!IS_SPEC_OBJECT(handler))
+ throw MakeTypeError("handler_non_object", ["create"])
+ if (!IS_SPEC_FUNCTION(callTrap))
+ throw MakeTypeError("trap_function_expected", ["createFunction", "call"])
+ if (IS_UNDEFINED(constructTrap)) {
+ constructTrap = callTrap
+ } else if (!IS_SPEC_FUNCTION(constructTrap)) {
+ throw MakeTypeError("trap_function_expected",
+ ["createFunction", "construct"])
+ }
+ return %CreateJSFunctionProxy(
+ handler, callTrap, constructTrap, $Function.prototype)
+}
@@ -73,6 +57,13 @@ $Proxy.create = function(handler, proto) {
// Builtins
////////////////////////////////////////////////////////////////////////////////
+function DelegateCallAndConstruct(callTrap, constructTrap) {
+ return function() {
+ return %Apply(%_IsConstructCall() ? constructTrap : callTrap,
+ this, arguments, 0, %_ArgumentsLength())
+ }
+}
+
function DerivedGetTrap(receiver, name) {
var desc = this.getPropertyDescriptor(name)
if (IS_UNDEFINED(desc)) { return desc }
« no previous file with comments | « src/objects-visiting.cc ('k') | src/runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698