Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
428 changes: 268 additions & 160 deletions Cargo.lock

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,18 @@ tag_ptr = { path = "utils/tag_ptr" }
# Shared deps
arbitrary = "1"
bitflags = "2.9.0"
clap = "4.5.32"
clap = "4.5.35"
colored = "3.0.0"
cow-utils = "0.1.3"
fast-float2 = "0.2.3"
hashbrown = "0.15.2"
indexmap = { version = "2.8.0", default-features = false }
indexmap = { version = "2.9.0", default-features = false }
indoc = "2.0.6"
itoa = "1.0.15"
jemallocator = "0.5.4"
num-bigint = "0.4.6"
num-traits = "0.2.19"
once_cell = { version = "1.21.1", default-features = false }
once_cell = { version = "1.21.3", default-features = false }
phf = { version = "0.11.2", default-features = false }
pollster = "0.4.0"
regex = "1.11.1"
Expand All @@ -81,7 +81,7 @@ time = { version = "0.3.41", default-features = false, features = [
"formatting",
"macros",
] }
log = "0.4.26"
log = "0.4.27"
simple_logger = "5.0.0"
cargo_metadata = "0.19.2"
trybuild = "1.0.104"
Expand Down Expand Up @@ -129,7 +129,7 @@ float-cmp = "0.10.0"
futures-lite = "2.6.0"
test-case = "3.3.1"
url = "2.5.4"
tokio = { version = "1.44.1", default-features = false }
tokio = { version = "1.44.2", default-features = false }
futures-concurrency = "7.6.3"


Expand Down
2 changes: 1 addition & 1 deletion cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ fn main() -> Result<()> {
}
if let Err(err) = context.run_jobs() {
eprintln!("{err}");
};
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions core/ast/src/declaration/variable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::{
Statement,
};
use boa_interner::{Interner, ToInternedString};
use core::{convert::TryFrom, ops::ControlFlow};
use core::{convert::TryFrom, fmt::Write as _, ops::ControlFlow};

/// A [`var`][var] statement, also called [`VariableStatement`][varstmt] in the spec.
///
Expand Down Expand Up @@ -263,7 +263,7 @@ impl ToInternedString for Variable {
let mut buf = self.binding.to_interned_string(interner);

if let Some(ref init) = self.init {
buf.push_str(&format!(" = {}", init.to_interned_string(interner)));
let _ = write!(buf, " = {}", init.to_interned_string(interner));
}
buf
}
Expand Down
34 changes: 21 additions & 13 deletions core/ast/src/expression/literal/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use crate::{
LinearPosition, LinearSpan, LinearSpanIgnoreEq,
};
use boa_interner::{Interner, Sym, ToIndentedString, ToInternedString};
use core::ops::ControlFlow;
use core::{fmt::Write as _, ops::ControlFlow};

/// Objects in ECMAScript may be defined as an unordered collection of related data, of
/// primitive or reference types, in the form of “key: value” pairs.
Expand Down Expand Up @@ -212,31 +212,39 @@ impl ToIndentedString for ObjectLiteral {
let mut buf = "{\n".to_owned();
let indentation = " ".repeat(indent_n + 1);
for property in &*self.properties {
buf.push_str(&match property {
match property {
PropertyDefinition::IdentifierReference(ident) => {
format!("{indentation}{},\n", interner.resolve_expect(ident.sym()))
let _ = writeln!(
buf,
"{indentation}{},",
interner.resolve_expect(ident.sym())
);
}
PropertyDefinition::Property(key, value) => {
format!(
"{indentation}{}: {},\n",
let _ = writeln!(
buf,
"{indentation}{}: {},",
key.to_interned_string(interner),
value.to_no_indent_string(interner, indent_n + 1)
)
);
}
PropertyDefinition::SpreadObject(key) => {
format!("{indentation}...{},\n", key.to_interned_string(interner))
let _ = writeln!(buf, "{indentation}...{},", key.to_interned_string(interner));
}
PropertyDefinition::MethodDefinition(m) => {
buf.push_str(&m.to_indented_string(interner, indent_n));
}
PropertyDefinition::MethodDefinition(m) => m.to_indented_string(interner, indent_n),
PropertyDefinition::CoverInitializedName(ident, expr) => {
format!(
"{indentation}{} = {},\n",
let _ = writeln!(
buf,
"{indentation}{} = {},",
interner.resolve_expect(ident.sym()),
expr.to_no_indent_string(interner, indent_n + 1)
)
);
}
});
}
}
buf.push_str(&format!("{}}}", " ".repeat(indent_n)));
let _ = write!(buf, "{}}}", " ".repeat(indent_n));

buf
}
Expand Down
6 changes: 3 additions & 3 deletions core/ast/src/expression/literal/template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::{
visitor::{VisitWith, Visitor, VisitorMut},
};
use boa_interner::{Interner, Sym, ToInternedString};
use core::ops::ControlFlow;
use core::{fmt::Write as _, ops::ControlFlow};

