Skip to content
Merged
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
34 changes: 13 additions & 21 deletions crates/oxc_codegen/src/gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -433,10 +433,8 @@ impl Gen for ForOfStatement<'_> {
impl Gen for ForStatementInit<'_> {
fn gen(&self, p: &mut Codegen, ctx: Context) {
match self {
match_expression!(ForStatementInit) => {
self.to_expression().print_expr(p, Precedence::Lowest, ctx);
}
Self::VariableDeclaration(var) => var.print(p, ctx),
_ => self.to_expression().print_expr(p, Precedence::Lowest, ctx),
}
}
}
Expand Down Expand Up @@ -1159,11 +1157,6 @@ impl Gen for ExportDefaultDeclaration<'_> {
impl Gen for ExportDefaultDeclarationKind<'_> {
fn gen(&self, p: &mut Codegen, ctx: Context) {
match self {
match_expression!(Self) => {
p.start_of_default_export = p.code_len();
self.to_expression().print_expr(p, Precedence::Comma, Context::empty());
p.print_semicolon_after_statement();
}
Self::FunctionDeclaration(fun) => {
fun.print(p, ctx);
p.print_soft_newline();
Expand All @@ -1173,6 +1166,11 @@ impl Gen for ExportDefaultDeclarationKind<'_> {
p.print_soft_newline();
}
Self::TSInterfaceDeclaration(interface) => interface.print(p, ctx),
_ => {
p.start_of_default_export = p.code_len();
self.to_expression().print_expr(p, Precedence::Comma, Context::empty());
p.print_semicolon_after_statement();
}
}
}
}
Expand Down Expand Up @@ -1472,21 +1470,17 @@ impl Gen for Argument<'_> {
fn gen(&self, p: &mut Codegen, ctx: Context) {
match self {
Self::SpreadElement(elem) => elem.print(p, ctx),
match_expression!(Self) => {
self.to_expression().print_expr(p, Precedence::Comma, Context::empty());
}
_ => self.to_expression().print_expr(p, Precedence::Comma, Context::empty()),
}
}
}

impl Gen for ArrayExpressionElement<'_> {
fn gen(&self, p: &mut Codegen, ctx: Context) {
match self {
match_expression!(Self) => {
self.to_expression().print_expr(p, Precedence::Comma, Context::empty());
}
Self::SpreadElement(elem) => elem.print(p, ctx),
Self::Elision(_span) => {}
_ => self.to_expression().print_expr(p, Precedence::Comma, Context::empty()),
}
}
}
Expand Down Expand Up @@ -1675,9 +1669,7 @@ impl Gen for PropertyKey<'_> {
Self::StringLiteral(s) => {
p.print_quoted_utf16(s.value.as_str(), /* allow_backtick */ false);
}
match_expression!(Self) => {
self.to_expression().print_expr(p, Precedence::Comma, Context::empty());
}
_ => self.to_expression().print_expr(p, Precedence::Comma, Context::empty()),
}
}
}
Expand Down Expand Up @@ -2042,7 +2034,7 @@ impl Gen for AssignmentTargetPropertyProperty<'_> {
PropertyKey::PrivateIdentifier(ident) => {
ident.print(p, ctx);
}
key @ match_expression!(PropertyKey) => {
key => {
if self.computed {
p.print_ascii_byte(b'[');
}
Expand Down Expand Up @@ -2451,8 +2443,8 @@ impl Gen for JSXEmptyExpression {
impl Gen for JSXExpression<'_> {
fn gen(&self, p: &mut Codegen, ctx: Context) {
match self {
match_expression!(Self) => p.print_expression(self.to_expression()),
Self::EmptyExpression(expr) => expr.print(p, ctx),
_ => p.print_expression(self.to_expression()),
}
}
}
Expand Down Expand Up @@ -3408,7 +3400,7 @@ impl Gen for TSSignature<'_> {
PropertyKey::PrivateIdentifier(key) => {
p.print_str(key.name.as_str());
}
key @ match_expression!(PropertyKey) => {
key => {
key.to_expression().print_expr(p, Precedence::Comma, ctx);
}
}
Expand Down Expand Up @@ -3474,7 +3466,7 @@ impl Gen for TSSignature<'_> {
PropertyKey::PrivateIdentifier(key) => {
p.print_str(key.name.as_str());
}
key @ match_expression!(PropertyKey) => {
key => {
key.to_expression().print_expr(p, Precedence::Comma, ctx);
}
}
Expand Down