Skip to content

Commit ea30a17

Browse files
author
Cameron McHenry
committed
feat(ast): compute max value that can be mapped to AstType
1 parent 242e721 commit ea30a17

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

crates/oxc_ast/src/generated/ast_kind.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,9 @@ pub enum AstType {
203203
JSDocUnknownType = 186,
204204
}
205205

206+
/// The largest integer value that can be mapped to an `AstType`/`AstKind` enum variant.
207+
pub const AST_TYPE_MAX: u16 = 187;
208+
206209
/// Untyped AST Node Kind
207210
#[derive(Debug, Clone, Copy)]
208211
#[repr(C, u8)]

tasks/ast_tools/src/generators/ast_kind.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,8 @@ impl Generator for AstKindGenerator {
132132
next_index += 1;
133133
}
134134

135+
let ast_type_max = number_lit(next_index);
136+
135137
let output = quote! {
136138
#![expect(missing_docs)] ///@ FIXME (in ast_tools/src/generators/ast_kind.rs)
137139
@@ -152,6 +154,10 @@ impl Generator for AstKindGenerator {
152154
#type_variants
153155
}
154156

157+
///@@line_break
158+
/// The largest integer value that can be mapped to an `AstType`/`AstKind` enum variant.
159+
pub const AST_TYPE_MAX: u16 = #ast_type_max;
160+
155161
///@@line_break
156162
/// Untyped AST Node Kind
157163
#[derive(Debug, Clone, Copy)]

0 commit comments

Comments
 (0)