Ignore:
Timestamp:
Jul 13, 2017, 12:11:45 AM (8 years ago)
Author:
Caio Lima
Message:

[ESnext] Implement Object Spread
https://bugs.webkit.org/show_bug.cgi?id=167963

Reviewed by Saam Barati.

JSTests:

  • stress/obj-rest-destructuring-order.js: Added.

(assert):
(o.get z):
(o.get a):

  • stress/obj-spread-order.js: Added.

(assert):
(o.get z):
(o.get a):

  • stress/object-spread.js: Added.

(let.assert):
(assert.sameValue):
(let.o.get a):
(let.obj.get c):
(cthulhu.get x):
(let.obj.set c):
(calls.o.get z):
(calls.o.get a):
(try.let.obj.get foo):
(get calls):

Source/JavaScriptCore:

This patch implements ECMA262 stage 3 Object Spread proposal [1].
It's implemented using CopyDataPropertiesNoExclusions to copy
all enumerable keys from object being spreaded. The implementation of
CopyDataPropertiesNoExclusions follows the CopyDataProperties
implementation, however we don't receive excludedNames as parameter.

[1] - https://github.com/tc39/proposal-object-rest-spread

  • builtins/GlobalOperations.js:

(globalPrivate.copyDataPropertiesNoExclusions):

  • bytecompiler/BytecodeGenerator.cpp:

(JSC::BytecodeGenerator::emitLoad):

  • bytecompiler/NodesCodegen.cpp:

(JSC::PropertyListNode::emitBytecode):
(JSC::ObjectSpreadExpressionNode::emitBytecode):

  • parser/ASTBuilder.h:

(JSC::ASTBuilder::createObjectSpreadExpression):
(JSC::ASTBuilder::createProperty):

  • parser/NodeConstructors.h:

(JSC::PropertyNode::PropertyNode):
(JSC::ObjectSpreadExpressionNode::ObjectSpreadExpressionNode):

  • parser/Nodes.h:

(JSC::ObjectSpreadExpressionNode::expression):

  • parser/Parser.cpp:

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

  • parser/SyntaxChecker.h:

(JSC::SyntaxChecker::createObjectSpreadExpression):
(JSC::SyntaxChecker::createProperty):

LayoutTests:

  • js/parser-syntax-check-expected.txt:
  • js/script-tests/parser-syntax-check.js:
File:
1 edited

Legend:

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

    r218861 r219443  
    7777        DeleteExpr, ArrayLiteralExpr, BindingDestructuring, RestParameter,
    7878        ArrayDestructuring, ObjectDestructuring, SourceElementsResult,
    79         FunctionBodyResult, SpreadExpr, ArgumentsResult,
     79        FunctionBodyResult, SpreadExpr, ObjectSpreadExpr, ArgumentsResult,
    8080        PropertyListResult, ArgumentsListResult, ElementsListResult,
    8181        StatementResult, FormalParameterListResult, ClauseResult,
     
    195195    int createArguments(int) { return ArgumentsResult; }
    196196    ExpressionType createSpreadExpression(const JSTokenLocation&, ExpressionType, int, int, int) { return SpreadExpr; }
     197    ExpressionType createObjectSpreadExpression(const JSTokenLocation&, ExpressionType, int, int, int) { return ObjectSpreadExpr; }
    197198    TemplateString createTemplateString(const JSTokenLocation&, const Identifier*, const Identifier*) { return TemplateStringResult; }
    198199    TemplateStringList createTemplateStringList(TemplateString) { return TemplateStringListResult; }
     
    212213        ASSERT(name);
    213214        return Property(name, type);
     215    }
     216    Property createProperty(int, PropertyNode::Type type, PropertyNode::PutType, bool, SuperBinding, bool)
     217    {
     218        return Property(type);
    214219    }
    215220    Property createProperty(VM* vm, ParserArena& parserArena, double name, int, PropertyNode::Type type, PropertyNode::PutType, bool complete, SuperBinding, bool)
Note: See TracChangeset for help on using the changeset viewer.