mirror of
https://github.com/danbulant/oxc
synced 2026-05-24 20:32:10 +00:00
parent
112580a408
commit
b2f3040e4f
2 changed files with 50 additions and 0 deletions
49
crates/oxc_ast/src/address.rs
Normal file
49
crates/oxc_ast/src/address.rs
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
//! Defines the `GetAddress` trait for getting the memory address of AST.
|
||||
|
||||
use oxc_allocator::Address;
|
||||
|
||||
use crate::ast::Statement;
|
||||
|
||||
/// Trait for getting the memory address of AST.
|
||||
pub trait GetAddress {
|
||||
fn address(&self) -> Address;
|
||||
}
|
||||
|
||||
impl<'a> GetAddress for Statement<'a> {
|
||||
fn address(&self) -> Address {
|
||||
match self {
|
||||
Statement::BlockStatement(s) => s.address(),
|
||||
Statement::BreakStatement(s) => s.address(),
|
||||
Statement::ContinueStatement(s) => s.address(),
|
||||
Statement::DebuggerStatement(s) => s.address(),
|
||||
Statement::DoWhileStatement(s) => s.address(),
|
||||
Statement::EmptyStatement(s) => s.address(),
|
||||
Statement::ExpressionStatement(s) => s.address(),
|
||||
Statement::ForInStatement(s) => s.address(),
|
||||
Statement::ForOfStatement(s) => s.address(),
|
||||
Statement::ForStatement(s) => s.address(),
|
||||
Statement::IfStatement(s) => s.address(),
|
||||
Statement::LabeledStatement(s) => s.address(),
|
||||
Statement::ReturnStatement(s) => s.address(),
|
||||
Statement::SwitchStatement(s) => s.address(),
|
||||
Statement::ThrowStatement(s) => s.address(),
|
||||
Statement::TryStatement(s) => s.address(),
|
||||
Statement::WhileStatement(s) => s.address(),
|
||||
Statement::WithStatement(s) => s.address(),
|
||||
Statement::VariableDeclaration(s) => s.address(),
|
||||
Statement::FunctionDeclaration(s) => s.address(),
|
||||
Statement::ClassDeclaration(s) => s.address(),
|
||||
Statement::TSTypeAliasDeclaration(s) => s.address(),
|
||||
Statement::TSInterfaceDeclaration(s) => s.address(),
|
||||
Statement::TSEnumDeclaration(s) => s.address(),
|
||||
Statement::TSModuleDeclaration(s) => s.address(),
|
||||
Statement::TSImportEqualsDeclaration(s) => s.address(),
|
||||
Statement::ImportDeclaration(s) => s.address(),
|
||||
Statement::ExportAllDeclaration(s) => s.address(),
|
||||
Statement::ExportDefaultDeclaration(s) => s.address(),
|
||||
Statement::ExportNamedDeclaration(s) => s.address(),
|
||||
Statement::TSExportAssignment(s) => s.address(),
|
||||
Statement::TSNamespaceExportDeclaration(s) => s.address(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -28,6 +28,7 @@
|
|||
#[cfg(feature = "serialize")]
|
||||
mod serialize;
|
||||
|
||||
pub mod address;
|
||||
pub mod ast;
|
||||
mod ast_builder_impl;
|
||||
mod ast_impl;
|
||||
|
|
|
|||
Loading…
Reference in a new issue