Ignore:
Timestamp:
Mar 16, 2017, 5:58:14 AM (8 years ago)
Author:
[email protected]
Message:

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

Patch by Caio Lima <Caio Lima> on 2017-03-16
Reviewed by Yusuke Suzuki.

JSTests:

  • 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 CopyDataProperties to copy all enumerable keys
from object being spreaded.

It's also fixing CopyDataProperties that was using
Object.getOwnPropertyNames to list all keys to be copied, and now is
using Relect.ownKeys.

[1] - https://github.com/sebmarkbage/ecmascript-rest-spread

  • builtins/GlobalOperations.js:

(globalPrivate.copyDataProperties):

  • bytecode/CodeBlock.cpp:

(JSC::CodeBlock::setConstantIdentifierSetRegisters):

  • bytecode/UnlinkedCodeBlock.h:

(JSC::UnlinkedCodeBlock::addSetConstant):

  • bytecompiler/BytecodeGenerator.cpp:

(JSC::BytecodeGenerator::emitLoad):

  • bytecompiler/BytecodeGenerator.h:
  • bytecompiler/NodesCodegen.cpp:

(JSC::PropertyListNode::emitBytecode):
(JSC::ObjectPatternNode::bindValue):
(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):

  • runtime/JSGlobalObject.cpp:

(JSC::JSGlobalObject::init):

  • runtime/JSGlobalObjectFunctions.cpp:

(JSC::privateToObject): Deleted.

  • runtime/JSGlobalObjectFunctions.h:

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

    r214029 r214038  
    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.