File tree Expand file tree Collapse file tree 2 files changed +9
-0
lines changed
crates/oxc_ast/src/generated
tasks/ast_tools/src/generators Expand file tree Collapse file tree 2 files changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -203,6 +203,9 @@ pub enum AstType {
203
203
JSDocUnknownType = 186 ,
204
204
}
205
205
206
+ /// The largest `usize` value that can be mapped to an `AstType`.
207
+ pub const AST_TYPE_MAX : usize = 186usize ;
208
+
206
209
/// Untyped AST Node Kind
207
210
#[ derive( Debug , Clone , Copy ) ]
208
211
#[ repr( C , u8 ) ]
Original file line number Diff line number Diff line change @@ -87,6 +87,7 @@ impl Generator for AstKindGenerator {
87
87
let mut span_match_arms = quote ! ( ) ;
88
88
let mut address_match_arms = quote ! ( ) ;
89
89
let mut as_methods = quote ! ( ) ;
90
+ let mut ast_type_max_usize: usize = 0 ;
90
91
91
92
let mut next_index = 0u16 ;
92
93
for type_def in & schema. types {
@@ -104,6 +105,7 @@ impl Generator for AstKindGenerator {
104
105
105
106
assert ! ( u8 :: try_from( next_index) . is_ok( ) ) ;
106
107
let index = number_lit ( next_index) ;
108
+ ast_type_max_usize = next_index as usize ;
107
109
type_variants. extend ( quote ! ( #type_ident = #index, ) ) ;
108
110
kind_variants. extend ( quote ! ( #type_ident( & ' a #type_ty) = AstType :: #type_ident as u8 , ) ) ;
109
111
@@ -152,6 +154,10 @@ impl Generator for AstKindGenerator {
152
154
#type_variants
153
155
}
154
156
157
+ ///@@line_break
158
+ /// The largest `usize` value that can be mapped to an `AstType`.
159
+ pub const AST_TYPE_MAX : usize = #ast_type_max_usize;
160
+
155
161
///@@line_break
156
162
/// Untyped AST Node Kind
157
163
#[ derive( Debug , Clone , Copy ) ]
You can’t perform that action at this time.
0 commit comments