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
5 changes: 5 additions & 0 deletions crates/oxc_ast/src/ast/literal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,3 +195,8 @@ bitflags! {
const V = 1 << 7;
}
}

/// Dummy type to communicate the content of `RegExpFlags` to `oxc_ast_tools`.
#[ast(foreign = RegExpFlags)]
#[expect(dead_code)]
struct RegExpFlagsAlias(u8);
12 changes: 6 additions & 6 deletions crates/oxc_ast/src/generated/assert_layouts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -791,6 +791,9 @@ const _: () = {
assert!(size_of::<RegExpPattern>() == 24);
assert!(align_of::<RegExpPattern>() == 8);

assert!(size_of::<RegExpFlags>() == 1);
assert!(align_of::<RegExpFlags>() == 1);

assert!(size_of::<JSXElement>() == 56);
assert!(align_of::<JSXElement>() == 8);
assert!(offset_of!(JSXElement, span) == 0);
Expand Down Expand Up @@ -1583,9 +1586,6 @@ const _: () = {
assert!(align_of::<NamedReference>() == 8);
assert!(offset_of!(NamedReference, span) == 0);
assert!(offset_of!(NamedReference, name) == 8);

assert!(size_of::<RegExpFlags>() == 1);
assert!(align_of::<RegExpFlags>() == 1);
};

#[cfg(target_pointer_width = "32")]
Expand Down Expand Up @@ -2369,6 +2369,9 @@ const _: () = {
assert!(size_of::<RegExpPattern>() == 12);
assert!(align_of::<RegExpPattern>() == 4);

assert!(size_of::<RegExpFlags>() == 1);
assert!(align_of::<RegExpFlags>() == 1);

assert!(size_of::<JSXElement>() == 32);
assert!(align_of::<JSXElement>() == 4);
assert!(offset_of!(JSXElement, span) == 0);
Expand Down Expand Up @@ -3161,9 +3164,6 @@ const _: () = {
assert!(align_of::<NamedReference>() == 4);
assert!(offset_of!(NamedReference, span) == 0);
assert!(offset_of!(NamedReference, name) == 8);

assert!(size_of::<RegExpFlags>() == 1);
assert!(align_of::<RegExpFlags>() == 1);
};

#[cfg(not(any(target_pointer_width = "64", target_pointer_width = "32")))]
Expand Down
28 changes: 0 additions & 28 deletions tasks/ast_tools/src/parse/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,22 +138,6 @@ impl<'c> Parser<'c> {
// TODO: Remove the need for this by adding
// `#[cfg_attr(target_pointer_width = "64", repr(align(8)))]` to all AST types
"PointerAlign" => primitive("PointerAlign"),
// Cannot be parsed normally as is defined inside `bitflags!` macro.
// TODO: Find a way to encode this in the actual file.
// e.g. `#[ast(alias_for(RegExpFlags))] struct RegExpFlagsAlias(u8);`
"RegExpFlags" => TypeDef::Struct(StructDef::new(
TypeId::DUMMY,
"RegExpFlags".to_string(),
false,
self.get_file_id("oxc_ast", "::ast::literal"),
Derives::none(),
vec![FieldDef::new(
"inner".to_string(),
self.type_id("u8"),
Visibility::Private,
None,
)],
)),
_ => panic!("Unknown type: {name}"),
};
self.create_new_type(type_def)
Expand Down Expand Up @@ -186,18 +170,6 @@ impl<'c> Parser<'c> {
type_id
}

/// Get [`FileId`] for file with provided crate and import path.
fn get_file_id(&self, krate: &str, import_path: &str) -> FileId {
let file_and_id = self
.files
.iter_enumerated()
.find(|(_, file)| file.krate() == krate && file.import_path() == import_path);
match file_and_id {
Some((file_id, _)) => file_id,
None => panic!("Could not find file with import path: {import_path}"),
}
}

/// Parse [`Skeleton`] to yield a [`TypeDef`].
fn parse_type(&mut self, type_id: TypeId, skeleton: Skeleton) -> TypeDef {
match skeleton {
Expand Down
Loading