Skip to content

Commit

Permalink
Fix the type of GeneratorFunction.prototype
Browse files Browse the repository at this point in the history
Signed-off-by: HyukWoo Park <[email protected]>
  • Loading branch information
clover2123 authored and ksh8281 committed Mar 26, 2024
1 parent 232a555 commit 870bc39
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/builtins/BuiltinAsyncGeneratorFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ void GlobalObject::installAsyncGenerator(ExecutionState& state)
ObjectPropertyDescriptor(new NativeFunctionObject(state, NativeFunctionInfo(state.context()->staticStrings().stringThrow, builtinAsyncGeneratorThrow, 1, NativeFunctionInfo::Strict)), (ObjectPropertyDescriptor::PresentAttribute)(ObjectPropertyDescriptor::WritablePresent | ObjectPropertyDescriptor::ConfigurablePresent)));

m_asyncGeneratorPrototype->directDefineOwnProperty(state, ObjectPropertyName(state, Value(state.context()->vmInstance()->globalSymbols().toStringTag)),
ObjectPropertyDescriptor(Value(state.context()->staticStrings().AsyncGenerator.string()), (ObjectPropertyDescriptor::PresentAttribute)(ObjectPropertyDescriptor::PresentAttribute)(ObjectPropertyDescriptor::NonWritablePresent | ObjectPropertyDescriptor::NonEnumerablePresent | ObjectPropertyDescriptor::ConfigurablePresent)));
ObjectPropertyDescriptor(state.context()->staticStrings().AsyncGenerator.string(), ObjectPropertyDescriptor::ConfigurablePresent));
}

} // namespace Escargot
9 changes: 5 additions & 4 deletions src/builtins/BuiltinGeneratorFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,15 @@ void GlobalObject::installGenerator(ExecutionState& state)
// %GeneratorFunction% : The constructor of generator objects
m_generatorFunction = new NativeFunctionObject(state, NativeFunctionInfo(state.context()->staticStrings().GeneratorFunction, builtinGeneratorFunction, 1), NativeFunctionObject::__ForBuiltinConstructor__);
m_generatorFunction->setGlobalIntrinsicObject(state);
m_generatorFunction->setPrototype(state, m_function);

// %Generator% : The initial value of the prototype property of %GeneratorFunction%
m_generator = new NativeFunctionObject(state, NativeFunctionInfo(state.context()->staticStrings().GeneratorFunction, nullptr, 0, NativeFunctionInfo::Strict));
m_generator = new PrototypeObject(state, m_functionPrototype);
m_generator->setGlobalIntrinsicObject(state, true);
m_generatorFunction->setFunctionPrototype(state, m_generator);

// 25.2.3.1 The initial value of GeneratorFunction.prototype.constructor is the intrinsic object %GeneratorFunction%.
m_generator->directDefineOwnProperty(state, ObjectPropertyName(state.context()->staticStrings().constructor), ObjectPropertyDescriptor(m_generatorFunction, (ObjectPropertyDescriptor::PresentAttribute)(ObjectPropertyDescriptor::NonWritablePresent | ObjectPropertyDescriptor::NonEnumerablePresent | ObjectPropertyDescriptor::ConfigurablePresent)));
m_generator->directDefineOwnProperty(state, ObjectPropertyName(state.context()->staticStrings().constructor), ObjectPropertyDescriptor(m_generatorFunction, ObjectPropertyDescriptor::ConfigurablePresent));

{
ASSERT(!!m_callerAndArgumentsGetterSetter);
Expand All @@ -99,7 +100,7 @@ void GlobalObject::installGenerator(ExecutionState& state)
// The initial value of the @@toStringTag property is the String value "GeneratorFunction"..
// This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
m_generator->directDefineOwnProperty(state, ObjectPropertyName(state, Value(state.context()->vmInstance()->globalSymbols().toStringTag)),
ObjectPropertyDescriptor(Value(state.context()->staticStrings().GeneratorFunction.string()), (ObjectPropertyDescriptor::PresentAttribute)(ObjectPropertyDescriptor::NonWritablePresent | ObjectPropertyDescriptor::NonEnumerablePresent | ObjectPropertyDescriptor::ConfigurablePresent)));
ObjectPropertyDescriptor(state.context()->staticStrings().GeneratorFunction.string(), ObjectPropertyDescriptor::ConfigurablePresent));

// The initial value of Generator.prototype.constructor is the intrinsic object %Generator%.
m_generatorPrototype->directDefineOwnProperty(state, ObjectPropertyName(state.context()->staticStrings().constructor), ObjectPropertyDescriptor(m_generator, ObjectPropertyDescriptor::ConfigurablePresent));
Expand All @@ -112,6 +113,6 @@ void GlobalObject::installGenerator(ExecutionState& state)
ObjectPropertyDescriptor(new NativeFunctionObject(state, NativeFunctionInfo(state.context()->staticStrings().stringThrow, builtinGeneratorThrow, 1, NativeFunctionInfo::Strict)), (ObjectPropertyDescriptor::PresentAttribute)(ObjectPropertyDescriptor::WritablePresent | ObjectPropertyDescriptor::ConfigurablePresent)));
// http://www.ecma-international.org/ecma-262/6.0/#sec-generatorfunction.prototype-@@tostringtag
m_generatorPrototype->directDefineOwnProperty(state, ObjectPropertyName(state, Value(state.context()->vmInstance()->globalSymbols().toStringTag)),
ObjectPropertyDescriptor(Value(state.context()->staticStrings().Generator.string()), (ObjectPropertyDescriptor::PresentAttribute)(ObjectPropertyDescriptor::PresentAttribute)(ObjectPropertyDescriptor::NonWritablePresent | ObjectPropertyDescriptor::NonEnumerablePresent | ObjectPropertyDescriptor::ConfigurablePresent)));
ObjectPropertyDescriptor(state.context()->staticStrings().Generator.string(), ObjectPropertyDescriptor::ConfigurablePresent));
}
} // namespace Escargot
2 changes: 1 addition & 1 deletion src/runtime/GlobalObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class FunctionObject;
F(callerAndArgumentsGetterSetter, FunctionObject, objName)
#define GLOBALOBJECT_BUILTIN_GENERATOR(F, objName) \
F(generatorFunction, FunctionObject, objName) \
F(generator, FunctionObject, objName) \
F(generator, Object, objName) \
F(generatorPrototype, Object, objName)
// INTL
#if defined(ENABLE_ICU) && defined(ENABLE_INTL)
Expand Down
1 change: 0 additions & 1 deletion tools/test/test262/excludelist.orig.xml
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,6 @@
<test id="built-ins/Date/year-zero"><reason>TODO</reason></test>
<test id="built-ins/Function/internals/Construct/derived-this-uninitialized-realm"><reason>TODO</reason></test>
<test id="built-ins/Function/prototype/toString/line-terminator-normalisation-CR"><reason>TODO</reason></test>
<test id="built-ins/GeneratorFunction/prototype/not-callable"><reason>TODO</reason></test>
<test id="built-ins/Iterator/constructor"><reason>TODO</reason></test>
<test id="built-ins/Iterator/from/callable"><reason>TODO</reason></test>
<test id="built-ins/Iterator/from/get-next-method-only-once"><reason>TODO</reason></test>
Expand Down

0 comments on commit 870bc39

Please sign in to comment.