Skip to content

Commit

Permalink
Merge 486ca8e into 9dda8d3
Browse files Browse the repository at this point in the history
  • Loading branch information
raskad authored Feb 23, 2022
2 parents 9dda8d3 + 486ca8e commit 16a33ca
Show file tree
Hide file tree
Showing 47 changed files with 2,313 additions and 936 deletions.
6 changes: 3 additions & 3 deletions boa_engine/src/builtins/function/arguments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::{
object::{JsObject, ObjectData},
property::PropertyDescriptor,
symbol::{self, WellKnownSymbols},
syntax::ast::node::FormalParameter,
syntax::ast::node::FormalParameterList,
Context, JsValue,
};
use boa_gc::{Finalize, Gc, Trace};
Expand Down Expand Up @@ -147,7 +147,7 @@ impl Arguments {
/// <https://tc39.es/ecma262/#sec-createmappedargumentsobject>
pub(crate) fn create_mapped_arguments_object(
func: &JsObject,
formals: &[FormalParameter],
formals: &FormalParameterList,
arguments_list: &[JsValue],
env: &Gc<DeclarativeEnvironment>,
context: &mut Context,
Expand Down Expand Up @@ -199,7 +199,7 @@ impl Arguments {

let mut bindings = FxHashMap::default();
let mut property_index = 0;
'outer: for formal in formals {
'outer: for formal in formals.parameters.iter() {
for name in formal.names() {
if property_index >= len {
break 'outer;
Expand Down
18 changes: 13 additions & 5 deletions boa_engine/src/builtins/function/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,11 @@ pub enum Function {
constructor: bool,
captures: Captures,
},
VmOrdinary {
Ordinary {
code: Gc<crate::vm::CodeBlock>,
environments: DeclarativeEnvironmentStack,
},
Generator {
code: Gc<crate::vm::CodeBlock>,
environments: DeclarativeEnvironmentStack,
},
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::Ordinary { code, .. } | Self::Generator { code, .. } => code.constructor,
}
}
}
Expand Down Expand Up @@ -454,11 +458,15 @@ impl BuiltInFunctionObject {
},
Some(name),
) => Ok(format!("function {name}() {{\n [native Code]\n}}").into()),
(Function::VmOrdinary { .. }, Some(name)) if name.is_empty() => {
(Function::Ordinary { .. }, Some(name)) if name.is_empty() => {
Ok("[Function (anonymous)]".into())
}
(Function::VmOrdinary { .. }, Some(name)) => Ok(format!("[Function: {name}]").into()),
(Function::VmOrdinary { .. }, None) => Ok("[Function (anonymous)]".into()),
(Function::Ordinary { .. }, Some(name)) => Ok(format!("[Function: {name}]").into()),
(Function::Ordinary { .. }, None) => Ok("[Function (anonymous)]".into()),
(Function::Generator { .. }, Some(name)) => {
Ok(format!("[Function*: {}]", &name).into())
}
(Function::Generator { .. }, None) => Ok("[Function* (anonymous)]".into()),
_ => Ok("TODO".into()),
}
}
Expand Down
Loading

0 comments on commit 16a33ca

Please sign in to comment.