Use interned strings for AST nodes.

This commit is contained in:
Stephen Chung
2022-08-13 18:07:42 +08:00
parent 1c7b80ed13
commit 28743594d0
11 changed files with 147 additions and 205 deletions

View File

@@ -60,7 +60,7 @@ pub struct CustomExpr {
/// List of keywords.
pub inputs: StaticVec<Expr>,
/// List of tokens actually parsed.
pub tokens: StaticVec<Identifier>,
pub tokens: StaticVec<ImmutableString>,
/// Is the current [`Scope`][crate::Scope] possibly modified by this custom statement
/// (e.g. introducing a new variable)?
pub scope_may_be_changed: bool,
@@ -183,7 +183,7 @@ pub struct FnCallExpr {
#[cfg(not(feature = "no_module"))]
pub namespace: super::Namespace,
/// Function name.
pub name: Identifier,
pub name: ImmutableString,
/// Pre-calculated hashes.
pub hashes: FnCallHashes,
/// List of function call argument expressions.
@@ -392,14 +392,18 @@ pub enum Expr {
/// This is to avoid reading a pointer redirection during each variable access.
Variable(
#[cfg(not(feature = "no_module"))]
Box<(Option<NonZeroUsize>, super::Namespace, u64, Identifier)>,
#[cfg(feature = "no_module")] Box<(Option<NonZeroUsize>, (), u64, Identifier)>,
Box<(Option<NonZeroUsize>, super::Namespace, u64, ImmutableString)>,
#[cfg(feature = "no_module")] Box<(Option<NonZeroUsize>, (), u64, ImmutableString)>,
Option<NonZeroU8>,
Position,
),
/// Property access - ((getter, hash), (setter, hash), prop)
Property(
Box<((Identifier, u64), (Identifier, u64), ImmutableString)>,
Box<(
(ImmutableString, u64),
(ImmutableString, u64),
ImmutableString,
)>,
Position,
),
/// xxx `.` method `(` expr `,` ... `)`