Skip to content

Commit

Permalink
Implement generator execution
Browse files Browse the repository at this point in the history
  • Loading branch information
raskad committed Feb 22, 2022
1 parent 2c6aceb commit 369d23e
Show file tree
Hide file tree
Showing 45 changed files with 1,913 additions and 541 deletions.
10 changes: 9 additions & 1 deletion boa_engine/src/builtins/function/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,10 @@ pub enum Function {
code: Gc<crate::vm::CodeBlock>,
environments: DeclarativeEnvironmentStack,
},
VmGenerator {
code: Gc<crate::vm::CodeBlock>,
environments: DeclarativeEnvironmentStack,
},
}

impl fmt::Debug for Function {
Expand All @@ -192,7 +196,7 @@ impl Function {
pub fn is_constructor(&self) -> bool {
match self {
Self::Native { constructor, .. } | Self::Closure { constructor, .. } => *constructor,
Self::VmOrdinary { code, .. } => code.constructor,
Self::VmOrdinary { code, .. } | Self::VmGenerator { code, .. } => code.constructor,
}
}
}
Expand Down Expand Up @@ -459,6 +463,10 @@ impl BuiltInFunctionObject {
}
(Function::VmOrdinary { .. }, Some(name)) => Ok(format!("[Function: {name}]").into()),
(Function::VmOrdinary { .. }, None) => Ok("[Function (anonymous)]".into()),
(Function::VmGenerator { .. }, Some(name)) => {
Ok(format!("[Function*: {}]", &name).into())
}
(Function::VmGenerator { .. }, None) => Ok("[Function* (anonymous)]".into()),
_ => Ok("TODO".into()),
}
}
Expand Down
Loading

0 comments on commit 369d23e

Please sign in to comment.