Skip to content

Commit

Permalink
u
Browse files Browse the repository at this point in the history
  • Loading branch information
Boshen committed Oct 18, 2024
1 parent 67ce02b commit dcd0279
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 39 deletions.
73 changes: 35 additions & 38 deletions crates/oxc_codegen/src/gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -846,46 +846,43 @@ impl<'a> Gen for ExportNamedDeclaration<'a> {
if self.export_kind.is_type() {
p.print_str("type ");
}
match &self.declaration {
Some(decl) => {
match decl {
Declaration::VariableDeclaration(decl) => decl.print(p, ctx),
Declaration::FunctionDeclaration(decl) => decl.print(p, ctx),
Declaration::ClassDeclaration(decl) => decl.print(p, ctx),
Declaration::TSModuleDeclaration(decl) => decl.print(p, ctx),
Declaration::TSTypeAliasDeclaration(decl) => decl.print(p, ctx),
Declaration::TSInterfaceDeclaration(decl) => decl.print(p, ctx),
Declaration::TSEnumDeclaration(decl) => decl.print(p, ctx),
Declaration::TSImportEqualsDeclaration(decl) => decl.print(p, ctx),
}
if matches!(
decl,
Declaration::VariableDeclaration(_)
| Declaration::TSTypeAliasDeclaration(_)
| Declaration::TSImportEqualsDeclaration(_)
) {
p.print_semicolon_after_statement();
} else {
p.print_soft_newline();
p.needs_semicolon = false;
}
}
None => {
p.print_ascii_byte(b'{');
if !self.specifiers.is_empty() {
p.print_soft_space();
p.print_list(&self.specifiers, ctx);
p.print_soft_space();
}
p.print_ascii_byte(b'}');
if let Some(source) = &self.source {
p.print_soft_space();
p.print_str("from");
p.print_soft_space();
source.print(p, ctx);
}
if let Some(decl) = &self.declaration {
match decl {
Declaration::VariableDeclaration(decl) => decl.print(p, ctx),
Declaration::FunctionDeclaration(decl) => decl.print(p, ctx),
Declaration::ClassDeclaration(decl) => decl.print(p, ctx),
Declaration::TSModuleDeclaration(decl) => decl.print(p, ctx),
Declaration::TSTypeAliasDeclaration(decl) => decl.print(p, ctx),
Declaration::TSInterfaceDeclaration(decl) => decl.print(p, ctx),
Declaration::TSEnumDeclaration(decl) => decl.print(p, ctx),
Declaration::TSImportEqualsDeclaration(decl) => decl.print(p, ctx),
}
if matches!(
decl,
Declaration::VariableDeclaration(_)
| Declaration::TSTypeAliasDeclaration(_)
| Declaration::TSImportEqualsDeclaration(_)
) {
p.print_semicolon_after_statement();
} else {
p.print_soft_newline();
p.needs_semicolon = false;
}
} else {
p.print_ascii_byte(b'{');
if !self.specifiers.is_empty() {
p.print_soft_space();
p.print_list(&self.specifiers, ctx);
p.print_soft_space();
}
p.print_ascii_byte(b'}');
if let Some(source) = &self.source {
p.print_soft_space();
p.print_str("from");
p.print_soft_space();
source.print(p, ctx);
}
p.print_semicolon_after_statement();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ impl<'a, 'b> PeepholeFoldConstants {
| (ValueType::Boolean, ValueType::Boolean) => {
let left_number = ctx.get_number_value(left)?;
let right_number = ctx.get_number_value(right)?;
let Ok(value) = TryInto::<f64>::try_into(left_number + right_number) else { return None };
let value = left_number + right_number;
// Float if value has a fractional part, otherwise Decimal
let number_base = if is_exact_int64(value) { NumberBase::Decimal } else { NumberBase::Float };
// todo: add raw &str
Expand Down
1 change: 1 addition & 0 deletions tasks/ast_tools/src/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ impl Layout {
/// Returns the max valid number in a primitive with the size of `n` bytes.
/// Panics
/// For `n` bigger than `16`, Or if it's not a power of 2 number
#[expect(clippy::cast_lossless)]
fn max_val_of_bytes(n: usize) -> u128 {
match n {
1 => u8::MAX as u128,
Expand Down
1 change: 1 addition & 0 deletions tasks/ast_tools/src/schema/defs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use crate::{
TypeId,
};

#[expect(clippy::large_enum_variant)]
#[derive(Debug, Serialize)]
#[serde(untagged)]
pub enum TypeDef {
Expand Down

0 comments on commit dcd0279

Please sign in to comment.