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 18, 2022
1 parent e303b8b commit af87126
Show file tree
Hide file tree
Showing 45 changed files with 1,946 additions and 558 deletions.
9 changes: 9 additions & 0 deletions boa/src/builtins/function/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,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,6 +196,7 @@ impl Function {
match self {
Self::Native { constructor, .. } | Self::Closure { constructor, .. } => *constructor,
Self::VmOrdinary { code, .. } => code.constructor,
Self::VmGenerator { code, .. } => code.constructor,
}
}
}
Expand Down Expand Up @@ -458,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 af87126

Please sign in to comment.