mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-11-23 10:09:54 +00:00
Fix some bug
issue:https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/I8PRR6 Signed-off-by: maojunwei <maojunwei1@huawei.com> Change-Id: I2b0ffa1f3223403527bc43c76381022b02b66e81
This commit is contained in:
parent
d2dcca40de
commit
99fe89a8b1
@ -2745,6 +2745,7 @@ void Builtins::InitializeGeneratorFunction(const JSHandle<GlobalEnv> &env,
|
||||
JSHandle<JSFunction> generatorFunction =
|
||||
NewBuiltinConstructor(env, generatorFuncPrototype, GeneratorObject::GeneratorFunctionConstructor,
|
||||
"GeneratorFunction", FunctionLength::ONE);
|
||||
JSObject::SetPrototype(thread_, JSHandle<JSObject>::Cast(generatorFunction), env->GetFunctionFunction());
|
||||
JSHandle<JSTaggedValue> constructorKey = globalConst->GetHandledConstructorString();
|
||||
PropertyDescriptor generatorDesc(thread_, JSHandle<JSTaggedValue>::Cast(generatorFunction), false, false, true);
|
||||
JSObject::DefineOwnProperty(thread_, generatorFuncPrototype, constructorKey, generatorDesc);
|
||||
@ -2763,7 +2764,7 @@ void Builtins::InitializeGeneratorFunction(const JSHandle<GlobalEnv> &env,
|
||||
|
||||
// 26.5.1.1 Generator.prototype.constructor -> %GeneratorFunction.prototype%.
|
||||
PropertyDescriptor generatorObjDesc(thread_, generatorFuncPrototypeValue, false, false, true);
|
||||
JSObject::DefineOwnProperty(thread_, JSHandle<JSObject>(env->GetInitialGenerator()),
|
||||
JSObject::DefineOwnProperty(thread_, JSHandle<JSObject>(env->GetGeneratorPrototype()),
|
||||
globalConst->GetHandledConstructorString(), generatorObjDesc);
|
||||
|
||||
// Generator instances prototype -> GeneratorFunction.prototype.prototype
|
||||
@ -2791,6 +2792,7 @@ void Builtins::InitializeAsyncGeneratorFunction(const JSHandle<GlobalEnv> &env,
|
||||
NewBuiltinConstructor(env, asyncGeneratorFuncPrototype,
|
||||
AsyncGeneratorObject::AsyncGeneratorFunctionConstructor, "AsyncGeneratorFunction",
|
||||
FunctionLength::ONE);
|
||||
JSObject::SetPrototype(thread_, JSHandle<JSObject>::Cast(asyncGeneratorFunction), env->GetFunctionFunction());
|
||||
JSHandle<JSTaggedValue> constructorKey = globalConst->GetHandledConstructorString();
|
||||
PropertyDescriptor asyncGeneratorDesc(thread_, JSHandle<JSTaggedValue>::Cast(asyncGeneratorFunction),
|
||||
false, false, true);
|
||||
@ -2822,29 +2824,25 @@ void Builtins::InitializeAsyncGeneratorFunction(const JSHandle<GlobalEnv> &env,
|
||||
void Builtins::InitializeGenerator(const JSHandle<GlobalEnv> &env, const JSHandle<JSHClass> &objFuncClass) const
|
||||
{
|
||||
[[maybe_unused]] EcmaHandleScope scope(thread_);
|
||||
const GlobalEnvConstants *globalConst = thread_->GlobalConstants();
|
||||
JSHandle<JSObject> generatorFuncPrototype = factory_->NewJSObjectWithInit(objFuncClass);
|
||||
JSHandle<JSObject> generatorPrototype = factory_->NewJSObjectWithInit(objFuncClass);
|
||||
|
||||
// GeneratorObject.prototype method
|
||||
// 26.5.1.2 Generator.prototype.next(value)
|
||||
SetFunction(env, generatorFuncPrototype, "next", GeneratorObject::GeneratorPrototypeNext, FunctionLength::ONE);
|
||||
SetFunction(env, generatorPrototype, "next", GeneratorObject::GeneratorPrototypeNext, FunctionLength::ONE);
|
||||
// 26.5.1.3 Generator.prototype.return(value)
|
||||
SetFunction(env, generatorFuncPrototype, "return", GeneratorObject::GeneratorPrototypeReturn, FunctionLength::ONE);
|
||||
SetFunction(env, generatorPrototype, "return", GeneratorObject::GeneratorPrototypeReturn, FunctionLength::ONE);
|
||||
// 26.5.1.4 Generator.prototype.throw(exception)
|
||||
SetFunction(env, generatorFuncPrototype, "throw", GeneratorObject::GeneratorPrototypeThrow, FunctionLength::ONE);
|
||||
SetFunction(env, generatorPrototype, "throw", GeneratorObject::GeneratorPrototypeThrow, FunctionLength::ONE);
|
||||
|
||||
// 26.5.1.5 Generator.prototype[@@toStringTag]
|
||||
SetStringTagSymbol(env, generatorFuncPrototype, "Generator");
|
||||
SetStringTagSymbol(env, generatorPrototype, "Generator");
|
||||
|
||||
// Generator with constructor, symbolTag, next/return/throw etc.
|
||||
PropertyDescriptor descriptor(thread_, env->GetIteratorPrototype(), true, false, false);
|
||||
JSObject::DefineOwnProperty(thread_, generatorFuncPrototype, globalConst->GetHandledPrototypeString(), descriptor);
|
||||
env->SetGeneratorPrototype(thread_, generatorFuncPrototype);
|
||||
JSObject::SetPrototype(thread_, generatorFuncPrototype, env->GetIteratorPrototype());
|
||||
env->SetGeneratorPrototype(thread_, generatorPrototype);
|
||||
JSObject::SetPrototype(thread_, generatorPrototype, env->GetIteratorPrototype());
|
||||
|
||||
// Generator {}
|
||||
JSHandle<JSObject> initialGeneratorFuncPrototype = factory_->NewJSObjectWithInit(objFuncClass);
|
||||
JSObject::SetPrototype(thread_, initialGeneratorFuncPrototype, JSHandle<JSTaggedValue>(generatorFuncPrototype));
|
||||
JSObject::SetPrototype(thread_, initialGeneratorFuncPrototype, JSHandle<JSTaggedValue>(generatorPrototype));
|
||||
env->SetInitialGenerator(thread_, initialGeneratorFuncPrototype);
|
||||
}
|
||||
|
||||
|
@ -100,7 +100,6 @@ void ProfileTypeAccessor::AddHandlerWithKey(JSHandle<JSTaggedValue> key, JSHandl
|
||||
ASSERT(!profileData.IsHole());
|
||||
auto index = slotId_;
|
||||
if (profileData.IsUndefined()) {
|
||||
ASSERT(profileTypeInfo_->Get(index + 1).IsUndefined());
|
||||
profileTypeInfo_->Set(thread_, index, key.GetTaggedValue());
|
||||
const int arrayLength = 2;
|
||||
JSHandle<TaggedArray> newArr = thread_->GetEcmaVM()->GetFactory()->NewTaggedArray(arrayLength);
|
||||
|
@ -18,3 +18,6 @@
|
||||
2 false
|
||||
undefined true
|
||||
undefined true
|
||||
[object GeneratorFunction]
|
||||
function Function() { [native code] }
|
||||
constructor,next,return,throw
|
||||
|
@ -47,4 +47,17 @@ print(b.value, b.done)
|
||||
var c = p.next()
|
||||
print(c.value, c.done)
|
||||
var d = p.next()
|
||||
print(d.value, d.done)
|
||||
print(d.value, d.done)
|
||||
|
||||
function* g1() { yield 1; }
|
||||
var iter = g1();
|
||||
var gf = iter.__proto__.constructor;
|
||||
print(Object.prototype.toString.call(gf));
|
||||
|
||||
var GeneratorFunctionPrototype = Object.getPrototypeOf(g1);
|
||||
var GeneratorFunction = GeneratorFunctionPrototype.constructor;
|
||||
var GeneratorObjectPrototype = GeneratorFunctionPrototype.prototype;
|
||||
print(Object.getPrototypeOf(GeneratorFunction));
|
||||
var found_property_names = Object.getOwnPropertyNames(GeneratorObjectPrototype);
|
||||
found_property_names.sort();
|
||||
print(found_property_names);
|
Loading…
Reference in New Issue
Block a user