Ignore:
Timestamp:
Aug 14, 2015, 4:50:25 PM (10 years ago)
Author:
[email protected]
Message:

ES6 class syntax should allow computed name method
https://bugs.webkit.org/show_bug.cgi?id=142690

Reviewed by Saam Barati.

Source/JavaScriptCore:

Added a new "attributes" attribute to op_put_getter_by_id, op_put_setter_by_id, op_put_getter_setter to specify
the property descriptor options so that we can use use op_put_setter_by_id and op_put_getter_setter to define
getters and setters for classes. Without this, getters and setters could erroneously override methods.

  • bytecode/BytecodeList.json:
  • bytecode/BytecodeUseDef.h:

(JSC::computeUsesForBytecodeOffset):

  • bytecode/CodeBlock.cpp:

(JSC::CodeBlock::dumpBytecode):

  • bytecompiler/BytecodeGenerator.cpp:

(JSC::BytecodeGenerator::emitDirectPutById):
(JSC::BytecodeGenerator::emitPutGetterById):
(JSC::BytecodeGenerator::emitPutSetterById):
(JSC::BytecodeGenerator::emitPutGetterSetter):

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

(JSC::PropertyListNode::emitBytecode): Always use emitPutGetterSetter to emit getters and setters for classes
as done for object literals.
(JSC::PropertyListNode::emitPutConstantProperty):
(JSC::ClassExprNode::emitBytecode):

  • jit/CCallHelpers.h:

(JSC::CCallHelpers::setupArgumentsWithExecState):

  • jit/JIT.h:
  • jit/JITInlines.h:

(JSC::JIT::callOperation):

  • jit/JITOperations.cpp:
  • jit/JITOperations.h:
  • jit/JITPropertyAccess.cpp:

(JSC::JIT::emit_op_put_getter_by_id):
(JSC::JIT::emit_op_put_setter_by_id):
(JSC::JIT::emit_op_put_getter_setter):
(JSC::JIT::emit_op_del_by_id):

  • jit/JITPropertyAccess32_64.cpp:

(JSC::JIT::emit_op_put_getter_by_id):
(JSC::JIT::emit_op_put_setter_by_id):
(JSC::JIT::emit_op_put_getter_setter):
(JSC::JIT::emit_op_del_by_id):

  • llint/LLIntSlowPaths.cpp:

(JSC::LLInt::LLINT_SLOW_PATH_DECL):

  • llint/LowLevelInterpreter.asm:
  • parser/ASTBuilder.h:

(JSC::ASTBuilder::createProperty):
(JSC::ASTBuilder::createPropertyList):

  • parser/NodeConstructors.h:

(JSC::PropertyNode::PropertyNode):

  • parser/Nodes.h:

(JSC::PropertyNode::expressionName):
(JSC::PropertyNode::name):

  • parser/Parser.cpp:

(JSC::Parser<LexerType>::parseClass): Added the support for computed property name. We don't support computed names
for getters and setters.

  • parser/SyntaxChecker.h:

(JSC::SyntaxChecker::createProperty):

  • runtime/JSObject.cpp:

(JSC::JSObject::allowsAccessFrom):
(JSC::JSObject::putGetter):
(JSC::JSObject::putSetter):

  • runtime/JSObject.h:
  • runtime/PropertyDescriptor.h:

LayoutTests:

Added test cases for computed method names.

  • js/class-syntax-method-names-expected.txt:
  • js/script-tests/class-syntax-method-names.js:
File:
1 edited

Legend:

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

    r188417 r188498  
    219219        return Property(&parserArena.identifierArena().makeNumericIdentifier(vm, name), type);
    220220    }
    221     Property createProperty(int, int, PropertyNode::Type type, PropertyNode::PutType, bool)
     221    Property createProperty(int, int, PropertyNode::Type type, PropertyNode::PutType, bool, SuperBinding = SuperBinding::NotNeeded)
    222222    {
    223223        return Property(type);
Note: See TracChangeset for help on using the changeset viewer.