mirror of
https://github.com/danbulant/oxc
synced 2026-05-24 20:32:10 +00:00
refactor(ast): move impl GetAddress for Statement (#6742)
Follow-on after #6738. Since `GetAddress` is now defined in `oxc_allocator` crate, `impl GetAddress for Statement` doesn't need its own file.
This commit is contained in:
parent
1248557f0e
commit
b66ae2e45e
3 changed files with 42 additions and 46 deletions
|
|
@ -1,44 +0,0 @@
|
|||
use oxc_allocator::{Address, GetAddress};
|
||||
|
||||
use crate::ast::Statement;
|
||||
|
||||
impl<'a> GetAddress for Statement<'a> {
|
||||
// `#[inline]` because compiler should boil this down to a single assembly instruction
|
||||
#[inline]
|
||||
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(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
#![warn(missing_docs)]
|
||||
use std::{borrow::Cow, cell::Cell, fmt};
|
||||
|
||||
use oxc_allocator::{Box, FromIn, Vec};
|
||||
use oxc_allocator::{Address, Box, FromIn, GetAddress, Vec};
|
||||
use oxc_span::{Atom, GetSpan, Span};
|
||||
use oxc_syntax::{
|
||||
operator::UnaryOperator,
|
||||
|
|
@ -768,6 +768,47 @@ impl<'a> FromIn<'a, Expression<'a>> for Statement<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> GetAddress for Statement<'a> {
|
||||
// `#[inline]` because compiler should boil this down to a single assembly instruction
|
||||
#[inline]
|
||||
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(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Directive<'a> {
|
||||
/// A Use Strict Directive is an ExpressionStatement in a Directive Prologue whose StringLiteral is either of the exact code point sequences "use strict" or 'use strict'.
|
||||
/// A Use Strict Directive may not contain an EscapeSequence or LineContinuation.
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@
|
|||
#[cfg(feature = "serialize")]
|
||||
mod serialize;
|
||||
|
||||
pub mod address;
|
||||
pub mod ast;
|
||||
mod ast_builder_impl;
|
||||
mod ast_impl;
|
||||
|
|
|
|||
Loading…
Reference in a new issue