Ignore:
Timestamp:
Apr 22, 2016, 4:04:55 PM (9 years ago)
Author:
[email protected]
Message:

super should be available in object literals
https://bugs.webkit.org/show_bug.cgi?id=156933

Reviewed by Saam Barati.

Source/JavaScriptCore:

When we originally implemented classes, super seemed to be a class-only
feature. But the final spec says it's available in object literals too.

  • bytecompiler/NodesCodegen.cpp:

(JSC::PropertyListNode::emitBytecode): Having 'super' and being a class
property are no longer synonymous, so we track two separate variables.

(JSC::PropertyListNode::emitPutConstantProperty): Being inside the super
branch no longer guarantees that you're a class property, so we decide
our attributes and our function name dynamically.

  • parser/ASTBuilder.h:

(JSC::ASTBuilder::createArrowFunctionExpr):
(JSC::ASTBuilder::createGetterOrSetterProperty):
(JSC::ASTBuilder::createArguments):
(JSC::ASTBuilder::createArgumentsList):
(JSC::ASTBuilder::createProperty):
(JSC::ASTBuilder::createPropertyList): Pass through state to indicate
whether we're a class property, since we can't infer it from 'super'
anymore.

  • parser/NodeConstructors.h:

(JSC::PropertyNode::PropertyNode): See ASTBuilder.h.

  • parser/Nodes.h:

(JSC::PropertyNode::expressionName):
(JSC::PropertyNode::name):
(JSC::PropertyNode::type):
(JSC::PropertyNode::needsSuperBinding):
(JSC::PropertyNode::isClassProperty):
(JSC::PropertyNode::putType): See ASTBuilder.h.

  • parser/Parser.cpp:

(JSC::Parser<LexerType>::parseFunctionInfo):
(JSC::Parser<LexerType>::parseClass):
(JSC::Parser<LexerType>::parseProperty):
(JSC::Parser<LexerType>::parsePropertyMethod):
(JSC::Parser<LexerType>::parseGetterSetter):
(JSC::Parser<LexerType>::parseMemberExpression): I made these error
messages generic because it is no longer practical to say concise things
about the list of places you can use super.

  • parser/Parser.h:
  • parser/SyntaxChecker.h:

(JSC::SyntaxChecker::createArgumentsList):
(JSC::SyntaxChecker::createProperty):
(JSC::SyntaxChecker::appendExportSpecifier):
(JSC::SyntaxChecker::appendConstDecl):
(JSC::SyntaxChecker::createGetterOrSetterProperty): Updated for
interface change.

  • tests/stress/generator-with-super.js:

(test):

  • tests/stress/modules-syntax-error.js:
  • tests/stress/super-in-lexical-scope.js:

(testSyntaxError):
(testSyntaxError.test):

  • tests/stress/tagged-templates-syntax.js: Updated for error message

changes. See Parser.cpp.

LayoutTests:

Updated expected results and added a few new tests.

  • js/arrowfunction-syntax-errors-expected.txt:
  • js/class-syntax-super-expected.txt:
  • js/object-literal-methods-expected.txt:
  • js/script-tests/arrowfunction-syntax-errors.js:
  • js/script-tests/class-syntax-super.js:
  • js/script-tests/object-literal-methods.js:
File:
1 edited

Legend:

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

    r199787 r199927  
    203203    int createArgumentsList(const JSTokenLocation&, int) { return ArgumentsListResult; }
    204204    int createArgumentsList(const JSTokenLocation&, int, int) { return ArgumentsListResult; }
    205     Property createProperty(const Identifier* name, int, PropertyNode::Type type, PropertyNode::PutType, bool complete, SuperBinding = SuperBinding::NotNeeded)
     205    Property createProperty(const Identifier* name, int, PropertyNode::Type type, PropertyNode::PutType, bool complete, SuperBinding, bool)
    206206    {
    207207        if (!complete)
     
    210210        return Property(name, type);
    211211    }
    212     Property createProperty(VM* vm, ParserArena& parserArena, double name, int, PropertyNode::Type type, PropertyNode::PutType, bool complete)
     212    Property createProperty(VM* vm, ParserArena& parserArena, double name, int, PropertyNode::Type type, PropertyNode::PutType, bool complete, SuperBinding, bool)
    213213    {
    214214        if (!complete)
     
    216216        return Property(&parserArena.identifierArena().makeNumericIdentifier(vm, name), type);
    217217    }
    218     Property createProperty(int, int, PropertyNode::Type type, PropertyNode::PutType, bool, SuperBinding = SuperBinding::NotNeeded)
     218    Property createProperty(int, int, PropertyNode::Type type, PropertyNode::PutType, bool, SuperBinding, bool)
    219219    {
    220220        return Property(type);
     
    270270
    271271    int appendConstDecl(const JSTokenLocation&, int, const Identifier*, int) { return StatementResult; }
    272     Property createGetterOrSetterProperty(const JSTokenLocation&, PropertyNode::Type type, bool strict, const Identifier* name, const ParserFunctionInfo<SyntaxChecker>&, SuperBinding)
     272    Property createGetterOrSetterProperty(const JSTokenLocation&, PropertyNode::Type type, bool strict, const Identifier* name, const ParserFunctionInfo<SyntaxChecker>&, bool)
    273273    {
    274274        ASSERT(name);
     
    277277        return Property(name, type);
    278278    }
    279     Property createGetterOrSetterProperty(const JSTokenLocation&, PropertyNode::Type type, bool, int, const ParserFunctionInfo<SyntaxChecker>&, SuperBinding)
     279    Property createGetterOrSetterProperty(const JSTokenLocation&, PropertyNode::Type type, bool, int, const ParserFunctionInfo<SyntaxChecker>&, bool)
    280280    {
    281281        return Property(type);
    282282    }
    283     Property createGetterOrSetterProperty(VM* vm, ParserArena& parserArena, const JSTokenLocation&, PropertyNode::Type type, bool strict, double name, const ParserFunctionInfo<SyntaxChecker>&, SuperBinding)
     283    Property createGetterOrSetterProperty(VM* vm, ParserArena& parserArena, const JSTokenLocation&, PropertyNode::Type type, bool strict, double name, const ParserFunctionInfo<SyntaxChecker>&, bool)
    284284    {
    285285        if (!strict)
Note: See TracChangeset for help on using the changeset viewer.