mirror of
https://github.com/danbulant/oxc
synced 2026-05-24 12:21:58 +00:00
refactor(ast,parser): remove Node::ctx
This is adding too many bytes to the AST
This commit is contained in:
parent
c640b4fb08
commit
d57ab2f088
3 changed files with 5 additions and 7 deletions
|
|
@ -6,7 +6,7 @@ use std::{
|
|||
use serde::Serialize;
|
||||
|
||||
#[allow(clippy::wildcard_imports)]
|
||||
use crate::{ast::*, context::Context};
|
||||
use crate::ast::*;
|
||||
|
||||
pub type Span = Range<usize>;
|
||||
|
||||
|
|
@ -14,15 +14,13 @@ pub type Span = Range<usize>;
|
|||
pub struct Node {
|
||||
pub start: usize,
|
||||
pub end: usize,
|
||||
#[serde(skip)]
|
||||
pub ctx: Context,
|
||||
}
|
||||
|
||||
impl Node {
|
||||
#[must_use]
|
||||
#[inline]
|
||||
pub const fn new(start: usize, end: usize, ctx: Context) -> Self {
|
||||
Self { start, end, ctx }
|
||||
pub const fn new(start: usize, end: usize) -> Self {
|
||||
Self { start, end }
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ impl<'a> Parser<'a> {
|
|||
#[must_use]
|
||||
pub const fn start_node(&self) -> Node {
|
||||
let token = self.cur_token();
|
||||
Node::new(token.start, 0, self.ctx)
|
||||
Node::new(token.start, 0)
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ impl<'a> Parser<'a> {
|
|||
let (directives, statements) =
|
||||
self.parse_directives_and_statements(/* is_top_level */ true)?;
|
||||
|
||||
let node = Node::new(0, self.source.len(), self.ctx);
|
||||
let node = Node::new(0, self.source.len());
|
||||
Ok(self.ast.program(node, directives, statements, self.source_type))
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue