mirror of
https://github.com/pjh456/OxideJS.git
synced 2026-10-24 10:41:11 +08:00
feat: async-generator 语义(async function*),yield/await 共存 + next 返回 Promise
- emit 识别 generator+async 组合,模块同时标记 is_generator/is_async - 新增 AsyncGeneratorState:帧快照 + 请求队列 + 当前请求 - next/return/throw 返回 Promise,请求入队逐条处理 - YIELD 让出经 promise unwrap 后交付(yield rejected promise 关闭生成器) - AWAIT 挂起保留当前请求,微任务恢复后继续执行 - %AsyncGeneratorPrototype% / %AsyncGeneratorFunction.prototype% 内建 - session GC / promote 支持异步生成器状态盒 - 普通 async 函数嵌套调用隔离外层异步生成器上下文
This commit is contained in:
@@ -35,6 +35,16 @@ impl Vm {
|
||||
let args: Vec<JsValue> = (0..arg_count)
|
||||
.map(|i| self.regs[first_arg_reg.wrapping_add(i as u8) as usize])
|
||||
.collect();
|
||||
// 异步生成器函数调用返回异步生成器迭代器对象。
|
||||
if sub_idx < self.sub_modules.len()
|
||||
&& self.sub_modules[sub_idx].is_generator
|
||||
&& self.sub_modules[sub_idx].is_async
|
||||
{
|
||||
let gen =
|
||||
self.create_async_generator_object(callee, self.regs[this_reg as usize], &args)?;
|
||||
self.regs[0] = gen;
|
||||
return Ok(false);
|
||||
}
|
||||
// 生成器函数调用返回迭代器对象,不执行函数体。
|
||||
if sub_idx < self.sub_modules.len() && self.sub_modules[sub_idx].is_generator {
|
||||
let gen = self.create_generator_object(callee, self.regs[this_reg as usize], &args)?;
|
||||
|
||||
Reference in New Issue
Block a user