Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 0 additions & 44 deletions crates/oxc_ast/src/address.rs

This file was deleted.

43 changes: 42 additions & 1 deletion crates/oxc_ast/src/ast_impl/js.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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.
Expand Down
1 change: 0 additions & 1 deletion crates/oxc_ast/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
#[cfg(feature = "serialize")]
mod serialize;

pub mod address;
pub mod ast;
mod ast_builder_impl;
mod ast_impl;
Expand Down