From 0c52c0db021afbbba22cee462868dc55fd7f5e0a Mon Sep 17 00:00:00 2001 From: rzvxa <3788964+rzvxa@users.noreply.github.com> Date: Sat, 3 Aug 2024 12:43:10 +0000 Subject: [PATCH] feat(ast_codegen): add alignment and size data to the schema. (#4615) This PR generates the layouts in the schema but doesn't use it to reorder. --- .../oxc_ast/src/generated/assert_layouts.rs | 2249 +++++++++++++++++ crates/oxc_ast/src/lib.rs | 2 + tasks/ast_codegen/src/defs.rs | 61 +- .../src/generators/assert_layouts.rs | 118 + tasks/ast_codegen/src/generators/mod.rs | 2 + tasks/ast_codegen/src/layout.rs | 181 ++ tasks/ast_codegen/src/main.rs | 10 +- tasks/ast_codegen/src/passes/calc_layout.rs | 370 +++ tasks/ast_codegen/src/passes/mod.rs | 2 + tasks/ast_codegen/src/schema.rs | 43 +- tasks/ast_codegen/src/util.rs | 9 +- 11 files changed, 3038 insertions(+), 9 deletions(-) create mode 100644 crates/oxc_ast/src/generated/assert_layouts.rs create mode 100644 tasks/ast_codegen/src/generators/assert_layouts.rs create mode 100644 tasks/ast_codegen/src/layout.rs create mode 100644 tasks/ast_codegen/src/passes/calc_layout.rs diff --git a/crates/oxc_ast/src/generated/assert_layouts.rs b/crates/oxc_ast/src/generated/assert_layouts.rs new file mode 100644 index 0000000000000..b39e5050a7b64 --- /dev/null +++ b/crates/oxc_ast/src/generated/assert_layouts.rs @@ -0,0 +1,2249 @@ +// Auto-generated code, DO NOT EDIT DIRECTLY! +// To edit this generated file you have to edit `tasks/ast_codegen/src/generators/assert_layouts.rs` + +use std::mem::{align_of, offset_of, size_of}; + +use crate::ast::*; + +#[cfg(target_pointer_width = "64")] +const _: () = { + assert!(size_of::() == 12usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(BooleanLiteral, span) == 0usize); + assert!(offset_of!(BooleanLiteral, value) == 8usize); + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(NullLiteral, span) == 0usize); + assert!(size_of::() == 40usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(NumericLiteral, span) == 0usize); + assert!(offset_of!(NumericLiteral, value) == 8usize); + assert!(offset_of!(NumericLiteral, raw) == 16usize); + assert!(offset_of!(NumericLiteral, base) == 32usize); + assert!(size_of::() == 32usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(BigIntLiteral, span) == 0usize); + assert!(offset_of!(BigIntLiteral, raw) == 8usize); + assert!(offset_of!(BigIntLiteral, base) == 24usize); + assert!(size_of::() == 32usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(RegExpLiteral, span) == 0usize); + assert!(offset_of!(RegExpLiteral, value) == 8usize); + assert!(offset_of!(RegExpLiteral, regex) == 8usize); + assert!(size_of::() == 24usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(RegExp, pattern) == 0usize); + assert!(offset_of!(RegExp, flags) == 16usize); + assert!(size_of::() == 0usize); + assert!(align_of::() == 1usize); + assert!(size_of::() == 24usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(StringLiteral, span) == 0usize); + assert!(offset_of!(StringLiteral, value) == 8usize); + assert!(size_of::() == 112usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(Program, span) == 0usize); + assert!(offset_of!(Program, source_type) == 8usize); + assert!(offset_of!(Program, hashbang) == 16usize); + assert!(offset_of!(Program, directives) == 40usize); + assert!(offset_of!(Program, body) == 72usize); + assert!(offset_of!(Program, scope_id) == 104usize); + assert!(size_of::() == 16usize); + assert!(align_of::() == 8usize); + assert!(size_of::() == 24usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(IdentifierName, span) == 0usize); + assert!(offset_of!(IdentifierName, name) == 8usize); + assert!(size_of::() == 32usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(IdentifierReference, span) == 0usize); + assert!(offset_of!(IdentifierReference, name) == 8usize); + assert!(offset_of!(IdentifierReference, reference_id) == 24usize); + assert!(offset_of!(IdentifierReference, reference_flag) == 28usize); + assert!(size_of::() == 32usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(BindingIdentifier, span) == 0usize); + assert!(offset_of!(BindingIdentifier, name) == 8usize); + assert!(offset_of!(BindingIdentifier, symbol_id) == 24usize); + assert!(size_of::() == 24usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(LabelIdentifier, span) == 0usize); + assert!(offset_of!(LabelIdentifier, name) == 8usize); + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(ThisExpression, span) == 0usize); + assert!(size_of::() == 56usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(ArrayExpression, span) == 0usize); + assert!(offset_of!(ArrayExpression, elements) == 8usize); + assert!(offset_of!(ArrayExpression, trailing_comma) == 40usize); + assert!(size_of::() == 16usize); + assert!(align_of::() == 8usize); + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(Elision, span) == 0usize); + assert!(size_of::() == 56usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(ObjectExpression, span) == 0usize); + assert!(offset_of!(ObjectExpression, properties) == 8usize); + assert!(offset_of!(ObjectExpression, trailing_comma) == 40usize); + assert!(size_of::() == 16usize); + assert!(align_of::() == 8usize); + assert!(size_of::() == 72usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(ObjectProperty, span) == 0usize); + assert!(offset_of!(ObjectProperty, kind) == 8usize); + assert!(offset_of!(ObjectProperty, key) == 16usize); + assert!(offset_of!(ObjectProperty, value) == 32usize); + assert!(offset_of!(ObjectProperty, init) == 48usize); + assert!(offset_of!(ObjectProperty, method) == 64usize); + assert!(offset_of!(ObjectProperty, shorthand) == 65usize); + assert!(offset_of!(ObjectProperty, computed) == 66usize); + assert!(size_of::() == 16usize); + assert!(align_of::() == 8usize); + assert!(size_of::() == 1usize); + assert!(align_of::() == 1usize); + assert!(size_of::() == 72usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(TemplateLiteral, span) == 0usize); + assert!(offset_of!(TemplateLiteral, quasis) == 8usize); + assert!(offset_of!(TemplateLiteral, expressions) == 40usize); + assert!(size_of::() == 104usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(TaggedTemplateExpression, span) == 0usize); + assert!(offset_of!(TaggedTemplateExpression, tag) == 8usize); + assert!(offset_of!(TaggedTemplateExpression, quasi) == 24usize); + assert!(offset_of!(TaggedTemplateExpression, type_parameters) == 96usize); + assert!(size_of::() == 48usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(TemplateElement, span) == 0usize); + assert!(offset_of!(TemplateElement, tail) == 8usize); + assert!(offset_of!(TemplateElement, value) == 16usize); + assert!(size_of::() == 32usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(TemplateElementValue, raw) == 0usize); + assert!(offset_of!(TemplateElementValue, cooked) == 16usize); + assert!(size_of::() == 16usize); + assert!(align_of::() == 8usize); + assert!(size_of::() == 48usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(ComputedMemberExpression, span) == 0usize); + assert!(offset_of!(ComputedMemberExpression, object) == 8usize); + assert!(offset_of!(ComputedMemberExpression, expression) == 24usize); + assert!(offset_of!(ComputedMemberExpression, optional) == 40usize); + assert!(size_of::() == 56usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(StaticMemberExpression, span) == 0usize); + assert!(offset_of!(StaticMemberExpression, object) == 8usize); + assert!(offset_of!(StaticMemberExpression, property) == 24usize); + assert!(offset_of!(StaticMemberExpression, optional) == 48usize); + assert!(size_of::() == 56usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(PrivateFieldExpression, span) == 0usize); + assert!(offset_of!(PrivateFieldExpression, object) == 8usize); + assert!(offset_of!(PrivateFieldExpression, field) == 24usize); + assert!(offset_of!(PrivateFieldExpression, optional) == 48usize); + assert!(size_of::() == 72usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(CallExpression, span) == 0usize); + assert!(offset_of!(CallExpression, arguments) == 8usize); + assert!(offset_of!(CallExpression, callee) == 40usize); + assert!(offset_of!(CallExpression, type_parameters) == 56usize); + assert!(offset_of!(CallExpression, optional) == 64usize); + assert!(size_of::() == 64usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(NewExpression, span) == 0usize); + assert!(offset_of!(NewExpression, callee) == 8usize); + assert!(offset_of!(NewExpression, arguments) == 24usize); + assert!(offset_of!(NewExpression, type_parameters) == 56usize); + assert!(size_of::() == 56usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(MetaProperty, span) == 0usize); + assert!(offset_of!(MetaProperty, meta) == 8usize); + assert!(offset_of!(MetaProperty, property) == 32usize); + assert!(size_of::() == 24usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(SpreadElement, span) == 0usize); + assert!(offset_of!(SpreadElement, argument) == 8usize); + assert!(size_of::() == 16usize); + assert!(align_of::() == 8usize); + assert!(size_of::() == 32usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(UpdateExpression, span) == 0usize); + assert!(offset_of!(UpdateExpression, operator) == 8usize); + assert!(offset_of!(UpdateExpression, prefix) == 9usize); + assert!(offset_of!(UpdateExpression, argument) == 16usize); + assert!(size_of::() == 32usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(UnaryExpression, span) == 0usize); + assert!(offset_of!(UnaryExpression, operator) == 8usize); + assert!(offset_of!(UnaryExpression, argument) == 16usize); + assert!(size_of::() == 48usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(BinaryExpression, span) == 0usize); + assert!(offset_of!(BinaryExpression, left) == 8usize); + assert!(offset_of!(BinaryExpression, operator) == 24usize); + assert!(offset_of!(BinaryExpression, right) == 32usize); + assert!(size_of::() == 56usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(PrivateInExpression, span) == 0usize); + assert!(offset_of!(PrivateInExpression, left) == 8usize); + assert!(offset_of!(PrivateInExpression, operator) == 32usize); + assert!(offset_of!(PrivateInExpression, right) == 40usize); + assert!(size_of::() == 48usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(LogicalExpression, span) == 0usize); + assert!(offset_of!(LogicalExpression, left) == 8usize); + assert!(offset_of!(LogicalExpression, operator) == 24usize); + assert!(offset_of!(LogicalExpression, right) == 32usize); + assert!(size_of::() == 56usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(ConditionalExpression, span) == 0usize); + assert!(offset_of!(ConditionalExpression, test) == 8usize); + assert!(offset_of!(ConditionalExpression, consequent) == 24usize); + assert!(offset_of!(ConditionalExpression, alternate) == 40usize); + assert!(size_of::() == 48usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(AssignmentExpression, span) == 0usize); + assert!(offset_of!(AssignmentExpression, operator) == 8usize); + assert!(offset_of!(AssignmentExpression, left) == 16usize); + assert!(offset_of!(AssignmentExpression, right) == 32usize); + assert!(size_of::() == 16usize); + assert!(align_of::() == 8usize); + assert!(size_of::() == 16usize); + assert!(align_of::() == 8usize); + assert!(size_of::() == 16usize); + assert!(align_of::() == 8usize); + assert!(size_of::() == 80usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(ArrayAssignmentTarget, span) == 0usize); + assert!(offset_of!(ArrayAssignmentTarget, elements) == 8usize); + assert!(offset_of!(ArrayAssignmentTarget, rest) == 40usize); + assert!(offset_of!(ArrayAssignmentTarget, trailing_comma) == 64usize); + assert!(size_of::() == 64usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(ObjectAssignmentTarget, span) == 0usize); + assert!(offset_of!(ObjectAssignmentTarget, properties) == 8usize); + assert!(offset_of!(ObjectAssignmentTarget, rest) == 40usize); + assert!(size_of::() == 24usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(AssignmentTargetRest, span) == 0usize); + assert!(offset_of!(AssignmentTargetRest, target) == 8usize); + assert!(size_of::() == 16usize); + assert!(align_of::() == 8usize); + assert!(size_of::() == 40usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(AssignmentTargetWithDefault, span) == 0usize); + assert!(offset_of!(AssignmentTargetWithDefault, binding) == 8usize); + assert!(offset_of!(AssignmentTargetWithDefault, init) == 24usize); + assert!(size_of::() == 16usize); + assert!(align_of::() == 8usize); + assert!(size_of::() == 56usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(AssignmentTargetPropertyIdentifier, span) == 0usize); + assert!(offset_of!(AssignmentTargetPropertyIdentifier, binding) == 8usize); + assert!(offset_of!(AssignmentTargetPropertyIdentifier, init) == 40usize); + assert!(size_of::() == 40usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(AssignmentTargetPropertyProperty, span) == 0usize); + assert!(offset_of!(AssignmentTargetPropertyProperty, name) == 8usize); + assert!(offset_of!(AssignmentTargetPropertyProperty, binding) == 24usize); + assert!(size_of::() == 40usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(SequenceExpression, span) == 0usize); + assert!(offset_of!(SequenceExpression, expressions) == 8usize); + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(Super, span) == 0usize); + assert!(size_of::() == 24usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(AwaitExpression, span) == 0usize); + assert!(offset_of!(AwaitExpression, argument) == 8usize); + assert!(size_of::() == 24usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(ChainExpression, span) == 0usize); + assert!(offset_of!(ChainExpression, expression) == 8usize); + assert!(size_of::() == 16usize); + assert!(align_of::() == 8usize); + assert!(size_of::() == 24usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(ParenthesizedExpression, span) == 0usize); + assert!(offset_of!(ParenthesizedExpression, expression) == 8usize); + assert!(size_of::() == 16usize); + assert!(align_of::() == 8usize); + assert!(size_of::() == 48usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(Directive, span) == 0usize); + assert!(offset_of!(Directive, expression) == 8usize); + assert!(offset_of!(Directive, directive) == 32usize); + assert!(size_of::() == 24usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(Hashbang, span) == 0usize); + assert!(offset_of!(Hashbang, value) == 8usize); + assert!(size_of::() == 48usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(BlockStatement, span) == 0usize); + assert!(offset_of!(BlockStatement, body) == 8usize); + assert!(offset_of!(BlockStatement, scope_id) == 40usize); + assert!(size_of::() == 16usize); + assert!(align_of::() == 8usize); + assert!(size_of::() == 56usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(VariableDeclaration, span) == 0usize); + assert!(offset_of!(VariableDeclaration, kind) == 8usize); + assert!(offset_of!(VariableDeclaration, declarations) == 16usize); + assert!(offset_of!(VariableDeclaration, declare) == 48usize); + assert!(size_of::() == 1usize); + assert!(align_of::() == 1usize); + assert!(size_of::() == 72usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(VariableDeclarator, span) == 0usize); + assert!(offset_of!(VariableDeclarator, kind) == 8usize); + assert!(offset_of!(VariableDeclarator, id) == 16usize); + assert!(offset_of!(VariableDeclarator, init) == 48usize); + assert!(offset_of!(VariableDeclarator, definite) == 64usize); + assert!(size_of::() == 48usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(UsingDeclaration, span) == 0usize); + assert!(offset_of!(UsingDeclaration, is_await) == 8usize); + assert!(offset_of!(UsingDeclaration, declarations) == 16usize); + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(EmptyStatement, span) == 0usize); + assert!(size_of::() == 24usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(ExpressionStatement, span) == 0usize); + assert!(offset_of!(ExpressionStatement, expression) == 8usize); + assert!(size_of::() == 56usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(IfStatement, span) == 0usize); + assert!(offset_of!(IfStatement, test) == 8usize); + assert!(offset_of!(IfStatement, consequent) == 24usize); + assert!(offset_of!(IfStatement, alternate) == 40usize); + assert!(size_of::() == 40usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(DoWhileStatement, span) == 0usize); + assert!(offset_of!(DoWhileStatement, body) == 8usize); + assert!(offset_of!(DoWhileStatement, test) == 24usize); + assert!(size_of::() == 40usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(WhileStatement, span) == 0usize); + assert!(offset_of!(WhileStatement, test) == 8usize); + assert!(offset_of!(WhileStatement, body) == 24usize); + assert!(size_of::() == 80usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(ForStatement, span) == 0usize); + assert!(offset_of!(ForStatement, init) == 8usize); + assert!(offset_of!(ForStatement, test) == 24usize); + assert!(offset_of!(ForStatement, update) == 40usize); + assert!(offset_of!(ForStatement, body) == 56usize); + assert!(offset_of!(ForStatement, scope_id) == 72usize); + assert!(size_of::() == 16usize); + assert!(align_of::() == 8usize); + assert!(size_of::() == 64usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(ForInStatement, span) == 0usize); + assert!(offset_of!(ForInStatement, left) == 8usize); + assert!(offset_of!(ForInStatement, right) == 24usize); + assert!(offset_of!(ForInStatement, body) == 40usize); + assert!(offset_of!(ForInStatement, scope_id) == 56usize); + assert!(size_of::() == 16usize); + assert!(align_of::() == 8usize); + assert!(size_of::() == 72usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(ForOfStatement, span) == 0usize); + assert!(offset_of!(ForOfStatement, r#await) == 8usize); + assert!(offset_of!(ForOfStatement, left) == 16usize); + assert!(offset_of!(ForOfStatement, right) == 32usize); + assert!(offset_of!(ForOfStatement, body) == 48usize); + assert!(offset_of!(ForOfStatement, scope_id) == 64usize); + assert!(size_of::() == 32usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(ContinueStatement, span) == 0usize); + assert!(offset_of!(ContinueStatement, label) == 8usize); + assert!(size_of::() == 32usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(BreakStatement, span) == 0usize); + assert!(offset_of!(BreakStatement, label) == 8usize); + assert!(size_of::() == 24usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(ReturnStatement, span) == 0usize); + assert!(offset_of!(ReturnStatement, argument) == 8usize); + assert!(size_of::() == 40usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(WithStatement, span) == 0usize); + assert!(offset_of!(WithStatement, object) == 8usize); + assert!(offset_of!(WithStatement, body) == 24usize); + assert!(size_of::() == 64usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(SwitchStatement, span) == 0usize); + assert!(offset_of!(SwitchStatement, discriminant) == 8usize); + assert!(offset_of!(SwitchStatement, cases) == 24usize); + assert!(offset_of!(SwitchStatement, scope_id) == 56usize); + assert!(size_of::() == 56usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(SwitchCase, span) == 0usize); + assert!(offset_of!(SwitchCase, test) == 8usize); + assert!(offset_of!(SwitchCase, consequent) == 24usize); + assert!(size_of::() == 48usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(LabeledStatement, span) == 0usize); + assert!(offset_of!(LabeledStatement, label) == 8usize); + assert!(offset_of!(LabeledStatement, body) == 32usize); + assert!(size_of::() == 24usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(ThrowStatement, span) == 0usize); + assert!(offset_of!(ThrowStatement, argument) == 8usize); + assert!(size_of::() == 32usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(TryStatement, span) == 0usize); + assert!(offset_of!(TryStatement, block) == 8usize); + assert!(offset_of!(TryStatement, handler) == 16usize); + assert!(offset_of!(TryStatement, finalizer) == 24usize); + assert!(size_of::() == 64usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(CatchClause, span) == 0usize); + assert!(offset_of!(CatchClause, param) == 8usize); + assert!(offset_of!(CatchClause, body) == 48usize); + assert!(offset_of!(CatchClause, scope_id) == 56usize); + assert!(size_of::() == 40usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(CatchParameter, span) == 0usize); + assert!(offset_of!(CatchParameter, pattern) == 8usize); + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(DebuggerStatement, span) == 0usize); + assert!(size_of::() == 32usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(BindingPattern, kind) == 0usize); + assert!(offset_of!(BindingPattern, type_annotation) == 16usize); + assert!(offset_of!(BindingPattern, optional) == 24usize); + assert!(size_of::() == 16usize); + assert!(align_of::() == 8usize); + assert!(size_of::() == 56usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(AssignmentPattern, span) == 0usize); + assert!(offset_of!(AssignmentPattern, left) == 8usize); + assert!(offset_of!(AssignmentPattern, right) == 40usize); + assert!(size_of::() == 48usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(ObjectPattern, span) == 0usize); + assert!(offset_of!(ObjectPattern, properties) == 8usize); + assert!(offset_of!(ObjectPattern, rest) == 40usize); + assert!(size_of::() == 64usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(BindingProperty, span) == 0usize); + assert!(offset_of!(BindingProperty, key) == 8usize); + assert!(offset_of!(BindingProperty, value) == 24usize); + assert!(offset_of!(BindingProperty, shorthand) == 56usize); + assert!(offset_of!(BindingProperty, computed) == 57usize); + assert!(size_of::() == 48usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(ArrayPattern, span) == 0usize); + assert!(offset_of!(ArrayPattern, elements) == 8usize); + assert!(offset_of!(ArrayPattern, rest) == 40usize); + assert!(size_of::() == 40usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(BindingRestElement, span) == 0usize); + assert!(offset_of!(BindingRestElement, argument) == 8usize); + assert!(size_of::() == 136usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(Function, r#type) == 0usize); + assert!(offset_of!(Function, span) == 4usize); + assert!(offset_of!(Function, id) == 16usize); + assert!(offset_of!(Function, generator) == 48usize); + assert!(offset_of!(Function, r#async) == 49usize); + assert!(offset_of!(Function, declare) == 50usize); + assert!(offset_of!(Function, type_parameters) == 56usize); + assert!(offset_of!(Function, this_param) == 64usize); + assert!(offset_of!(Function, params) == 104usize); + assert!(offset_of!(Function, return_type) == 112usize); + assert!(offset_of!(Function, body) == 120usize); + assert!(offset_of!(Function, scope_id) == 128usize); + assert!(size_of::() == 1usize); + assert!(align_of::() == 1usize); + assert!(size_of::() == 56usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(FormalParameters, span) == 0usize); + assert!(offset_of!(FormalParameters, kind) == 8usize); + assert!(offset_of!(FormalParameters, items) == 16usize); + assert!(offset_of!(FormalParameters, rest) == 48usize); + assert!(size_of::() == 80usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(FormalParameter, span) == 0usize); + assert!(offset_of!(FormalParameter, decorators) == 8usize); + assert!(offset_of!(FormalParameter, pattern) == 40usize); + assert!(offset_of!(FormalParameter, accessibility) == 72usize); + assert!(offset_of!(FormalParameter, readonly) == 73usize); + assert!(offset_of!(FormalParameter, r#override) == 74usize); + assert!(size_of::() == 1usize); + assert!(align_of::() == 1usize); + assert!(size_of::() == 72usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(FunctionBody, span) == 0usize); + assert!(offset_of!(FunctionBody, directives) == 8usize); + assert!(offset_of!(FunctionBody, statements) == 40usize); + assert!(size_of::() == 56usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(ArrowFunctionExpression, span) == 0usize); + assert!(offset_of!(ArrowFunctionExpression, expression) == 8usize); + assert!(offset_of!(ArrowFunctionExpression, r#async) == 9usize); + assert!(offset_of!(ArrowFunctionExpression, type_parameters) == 16usize); + assert!(offset_of!(ArrowFunctionExpression, params) == 24usize); + assert!(offset_of!(ArrowFunctionExpression, return_type) == 32usize); + assert!(offset_of!(ArrowFunctionExpression, body) == 40usize); + assert!(offset_of!(ArrowFunctionExpression, scope_id) == 48usize); + assert!(size_of::() == 32usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(YieldExpression, span) == 0usize); + assert!(offset_of!(YieldExpression, delegate) == 8usize); + assert!(offset_of!(YieldExpression, argument) == 16usize); + assert!(size_of::() == 160usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(Class, r#type) == 0usize); + assert!(offset_of!(Class, span) == 4usize); + assert!(offset_of!(Class, decorators) == 16usize); + assert!(offset_of!(Class, id) == 48usize); + assert!(offset_of!(Class, type_parameters) == 80usize); + assert!(offset_of!(Class, super_class) == 88usize); + assert!(offset_of!(Class, super_type_parameters) == 104usize); + assert!(offset_of!(Class, implements) == 112usize); + assert!(offset_of!(Class, body) == 144usize); + assert!(offset_of!(Class, r#abstract) == 152usize); + assert!(offset_of!(Class, declare) == 153usize); + assert!(offset_of!(Class, scope_id) == 156usize); + assert!(size_of::() == 1usize); + assert!(align_of::() == 1usize); + assert!(size_of::() == 40usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(ClassBody, span) == 0usize); + assert!(offset_of!(ClassBody, body) == 8usize); + assert!(size_of::() == 16usize); + assert!(align_of::() == 8usize); + assert!(size_of::() == 80usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(MethodDefinition, r#type) == 0usize); + assert!(offset_of!(MethodDefinition, span) == 4usize); + assert!(offset_of!(MethodDefinition, decorators) == 16usize); + assert!(offset_of!(MethodDefinition, key) == 48usize); + assert!(offset_of!(MethodDefinition, value) == 64usize); + assert!(offset_of!(MethodDefinition, kind) == 72usize); + assert!(offset_of!(MethodDefinition, computed) == 73usize); + assert!(offset_of!(MethodDefinition, r#static) == 74usize); + assert!(offset_of!(MethodDefinition, r#override) == 75usize); + assert!(offset_of!(MethodDefinition, optional) == 76usize); + assert!(offset_of!(MethodDefinition, accessibility) == 77usize); + assert!(size_of::() == 1usize); + assert!(align_of::() == 1usize); + assert!(size_of::() == 104usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(PropertyDefinition, r#type) == 0usize); + assert!(offset_of!(PropertyDefinition, span) == 4usize); + assert!(offset_of!(PropertyDefinition, decorators) == 16usize); + assert!(offset_of!(PropertyDefinition, key) == 48usize); + assert!(offset_of!(PropertyDefinition, value) == 64usize); + assert!(offset_of!(PropertyDefinition, computed) == 80usize); + assert!(offset_of!(PropertyDefinition, r#static) == 81usize); + assert!(offset_of!(PropertyDefinition, declare) == 82usize); + assert!(offset_of!(PropertyDefinition, r#override) == 83usize); + assert!(offset_of!(PropertyDefinition, optional) == 84usize); + assert!(offset_of!(PropertyDefinition, definite) == 85usize); + assert!(offset_of!(PropertyDefinition, readonly) == 86usize); + assert!(offset_of!(PropertyDefinition, type_annotation) == 88usize); + assert!(offset_of!(PropertyDefinition, accessibility) == 96usize); + assert!(size_of::() == 1usize); + assert!(align_of::() == 1usize); + assert!(size_of::() == 1usize); + assert!(align_of::() == 1usize); + assert!(size_of::() == 24usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(PrivateIdentifier, span) == 0usize); + assert!(offset_of!(PrivateIdentifier, name) == 8usize); + assert!(size_of::() == 48usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(StaticBlock, span) == 0usize); + assert!(offset_of!(StaticBlock, body) == 8usize); + assert!(offset_of!(StaticBlock, scope_id) == 40usize); + assert!(size_of::() == 16usize); + assert!(align_of::() == 8usize); + assert!(size_of::() == 1usize); + assert!(align_of::() == 1usize); + assert!(size_of::() == 88usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(AccessorProperty, r#type) == 0usize); + assert!(offset_of!(AccessorProperty, span) == 4usize); + assert!(offset_of!(AccessorProperty, decorators) == 16usize); + assert!(offset_of!(AccessorProperty, key) == 48usize); + assert!(offset_of!(AccessorProperty, value) == 64usize); + assert!(offset_of!(AccessorProperty, computed) == 80usize); + assert!(offset_of!(AccessorProperty, r#static) == 81usize); + assert!(size_of::() == 56usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(ImportExpression, span) == 0usize); + assert!(offset_of!(ImportExpression, source) == 8usize); + assert!(offset_of!(ImportExpression, arguments) == 24usize); + assert!(size_of::() == 136usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(ImportDeclaration, span) == 0usize); + assert!(offset_of!(ImportDeclaration, specifiers) == 8usize); + assert!(offset_of!(ImportDeclaration, source) == 40usize); + assert!(offset_of!(ImportDeclaration, with_clause) == 64usize); + assert!(offset_of!(ImportDeclaration, import_kind) == 128usize); + assert!(size_of::() == 16usize); + assert!(align_of::() == 8usize); + assert!(size_of::() == 88usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(ImportSpecifier, span) == 0usize); + assert!(offset_of!(ImportSpecifier, imported) == 8usize); + assert!(offset_of!(ImportSpecifier, local) == 48usize); + assert!(offset_of!(ImportSpecifier, import_kind) == 80usize); + assert!(size_of::() == 40usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(ImportDefaultSpecifier, span) == 0usize); + assert!(offset_of!(ImportDefaultSpecifier, local) == 8usize); + assert!(size_of::() == 40usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(ImportNamespaceSpecifier, span) == 0usize); + assert!(offset_of!(ImportNamespaceSpecifier, local) == 8usize); + assert!(size_of::() == 64usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(WithClause, span) == 0usize); + assert!(offset_of!(WithClause, attributes_keyword) == 8usize); + assert!(offset_of!(WithClause, with_entries) == 32usize); + assert!(size_of::() == 64usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(ImportAttribute, span) == 0usize); + assert!(offset_of!(ImportAttribute, key) == 8usize); + assert!(offset_of!(ImportAttribute, value) == 40usize); + assert!(size_of::() == 32usize); + assert!(align_of::() == 8usize); + assert!(size_of::() == 152usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(ExportNamedDeclaration, span) == 0usize); + assert!(offset_of!(ExportNamedDeclaration, declaration) == 8usize); + assert!(offset_of!(ExportNamedDeclaration, specifiers) == 24usize); + assert!(offset_of!(ExportNamedDeclaration, source) == 56usize); + assert!(offset_of!(ExportNamedDeclaration, export_kind) == 80usize); + assert!(offset_of!(ExportNamedDeclaration, with_clause) == 88usize); + assert!(size_of::() == 64usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(ExportDefaultDeclaration, span) == 0usize); + assert!(offset_of!(ExportDefaultDeclaration, declaration) == 8usize); + assert!(offset_of!(ExportDefaultDeclaration, exported) == 24usize); + assert!(size_of::() == 144usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(ExportAllDeclaration, span) == 0usize); + assert!(offset_of!(ExportAllDeclaration, exported) == 8usize); + assert!(offset_of!(ExportAllDeclaration, source) == 48usize); + assert!(offset_of!(ExportAllDeclaration, with_clause) == 72usize); + assert!(offset_of!(ExportAllDeclaration, export_kind) == 136usize); + assert!(size_of::() == 96usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(ExportSpecifier, span) == 0usize); + assert!(offset_of!(ExportSpecifier, local) == 8usize); + assert!(offset_of!(ExportSpecifier, exported) == 48usize); + assert!(offset_of!(ExportSpecifier, export_kind) == 88usize); + assert!(size_of::() == 16usize); + assert!(align_of::() == 8usize); + assert!(size_of::() == 40usize); + assert!(align_of::() == 8usize); + assert!(size_of::() == 40usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(TSThisParameter, span) == 0usize); + assert!(offset_of!(TSThisParameter, this) == 8usize); + assert!(offset_of!(TSThisParameter, type_annotation) == 32usize); + assert!(size_of::() == 80usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(TSEnumDeclaration, span) == 0usize); + assert!(offset_of!(TSEnumDeclaration, id) == 8usize); + assert!(offset_of!(TSEnumDeclaration, members) == 40usize); + assert!(offset_of!(TSEnumDeclaration, r#const) == 72usize); + assert!(offset_of!(TSEnumDeclaration, declare) == 73usize); + assert!(offset_of!(TSEnumDeclaration, scope_id) == 76usize); + assert!(size_of::() == 40usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(TSEnumMember, span) == 0usize); + assert!(offset_of!(TSEnumMember, id) == 8usize); + assert!(offset_of!(TSEnumMember, initializer) == 24usize); + assert!(size_of::() == 16usize); + assert!(align_of::() == 8usize); + assert!(size_of::() == 24usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(TSTypeAnnotation, span) == 0usize); + assert!(offset_of!(TSTypeAnnotation, type_annotation) == 8usize); + assert!(size_of::() == 24usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(TSLiteralType, span) == 0usize); + assert!(offset_of!(TSLiteralType, literal) == 8usize); + assert!(size_of::() == 16usize); + assert!(align_of::() == 8usize); + assert!(size_of::() == 16usize); + assert!(align_of::() == 8usize); + assert!(size_of::() == 80usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(TSConditionalType, span) == 0usize); + assert!(offset_of!(TSConditionalType, check_type) == 8usize); + assert!(offset_of!(TSConditionalType, extends_type) == 24usize); + assert!(offset_of!(TSConditionalType, true_type) == 40usize); + assert!(offset_of!(TSConditionalType, false_type) == 56usize); + assert!(offset_of!(TSConditionalType, scope_id) == 72usize); + assert!(size_of::() == 40usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(TSUnionType, span) == 0usize); + assert!(offset_of!(TSUnionType, types) == 8usize); + assert!(size_of::() == 40usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(TSIntersectionType, span) == 0usize); + assert!(offset_of!(TSIntersectionType, types) == 8usize); + assert!(size_of::() == 24usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(TSParenthesizedType, span) == 0usize); + assert!(offset_of!(TSParenthesizedType, type_annotation) == 8usize); + assert!(size_of::() == 32usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(TSTypeOperator, span) == 0usize); + assert!(offset_of!(TSTypeOperator, operator) == 8usize); + assert!(offset_of!(TSTypeOperator, type_annotation) == 16usize); + assert!(size_of::() == 1usize); + assert!(align_of::() == 1usize); + assert!(size_of::() == 24usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(TSArrayType, span) == 0usize); + assert!(offset_of!(TSArrayType, element_type) == 8usize); + assert!(size_of::() == 40usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(TSIndexedAccessType, span) == 0usize); + assert!(offset_of!(TSIndexedAccessType, object_type) == 8usize); + assert!(offset_of!(TSIndexedAccessType, index_type) == 24usize); + assert!(size_of::() == 40usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(TSTupleType, span) == 0usize); + assert!(offset_of!(TSTupleType, element_types) == 8usize); + assert!(size_of::() == 56usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(TSNamedTupleMember, span) == 0usize); + assert!(offset_of!(TSNamedTupleMember, element_type) == 8usize); + assert!(offset_of!(TSNamedTupleMember, label) == 24usize); + assert!(offset_of!(TSNamedTupleMember, optional) == 48usize); + assert!(size_of::() == 24usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(TSOptionalType, span) == 0usize); + assert!(offset_of!(TSOptionalType, type_annotation) == 8usize); + assert!(size_of::() == 24usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(TSRestType, span) == 0usize); + assert!(offset_of!(TSRestType, type_annotation) == 8usize); + assert!(size_of::() == 16usize); + assert!(align_of::() == 8usize); + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(TSAnyKeyword, span) == 0usize); + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(TSStringKeyword, span) == 0usize); + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(TSBooleanKeyword, span) == 0usize); + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(TSNumberKeyword, span) == 0usize); + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(TSNeverKeyword, span) == 0usize); + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(TSIntrinsicKeyword, span) == 0usize); + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(TSUnknownKeyword, span) == 0usize); + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(TSNullKeyword, span) == 0usize); + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(TSUndefinedKeyword, span) == 0usize); + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(TSVoidKeyword, span) == 0usize); + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(TSSymbolKeyword, span) == 0usize); + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(TSThisType, span) == 0usize); + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(TSObjectKeyword, span) == 0usize); + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(TSBigIntKeyword, span) == 0usize); + assert!(size_of::() == 32usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(TSTypeReference, span) == 0usize); + assert!(offset_of!(TSTypeReference, type_name) == 8usize); + assert!(offset_of!(TSTypeReference, type_parameters) == 24usize); + assert!(size_of::() == 16usize); + assert!(align_of::() == 8usize); + assert!(size_of::() == 48usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(TSQualifiedName, span) == 0usize); + assert!(offset_of!(TSQualifiedName, left) == 8usize); + assert!(offset_of!(TSQualifiedName, right) == 24usize); + assert!(size_of::() == 40usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(TSTypeParameterInstantiation, span) == 0usize); + assert!(offset_of!(TSTypeParameterInstantiation, params) == 8usize); + assert!(size_of::() == 80usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(TSTypeParameter, span) == 0usize); + assert!(offset_of!(TSTypeParameter, name) == 8usize); + assert!(offset_of!(TSTypeParameter, constraint) == 40usize); + assert!(offset_of!(TSTypeParameter, default) == 56usize); + assert!(offset_of!(TSTypeParameter, r#in) == 72usize); + assert!(offset_of!(TSTypeParameter, out) == 73usize); + assert!(offset_of!(TSTypeParameter, r#const) == 74usize); + assert!(size_of::() == 40usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(TSTypeParameterDeclaration, span) == 0usize); + assert!(offset_of!(TSTypeParameterDeclaration, params) == 8usize); + assert!(size_of::() == 72usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(TSTypeAliasDeclaration, span) == 0usize); + assert!(offset_of!(TSTypeAliasDeclaration, id) == 8usize); + assert!(offset_of!(TSTypeAliasDeclaration, type_parameters) == 40usize); + assert!(offset_of!(TSTypeAliasDeclaration, type_annotation) == 48usize); + assert!(offset_of!(TSTypeAliasDeclaration, declare) == 64usize); + assert!(offset_of!(TSTypeAliasDeclaration, scope_id) == 68usize); + assert!(size_of::() == 1usize); + assert!(align_of::() == 1usize); + assert!(size_of::() == 32usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(TSClassImplements, span) == 0usize); + assert!(offset_of!(TSClassImplements, expression) == 8usize); + assert!(offset_of!(TSClassImplements, type_parameters) == 24usize); + assert!(size_of::() == 96usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(TSInterfaceDeclaration, span) == 0usize); + assert!(offset_of!(TSInterfaceDeclaration, id) == 8usize); + assert!(offset_of!(TSInterfaceDeclaration, extends) == 40usize); + assert!(offset_of!(TSInterfaceDeclaration, type_parameters) == 72usize); + assert!(offset_of!(TSInterfaceDeclaration, body) == 80usize); + assert!(offset_of!(TSInterfaceDeclaration, declare) == 88usize); + assert!(offset_of!(TSInterfaceDeclaration, scope_id) == 92usize); + assert!(size_of::() == 40usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(TSInterfaceBody, span) == 0usize); + assert!(offset_of!(TSInterfaceBody, body) == 8usize); + assert!(size_of::() == 40usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(TSPropertySignature, span) == 0usize); + assert!(offset_of!(TSPropertySignature, computed) == 8usize); + assert!(offset_of!(TSPropertySignature, optional) == 9usize); + assert!(offset_of!(TSPropertySignature, readonly) == 10usize); + assert!(offset_of!(TSPropertySignature, key) == 16usize); + assert!(offset_of!(TSPropertySignature, type_annotation) == 32usize); + assert!(size_of::() == 16usize); + assert!(align_of::() == 8usize); + assert!(size_of::() == 56usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(TSIndexSignature, span) == 0usize); + assert!(offset_of!(TSIndexSignature, parameters) == 8usize); + assert!(offset_of!(TSIndexSignature, type_annotation) == 40usize); + assert!(offset_of!(TSIndexSignature, readonly) == 48usize); + assert!(size_of::() == 72usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(TSCallSignatureDeclaration, span) == 0usize); + assert!(offset_of!(TSCallSignatureDeclaration, this_param) == 8usize); + assert!(offset_of!(TSCallSignatureDeclaration, params) == 48usize); + assert!(offset_of!(TSCallSignatureDeclaration, return_type) == 56usize); + assert!(offset_of!(TSCallSignatureDeclaration, type_parameters) == 64usize); + assert!(size_of::() == 1usize); + assert!(align_of::() == 1usize); + assert!(size_of::() == 104usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(TSMethodSignature, span) == 0usize); + assert!(offset_of!(TSMethodSignature, key) == 8usize); + assert!(offset_of!(TSMethodSignature, computed) == 24usize); + assert!(offset_of!(TSMethodSignature, optional) == 25usize); + assert!(offset_of!(TSMethodSignature, kind) == 26usize); + assert!(offset_of!(TSMethodSignature, this_param) == 32usize); + assert!(offset_of!(TSMethodSignature, params) == 72usize); + assert!(offset_of!(TSMethodSignature, return_type) == 80usize); + assert!(offset_of!(TSMethodSignature, type_parameters) == 88usize); + assert!(offset_of!(TSMethodSignature, scope_id) == 96usize); + assert!(size_of::() == 40usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(TSConstructSignatureDeclaration, span) == 0usize); + assert!(offset_of!(TSConstructSignatureDeclaration, params) == 8usize); + assert!(offset_of!(TSConstructSignatureDeclaration, return_type) == 16usize); + assert!(offset_of!(TSConstructSignatureDeclaration, type_parameters) == 24usize); + assert!(offset_of!(TSConstructSignatureDeclaration, scope_id) == 32usize); + assert!(size_of::() == 32usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(TSIndexSignatureName, span) == 0usize); + assert!(offset_of!(TSIndexSignatureName, name) == 8usize); + assert!(offset_of!(TSIndexSignatureName, type_annotation) == 24usize); + assert!(size_of::() == 32usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(TSInterfaceHeritage, span) == 0usize); + assert!(offset_of!(TSInterfaceHeritage, expression) == 8usize); + assert!(offset_of!(TSInterfaceHeritage, type_parameters) == 24usize); + assert!(size_of::() == 40usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(TSTypePredicate, span) == 0usize); + assert!(offset_of!(TSTypePredicate, parameter_name) == 8usize); + assert!(offset_of!(TSTypePredicate, asserts) == 24usize); + assert!(offset_of!(TSTypePredicate, type_annotation) == 32usize); + assert!(size_of::() == 16usize); + assert!(align_of::() == 8usize); + assert!(size_of::() == 64usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(TSModuleDeclaration, span) == 0usize); + assert!(offset_of!(TSModuleDeclaration, id) == 8usize); + assert!(offset_of!(TSModuleDeclaration, body) == 40usize); + assert!(offset_of!(TSModuleDeclaration, kind) == 56usize); + assert!(offset_of!(TSModuleDeclaration, declare) == 57usize); + assert!(offset_of!(TSModuleDeclaration, scope_id) == 60usize); + assert!(size_of::() == 1usize); + assert!(align_of::() == 1usize); + assert!(size_of::() == 32usize); + assert!(align_of::() == 8usize); + assert!(size_of::() == 16usize); + assert!(align_of::() == 8usize); + assert!(size_of::() == 72usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(TSModuleBlock, span) == 0usize); + assert!(offset_of!(TSModuleBlock, directives) == 8usize); + assert!(offset_of!(TSModuleBlock, body) == 40usize); + assert!(size_of::() == 40usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(TSTypeLiteral, span) == 0usize); + assert!(offset_of!(TSTypeLiteral, members) == 8usize); + assert!(size_of::() == 16usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(TSInferType, span) == 0usize); + assert!(offset_of!(TSInferType, type_parameter) == 8usize); + assert!(size_of::() == 32usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(TSTypeQuery, span) == 0usize); + assert!(offset_of!(TSTypeQuery, expr_name) == 8usize); + assert!(offset_of!(TSTypeQuery, type_parameters) == 24usize); + assert!(size_of::() == 16usize); + assert!(align_of::() == 8usize); + assert!(size_of::() == 96usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(TSImportType, span) == 0usize); + assert!(offset_of!(TSImportType, is_type_of) == 8usize); + assert!(offset_of!(TSImportType, parameter) == 16usize); + assert!(offset_of!(TSImportType, qualifier) == 32usize); + assert!(offset_of!(TSImportType, attributes) == 48usize); + assert!(offset_of!(TSImportType, type_parameters) == 88usize); + assert!(size_of::() == 40usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(TSImportAttributes, span) == 0usize); + assert!(offset_of!(TSImportAttributes, elements) == 8usize); + assert!(size_of::() == 56usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(TSImportAttribute, span) == 0usize); + assert!(offset_of!(TSImportAttribute, name) == 8usize); + assert!(offset_of!(TSImportAttribute, value) == 40usize); + assert!(size_of::() == 32usize); + assert!(align_of::() == 8usize); + assert!(size_of::() == 72usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(TSFunctionType, span) == 0usize); + assert!(offset_of!(TSFunctionType, this_param) == 8usize); + assert!(offset_of!(TSFunctionType, params) == 48usize); + assert!(offset_of!(TSFunctionType, return_type) == 56usize); + assert!(offset_of!(TSFunctionType, type_parameters) == 64usize); + assert!(size_of::() == 40usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(TSConstructorType, span) == 0usize); + assert!(offset_of!(TSConstructorType, r#abstract) == 8usize); + assert!(offset_of!(TSConstructorType, params) == 16usize); + assert!(offset_of!(TSConstructorType, return_type) == 24usize); + assert!(offset_of!(TSConstructorType, type_parameters) == 32usize); + assert!(size_of::() == 56usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(TSMappedType, span) == 0usize); + assert!(offset_of!(TSMappedType, type_parameter) == 8usize); + assert!(offset_of!(TSMappedType, name_type) == 16usize); + assert!(offset_of!(TSMappedType, type_annotation) == 32usize); + assert!(offset_of!(TSMappedType, optional) == 48usize); + assert!(offset_of!(TSMappedType, readonly) == 49usize); + assert!(offset_of!(TSMappedType, scope_id) == 52usize); + assert!(size_of::() == 1usize); + assert!(align_of::() == 1usize); + assert!(size_of::() == 72usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(TSTemplateLiteralType, span) == 0usize); + assert!(offset_of!(TSTemplateLiteralType, quasis) == 8usize); + assert!(offset_of!(TSTemplateLiteralType, types) == 40usize); + assert!(size_of::() == 40usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(TSAsExpression, span) == 0usize); + assert!(offset_of!(TSAsExpression, expression) == 8usize); + assert!(offset_of!(TSAsExpression, type_annotation) == 24usize); + assert!(size_of::() == 40usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(TSSatisfiesExpression, span) == 0usize); + assert!(offset_of!(TSSatisfiesExpression, expression) == 8usize); + assert!(offset_of!(TSSatisfiesExpression, type_annotation) == 24usize); + assert!(size_of::() == 40usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(TSTypeAssertion, span) == 0usize); + assert!(offset_of!(TSTypeAssertion, expression) == 8usize); + assert!(offset_of!(TSTypeAssertion, type_annotation) == 24usize); + assert!(size_of::() == 64usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(TSImportEqualsDeclaration, span) == 0usize); + assert!(offset_of!(TSImportEqualsDeclaration, id) == 8usize); + assert!(offset_of!(TSImportEqualsDeclaration, module_reference) == 40usize); + assert!(offset_of!(TSImportEqualsDeclaration, import_kind) == 56usize); + assert!(size_of::() == 16usize); + assert!(align_of::() == 8usize); + assert!(size_of::() == 32usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(TSExternalModuleReference, span) == 0usize); + assert!(offset_of!(TSExternalModuleReference, expression) == 8usize); + assert!(size_of::() == 24usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(TSNonNullExpression, span) == 0usize); + assert!(offset_of!(TSNonNullExpression, expression) == 8usize); + assert!(size_of::() == 24usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(Decorator, span) == 0usize); + assert!(offset_of!(Decorator, expression) == 8usize); + assert!(size_of::() == 24usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(TSExportAssignment, span) == 0usize); + assert!(offset_of!(TSExportAssignment, expression) == 8usize); + assert!(size_of::() == 32usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(TSNamespaceExportDeclaration, span) == 0usize); + assert!(offset_of!(TSNamespaceExportDeclaration, id) == 8usize); + assert!(size_of::() == 32usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(TSInstantiationExpression, span) == 0usize); + assert!(offset_of!(TSInstantiationExpression, expression) == 8usize); + assert!(offset_of!(TSInstantiationExpression, type_parameters) == 24usize); + assert!(size_of::() == 1usize); + assert!(align_of::() == 1usize); + assert!(size_of::() == 32usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(JSDocNullableType, span) == 0usize); + assert!(offset_of!(JSDocNullableType, type_annotation) == 8usize); + assert!(offset_of!(JSDocNullableType, postfix) == 24usize); + assert!(size_of::() == 32usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(JSDocNonNullableType, span) == 0usize); + assert!(offset_of!(JSDocNonNullableType, type_annotation) == 8usize); + assert!(offset_of!(JSDocNonNullableType, postfix) == 24usize); + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(JSDocUnknownType, span) == 0usize); + assert!(size_of::() == 56usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(JSXElement, span) == 0usize); + assert!(offset_of!(JSXElement, opening_element) == 8usize); + assert!(offset_of!(JSXElement, closing_element) == 16usize); + assert!(offset_of!(JSXElement, children) == 24usize); + assert!(size_of::() == 72usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(JSXOpeningElement, span) == 0usize); + assert!(offset_of!(JSXOpeningElement, self_closing) == 8usize); + assert!(offset_of!(JSXOpeningElement, name) == 16usize); + assert!(offset_of!(JSXOpeningElement, attributes) == 32usize); + assert!(offset_of!(JSXOpeningElement, type_parameters) == 64usize); + assert!(size_of::() == 24usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(JSXClosingElement, span) == 0usize); + assert!(offset_of!(JSXClosingElement, name) == 8usize); + assert!(size_of::() == 56usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(JSXFragment, span) == 0usize); + assert!(offset_of!(JSXFragment, opening_fragment) == 8usize); + assert!(offset_of!(JSXFragment, closing_fragment) == 16usize); + assert!(offset_of!(JSXFragment, children) == 24usize); + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(JSXOpeningFragment, span) == 0usize); + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(JSXClosingFragment, span) == 0usize); + assert!(size_of::() == 16usize); + assert!(align_of::() == 8usize); + assert!(size_of::() == 56usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(JSXNamespacedName, span) == 0usize); + assert!(offset_of!(JSXNamespacedName, namespace) == 8usize); + assert!(offset_of!(JSXNamespacedName, property) == 32usize); + assert!(size_of::() == 48usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(JSXMemberExpression, span) == 0usize); + assert!(offset_of!(JSXMemberExpression, object) == 8usize); + assert!(offset_of!(JSXMemberExpression, property) == 24usize); + assert!(size_of::() == 16usize); + assert!(align_of::() == 8usize); + assert!(size_of::() == 24usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(JSXExpressionContainer, span) == 0usize); + assert!(offset_of!(JSXExpressionContainer, expression) == 8usize); + assert!(size_of::() == 16usize); + assert!(align_of::() == 8usize); + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(JSXEmptyExpression, span) == 0usize); + assert!(size_of::() == 16usize); + assert!(align_of::() == 8usize); + assert!(size_of::() == 40usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(JSXAttribute, span) == 0usize); + assert!(offset_of!(JSXAttribute, name) == 8usize); + assert!(offset_of!(JSXAttribute, value) == 24usize); + assert!(size_of::() == 24usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(JSXSpreadAttribute, span) == 0usize); + assert!(offset_of!(JSXSpreadAttribute, argument) == 8usize); + assert!(size_of::() == 16usize); + assert!(align_of::() == 8usize); + assert!(size_of::() == 16usize); + assert!(align_of::() == 8usize); + assert!(size_of::() == 24usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(JSXIdentifier, span) == 0usize); + assert!(offset_of!(JSXIdentifier, name) == 8usize); + assert!(size_of::() == 16usize); + assert!(align_of::() == 8usize); + assert!(size_of::() == 24usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(JSXSpreadChild, span) == 0usize); + assert!(offset_of!(JSXSpreadChild, expression) == 8usize); + assert!(size_of::() == 24usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(JSXText, span) == 0usize); + assert!(offset_of!(JSXText, value) == 8usize); +}; + +#[cfg(target_pointer_width = "32")] +const _: () = { + assert!(size_of::() == 12usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(BooleanLiteral, span) == 0usize); + assert!(offset_of!(BooleanLiteral, value) == 8usize); + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(NullLiteral, span) == 0usize); + assert!(size_of::() == 32usize); + assert!(align_of::() == 8usize); + assert!(offset_of!(NumericLiteral, span) == 0usize); + assert!(offset_of!(NumericLiteral, value) == 8usize); + assert!(offset_of!(NumericLiteral, raw) == 16usize); + assert!(offset_of!(NumericLiteral, base) == 32usize); + assert!(size_of::() == 20usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(BigIntLiteral, span) == 0usize); + assert!(offset_of!(BigIntLiteral, raw) == 8usize); + assert!(offset_of!(BigIntLiteral, base) == 24usize); + assert!(size_of::() == 20usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(RegExpLiteral, span) == 0usize); + assert!(offset_of!(RegExpLiteral, value) == 8usize); + assert!(offset_of!(RegExpLiteral, regex) == 8usize); + assert!(size_of::() == 12usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(RegExp, pattern) == 0usize); + assert!(offset_of!(RegExp, flags) == 16usize); + assert!(size_of::() == 0usize); + assert!(align_of::() == 1usize); + assert!(size_of::() == 16usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(StringLiteral, span) == 0usize); + assert!(offset_of!(StringLiteral, value) == 8usize); + assert!(size_of::() == 64usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(Program, span) == 0usize); + assert!(offset_of!(Program, source_type) == 8usize); + assert!(offset_of!(Program, hashbang) == 16usize); + assert!(offset_of!(Program, directives) == 40usize); + assert!(offset_of!(Program, body) == 72usize); + assert!(offset_of!(Program, scope_id) == 104usize); + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + assert!(size_of::() == 16usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(IdentifierName, span) == 0usize); + assert!(offset_of!(IdentifierName, name) == 8usize); + assert!(size_of::() == 24usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(IdentifierReference, span) == 0usize); + assert!(offset_of!(IdentifierReference, name) == 8usize); + assert!(offset_of!(IdentifierReference, reference_id) == 24usize); + assert!(offset_of!(IdentifierReference, reference_flag) == 28usize); + assert!(size_of::() == 20usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(BindingIdentifier, span) == 0usize); + assert!(offset_of!(BindingIdentifier, name) == 8usize); + assert!(offset_of!(BindingIdentifier, symbol_id) == 24usize); + assert!(size_of::() == 16usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(LabelIdentifier, span) == 0usize); + assert!(offset_of!(LabelIdentifier, name) == 8usize); + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(ThisExpression, span) == 0usize); + assert!(size_of::() == 36usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(ArrayExpression, span) == 0usize); + assert!(offset_of!(ArrayExpression, elements) == 8usize); + assert!(offset_of!(ArrayExpression, trailing_comma) == 40usize); + assert!(size_of::() == 12usize); + assert!(align_of::() == 4usize); + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(Elision, span) == 0usize); + assert!(size_of::() == 36usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(ObjectExpression, span) == 0usize); + assert!(offset_of!(ObjectExpression, properties) == 8usize); + assert!(offset_of!(ObjectExpression, trailing_comma) == 40usize); + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + assert!(size_of::() == 40usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(ObjectProperty, span) == 0usize); + assert!(offset_of!(ObjectProperty, kind) == 8usize); + assert!(offset_of!(ObjectProperty, key) == 16usize); + assert!(offset_of!(ObjectProperty, value) == 32usize); + assert!(offset_of!(ObjectProperty, init) == 48usize); + assert!(offset_of!(ObjectProperty, method) == 64usize); + assert!(offset_of!(ObjectProperty, shorthand) == 65usize); + assert!(offset_of!(ObjectProperty, computed) == 66usize); + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + assert!(size_of::() == 1usize); + assert!(align_of::() == 1usize); + assert!(size_of::() == 40usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(TemplateLiteral, span) == 0usize); + assert!(offset_of!(TemplateLiteral, quasis) == 8usize); + assert!(offset_of!(TemplateLiteral, expressions) == 40usize); + assert!(size_of::() == 60usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(TaggedTemplateExpression, span) == 0usize); + assert!(offset_of!(TaggedTemplateExpression, tag) == 8usize); + assert!(offset_of!(TaggedTemplateExpression, quasi) == 24usize); + assert!(offset_of!(TaggedTemplateExpression, type_parameters) == 96usize); + assert!(size_of::() == 28usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(TemplateElement, span) == 0usize); + assert!(offset_of!(TemplateElement, tail) == 8usize); + assert!(offset_of!(TemplateElement, value) == 16usize); + assert!(size_of::() == 16usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(TemplateElementValue, raw) == 0usize); + assert!(offset_of!(TemplateElementValue, cooked) == 16usize); + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + assert!(size_of::() == 28usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(ComputedMemberExpression, span) == 0usize); + assert!(offset_of!(ComputedMemberExpression, object) == 8usize); + assert!(offset_of!(ComputedMemberExpression, expression) == 24usize); + assert!(offset_of!(ComputedMemberExpression, optional) == 40usize); + assert!(size_of::() == 36usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(StaticMemberExpression, span) == 0usize); + assert!(offset_of!(StaticMemberExpression, object) == 8usize); + assert!(offset_of!(StaticMemberExpression, property) == 24usize); + assert!(offset_of!(StaticMemberExpression, optional) == 48usize); + assert!(size_of::() == 36usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(PrivateFieldExpression, span) == 0usize); + assert!(offset_of!(PrivateFieldExpression, object) == 8usize); + assert!(offset_of!(PrivateFieldExpression, field) == 24usize); + assert!(offset_of!(PrivateFieldExpression, optional) == 48usize); + assert!(size_of::() == 40usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(CallExpression, span) == 0usize); + assert!(offset_of!(CallExpression, arguments) == 8usize); + assert!(offset_of!(CallExpression, callee) == 40usize); + assert!(offset_of!(CallExpression, type_parameters) == 56usize); + assert!(offset_of!(CallExpression, optional) == 64usize); + assert!(size_of::() == 36usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(NewExpression, span) == 0usize); + assert!(offset_of!(NewExpression, callee) == 8usize); + assert!(offset_of!(NewExpression, arguments) == 24usize); + assert!(offset_of!(NewExpression, type_parameters) == 56usize); + assert!(size_of::() == 40usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(MetaProperty, span) == 0usize); + assert!(offset_of!(MetaProperty, meta) == 8usize); + assert!(offset_of!(MetaProperty, property) == 32usize); + assert!(size_of::() == 16usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(SpreadElement, span) == 0usize); + assert!(offset_of!(SpreadElement, argument) == 8usize); + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + assert!(size_of::() == 20usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(UpdateExpression, span) == 0usize); + assert!(offset_of!(UpdateExpression, operator) == 8usize); + assert!(offset_of!(UpdateExpression, prefix) == 9usize); + assert!(offset_of!(UpdateExpression, argument) == 16usize); + assert!(size_of::() == 20usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(UnaryExpression, span) == 0usize); + assert!(offset_of!(UnaryExpression, operator) == 8usize); + assert!(offset_of!(UnaryExpression, argument) == 16usize); + assert!(size_of::() == 28usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(BinaryExpression, span) == 0usize); + assert!(offset_of!(BinaryExpression, left) == 8usize); + assert!(offset_of!(BinaryExpression, operator) == 24usize); + assert!(offset_of!(BinaryExpression, right) == 32usize); + assert!(size_of::() == 36usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(PrivateInExpression, span) == 0usize); + assert!(offset_of!(PrivateInExpression, left) == 8usize); + assert!(offset_of!(PrivateInExpression, operator) == 32usize); + assert!(offset_of!(PrivateInExpression, right) == 40usize); + assert!(size_of::() == 28usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(LogicalExpression, span) == 0usize); + assert!(offset_of!(LogicalExpression, left) == 8usize); + assert!(offset_of!(LogicalExpression, operator) == 24usize); + assert!(offset_of!(LogicalExpression, right) == 32usize); + assert!(size_of::() == 32usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(ConditionalExpression, span) == 0usize); + assert!(offset_of!(ConditionalExpression, test) == 8usize); + assert!(offset_of!(ConditionalExpression, consequent) == 24usize); + assert!(offset_of!(ConditionalExpression, alternate) == 40usize); + assert!(size_of::() == 28usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(AssignmentExpression, span) == 0usize); + assert!(offset_of!(AssignmentExpression, operator) == 8usize); + assert!(offset_of!(AssignmentExpression, left) == 16usize); + assert!(offset_of!(AssignmentExpression, right) == 32usize); + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + assert!(size_of::() == 52usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(ArrayAssignmentTarget, span) == 0usize); + assert!(offset_of!(ArrayAssignmentTarget, elements) == 8usize); + assert!(offset_of!(ArrayAssignmentTarget, rest) == 40usize); + assert!(offset_of!(ArrayAssignmentTarget, trailing_comma) == 64usize); + assert!(size_of::() == 40usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(ObjectAssignmentTarget, span) == 0usize); + assert!(offset_of!(ObjectAssignmentTarget, properties) == 8usize); + assert!(offset_of!(ObjectAssignmentTarget, rest) == 40usize); + assert!(size_of::() == 16usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(AssignmentTargetRest, span) == 0usize); + assert!(offset_of!(AssignmentTargetRest, target) == 8usize); + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + assert!(size_of::() == 24usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(AssignmentTargetWithDefault, span) == 0usize); + assert!(offset_of!(AssignmentTargetWithDefault, binding) == 8usize); + assert!(offset_of!(AssignmentTargetWithDefault, init) == 24usize); + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + assert!(size_of::() == 40usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(AssignmentTargetPropertyIdentifier, span) == 0usize); + assert!(offset_of!(AssignmentTargetPropertyIdentifier, binding) == 8usize); + assert!(offset_of!(AssignmentTargetPropertyIdentifier, init) == 40usize); + assert!(size_of::() == 24usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(AssignmentTargetPropertyProperty, span) == 0usize); + assert!(offset_of!(AssignmentTargetPropertyProperty, name) == 8usize); + assert!(offset_of!(AssignmentTargetPropertyProperty, binding) == 24usize); + assert!(size_of::() == 24usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(SequenceExpression, span) == 0usize); + assert!(offset_of!(SequenceExpression, expressions) == 8usize); + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(Super, span) == 0usize); + assert!(size_of::() == 16usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(AwaitExpression, span) == 0usize); + assert!(offset_of!(AwaitExpression, argument) == 8usize); + assert!(size_of::() == 16usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(ChainExpression, span) == 0usize); + assert!(offset_of!(ChainExpression, expression) == 8usize); + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + assert!(size_of::() == 16usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(ParenthesizedExpression, span) == 0usize); + assert!(offset_of!(ParenthesizedExpression, expression) == 8usize); + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + assert!(size_of::() == 32usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(Directive, span) == 0usize); + assert!(offset_of!(Directive, expression) == 8usize); + assert!(offset_of!(Directive, directive) == 32usize); + assert!(size_of::() == 16usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(Hashbang, span) == 0usize); + assert!(offset_of!(Hashbang, value) == 8usize); + assert!(size_of::() == 28usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(BlockStatement, span) == 0usize); + assert!(offset_of!(BlockStatement, body) == 8usize); + assert!(offset_of!(BlockStatement, scope_id) == 40usize); + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + assert!(size_of::() == 32usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(VariableDeclaration, span) == 0usize); + assert!(offset_of!(VariableDeclaration, kind) == 8usize); + assert!(offset_of!(VariableDeclaration, declarations) == 16usize); + assert!(offset_of!(VariableDeclaration, declare) == 48usize); + assert!(size_of::() == 1usize); + assert!(align_of::() == 1usize); + assert!(size_of::() == 40usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(VariableDeclarator, span) == 0usize); + assert!(offset_of!(VariableDeclarator, kind) == 8usize); + assert!(offset_of!(VariableDeclarator, id) == 16usize); + assert!(offset_of!(VariableDeclarator, init) == 48usize); + assert!(offset_of!(VariableDeclarator, definite) == 64usize); + assert!(size_of::() == 28usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(UsingDeclaration, span) == 0usize); + assert!(offset_of!(UsingDeclaration, is_await) == 8usize); + assert!(offset_of!(UsingDeclaration, declarations) == 16usize); + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(EmptyStatement, span) == 0usize); + assert!(size_of::() == 16usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(ExpressionStatement, span) == 0usize); + assert!(offset_of!(ExpressionStatement, expression) == 8usize); + assert!(size_of::() == 32usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(IfStatement, span) == 0usize); + assert!(offset_of!(IfStatement, test) == 8usize); + assert!(offset_of!(IfStatement, consequent) == 24usize); + assert!(offset_of!(IfStatement, alternate) == 40usize); + assert!(size_of::() == 24usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(DoWhileStatement, span) == 0usize); + assert!(offset_of!(DoWhileStatement, body) == 8usize); + assert!(offset_of!(DoWhileStatement, test) == 24usize); + assert!(size_of::() == 24usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(WhileStatement, span) == 0usize); + assert!(offset_of!(WhileStatement, test) == 8usize); + assert!(offset_of!(WhileStatement, body) == 24usize); + assert!(size_of::() == 44usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(ForStatement, span) == 0usize); + assert!(offset_of!(ForStatement, init) == 8usize); + assert!(offset_of!(ForStatement, test) == 24usize); + assert!(offset_of!(ForStatement, update) == 40usize); + assert!(offset_of!(ForStatement, body) == 56usize); + assert!(offset_of!(ForStatement, scope_id) == 72usize); + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + assert!(size_of::() == 36usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(ForInStatement, span) == 0usize); + assert!(offset_of!(ForInStatement, left) == 8usize); + assert!(offset_of!(ForInStatement, right) == 24usize); + assert!(offset_of!(ForInStatement, body) == 40usize); + assert!(offset_of!(ForInStatement, scope_id) == 56usize); + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + assert!(size_of::() == 40usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(ForOfStatement, span) == 0usize); + assert!(offset_of!(ForOfStatement, r#await) == 8usize); + assert!(offset_of!(ForOfStatement, left) == 16usize); + assert!(offset_of!(ForOfStatement, right) == 32usize); + assert!(offset_of!(ForOfStatement, body) == 48usize); + assert!(offset_of!(ForOfStatement, scope_id) == 64usize); + assert!(size_of::() == 24usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(ContinueStatement, span) == 0usize); + assert!(offset_of!(ContinueStatement, label) == 8usize); + assert!(size_of::() == 24usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(BreakStatement, span) == 0usize); + assert!(offset_of!(BreakStatement, label) == 8usize); + assert!(size_of::() == 16usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(ReturnStatement, span) == 0usize); + assert!(offset_of!(ReturnStatement, argument) == 8usize); + assert!(size_of::() == 24usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(WithStatement, span) == 0usize); + assert!(offset_of!(WithStatement, object) == 8usize); + assert!(offset_of!(WithStatement, body) == 24usize); + assert!(size_of::() == 36usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(SwitchStatement, span) == 0usize); + assert!(offset_of!(SwitchStatement, discriminant) == 8usize); + assert!(offset_of!(SwitchStatement, cases) == 24usize); + assert!(offset_of!(SwitchStatement, scope_id) == 56usize); + assert!(size_of::() == 32usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(SwitchCase, span) == 0usize); + assert!(offset_of!(SwitchCase, test) == 8usize); + assert!(offset_of!(SwitchCase, consequent) == 24usize); + assert!(size_of::() == 32usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(LabeledStatement, span) == 0usize); + assert!(offset_of!(LabeledStatement, label) == 8usize); + assert!(offset_of!(LabeledStatement, body) == 32usize); + assert!(size_of::() == 16usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(ThrowStatement, span) == 0usize); + assert!(offset_of!(ThrowStatement, argument) == 8usize); + assert!(size_of::() == 20usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(TryStatement, span) == 0usize); + assert!(offset_of!(TryStatement, block) == 8usize); + assert!(offset_of!(TryStatement, handler) == 16usize); + assert!(offset_of!(TryStatement, finalizer) == 24usize); + assert!(size_of::() == 40usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(CatchClause, span) == 0usize); + assert!(offset_of!(CatchClause, param) == 8usize); + assert!(offset_of!(CatchClause, body) == 48usize); + assert!(offset_of!(CatchClause, scope_id) == 56usize); + assert!(size_of::() == 24usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(CatchParameter, span) == 0usize); + assert!(offset_of!(CatchParameter, pattern) == 8usize); + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(DebuggerStatement, span) == 0usize); + assert!(size_of::() == 16usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(BindingPattern, kind) == 0usize); + assert!(offset_of!(BindingPattern, type_annotation) == 16usize); + assert!(offset_of!(BindingPattern, optional) == 24usize); + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + assert!(size_of::() == 32usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(AssignmentPattern, span) == 0usize); + assert!(offset_of!(AssignmentPattern, left) == 8usize); + assert!(offset_of!(AssignmentPattern, right) == 40usize); + assert!(size_of::() == 28usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(ObjectPattern, span) == 0usize); + assert!(offset_of!(ObjectPattern, properties) == 8usize); + assert!(offset_of!(ObjectPattern, rest) == 40usize); + assert!(size_of::() == 36usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(BindingProperty, span) == 0usize); + assert!(offset_of!(BindingProperty, key) == 8usize); + assert!(offset_of!(BindingProperty, value) == 24usize); + assert!(offset_of!(BindingProperty, shorthand) == 56usize); + assert!(offset_of!(BindingProperty, computed) == 57usize); + assert!(size_of::() == 28usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(ArrayPattern, span) == 0usize); + assert!(offset_of!(ArrayPattern, elements) == 8usize); + assert!(offset_of!(ArrayPattern, rest) == 40usize); + assert!(size_of::() == 24usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(BindingRestElement, span) == 0usize); + assert!(offset_of!(BindingRestElement, argument) == 8usize); + assert!(size_of::() == 84usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(Function, r#type) == 0usize); + assert!(offset_of!(Function, span) == 4usize); + assert!(offset_of!(Function, id) == 16usize); + assert!(offset_of!(Function, generator) == 48usize); + assert!(offset_of!(Function, r#async) == 49usize); + assert!(offset_of!(Function, declare) == 50usize); + assert!(offset_of!(Function, type_parameters) == 56usize); + assert!(offset_of!(Function, this_param) == 64usize); + assert!(offset_of!(Function, params) == 104usize); + assert!(offset_of!(Function, return_type) == 112usize); + assert!(offset_of!(Function, body) == 120usize); + assert!(offset_of!(Function, scope_id) == 128usize); + assert!(size_of::() == 1usize); + assert!(align_of::() == 1usize); + assert!(size_of::() == 32usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(FormalParameters, span) == 0usize); + assert!(offset_of!(FormalParameters, kind) == 8usize); + assert!(offset_of!(FormalParameters, items) == 16usize); + assert!(offset_of!(FormalParameters, rest) == 48usize); + assert!(size_of::() == 44usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(FormalParameter, span) == 0usize); + assert!(offset_of!(FormalParameter, decorators) == 8usize); + assert!(offset_of!(FormalParameter, pattern) == 40usize); + assert!(offset_of!(FormalParameter, accessibility) == 72usize); + assert!(offset_of!(FormalParameter, readonly) == 73usize); + assert!(offset_of!(FormalParameter, r#override) == 74usize); + assert!(size_of::() == 1usize); + assert!(align_of::() == 1usize); + assert!(size_of::() == 40usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(FunctionBody, span) == 0usize); + assert!(offset_of!(FunctionBody, directives) == 8usize); + assert!(offset_of!(FunctionBody, statements) == 40usize); + assert!(size_of::() == 32usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(ArrowFunctionExpression, span) == 0usize); + assert!(offset_of!(ArrowFunctionExpression, expression) == 8usize); + assert!(offset_of!(ArrowFunctionExpression, r#async) == 9usize); + assert!(offset_of!(ArrowFunctionExpression, type_parameters) == 16usize); + assert!(offset_of!(ArrowFunctionExpression, params) == 24usize); + assert!(offset_of!(ArrowFunctionExpression, return_type) == 32usize); + assert!(offset_of!(ArrowFunctionExpression, body) == 40usize); + assert!(offset_of!(ArrowFunctionExpression, scope_id) == 48usize); + assert!(size_of::() == 20usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(YieldExpression, span) == 0usize); + assert!(offset_of!(YieldExpression, delegate) == 8usize); + assert!(offset_of!(YieldExpression, argument) == 16usize); + assert!(size_of::() == 92usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(Class, r#type) == 0usize); + assert!(offset_of!(Class, span) == 4usize); + assert!(offset_of!(Class, decorators) == 16usize); + assert!(offset_of!(Class, id) == 48usize); + assert!(offset_of!(Class, type_parameters) == 80usize); + assert!(offset_of!(Class, super_class) == 88usize); + assert!(offset_of!(Class, super_type_parameters) == 104usize); + assert!(offset_of!(Class, implements) == 112usize); + assert!(offset_of!(Class, body) == 144usize); + assert!(offset_of!(Class, r#abstract) == 152usize); + assert!(offset_of!(Class, declare) == 153usize); + assert!(offset_of!(Class, scope_id) == 156usize); + assert!(size_of::() == 1usize); + assert!(align_of::() == 1usize); + assert!(size_of::() == 24usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(ClassBody, span) == 0usize); + assert!(offset_of!(ClassBody, body) == 8usize); + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + assert!(size_of::() == 48usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(MethodDefinition, r#type) == 0usize); + assert!(offset_of!(MethodDefinition, span) == 4usize); + assert!(offset_of!(MethodDefinition, decorators) == 16usize); + assert!(offset_of!(MethodDefinition, key) == 48usize); + assert!(offset_of!(MethodDefinition, value) == 64usize); + assert!(offset_of!(MethodDefinition, kind) == 72usize); + assert!(offset_of!(MethodDefinition, computed) == 73usize); + assert!(offset_of!(MethodDefinition, r#static) == 74usize); + assert!(offset_of!(MethodDefinition, r#override) == 75usize); + assert!(offset_of!(MethodDefinition, optional) == 76usize); + assert!(offset_of!(MethodDefinition, accessibility) == 77usize); + assert!(size_of::() == 1usize); + assert!(align_of::() == 1usize); + assert!(size_of::() == 60usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(PropertyDefinition, r#type) == 0usize); + assert!(offset_of!(PropertyDefinition, span) == 4usize); + assert!(offset_of!(PropertyDefinition, decorators) == 16usize); + assert!(offset_of!(PropertyDefinition, key) == 48usize); + assert!(offset_of!(PropertyDefinition, value) == 64usize); + assert!(offset_of!(PropertyDefinition, computed) == 80usize); + assert!(offset_of!(PropertyDefinition, r#static) == 81usize); + assert!(offset_of!(PropertyDefinition, declare) == 82usize); + assert!(offset_of!(PropertyDefinition, r#override) == 83usize); + assert!(offset_of!(PropertyDefinition, optional) == 84usize); + assert!(offset_of!(PropertyDefinition, definite) == 85usize); + assert!(offset_of!(PropertyDefinition, readonly) == 86usize); + assert!(offset_of!(PropertyDefinition, type_annotation) == 88usize); + assert!(offset_of!(PropertyDefinition, accessibility) == 96usize); + assert!(size_of::() == 1usize); + assert!(align_of::() == 1usize); + assert!(size_of::() == 1usize); + assert!(align_of::() == 1usize); + assert!(size_of::() == 16usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(PrivateIdentifier, span) == 0usize); + assert!(offset_of!(PrivateIdentifier, name) == 8usize); + assert!(size_of::() == 28usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(StaticBlock, span) == 0usize); + assert!(offset_of!(StaticBlock, body) == 8usize); + assert!(offset_of!(StaticBlock, scope_id) == 40usize); + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + assert!(size_of::() == 1usize); + assert!(align_of::() == 1usize); + assert!(size_of::() == 48usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(AccessorProperty, r#type) == 0usize); + assert!(offset_of!(AccessorProperty, span) == 4usize); + assert!(offset_of!(AccessorProperty, decorators) == 16usize); + assert!(offset_of!(AccessorProperty, key) == 48usize); + assert!(offset_of!(AccessorProperty, value) == 64usize); + assert!(offset_of!(AccessorProperty, computed) == 80usize); + assert!(offset_of!(AccessorProperty, r#static) == 81usize); + assert!(size_of::() == 32usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(ImportExpression, span) == 0usize); + assert!(offset_of!(ImportExpression, source) == 8usize); + assert!(offset_of!(ImportExpression, arguments) == 24usize); + assert!(size_of::() == 84usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(ImportDeclaration, span) == 0usize); + assert!(offset_of!(ImportDeclaration, specifiers) == 8usize); + assert!(offset_of!(ImportDeclaration, source) == 40usize); + assert!(offset_of!(ImportDeclaration, with_clause) == 64usize); + assert!(offset_of!(ImportDeclaration, import_kind) == 128usize); + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + assert!(size_of::() == 60usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(ImportSpecifier, span) == 0usize); + assert!(offset_of!(ImportSpecifier, imported) == 8usize); + assert!(offset_of!(ImportSpecifier, local) == 48usize); + assert!(offset_of!(ImportSpecifier, import_kind) == 80usize); + assert!(size_of::() == 28usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(ImportDefaultSpecifier, span) == 0usize); + assert!(offset_of!(ImportDefaultSpecifier, local) == 8usize); + assert!(size_of::() == 28usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(ImportNamespaceSpecifier, span) == 0usize); + assert!(offset_of!(ImportNamespaceSpecifier, local) == 8usize); + assert!(size_of::() == 40usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(WithClause, span) == 0usize); + assert!(offset_of!(WithClause, attributes_keyword) == 8usize); + assert!(offset_of!(WithClause, with_entries) == 32usize); + assert!(size_of::() == 44usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(ImportAttribute, span) == 0usize); + assert!(offset_of!(ImportAttribute, key) == 8usize); + assert!(offset_of!(ImportAttribute, value) == 40usize); + assert!(size_of::() == 20usize); + assert!(align_of::() == 4usize); + assert!(size_of::() == 92usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(ExportNamedDeclaration, span) == 0usize); + assert!(offset_of!(ExportNamedDeclaration, declaration) == 8usize); + assert!(offset_of!(ExportNamedDeclaration, specifiers) == 24usize); + assert!(offset_of!(ExportNamedDeclaration, source) == 56usize); + assert!(offset_of!(ExportNamedDeclaration, export_kind) == 80usize); + assert!(offset_of!(ExportNamedDeclaration, with_clause) == 88usize); + assert!(size_of::() == 44usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(ExportDefaultDeclaration, span) == 0usize); + assert!(offset_of!(ExportDefaultDeclaration, declaration) == 8usize); + assert!(offset_of!(ExportDefaultDeclaration, exported) == 24usize); + assert!(size_of::() == 96usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(ExportAllDeclaration, span) == 0usize); + assert!(offset_of!(ExportAllDeclaration, exported) == 8usize); + assert!(offset_of!(ExportAllDeclaration, source) == 48usize); + assert!(offset_of!(ExportAllDeclaration, with_clause) == 72usize); + assert!(offset_of!(ExportAllDeclaration, export_kind) == 136usize); + assert!(size_of::() == 68usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(ExportSpecifier, span) == 0usize); + assert!(offset_of!(ExportSpecifier, local) == 8usize); + assert!(offset_of!(ExportSpecifier, exported) == 48usize); + assert!(offset_of!(ExportSpecifier, export_kind) == 88usize); + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + assert!(size_of::() == 28usize); + assert!(align_of::() == 4usize); + assert!(size_of::() == 28usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(TSThisParameter, span) == 0usize); + assert!(offset_of!(TSThisParameter, this) == 8usize); + assert!(offset_of!(TSThisParameter, type_annotation) == 32usize); + assert!(size_of::() == 52usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(TSEnumDeclaration, span) == 0usize); + assert!(offset_of!(TSEnumDeclaration, id) == 8usize); + assert!(offset_of!(TSEnumDeclaration, members) == 40usize); + assert!(offset_of!(TSEnumDeclaration, r#const) == 72usize); + assert!(offset_of!(TSEnumDeclaration, declare) == 73usize); + assert!(offset_of!(TSEnumDeclaration, scope_id) == 76usize); + assert!(size_of::() == 24usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(TSEnumMember, span) == 0usize); + assert!(offset_of!(TSEnumMember, id) == 8usize); + assert!(offset_of!(TSEnumMember, initializer) == 24usize); + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + assert!(size_of::() == 16usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(TSTypeAnnotation, span) == 0usize); + assert!(offset_of!(TSTypeAnnotation, type_annotation) == 8usize); + assert!(size_of::() == 16usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(TSLiteralType, span) == 0usize); + assert!(offset_of!(TSLiteralType, literal) == 8usize); + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + assert!(size_of::() == 44usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(TSConditionalType, span) == 0usize); + assert!(offset_of!(TSConditionalType, check_type) == 8usize); + assert!(offset_of!(TSConditionalType, extends_type) == 24usize); + assert!(offset_of!(TSConditionalType, true_type) == 40usize); + assert!(offset_of!(TSConditionalType, false_type) == 56usize); + assert!(offset_of!(TSConditionalType, scope_id) == 72usize); + assert!(size_of::() == 24usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(TSUnionType, span) == 0usize); + assert!(offset_of!(TSUnionType, types) == 8usize); + assert!(size_of::() == 24usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(TSIntersectionType, span) == 0usize); + assert!(offset_of!(TSIntersectionType, types) == 8usize); + assert!(size_of::() == 16usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(TSParenthesizedType, span) == 0usize); + assert!(offset_of!(TSParenthesizedType, type_annotation) == 8usize); + assert!(size_of::() == 20usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(TSTypeOperator, span) == 0usize); + assert!(offset_of!(TSTypeOperator, operator) == 8usize); + assert!(offset_of!(TSTypeOperator, type_annotation) == 16usize); + assert!(size_of::() == 1usize); + assert!(align_of::() == 1usize); + assert!(size_of::() == 16usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(TSArrayType, span) == 0usize); + assert!(offset_of!(TSArrayType, element_type) == 8usize); + assert!(size_of::() == 24usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(TSIndexedAccessType, span) == 0usize); + assert!(offset_of!(TSIndexedAccessType, object_type) == 8usize); + assert!(offset_of!(TSIndexedAccessType, index_type) == 24usize); + assert!(size_of::() == 24usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(TSTupleType, span) == 0usize); + assert!(offset_of!(TSTupleType, element_types) == 8usize); + assert!(size_of::() == 36usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(TSNamedTupleMember, span) == 0usize); + assert!(offset_of!(TSNamedTupleMember, element_type) == 8usize); + assert!(offset_of!(TSNamedTupleMember, label) == 24usize); + assert!(offset_of!(TSNamedTupleMember, optional) == 48usize); + assert!(size_of::() == 16usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(TSOptionalType, span) == 0usize); + assert!(offset_of!(TSOptionalType, type_annotation) == 8usize); + assert!(size_of::() == 16usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(TSRestType, span) == 0usize); + assert!(offset_of!(TSRestType, type_annotation) == 8usize); + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(TSAnyKeyword, span) == 0usize); + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(TSStringKeyword, span) == 0usize); + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(TSBooleanKeyword, span) == 0usize); + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(TSNumberKeyword, span) == 0usize); + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(TSNeverKeyword, span) == 0usize); + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(TSIntrinsicKeyword, span) == 0usize); + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(TSUnknownKeyword, span) == 0usize); + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(TSNullKeyword, span) == 0usize); + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(TSUndefinedKeyword, span) == 0usize); + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(TSVoidKeyword, span) == 0usize); + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(TSSymbolKeyword, span) == 0usize); + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(TSThisType, span) == 0usize); + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(TSObjectKeyword, span) == 0usize); + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(TSBigIntKeyword, span) == 0usize); + assert!(size_of::() == 20usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(TSTypeReference, span) == 0usize); + assert!(offset_of!(TSTypeReference, type_name) == 8usize); + assert!(offset_of!(TSTypeReference, type_parameters) == 24usize); + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + assert!(size_of::() == 32usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(TSQualifiedName, span) == 0usize); + assert!(offset_of!(TSQualifiedName, left) == 8usize); + assert!(offset_of!(TSQualifiedName, right) == 24usize); + assert!(size_of::() == 24usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(TSTypeParameterInstantiation, span) == 0usize); + assert!(offset_of!(TSTypeParameterInstantiation, params) == 8usize); + assert!(size_of::() == 48usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(TSTypeParameter, span) == 0usize); + assert!(offset_of!(TSTypeParameter, name) == 8usize); + assert!(offset_of!(TSTypeParameter, constraint) == 40usize); + assert!(offset_of!(TSTypeParameter, default) == 56usize); + assert!(offset_of!(TSTypeParameter, r#in) == 72usize); + assert!(offset_of!(TSTypeParameter, out) == 73usize); + assert!(offset_of!(TSTypeParameter, r#const) == 74usize); + assert!(size_of::() == 24usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(TSTypeParameterDeclaration, span) == 0usize); + assert!(offset_of!(TSTypeParameterDeclaration, params) == 8usize); + assert!(size_of::() == 48usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(TSTypeAliasDeclaration, span) == 0usize); + assert!(offset_of!(TSTypeAliasDeclaration, id) == 8usize); + assert!(offset_of!(TSTypeAliasDeclaration, type_parameters) == 40usize); + assert!(offset_of!(TSTypeAliasDeclaration, type_annotation) == 48usize); + assert!(offset_of!(TSTypeAliasDeclaration, declare) == 64usize); + assert!(offset_of!(TSTypeAliasDeclaration, scope_id) == 68usize); + assert!(size_of::() == 1usize); + assert!(align_of::() == 1usize); + assert!(size_of::() == 20usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(TSClassImplements, span) == 0usize); + assert!(offset_of!(TSClassImplements, expression) == 8usize); + assert!(offset_of!(TSClassImplements, type_parameters) == 24usize); + assert!(size_of::() == 60usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(TSInterfaceDeclaration, span) == 0usize); + assert!(offset_of!(TSInterfaceDeclaration, id) == 8usize); + assert!(offset_of!(TSInterfaceDeclaration, extends) == 40usize); + assert!(offset_of!(TSInterfaceDeclaration, type_parameters) == 72usize); + assert!(offset_of!(TSInterfaceDeclaration, body) == 80usize); + assert!(offset_of!(TSInterfaceDeclaration, declare) == 88usize); + assert!(offset_of!(TSInterfaceDeclaration, scope_id) == 92usize); + assert!(size_of::() == 24usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(TSInterfaceBody, span) == 0usize); + assert!(offset_of!(TSInterfaceBody, body) == 8usize); + assert!(size_of::() == 24usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(TSPropertySignature, span) == 0usize); + assert!(offset_of!(TSPropertySignature, computed) == 8usize); + assert!(offset_of!(TSPropertySignature, optional) == 9usize); + assert!(offset_of!(TSPropertySignature, readonly) == 10usize); + assert!(offset_of!(TSPropertySignature, key) == 16usize); + assert!(offset_of!(TSPropertySignature, type_annotation) == 32usize); + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + assert!(size_of::() == 32usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(TSIndexSignature, span) == 0usize); + assert!(offset_of!(TSIndexSignature, parameters) == 8usize); + assert!(offset_of!(TSIndexSignature, type_annotation) == 40usize); + assert!(offset_of!(TSIndexSignature, readonly) == 48usize); + assert!(size_of::() == 48usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(TSCallSignatureDeclaration, span) == 0usize); + assert!(offset_of!(TSCallSignatureDeclaration, this_param) == 8usize); + assert!(offset_of!(TSCallSignatureDeclaration, params) == 48usize); + assert!(offset_of!(TSCallSignatureDeclaration, return_type) == 56usize); + assert!(offset_of!(TSCallSignatureDeclaration, type_parameters) == 64usize); + assert!(size_of::() == 1usize); + assert!(align_of::() == 1usize); + assert!(size_of::() == 64usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(TSMethodSignature, span) == 0usize); + assert!(offset_of!(TSMethodSignature, key) == 8usize); + assert!(offset_of!(TSMethodSignature, computed) == 24usize); + assert!(offset_of!(TSMethodSignature, optional) == 25usize); + assert!(offset_of!(TSMethodSignature, kind) == 26usize); + assert!(offset_of!(TSMethodSignature, this_param) == 32usize); + assert!(offset_of!(TSMethodSignature, params) == 72usize); + assert!(offset_of!(TSMethodSignature, return_type) == 80usize); + assert!(offset_of!(TSMethodSignature, type_parameters) == 88usize); + assert!(offset_of!(TSMethodSignature, scope_id) == 96usize); + assert!(size_of::() == 24usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(TSConstructSignatureDeclaration, span) == 0usize); + assert!(offset_of!(TSConstructSignatureDeclaration, params) == 8usize); + assert!(offset_of!(TSConstructSignatureDeclaration, return_type) == 16usize); + assert!(offset_of!(TSConstructSignatureDeclaration, type_parameters) == 24usize); + assert!(offset_of!(TSConstructSignatureDeclaration, scope_id) == 32usize); + assert!(size_of::() == 20usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(TSIndexSignatureName, span) == 0usize); + assert!(offset_of!(TSIndexSignatureName, name) == 8usize); + assert!(offset_of!(TSIndexSignatureName, type_annotation) == 24usize); + assert!(size_of::() == 20usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(TSInterfaceHeritage, span) == 0usize); + assert!(offset_of!(TSInterfaceHeritage, expression) == 8usize); + assert!(offset_of!(TSInterfaceHeritage, type_parameters) == 24usize); + assert!(size_of::() == 28usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(TSTypePredicate, span) == 0usize); + assert!(offset_of!(TSTypePredicate, parameter_name) == 8usize); + assert!(offset_of!(TSTypePredicate, asserts) == 24usize); + assert!(offset_of!(TSTypePredicate, type_annotation) == 32usize); + assert!(size_of::() == 12usize); + assert!(align_of::() == 4usize); + assert!(size_of::() == 44usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(TSModuleDeclaration, span) == 0usize); + assert!(offset_of!(TSModuleDeclaration, id) == 8usize); + assert!(offset_of!(TSModuleDeclaration, body) == 40usize); + assert!(offset_of!(TSModuleDeclaration, kind) == 56usize); + assert!(offset_of!(TSModuleDeclaration, declare) == 57usize); + assert!(offset_of!(TSModuleDeclaration, scope_id) == 60usize); + assert!(size_of::() == 1usize); + assert!(align_of::() == 1usize); + assert!(size_of::() == 20usize); + assert!(align_of::() == 4usize); + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + assert!(size_of::() == 40usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(TSModuleBlock, span) == 0usize); + assert!(offset_of!(TSModuleBlock, directives) == 8usize); + assert!(offset_of!(TSModuleBlock, body) == 40usize); + assert!(size_of::() == 24usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(TSTypeLiteral, span) == 0usize); + assert!(offset_of!(TSTypeLiteral, members) == 8usize); + assert!(size_of::() == 12usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(TSInferType, span) == 0usize); + assert!(offset_of!(TSInferType, type_parameter) == 8usize); + assert!(size_of::() == 20usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(TSTypeQuery, span) == 0usize); + assert!(offset_of!(TSTypeQuery, expr_name) == 8usize); + assert!(offset_of!(TSTypeQuery, type_parameters) == 24usize); + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + assert!(size_of::() == 56usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(TSImportType, span) == 0usize); + assert!(offset_of!(TSImportType, is_type_of) == 8usize); + assert!(offset_of!(TSImportType, parameter) == 16usize); + assert!(offset_of!(TSImportType, qualifier) == 32usize); + assert!(offset_of!(TSImportType, attributes) == 48usize); + assert!(offset_of!(TSImportType, type_parameters) == 88usize); + assert!(size_of::() == 24usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(TSImportAttributes, span) == 0usize); + assert!(offset_of!(TSImportAttributes, elements) == 8usize); + assert!(size_of::() == 36usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(TSImportAttribute, span) == 0usize); + assert!(offset_of!(TSImportAttribute, name) == 8usize); + assert!(offset_of!(TSImportAttribute, value) == 40usize); + assert!(size_of::() == 20usize); + assert!(align_of::() == 4usize); + assert!(size_of::() == 48usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(TSFunctionType, span) == 0usize); + assert!(offset_of!(TSFunctionType, this_param) == 8usize); + assert!(offset_of!(TSFunctionType, params) == 48usize); + assert!(offset_of!(TSFunctionType, return_type) == 56usize); + assert!(offset_of!(TSFunctionType, type_parameters) == 64usize); + assert!(size_of::() == 24usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(TSConstructorType, span) == 0usize); + assert!(offset_of!(TSConstructorType, r#abstract) == 8usize); + assert!(offset_of!(TSConstructorType, params) == 16usize); + assert!(offset_of!(TSConstructorType, return_type) == 24usize); + assert!(offset_of!(TSConstructorType, type_parameters) == 32usize); + assert!(size_of::() == 36usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(TSMappedType, span) == 0usize); + assert!(offset_of!(TSMappedType, type_parameter) == 8usize); + assert!(offset_of!(TSMappedType, name_type) == 16usize); + assert!(offset_of!(TSMappedType, type_annotation) == 32usize); + assert!(offset_of!(TSMappedType, optional) == 48usize); + assert!(offset_of!(TSMappedType, readonly) == 49usize); + assert!(offset_of!(TSMappedType, scope_id) == 52usize); + assert!(size_of::() == 1usize); + assert!(align_of::() == 1usize); + assert!(size_of::() == 40usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(TSTemplateLiteralType, span) == 0usize); + assert!(offset_of!(TSTemplateLiteralType, quasis) == 8usize); + assert!(offset_of!(TSTemplateLiteralType, types) == 40usize); + assert!(size_of::() == 24usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(TSAsExpression, span) == 0usize); + assert!(offset_of!(TSAsExpression, expression) == 8usize); + assert!(offset_of!(TSAsExpression, type_annotation) == 24usize); + assert!(size_of::() == 24usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(TSSatisfiesExpression, span) == 0usize); + assert!(offset_of!(TSSatisfiesExpression, expression) == 8usize); + assert!(offset_of!(TSSatisfiesExpression, type_annotation) == 24usize); + assert!(size_of::() == 24usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(TSTypeAssertion, span) == 0usize); + assert!(offset_of!(TSTypeAssertion, expression) == 8usize); + assert!(offset_of!(TSTypeAssertion, type_annotation) == 24usize); + assert!(size_of::() == 40usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(TSImportEqualsDeclaration, span) == 0usize); + assert!(offset_of!(TSImportEqualsDeclaration, id) == 8usize); + assert!(offset_of!(TSImportEqualsDeclaration, module_reference) == 40usize); + assert!(offset_of!(TSImportEqualsDeclaration, import_kind) == 56usize); + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + assert!(size_of::() == 24usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(TSExternalModuleReference, span) == 0usize); + assert!(offset_of!(TSExternalModuleReference, expression) == 8usize); + assert!(size_of::() == 16usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(TSNonNullExpression, span) == 0usize); + assert!(offset_of!(TSNonNullExpression, expression) == 8usize); + assert!(size_of::() == 16usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(Decorator, span) == 0usize); + assert!(offset_of!(Decorator, expression) == 8usize); + assert!(size_of::() == 16usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(TSExportAssignment, span) == 0usize); + assert!(offset_of!(TSExportAssignment, expression) == 8usize); + assert!(size_of::() == 24usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(TSNamespaceExportDeclaration, span) == 0usize); + assert!(offset_of!(TSNamespaceExportDeclaration, id) == 8usize); + assert!(size_of::() == 20usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(TSInstantiationExpression, span) == 0usize); + assert!(offset_of!(TSInstantiationExpression, expression) == 8usize); + assert!(offset_of!(TSInstantiationExpression, type_parameters) == 24usize); + assert!(size_of::() == 1usize); + assert!(align_of::() == 1usize); + assert!(size_of::() == 20usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(JSDocNullableType, span) == 0usize); + assert!(offset_of!(JSDocNullableType, type_annotation) == 8usize); + assert!(offset_of!(JSDocNullableType, postfix) == 24usize); + assert!(size_of::() == 20usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(JSDocNonNullableType, span) == 0usize); + assert!(offset_of!(JSDocNonNullableType, type_annotation) == 8usize); + assert!(offset_of!(JSDocNonNullableType, postfix) == 24usize); + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(JSDocUnknownType, span) == 0usize); + assert!(size_of::() == 32usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(JSXElement, span) == 0usize); + assert!(offset_of!(JSXElement, opening_element) == 8usize); + assert!(offset_of!(JSXElement, closing_element) == 16usize); + assert!(offset_of!(JSXElement, children) == 24usize); + assert!(size_of::() == 40usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(JSXOpeningElement, span) == 0usize); + assert!(offset_of!(JSXOpeningElement, self_closing) == 8usize); + assert!(offset_of!(JSXOpeningElement, name) == 16usize); + assert!(offset_of!(JSXOpeningElement, attributes) == 32usize); + assert!(offset_of!(JSXOpeningElement, type_parameters) == 64usize); + assert!(size_of::() == 16usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(JSXClosingElement, span) == 0usize); + assert!(offset_of!(JSXClosingElement, name) == 8usize); + assert!(size_of::() == 40usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(JSXFragment, span) == 0usize); + assert!(offset_of!(JSXFragment, opening_fragment) == 8usize); + assert!(offset_of!(JSXFragment, closing_fragment) == 16usize); + assert!(offset_of!(JSXFragment, children) == 24usize); + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(JSXOpeningFragment, span) == 0usize); + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(JSXClosingFragment, span) == 0usize); + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + assert!(size_of::() == 40usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(JSXNamespacedName, span) == 0usize); + assert!(offset_of!(JSXNamespacedName, namespace) == 8usize); + assert!(offset_of!(JSXNamespacedName, property) == 32usize); + assert!(size_of::() == 32usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(JSXMemberExpression, span) == 0usize); + assert!(offset_of!(JSXMemberExpression, object) == 8usize); + assert!(offset_of!(JSXMemberExpression, property) == 24usize); + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + assert!(size_of::() == 20usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(JSXExpressionContainer, span) == 0usize); + assert!(offset_of!(JSXExpressionContainer, expression) == 8usize); + assert!(size_of::() == 12usize); + assert!(align_of::() == 4usize); + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(JSXEmptyExpression, span) == 0usize); + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + assert!(size_of::() == 24usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(JSXAttribute, span) == 0usize); + assert!(offset_of!(JSXAttribute, name) == 8usize); + assert!(offset_of!(JSXAttribute, value) == 24usize); + assert!(size_of::() == 16usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(JSXSpreadAttribute, span) == 0usize); + assert!(offset_of!(JSXSpreadAttribute, argument) == 8usize); + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + assert!(size_of::() == 16usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(JSXIdentifier, span) == 0usize); + assert!(offset_of!(JSXIdentifier, name) == 8usize); + assert!(size_of::() == 8usize); + assert!(align_of::() == 4usize); + assert!(size_of::() == 16usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(JSXSpreadChild, span) == 0usize); + assert!(offset_of!(JSXSpreadChild, expression) == 8usize); + assert!(size_of::() == 16usize); + assert!(align_of::() == 4usize); + assert!(offset_of!(JSXText, span) == 0usize); + assert!(offset_of!(JSXText, value) == 8usize); +}; + +#[cfg(not(any(target_pointer_width = "64", target_pointer_width = "32")))] +const _: () = panic!("Platforms with pointer width other than 64 or 32 bit are not supported"); diff --git a/crates/oxc_ast/src/lib.rs b/crates/oxc_ast/src/lib.rs index 67f453b73e7d8..13f0efb7ba4ba 100644 --- a/crates/oxc_ast/src/lib.rs +++ b/crates/oxc_ast/src/lib.rs @@ -37,6 +37,8 @@ pub mod syntax_directed_operations; mod trivia; mod generated { + #[cfg(test)] + pub mod assert_layouts; pub mod ast_builder; pub mod ast_kind; pub mod span; diff --git a/tasks/ast_codegen/src/defs.rs b/tasks/ast_codegen/src/defs.rs index 4ab475fb1b28f..b03f9b8b12edf 100644 --- a/tasks/ast_codegen/src/defs.rs +++ b/tasks/ast_codegen/src/defs.rs @@ -1,5 +1,5 @@ use super::{REnum, RStruct, RType}; -use crate::{schema::Inherit, util::TypeExt, TypeName}; +use crate::{layout::KnownLayout, schema::Inherit, util::TypeExt, TypeName}; use quote::ToTokens; use serde::Serialize; @@ -9,11 +9,26 @@ pub enum TypeDef { Enum(EnumDef), } +impl TypeDef { + pub fn name(&self) -> &String { + match self { + Self::Struct(it) => &it.name, + Self::Enum(it) => &it.name, + } + } +} + #[derive(Debug, Serialize)] pub struct StructDef { pub name: TypeName, pub fields: Vec, pub has_lifetime: bool, + pub size_64: usize, + pub align_64: usize, + pub offsets_64: Option>, + pub size_32: usize, + pub align_32: usize, + pub offsets_32: Option>, } #[derive(Debug, Serialize)] @@ -23,6 +38,12 @@ pub struct EnumDef { /// For `@inherits` inherited enum variants pub inherits: Vec, pub has_lifetime: bool, + pub size_64: usize, + pub align_64: usize, + pub offsets_64: Option>, + pub size_32: usize, + pub align_32: usize, + pub offsets_32: Option>, } #[derive(Debug, Serialize)] @@ -57,21 +78,55 @@ impl From<&RType> for Option { impl From<&REnum> for EnumDef { fn from(it @ REnum { item, meta }: &REnum) -> Self { + let (size_64, align_64, offsets_64) = meta + .layout_64 + .clone() + .layout() + .map_or_else(|| panic!("Uncalculated layout on {}!", item.ident), KnownLayout::unpack); + let (size_32, align_32, offsets_32) = meta + .layout_32 + .clone() + .layout() + .map_or_else(|| panic!("Uncalculated layout on {}!", item.ident), KnownLayout::unpack); Self { name: it.ident().to_string(), variants: item.variants.iter().map(Into::into).collect(), - has_lifetime: item.generics.lifetimes().count() > 0, inherits: meta.inherits.iter().map(Into::into).collect(), + has_lifetime: item.generics.lifetimes().count() > 0, + + size_64, + align_64, + offsets_64, + size_32, + align_32, + offsets_32, } } } impl From<&RStruct> for StructDef { - fn from(it @ RStruct { item, .. }: &RStruct) -> Self { + fn from(it @ RStruct { item, meta }: &RStruct) -> Self { + let (size_64, align_64, offsets_64) = meta + .layout_64 + .clone() + .layout() + .map_or_else(|| panic!("Uncalculated layout on {}!", item.ident), KnownLayout::unpack); + let (size_32, align_32, offsets_32) = meta + .layout_32 + .clone() + .layout() + .map_or_else(|| panic!("Uncalculated layout on {}!", item.ident), KnownLayout::unpack); Self { name: it.ident().to_string(), fields: item.fields.iter().map(Into::into).collect(), has_lifetime: item.generics.lifetimes().count() > 0, + + size_64, + align_64, + offsets_64, + size_32, + align_32, + offsets_32, } } } diff --git a/tasks/ast_codegen/src/generators/assert_layouts.rs b/tasks/ast_codegen/src/generators/assert_layouts.rs new file mode 100644 index 0000000000000..8fac98436e697 --- /dev/null +++ b/tasks/ast_codegen/src/generators/assert_layouts.rs @@ -0,0 +1,118 @@ +use proc_macro2::TokenStream; +use quote::{format_ident, quote}; +use syn::{PathArguments, Type}; + +use crate::{ + defs::{FieldDef, TypeDef}, + output, CodegenCtx, Generator, GeneratorOutput, +}; + +use super::{define_generator, generated_header}; + +define_generator! { + pub struct AssertLayouts; +} + +impl Generator for AssertLayouts { + fn name(&self) -> &'static str { + stringify!(AssertLayouts) + } + + fn generate(&mut self, ctx: &CodegenCtx) -> GeneratorOutput { + let (assertions_64, assertions_32) = ctx + .schema + .borrow() + .definitions + .iter() + .map(|def| { + let typ = + ctx.find(def.name()).and_then(|ty| ty.borrow().as_type()).map(|mut ty| { + if let Type::Path(ty) = &mut ty { + if let Some(seg) = ty.path.segments.first_mut() { + seg.arguments = PathArguments::None; + } + } + ty + }); + let typ = typ.unwrap(); + assert_type(&typ, def) + }) + .collect::<(Vec, Vec)>(); + + let header = generated_header!(); + + GeneratorOutput::Stream(( + output(crate::AST_CRATE, "assert_layouts.rs"), + quote! { + #header + + use std::mem::{align_of, offset_of, size_of}; + + endl!(); + + use crate::ast::*; + + endl!(); + + #[cfg(target_pointer_width = "64")] + const _: () = { #(#assertions_64)* }; + endl!(); + + #[cfg(target_pointer_width = "32")] + const _: () = { #(#assertions_32)* }; + endl!(); + + #[cfg(not(any(target_pointer_width = "64", target_pointer_width = "32")))] + const _: () = panic!("Platforms with pointer width other than 64 or 32 bit are not supported"); + }, + )) + } +} + +fn assert_type(ty: &Type, def: &TypeDef) -> (TokenStream, TokenStream) { + match def { + TypeDef::Struct(def) => ( + with_offsets_assertion( + assert_size_align(ty, def.size_64, def.align_64), + ty, + &def.fields, + def.offsets_64.as_deref(), + ), + with_offsets_assertion( + assert_size_align(ty, def.size_32, def.align_32), + ty, + &def.fields, + def.offsets_64.as_deref(), + ), + ), + TypeDef::Enum(def) => ( + assert_size_align(ty, def.size_64, def.align_64), + assert_size_align(ty, def.size_32, def.align_32), + ), + } +} + +fn assert_size_align(ty: &Type, size: usize, align: usize) -> TokenStream { + quote! { + assert!(size_of::<#ty>() == #size); + assert!(align_of::<#ty>() == #align); + } +} + +fn with_offsets_assertion( + mut tk: TokenStream, + ty: &Type, + fields: &[FieldDef], + offsets: Option<&[usize]>, +) -> TokenStream { + let Some(offsets) = offsets else { return tk }; + + let assertions = fields.iter().zip(offsets).map(|(field, offset)| { + let field = field.name.as_ref().map(|it| format_ident!("{it}")); + quote! { + assert!(offset_of!(#ty, #field) == #offset); + } + }); + tk.extend(assertions); + tk +} diff --git a/tasks/ast_codegen/src/generators/mod.rs b/tasks/ast_codegen/src/generators/mod.rs index 7d747df9bf43f..c8476221c53e9 100644 --- a/tasks/ast_codegen/src/generators/mod.rs +++ b/tasks/ast_codegen/src/generators/mod.rs @@ -1,3 +1,4 @@ +mod assert_layouts; mod ast_builder; mod ast_kind; mod impl_get_span; @@ -39,6 +40,7 @@ macro_rules! generated_header { pub(crate) use generated_header; pub(crate) use insert; +pub use assert_layouts::AssertLayouts; pub use ast_builder::AstBuilderGenerator; pub use ast_kind::AstKindGenerator; pub use impl_get_span::ImplGetSpanGenerator; diff --git a/tasks/ast_codegen/src/layout.rs b/tasks/ast_codegen/src/layout.rs new file mode 100644 index 0000000000000..42b85aee590b7 --- /dev/null +++ b/tasks/ast_codegen/src/layout.rs @@ -0,0 +1,181 @@ +#[derive(Debug, Default, Clone)] +pub enum Layout { + #[default] + Unknown, + Layout(KnownLayout), +} + +impl Layout { + pub const fn known(size: usize, align: usize, niches: u128) -> Self { + Self::Layout(KnownLayout { size, align, niches, offsets: None }) + } + + pub fn layout(self) -> Option { + if let Self::Layout(layout) = self { + Some(layout) + } else { + None + } + } +} + +impl From for Layout { + fn from(layout: KnownLayout) -> Self { + Self::Layout(layout) + } +} + +#[derive(Debug, Default, Clone)] +pub struct KnownLayout { + size: usize, + align: usize, + /// number of available niches + niches: u128, + offsets: Option>, +} + +impl KnownLayout { + pub const fn new(size: usize, align: usize, niches: u128) -> Self { + Self { size, align, niches, offsets: None } + } + + #[inline] + pub fn size(&self) -> usize { + self.size + } + + #[inline] + pub fn align(&self) -> usize { + self.align + } + + /// number of available niches + #[inline] + pub fn niches(&self) -> u128 { + self.niches + } + + #[inline] + pub fn offsets(&self) -> Option<&Vec> { + self.offsets.as_ref() + } + + pub unsafe fn set_size_unchecked(&mut self, size: usize) { + self.size = size; + } + + pub unsafe fn set_align_unchecked(&mut self, align: usize) { + self.align = align; + } + + pub unsafe fn set_niches_unchecked(&mut self, niches: u128) { + self.niches = niches; + } + + pub fn with_offsets(mut self, offsets: Vec) -> Self { + self.offsets = Some(offsets); + self + } + + /// Panics + /// if doesn't have enough viable space and `can_resize` is false + pub fn consume_niches(&mut self, n: u128, can_resize: bool) { + if self.niches() >= n { + self.niches -= n; + } else if can_resize { + let align = self.align(); + self.size += align; + self.niches += max_val_of_bytes(align); + self.consume_niches(n, can_resize); + } else { + panic!("`{}` called on a layout without enough space.", stringify!(consume_niches)); + } + } + + pub fn unpack(self) -> (/* size */ usize, /* align */ usize, /* offsets */ Option>) { + let Self { size, align, offsets, .. } = self; + (size, align, offsets) + } +} + +impl Layout { + /// # Panics + /// If `T` has more than 8 niches. + pub const fn of() -> Self { + // TODO: find a better way of calculating this. + struct N1(Option); + struct N2(N1>); + struct N3(N1>); + struct N4(N1>); + struct N5(N1>); + struct N6(N1>); + struct N7(N1>); + struct N8(N1>); + + let size = size_of::(); + let align = align_of::(); + let niches = if size_of::>() > size { + 0 + } else if size_of::>() > size { + 1 + } else if size_of::>() > size { + 2 + } else if size_of::>() > size { + 3 + } else if size_of::>() > size { + 4 + } else if size_of::>() > size { + 5 + } else if size_of::>() > size { + 6 + } else if size_of::>() > size { + 7 + } else if size_of::>() == size { + 8 + } else { + panic!("`T` has more niches than what we can infer automatically"); + }; + + Self::known(size, align, niches) + } + + pub const fn zero() -> Self { + #[repr(C)] + struct Empty; + Self::of::() + } + + pub const fn ptr_32() -> Self { + Layout::known(4, 4, 0) + } + + pub const fn ptr_64() -> Self { + Layout::known(8, 8, 0) + } + + pub const fn wide_ptr_32() -> Self { + Layout::known(8, 4, 1) + } + + pub const fn wide_ptr_64() -> Self { + Layout::of::<&str>() + } + + pub fn is_unknown(&self) -> bool { + matches!(self, Self::Unknown) + } +} + +/// 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 +fn max_val_of_bytes(n: usize) -> u128 { + match n { + 1 => u8::MAX as u128, + 2 => u16::MAX as u128, + 4 => u32::MAX as u128, + 8 => u64::MAX as u128, + 16 => u128::MAX, + _ => panic!("We do not support `n` bigger than 16 bytes."), + } +} diff --git a/tasks/ast_codegen/src/main.rs b/tasks/ast_codegen/src/main.rs index 2dbee92bc8644..997a0c3b3b155 100644 --- a/tasks/ast_codegen/src/main.rs +++ b/tasks/ast_codegen/src/main.rs @@ -1,8 +1,11 @@ const AST_CRATE: &str = "crates/oxc_ast"; +#[allow(dead_code)] +const AST_MACROS_CRATE: &str = "crates/oxc_ast_macros"; mod defs; mod fmt; mod generators; +mod layout; mod markers; mod passes; mod schema; @@ -13,13 +16,14 @@ use std::{cell::RefCell, collections::HashMap, io::Read, path::PathBuf, rc::Rc}; use bpaf::{Bpaf, Parser}; use fmt::{cargo_fmt, pprint}; use itertools::Itertools; -use passes::{BuildSchema, Linker, Pass}; +use passes::{BuildSchema, CalcLayout, Linker, Pass}; use proc_macro2::TokenStream; use syn::parse_file; use defs::TypeDef; use generators::{ - AstBuilderGenerator, AstKindGenerator, Generator, VisitGenerator, VisitMutGenerator, + AssertLayouts, AstBuilderGenerator, AstKindGenerator, Generator, VisitGenerator, + VisitMutGenerator, }; use schema::{Module, REnum, RStruct, RType, Schema}; use util::{write_all_to, NormalizeError}; @@ -258,7 +262,9 @@ fn main() -> std::result::Result<(), Box> { let CodegenResult { outputs, schema } = files() .fold(AstCodegen::default(), AstCodegen::add_file) .pass(Linker) + .pass(CalcLayout) .pass(BuildSchema) + .gen(AssertLayouts) .gen(AstKindGenerator) .gen(AstBuilderGenerator) .gen(ImplGetSpanGenerator) diff --git a/tasks/ast_codegen/src/passes/calc_layout.rs b/tasks/ast_codegen/src/passes/calc_layout.rs new file mode 100644 index 0000000000000..f9ccfaa298f37 --- /dev/null +++ b/tasks/ast_codegen/src/passes/calc_layout.rs @@ -0,0 +1,370 @@ +/// We use compiler to infer 64bit type layouts. +#[cfg(not(target_pointer_width = "64"))] +compile_error!("`oxc_ast_codegen::layout` only supports 64 architectures."); +use std::collections::HashMap; + +use itertools::Itertools; +use lazy_static::lazy_static; +use quote::ToTokens; +use syn::Type; + +use crate::{ + layout::{KnownLayout, Layout}, + schema::{REnum, RStruct, RType}, + util::{NormalizeError, TypeAnalyzeResult, TypeExt, TypeWrapper}, + CodegenCtx, Result, TypeRef, +}; + +use super::{define_pass, Pass}; + +type WellKnown = HashMap<&'static str, PlatformLayout>; + +define_pass! { + pub struct CalcLayout; +} + +impl Pass for CalcLayout { + fn name(&self) -> &'static str { + stringify!(CalcLayout) + } + + fn each(&mut self, ty: &mut RType, ctx: &CodegenCtx) -> crate::Result { + calc_layout(ty, ctx) + } +} + +#[derive(Debug, Clone)] +struct PlatformLayout(/* 64 */ Layout, /* 32 */ Layout); + +impl PlatformLayout { + const UNKNOWN: Self = Self(Layout::Unknown, Layout::Unknown); + + const fn zero() -> Self { + Self(Layout::zero(), Layout::zero()) + } + + const fn ptr() -> Self { + Self(Layout::ptr_64(), Layout::ptr_32()) + } + + const fn wide_ptr() -> Self { + Self(Layout::wide_ptr_64(), Layout::wide_ptr_32()) + } + + /// Return `true` if either of platform layouts is unknown. + fn is_unknown(&self) -> bool { + self.0.is_unknown() || self.1.is_unknown() + } +} + +impl From<(Layout, Layout)> for PlatformLayout { + fn from((x64, x32): (Layout, Layout)) -> Self { + Self(x64, x32) + } +} + +/// Calculates the layout of `ty` by mutating it. +/// Returns `false` if the layout is unknown at this point. +pub fn calc_layout(ty: &mut RType, ctx: &CodegenCtx) -> Result { + let unknown_layout = ty + .layout_32() + .and_then(|x32| ty.layout_64().map(|x64| PlatformLayout(x64, x32))) + .is_ok_and(|pl| pl.is_unknown()); + let layout = match ty { + RType::Enum(enum_) if unknown_layout => calc_enum_layout(enum_, ctx), + RType::Struct(struct_) if unknown_layout => calc_struct_layout(struct_, ctx), + _ => return Ok(true), + }?; + if layout.is_unknown() { + Ok(false) + } else { + let PlatformLayout(x64, x32) = layout; + ty.set_layout(x64, x32)?; + Ok(true) + } +} + +fn calc_enum_layout(ty: &mut REnum, ctx: &CodegenCtx) -> Result { + fn collect_variant_layouts(ty: &REnum, ctx: &CodegenCtx) -> Result> { + // all unit variants? + if ty.item.variants.iter().all(|var| var.fields.is_empty()) { + // all AST enums are `repr(u8)` so it would have a 1 byte layout/alignment, + // if it holds no data + let layout = KnownLayout::new(0, 1, 0); + let layout = Layout::Layout(layout); + Ok(vec![PlatformLayout(layout.clone(), layout)]) + } else { + ty.item + .variants + .iter() + .map(|var| { + let typ = + var.fields.iter().exactly_one().map(|f| f.ty.analyze(ctx)).normalize()?; + calc_type_layout(&typ, ctx) + }) + .collect() + } + } + + #[allow(clippy::needless_pass_by_value)] + fn fold_layout(mut acc: KnownLayout, layout: KnownLayout) -> KnownLayout { + // SAFETY: we are folding valid layouts so it is safe. + unsafe { + // max alignment + if layout.align() > acc.align() { + acc.set_align_unchecked(layout.align()); + } + // max size + if layout.size() > acc.size() { + acc.set_size_unchecked(layout.size()); + } + // min niches + if layout.niches() < acc.niches() { + acc.set_niches_unchecked(layout.niches()); + } + } + acc + } + + let with_tag = |mut acc: KnownLayout| -> KnownLayout { + acc.consume_niches(ty.item.variants.len() as u128, true); + acc + }; + + let layouts = collect_variant_layouts(ty, ctx)?; + let (layouts_x64, layouts_x32): (Vec, Vec) = layouts + .into_iter() + .map(|PlatformLayout(x64, x32)| { + x64.layout().and_then(|x64| x32.layout().map(|x32| (x64, x32))) + }) + .collect::>() + .expect("already checked."); + + let x32 = with_tag(layouts_x32.into_iter().fold(KnownLayout::default(), fold_layout)); + let x64 = with_tag(layouts_x64.into_iter().fold(KnownLayout::default(), fold_layout)); + Ok(PlatformLayout(Layout::from(x64), Layout::from(x32))) +} + +fn calc_struct_layout(ty: &mut RStruct, ctx: &CodegenCtx) -> Result { + fn collect_field_layouts(ty: &RStruct, ctx: &CodegenCtx) -> Result> { + if ty.item.fields.is_empty() { + Ok(vec![PlatformLayout::zero()]) + } else { + ty.item + .fields + .iter() + .map(|field| { + let typ = field.ty.analyze(ctx); + calc_type_layout(&typ, ctx) + }) + .collect() + } + } + + fn with_padding( + layouts: &[KnownLayout], + ) -> std::result::Result { + let layouts = layouts.iter().enumerate(); + let mut offsets = vec![0; layouts.len()]; + let mut output = std::alloc::Layout::from_size_align(0, 1)?; + let mut niches = 0; + for (ix, layout) in layouts { + let (new_layout, offset) = output + .extend(std::alloc::Layout::from_size_align(layout.size(), layout.align())?)?; + output = new_layout; + niches += layout.niches(); + offsets[ix] = offset; + } + let output = output.pad_to_align(); + Ok(KnownLayout::new(output.size(), output.align(), niches).with_offsets(offsets)) + } + + let layouts = collect_field_layouts(ty, ctx)?; + + if layouts.iter().any(PlatformLayout::is_unknown) { + return Ok(PlatformLayout::UNKNOWN); + } + + let (layouts_x64, layouts_x32): (Vec, Vec) = layouts + .into_iter() + .map(|PlatformLayout(x64, x32)| { + x64.layout().and_then(|x64| x32.layout().map(|x32| (x64, x32))) + }) + .collect::>() + .expect("already checked."); + + let x32 = with_padding(&layouts_x32).normalize()?; + let x64 = with_padding(&layouts_x64).normalize()?; + + Ok(PlatformLayout(Layout::from(x64), Layout::from(x32))) +} + +fn calc_type_layout(ty: &TypeAnalyzeResult, ctx: &CodegenCtx) -> Result { + fn is_slice(ty: &TypeAnalyzeResult) -> bool { + if let Type::Reference(typ) = &ty.typ { + // TODO: support for &[T] slices. + typ.elem.get_ident().as_ident().is_some_and(|id| id == "str") + } else { + false + } + } + + fn try_fold_option(layout: Layout) -> Layout { + let Layout::Layout(mut known) = layout else { return layout }; + // option needs only one niche, We allow resizing in case there isn't enough space. + known.consume_niches(1, true); + Layout::Layout(known) + } + + let get_layout = |type_ref: Option<&TypeRef>| -> Result { + let result = if let Some(type_ref) = &type_ref { + if calc_layout(&mut type_ref.borrow_mut(), ctx)? { + type_ref.borrow().layouts().map(PlatformLayout::from)? + } else { + PlatformLayout::UNKNOWN + } + } else if let Some(well_known) = + WELL_KNOWN.get(ty.typ.get_ident().inner_ident().to_string().as_str()) + { + well_known.clone() + } else { + let Type::Path(typ) = &ty.typ else { + panic!(); + }; + + let typ = typ + .path + .segments + .first() + .map(|it| it.to_token_stream().to_string().replace(' ', "")) + .expect("We only accept single segment types."); + + if let Some(typ) = WELL_KNOWN.get(typ.as_str()) { + typ.clone() + } else { + panic!("Unsupported type: {:#?}", ty.typ.to_token_stream().to_string()) + } + }; + Ok(result) + }; + + let layout = match ty.wrapper { + TypeWrapper::Vec | TypeWrapper::VecBox | TypeWrapper::VecOpt => { + WELL_KNOWN[stringify!(Vec)].clone() + } + TypeWrapper::OptVec => { + let mut pl = WELL_KNOWN[stringify!(Vec)].clone(); + // preconsume one niche for option + if let Layout::Layout(layout) = &mut pl.0 { + layout.consume_niches(1, true); + } + if let Layout::Layout(layout) = &mut pl.1 { + layout.consume_niches(1, true); + } + pl + } + TypeWrapper::Ref if is_slice(ty) => PlatformLayout::wide_ptr(), + TypeWrapper::Ref | TypeWrapper::Box | TypeWrapper::OptBox => PlatformLayout::ptr(), + TypeWrapper::None => get_layout(ty.type_ref.as_ref())?, + TypeWrapper::Opt => { + let PlatformLayout(x64, x32) = get_layout(ty.type_ref.as_ref())?; + PlatformLayout(try_fold_option(x64), try_fold_option(x32)) + } + TypeWrapper::Complex => { + let PlatformLayout(x64, x32) = get_layout(ty.type_ref.as_ref())?; + PlatformLayout(x64, x32) + } + }; + Ok(layout) +} + +macro_rules! well_known { + ($($typ:ty: { $($platform:tt => $layout:expr,)*},)*) => { + WellKnown::from([ + $(( + stringify!($typ), + well_known!(@ $( $platform => $layout,)*) + )),* + ]) + }; + + // entries + (@ _ => $layout:expr,) => { + PlatformLayout($layout, $layout) + }; + (@ 64 => $layout_64:expr, 32 => $layout_32:expr,) => { + PlatformLayout($layout_64, $layout_32) + }; + (@ 32 => $layout_32:expr, 64 => $layout_64:expr,) => { + well_known!(@ 64 => $layout_64, 32 => $layout_32) + }; + + // compile errors + (@ 32 => $layout:expr,) => { + ::std::compile_error!("non_exhaustive well known type, `64` target isn't covered.") + }; + (@ 64 => $layout:expr,) => { + ::std::compile_error!("non_exhaustive well known type, `32` target isn't covered.") + }; +} + +lazy_static! { + static ref WELL_KNOWN: WellKnown = well_known! { + // builtins + // types smaller or equal to 4bytes have the same layout on most platforms. + char: { _ => Layout::of::(), }, + bool: { _ => Layout::of::(), }, + u8: { _ => Layout::of::(), }, + i8: { _ => Layout::of::(), }, + u16: { _ => Layout::of::(), }, + i16: { _ => Layout::of::(), }, + u32: { _ => Layout::of::(), }, + i32: { _ => Layout::of::(), }, + f32: { _ => Layout::of::(), }, + // 32bit layouts are based on WASM + u64: { + 64 => Layout::of::(), + 32 => Layout::known(8, 8, 0), + }, + i64: { + 64 => Layout::of::(), + 32 => Layout::known(8, 8, 0), + }, + f64: { + 64 => Layout::of::(), + 32 => Layout::known(8, 8, 0), + }, + usize: { + 64 => Layout::of::(), + 32 => Layout::known(4, 4, 0), + }, + isize: { + 64 => Layout::of::(), + 32 => Layout::known(4, 4, 0), + }, + // well known types + // TODO: generate const assertions for these in the ast crate + Span: { _ => Layout::known(8, 4, 0), }, + Atom: { + 64 => Layout::wide_ptr_64(), + 32 => Layout::wide_ptr_32(), + }, + Vec: { + 64 => Layout::known(32, 8, 1), + 32 => Layout::known(16, 4, 1), + }, + Cell>: { _ => Layout::known(4, 4, 0), }, + Cell>: { _ => Layout::known(4, 4, 0), }, + Cell>: { _ => Layout::known(4, 4, 0), }, + ReferenceFlag: { _ => Layout::known(1, 1, 0), }, + AssignmentOperator: { _ => Layout::known(1, 1, 1), }, + LogicalOperator: { _ => Layout::known(1, 1, 1), }, + UnaryOperator: { _ => Layout::known(1, 1, 1), }, + BinaryOperator: { _ => Layout::known(1, 1, 1), }, + UpdateOperator: { _ => Layout::known(1, 1, 1), }, + SourceType: { _ => Layout::known(4, 1, 1), }, + RegExpFlags: { _ => Layout::known(1, 1, 0), }, + BigintBase: { _ => Layout::known(1, 1, 1), }, + NumberBase: { _ => Layout::known(1, 1, 1), }, + }; +} diff --git a/tasks/ast_codegen/src/passes/mod.rs b/tasks/ast_codegen/src/passes/mod.rs index 3d56fc7153dc9..2a149382fb8be 100644 --- a/tasks/ast_codegen/src/passes/mod.rs +++ b/tasks/ast_codegen/src/passes/mod.rs @@ -1,4 +1,5 @@ mod build_schema; +mod calc_layout; mod linker; use std::collections::VecDeque; @@ -8,6 +9,7 @@ use itertools::Itertools; use crate::{schema::RType, CodegenCtx, Result}; pub use build_schema::BuildSchema; +pub use calc_layout::CalcLayout; pub use linker::Linker; pub trait Pass { diff --git a/tasks/ast_codegen/src/schema.rs b/tasks/ast_codegen/src/schema.rs index 7829891c87fec..85a2466cc9e50 100644 --- a/tasks/ast_codegen/src/schema.rs +++ b/tasks/ast_codegen/src/schema.rs @@ -9,13 +9,13 @@ use syn::{ Path, Token, Type, Variant, Visibility, }; -use crate::{util::NormalizeError, TypeName}; +use crate::{layout::Layout, util::NormalizeError, TypeName}; use super::{parse_file, Itertools, PathBuf, Rc, Read, RefCell, Result, TypeDef, TypeRef}; #[derive(Debug, Default, serde::Serialize)] pub struct Schema { - definitions: Vec, + pub definitions: Vec, } #[derive(Debug, Clone)] @@ -33,6 +33,8 @@ impl From for Inherit { #[derive(Debug, Default, Clone)] pub struct EnumMeta { pub inherits: Vec, + pub layout_32: Layout, + pub layout_64: Layout, pub visitable: bool, pub ast: bool, } @@ -68,6 +70,8 @@ impl From for REnum { /// Placeholder for now! #[derive(Debug, Default, Clone)] pub struct StructMeta { + pub layout_32: Layout, + pub layout_64: Layout, pub visitable: bool, pub ast: bool, } @@ -170,6 +174,41 @@ impl RType { } Ok(()) } + + pub fn layout_32(&self) -> Result { + match self { + RType::Enum(it) => Ok(it.meta.layout_32.clone()), + RType::Struct(it) => Ok(it.meta.layout_32.clone()), + _ => Err("Unsupported type!".to_string()), + } + } + + pub fn layout_64(&self) -> Result { + match self { + RType::Enum(it) => Ok(it.meta.layout_64.clone()), + RType::Struct(it) => Ok(it.meta.layout_64.clone()), + _ => Err("Unsupported type!".to_string()), + } + } + + pub fn layouts(&self) -> Result<(/* 64 */ Layout, /* 32 */ Layout)> { + self.layout_64().and_then(|x64| self.layout_32().map(|x32| (x64, x32))) + } + + pub fn set_layout(&mut self, layout_64: Layout, layout_32: Layout) -> Result<()> { + macro_rules! assign { + ($it:ident) => {{ + $it.meta.layout_32 = layout_32; + $it.meta.layout_64 = layout_64; + }}; + } + match self { + RType::Enum(it) => assign!(it), + RType::Struct(it) => assign!(it), + _ => return Err("Unsupported type!".to_string()), + } + Ok(()) + } } impl TryFrom for RType { diff --git a/tasks/ast_codegen/src/util.rs b/tasks/ast_codegen/src/util.rs index 878e280800190..ed924a0762de5 100644 --- a/tasks/ast_codegen/src/util.rs +++ b/tasks/ast_codegen/src/util.rs @@ -132,6 +132,7 @@ pub enum TypeWrapper { pub struct TypeAnalyzeResult { pub type_ref: Option, pub wrapper: TypeWrapper, + pub typ: Type, } impl TypeExt for Type { @@ -225,11 +226,15 @@ impl TypeExt for Type { } let type_ident = self.get_ident(); let Some((type_ident, wrapper)) = analyze(&type_ident) else { - return TypeAnalyzeResult { type_ref: None, wrapper: TypeWrapper::Ref }; + return TypeAnalyzeResult { + type_ref: None, + wrapper: TypeWrapper::Ref, + typ: self.clone(), + }; }; let type_ref = ctx.find(&type_ident.to_string()); - TypeAnalyzeResult { type_ref, wrapper } + TypeAnalyzeResult { type_ref, wrapper, typ: self.clone() } } }