/// Template literals are string literals allowing embedded expressions.
///
Expand Down Expand Up @@ -88,10 +88,10 @@ impl ToInternedString for TemplateLiteral {
for elt in &self.elements {
match elt {
TemplateElement::String(s) => {
buf.push_str(&format!("{}", interner.resolve_expect(*s)));
let _ = write!(buf, "{}", interner.resolve_expect(*s));
}
TemplateElement::Expr(n) => {
buf.push_str(&format!("${{{}}}", n.to_interned_string(interner)));
let _ = write!(buf, "${{{}}}", n.to_interned_string(interner));
}
}
}
Expand Down
18 changes: 11 additions & 7 deletions core/ast/src/expression/optional.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::{
visitor::{VisitWith, Visitor, VisitorMut},
};
use boa_interner::{Interner, ToInternedString};
use core::ops::ControlFlow;
use core::{fmt::Write as _, ops::ControlFlow};

/// List of valid operations in an [`Optional`] chain.
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
Expand Down Expand Up @@ -118,18 +118,22 @@ impl ToInternedString for OptionalOperation {

String::new()
};
buf.push_str(&match &self.kind {
match &self.kind {
OptionalOperationKind::SimplePropertyAccess { field } => match field {
PropertyAccessField::Const(name) => interner.resolve_expect(*name).to_string(),
PropertyAccessField::Const(name) => {
buf.push_str(&interner.resolve_expect(*name).to_string());
}
PropertyAccessField::Expr(expr) => {
format!("[{}]", expr.to_interned_string(interner))
let _ = write!(buf, "[{}]", expr.to_interned_string(interner));
}
},
OptionalOperationKind::PrivatePropertyAccess { field } => {
format!("#{}", interner.resolve_expect(field.description()))
let _ = write!(buf, "#{}", interner.resolve_expect(field.description()));
}
OptionalOperationKind::Call { args } => {
let _ = write!(buf, "({})", join_nodes(interner, args));
}
OptionalOperationKind::Call { args } => format!("({})", join_nodes(interner, args)),
});
}
buf
}
}
Expand Down
12 changes: 5 additions & 7 deletions core/ast/src/expression/tagged_template.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
use boa_interner::{Interner, Sym, ToInternedString};
use core::ops::ControlFlow;

use crate::visitor::{VisitWith, Visitor, VisitorMut};

use super::Expression;
use crate::visitor::{VisitWith, Visitor, VisitorMut};
use boa_interner::{Interner, Sym, ToInternedString};
use core::{fmt::Write as _, ops::ControlFlow};

