Revision: 9761
Author: [email protected]
Date: Mon Oct 24 09:25:30 2011
Log: Adapt to latest spec changes for Proxy.create[Function].
[email protected]
BUG=
TEST=
Review URL: http://codereview.chromium.org/8271005
http://code.google.com/p/v8/source/detail?r=9761
Modified:
/branches/bleeding_edge/src/messages.js
/branches/bleeding_edge/src/proxy.js
/branches/bleeding_edge/test/mjsunit/harmony/proxies-function.js
/branches/bleeding_edge/test/mjsunit/harmony/proxies.js
=======================================
--- /branches/bleeding_edge/src/messages.js Thu Oct 20 05:31:33 2011
+++ /branches/bleeding_edge/src/messages.js Mon Oct 24 09:25:30 2011
@@ -185,6 +185,7 @@
"define_disallowed", ["Cannot define property:", "%0", ",
object is not extensible."],
"non_extensible_proto", ["%0", " is not extensible"],
"handler_non_object", ["Proxy.", "%0", " called with
non-object as handler"],
+ "proto_non_object", ["Proxy.", "%0", " called with
non-object as prototype"],
"trap_function_expected", ["Proxy.", "%0", " called with
non-function for '", "%1", "' trap"],
"handler_trap_missing", ["Proxy handler ", "%0", " has
no '", "%1", "' trap"],
"handler_trap_must_be_callable", ["Proxy handler ", "%0", " has
non-callable '", "%1", "' trap"],
=======================================
--- /branches/bleeding_edge/src/proxy.js Mon Oct 24 08:56:18 2011
+++ /branches/bleeding_edge/src/proxy.js Mon Oct 24 09:25:30 2011
@@ -32,7 +32,10 @@
$Proxy.create = function(handler, proto) {
if (!IS_SPEC_OBJECT(handler))
throw MakeTypeError("handler_non_object", ["create"])
- if (!IS_SPEC_OBJECT(proto)) proto = null // Mozilla does this...
+ if (IS_UNDEFINED(proto))
+ proto = null
+ else if (!(IS_SPEC_OBJECT(proto) || proto === null))
+ throw MakeTypeError("proto_non_object", ["create"])
return %CreateJSProxy(handler, proto)
}
@@ -41,20 +44,20 @@
throw MakeTypeError("handler_non_object", ["create"])
if (!IS_SPEC_FUNCTION(callTrap))
throw MakeTypeError("trap_function_expected",
["createFunction", "call"])
- var construct
if (IS_UNDEFINED(constructTrap)) {
- construct = DerivedConstructTrap(callTrap)
+ constructTrap = DerivedConstructTrap(callTrap)
} else if (IS_SPEC_FUNCTION(constructTrap)) {
- construct = function() {
- // Make sure the trap receives 'undefined' as this.
- return %Apply(constructTrap, void 0, arguments,
0, %_ArgumentsLength());
+ // Make sure the trap receives 'undefined' as this.
+ var construct = constructTrap
+ constructTrap = function() {
+ return %Apply(construct, void 0, arguments, 0, %_ArgumentsLength());
}
} else {
throw MakeTypeError("trap_function_expected",
["createFunction", "construct"])
}
return %CreateJSFunctionProxy(
- handler, callTrap, construct, $Function.prototype)
+ handler, callTrap, constructTrap, $Function.prototype)
}
=======================================
--- /branches/bleeding_edge/test/mjsunit/harmony/proxies-function.js Mon
Oct 17 05:44:16 2011
+++ /branches/bleeding_edge/test/mjsunit/harmony/proxies-function.js Mon
Oct 24 09:25:30 2011
@@ -286,24 +286,11 @@
assertEquals(42, o.sum)
assertSame(proto, Object.getPrototypeOf(o))
-// TODO(rossberg): does not work yet.
-// var ff = Function.prototype.bind.call(f, o, 10)
-// var o = new ff(32)
-// assertEquals(undefined, receiver)
-// assertEquals(42, o.sum)
-// assertSame(proto, Object.getPrototypeOf(o))
-
var f = CreateFrozen(handler, function() {}, constructTrap)
var o = new f(11, 32)
assertEquals(undefined, receiver)
assertEquals(43, o.sum)
assertSame(proto, Object.getPrototypeOf(o))
-
- var ff = Function.prototype.bind.call(f, o, 10)
- var o = new ff(32)
- assertEquals(undefined, receiver)
- assertEquals(42, o.sum)
- assertSame(proto, Object.getPrototypeOf(o))
}
TestConstruct(Object.prototype, ReturnNew)
@@ -331,25 +318,11 @@
assertEquals(42, o.sum)
assertSame(proto, Object.getPrototypeOf(o))
-// TODO(rossberg): does not work yet.
-// var ff = Function.prototype.bind.call(f, o, 10)
-// var o = new ff(32)
-// assertEquals(undefined, receiver)
-// assertEquals(42, o.sum)
-// assertSame(proto, Object.getPrototypeOf(o))
-
var f = CreateFrozen(handler, callTrap)
var o = new f(11, 32)
if (returnsThis) assertEquals(o, receiver)
assertEquals(43, o.sum)
assertSame(proto, Object.getPrototypeOf(o))
-
-// TODO(rossberg): does not work yet.
-// var ff = Function.prototype.bind.call(f, o, 10)
-// var o = new ff(32)
-// assertEquals(undefined, receiver)
-// assertEquals(42, o.sum)
-// assertSame(proto, Object.getPrototypeOf(o))
}
TestConstructFromCall(Object.prototype, true, ReturnUndef)
=======================================
--- /branches/bleeding_edge/test/mjsunit/harmony/proxies.js Mon Oct 24
08:56:18 2011
+++ /branches/bleeding_edge/test/mjsunit/harmony/proxies.js Mon Oct 24
09:25:30 2011
@@ -1464,7 +1464,7 @@
var p1 = Proxy.create({})
var p2 = Proxy.create({}, o1)
var p3 = Proxy.create({}, p2)
- var p4 = Proxy.create({}, 666)
+ var p4 = Proxy.create({}, null)
var o2 = Object.create(p3)
assertSame(Object.getPrototypeOf(o1), Object.prototype)
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev