I like this approach. But...
How is this going to work? new.target needs to work outside classes. That
is the
mechanism we are using to allow determining if a function was [[Call]]ed vs
[[Construct]]ed.
roughly:
function Date() {
if (new.target === undefined) {
return '2015-02-08';
}
return {[[TimeValue]]: 423443346, __proto__: new.target.prototype};
}
Maybe if we can keep track of `new.target` we can use the same idea for
ordinary
functions when they reference `new.target`?
https://codereview.chromium.org/908883002/diff/20001/src/compiler.cc
File src/compiler.cc (right):
https://codereview.chromium.org/908883002/diff/20001/src/compiler.cc#newcode623
src/compiler.cc:623:
function_info->set_formal_parameter_count(lit->parameter_count() + 1);
I'm worried about doing it at this high abstraction level. NewTarget is
not a formal parameter. Maybe it is better do it at a lower level
abstraction in case other code wants to use the formal parameter count
for what it sounds like (function length, rest params etc).
The SFI already has a field for the FunctionKind so deferring this
choice seems safer.
https://codereview.chromium.org/908883002/diff/20001/src/runtime/runtime-object.cc
File src/runtime/runtime-object.cc (right):
https://codereview.chromium.org/908883002/diff/20001/src/runtime/runtime-object.cc#newcode1304
src/runtime/runtime-object.cc:1304: if (*original_function != *function)
{
Is this is to set up the prototype from the NewTarget. Maybe add a
comment?
https://codereview.chromium.org/908883002/diff/20001/test/mjsunit/harmony/classes-experimental.js
File test/mjsunit/harmony/classes-experimental.js (right):
https://codereview.chromium.org/908883002/diff/20001/test/mjsunit/harmony/classes-experimental.js#newcode161
test/mjsunit/harmony/classes-experimental.js:161: class
ExtendedUint8Array extends Uint8Array {
HOT!
https://codereview.chromium.org/908883002/diff/20001/test/mjsunit/harmony/classes-experimental.js#newcode174
test/mjsunit/harmony/classes-experimental.js:174:
assertTrue(eua.__proto__ === ExtendedUint8Array.prototype);
Maybe a test with Object.prototype.toString to make sure the instance is
the right exotic object kind.
https://codereview.chromium.org/908883002/
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.