/// A [`TaggedTemplate`][moz] expression, as defined by the [spec].
///
Expand Down Expand Up @@ -87,9 +85,9 @@ impl ToInternedString for TaggedTemplate {
let mut exprs = self.exprs.iter();

for raw in &self.raws {
buf.push_str(&format!("{}", interner.resolve_expect(*raw)));
let _ = write!(buf, "{}", interner.resolve_expect(*raw));
if let Some(expr) = exprs.next() {
buf.push_str(&format!("${{{}}}", expr.to_interned_string(interner)));
let _ = write!(buf, "${{{}}}", expr.to_interned_string(interner));
}
}
buf.push('`');
Expand Down
10 changes: 5 additions & 5 deletions core/ast/src/function/arrow_function.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use super::{FormalParameterList, FunctionBody};
use crate::operations::{contains, ContainsSymbol};
use crate::scope::FunctionScopes;
use crate::visitor::{VisitWith, Visitor, VisitorMut};
Expand All @@ -7,9 +8,7 @@ use crate::{
};
use crate::{LinearSpan, LinearSpanIgnoreEq};
use boa_interner::{Interner, ToIndentedString};
use core::ops::ControlFlow;

use super::{FormalParameterList, FunctionBody};
use core::{fmt::Write as _, ops::ControlFlow};

/// An arrow function expression, as defined by the [spec].
///
Expand Down Expand Up @@ -111,11 +110,12 @@ impl ToIndentedString for ArrowFunction {
if self.body().statements().is_empty() {
buf.push_str(") => {}");
} else {
buf.push_str(&format!(
let _ = write!(
buf,
") => {{\n{}{}}}",
self.body.to_indented_string(interner, indentation + 1),
" ".repeat(indentation)
));
);
}
buf
}
Expand Down
8 changes: 4 additions & 4 deletions core/ast/src/function/async_arrow_function.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use std::ops::ControlFlow;

use super::{FormalParameterList, FunctionBody};
use crate::operations::{contains, ContainsSymbol};
use crate::scope::FunctionScopes;
Expand All @@ -10,6 +8,7 @@ use crate::{
};
use crate::{LinearSpan, LinearSpanIgnoreEq};
use boa_interner::{Interner, ToIndentedString};
use core::{fmt::Write as _, ops::ControlFlow};

/// An async arrow function expression, as defined by the [spec].
///
Expand Down Expand Up @@ -111,11 +110,12 @@ impl ToIndentedString for AsyncArrowFunction {
if self.body().statements().is_empty() {
buf.push_str(") => {}");
} else {
buf.push_str(&format!(
let _ = write!(
buf,
") => {{\n{}{}}}",
self.body.to_indented_string(interner, indentation + 1),
" ".repeat(indentation)
));
);
}
buf
}
Expand Down
14 changes: 6 additions & 8 deletions core/ast/src/function/async_function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use crate::{
Declaration, LinearSpan, LinearSpanIgnoreEq,
};
use boa_interner::{Interner, ToIndentedString};
use core::ops::ControlFlow;
use core::{fmt::Write as _, ops::ControlFlow};

/// An async function declaration.
///
Expand Down Expand Up @@ -251,21 +251,19 @@ impl ToIndentedString for AsyncFunctionExpression {
let mut buf = "async function".to_owned();
if self.has_binding_identifier {
if let Some(name) = self.name {
buf.push_str(&format!(" {}", interner.resolve_expect(name.sym())));
let _ = write!(buf, " {}", interner.resolve_expect(name.sym()));
}
}
buf.push_str(&format!(
"({}",
join_nodes(interner, self.parameters.as_ref())
));
let _ = write!(buf, "({}", join_nodes(interner, self.parameters.as_ref()));
if self.body().statements().is_empty() {
buf.push_str(") {}");
} else {
buf.push_str(&format!(
let _ = write!(
buf,
") {{\n{}{}}}",
self.body.to_indented_string(interner, indentation + 1),
" ".repeat(indentation)
));
);
}
buf
}
Expand Down
13 changes: 7 additions & 6 deletions core/ast/src/function/async_generator.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
//! Async Generator Expression

use super::{FormalParameterList, FunctionBody};
use crate::operations::{contains, ContainsSymbol};
use crate::scope::{FunctionScopes, Scope};
use crate::visitor::{VisitWith, Visitor, VisitorMut};
Expand All @@ -9,9 +11,7 @@ use crate::{
};
use crate::{LinearSpan, LinearSpanIgnoreEq};
use boa_interner::{Interner, ToIndentedString};
use core::ops::ControlFlow;

use super::{FormalParameterList, FunctionBody};
use core::{fmt::Write as _, ops::ControlFlow};

/// An async generator declaration.
///
Expand Down Expand Up @@ -251,14 +251,15 @@ impl ToIndentedString for AsyncGeneratorExpression {
let mut buf = "async function*".to_owned();
if self.has_binding_identifier {
if let Some(name) = self.name {
buf.push_str(&format!(" {}", interner.resolve_expect(name.sym())));
let _ = write!(buf, " {}", interner.resolve_expect(name.sym()));
}
}
buf.push_str(&format!(
let _ = write!(
buf,
"({}) {}",
join_nodes(interner, self.parameters.as_ref()),
block_to_string(&self.body.statements, interner, indentation)
));
);

buf
}
Expand Down
Loading
Loading