Ignore:
Timestamp:
Dec 30, 2015, 1:08:16 PM (10 years ago)
Author:
[email protected]
Message:

[ES6] Arrow function syntax. Arrow function specific features. Lexical bind "super"
https://bugs.webkit.org/show_bug.cgi?id=149615

Source/JavaScriptCore:

Patch by Aleksandr Skachkov <[email protected]> on 2015-12-30
Reviewed by Saam Barati.

Implemented lexical bind "super" property for arrow function. 'super' property can be accessed
inside of the arrow function in case if arrow function is nested in constructor, method,
getter or setter of class. In current patch using 'super' in arrow function, that declared out of the
class, lead to wrong type of error, should be SyntaxError(https://bugs.webkit.org/show_bug.cgi?id=150893)
and this will be fixed in separete patch.

  • builtins/BuiltinExecutables.cpp:

(JSC::createExecutableInternal):

  • bytecode/EvalCodeCache.h:

(JSC::EvalCodeCache::getSlow):

  • bytecode/ExecutableInfo.h:

(JSC::ExecutableInfo::ExecutableInfo):
(JSC::ExecutableInfo::derivedContextType):
(JSC::ExecutableInfo::isClassContext):

  • bytecode/UnlinkedCodeBlock.cpp:

(JSC::UnlinkedCodeBlock::UnlinkedCodeBlock):

  • bytecode/UnlinkedCodeBlock.h:

(JSC::UnlinkedCodeBlock::derivedContextType):
(JSC::UnlinkedCodeBlock::isClassContext):

  • bytecode/UnlinkedFunctionExecutable.cpp:

(JSC::generateUnlinkedFunctionCodeBlock):
(JSC::UnlinkedFunctionExecutable::UnlinkedFunctionExecutable):

  • bytecode/UnlinkedFunctionExecutable.h:
  • bytecompiler/BytecodeGenerator.cpp:

(JSC::BytecodeGenerator::BytecodeGenerator):
(JSC::BytecodeGenerator::emitPutDerivedConstructorToArrowFunctionContextScope):

  • bytecompiler/BytecodeGenerator.h:

(JSC::BytecodeGenerator::derivedContextType):
(JSC::BytecodeGenerator::isDerivedConstructorContext):
(JSC::BytecodeGenerator::isDerivedClassContext):
(JSC::BytecodeGenerator::isArrowFunction):
(JSC::BytecodeGenerator::makeFunction):

  • bytecompiler/NodesCodegen.cpp:

(JSC::emitHomeObjectForCallee):
(JSC::FunctionCallValueNode::emitBytecode):

  • debugger/DebuggerCallFrame.cpp:

(JSC::DebuggerCallFrame::evaluate):

  • interpreter/Interpreter.cpp:

(JSC::eval):

  • runtime/CodeCache.cpp:

(JSC::CodeCache::getFunctionExecutableFromGlobalCode):

  • runtime/Executable.cpp:

(JSC::ScriptExecutable::ScriptExecutable):
(JSC::EvalExecutable::create):
(JSC::EvalExecutable::EvalExecutable):
(JSC::ProgramExecutable::ProgramExecutable):
(JSC::ModuleProgramExecutable::ModuleProgramExecutable):
(JSC::FunctionExecutable::FunctionExecutable):

  • runtime/Executable.h:

(JSC::ScriptExecutable::derivedContextType):

  • runtime/JSGlobalObjectFunctions.cpp:

(JSC::globalFuncEval):

  • tests/es6.yaml:
  • tests/stress/arrowfunction-lexical-bind-superproperty.js: Added.

LayoutTests:

Patch by Skachkov Oleksandr <[email protected]> on 2015-12-30
Reviewed by Saam Barati.

  • js/arrowfunction-superproperty-expected.txt: Added.
  • js/arrowfunction-superproperty.html: Added.
  • js/script-tests/arrowfunction-superproperty.js: Added.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/bytecode/ExecutableInfo.h

    r194435 r194449  
    3030
    3131namespace JSC {
     32   
     33enum class DerivedContextType { None, DerivedConstructorContext, DerivedMethodContext };
    3234
    3335// FIXME: These flags, ParserModes and propagation to XXXCodeBlocks should be reorganized.
    3436// https://bugs.webkit.org/show_bug.cgi?id=151547
    3537struct ExecutableInfo {
    36     ExecutableInfo(bool needsActivation, bool usesEval, bool isStrictMode, bool isConstructor, bool isBuiltinFunction, ConstructorKind constructorKind, SuperBinding superBinding, SourceParseMode parseMode, bool isDerivedConstructorContext, bool isArrowFunctionContext)
     38    ExecutableInfo(bool needsActivation, bool usesEval, bool isStrictMode, bool isConstructor, bool isBuiltinFunction, ConstructorKind constructorKind, SuperBinding superBinding, SourceParseMode parseMode, DerivedContextType derivedContextType, bool isArrowFunctionContext, bool isClassContext)
    3739        : m_needsActivation(needsActivation)
    3840        , m_usesEval(usesEval)
     
    4345        , m_superBinding(static_cast<unsigned>(superBinding))
    4446        , m_parseMode(parseMode)
    45         , m_isDerivedConstructorContext(isDerivedConstructorContext)
     47        , m_derivedContextType(static_cast<unsigned>(derivedContextType))
    4648        , m_isArrowFunctionContext(isArrowFunctionContext)
     49        , m_isClassContext(isClassContext)
    4750    {
    4851        ASSERT(m_constructorKind == static_cast<unsigned>(constructorKind));
     
    5861    SuperBinding superBinding() const { return static_cast<SuperBinding>(m_superBinding); }
    5962    SourceParseMode parseMode() const { return m_parseMode; }
    60     bool isDerivedConstructorContext() const { return m_isDerivedConstructorContext; }
     63    DerivedContextType derivedContextType() const { return static_cast<DerivedContextType>(m_derivedContextType); }
    6164    bool isArrowFunctionContext() const { return m_isArrowFunctionContext; }
     65    bool isClassContext() const { return m_isClassContext; }
    6266
    6367private:
     
    7074    unsigned m_superBinding : 1;
    7175    SourceParseMode m_parseMode;
    72     unsigned m_isDerivedConstructorContext : 1;
     76    unsigned m_derivedContextType : 2;
    7377    unsigned m_isArrowFunctionContext : 1;
     78    unsigned m_isClassContext : 1;
    7479};
    7580
Note: See TracChangeset for help on using the changeset viewer.