Ignore:
Timestamp:
Jul 21, 2015, 11:18:42 AM (10 years ago)
Author:
[email protected]
Message:

Add support for the new.target syntax.
https://bugs.webkit.org/show_bug.cgi?id=147051

Patch by Keith Miller <[email protected]> on 2015-07-21
Reviewed by Yusuke Suzuki.

Add support for new.target. Essentially the implementation is, before constructor calls,
the target of a "new" is placed where "this" noramlly goes in the calling convention.
Then in the constructor before object is initialized we move the target of the "new"
into a local variable.

  • bytecompiler/BytecodeGenerator.cpp:

(JSC::BytecodeGenerator::BytecodeGenerator):

  • bytecompiler/NodesCodegen.cpp:

(JSC::NewTargetNode::emitBytecode):

  • parser/ASTBuilder.h:

(JSC::ASTBuilder::newTargetExpr):

  • parser/NodeConstructors.h:

(JSC::NewTargetNode::NewTargetNode):

  • parser/Nodes.h:
  • parser/Parser.cpp:

(JSC::Parser<LexerType>::parseMemberExpression):

  • parser/SyntaxChecker.h:

(JSC::SyntaxChecker::newTargetExpr):

  • runtime/CommonIdentifiers.h:
  • tests/stress/new-target.js: Added.

(test):
(call):
(Constructor.subCall):
(Constructor.SubConstructor):
(Constructor):
(noAssign):
(doWeirdThings):
(SuperClass):
(SubClass):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/parser/SyntaxChecker.h

    r187012 r187108  
    7575        FunctionExpr, ClassExpr, SuperExpr, BracketExpr, DotExpr, CallExpr,
    7676        NewExpr, PreExpr, PostExpr, UnaryExpr, BinaryExpr,
    77         ConditionalExpr, AssignmentExpr, TypeofExpr,
     77        ConditionalExpr, AssignmentExpr, TypeofExpr, NewTargetExpr,
    7878        DeleteExpr, ArrayLiteralExpr, BindingDestructuring,
    7979        ArrayDestructuring, ObjectDestructuring, SourceElementsResult,
     
    155155    ExpressionType thisExpr(const JSTokenLocation&, ThisTDZMode) { return ThisExpr; }
    156156    ExpressionType superExpr(const JSTokenLocation&) { return SuperExpr; }
     157    ExpressionType newTargetExpr(const JSTokenLocation&) { return NewTargetExpr; }
    157158    ExpressionType createResolve(const JSTokenLocation&, const Identifier*, int) { return ResolveExpr; }
    158159    ExpressionType createObjectLiteral(const JSTokenLocation&) { return ObjectLiteralExpr; }
Note: See TracChangeset for help on using the changeset viewer.