Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce environment allocations #4002

Merged
merged 4 commits into from
Dec 4, 2024
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
7 changes: 7 additions & 0 deletions core/ast/src/expression/literal/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,13 @@ impl ObjectMethodDefinition {
pub const fn scopes(&self) -> &FunctionScopes {
&self.scopes
}

/// Returns `true` if the object method definition contains a direct call to `eval`.
#[inline]
#[must_use]
pub const fn contains_direct_eval(&self) -> bool {
self.contains_direct_eval
}
}

impl ToIndentedString for ObjectMethodDefinition {
Expand Down
7 changes: 7 additions & 0 deletions core/ast/src/function/arrow_function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,13 @@ impl ArrowFunction {
pub const fn scopes(&self) -> &FunctionScopes {
&self.scopes
}

/// Returns `true` if the arrow function contains a direct call to `eval`.
#[inline]
#[must_use]
pub const fn contains_direct_eval(&self) -> bool {
self.contains_direct_eval
}
}

impl ToIndentedString for ArrowFunction {
Expand Down
7 changes: 7 additions & 0 deletions core/ast/src/function/async_arrow_function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,13 @@ impl AsyncArrowFunction {
pub const fn scopes(&self) -> &FunctionScopes {
&self.scopes
}

/// Returns `true` if the function declaration contains a direct call to `eval`.
#[inline]
#[must_use]
pub const fn contains_direct_eval(&self) -> bool {
self.contains_direct_eval
}
}

impl ToIndentedString for AsyncArrowFunction {
Expand Down
14 changes: 14 additions & 0 deletions core/ast/src/function/async_function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@ impl AsyncFunctionDeclaration {
pub const fn scopes(&self) -> &FunctionScopes {
&self.scopes
}

/// Returns `true` if the async function declaration contains a direct call to `eval`.
#[inline]
#[must_use]
pub const fn contains_direct_eval(&self) -> bool {
self.contains_direct_eval
}
}

impl ToIndentedString for AsyncFunctionDeclaration {
Expand Down Expand Up @@ -207,6 +214,13 @@ impl AsyncFunctionExpression {
pub const fn scopes(&self) -> &FunctionScopes {
&self.scopes
}

/// Returns `true` if the async function expression contains a direct call to `eval`.
#[inline]
#[must_use]
pub const fn contains_direct_eval(&self) -> bool {
self.contains_direct_eval
}
}

impl ToIndentedString for AsyncFunctionExpression {
Expand Down
14 changes: 14 additions & 0 deletions core/ast/src/function/async_generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@ impl AsyncGeneratorDeclaration {
pub const fn scopes(&self) -> &FunctionScopes {
&self.scopes
}

/// Returns `true` if the async generator declaration contains a direct call to `eval`.
#[inline]
#[must_use]
pub const fn contains_direct_eval(&self) -> bool {
self.contains_direct_eval
}
}

impl ToIndentedString for AsyncGeneratorDeclaration {
Expand Down Expand Up @@ -206,6 +213,13 @@ impl AsyncGeneratorExpression {
pub const fn scopes(&self) -> &FunctionScopes {
&self.scopes
}

/// Returns `true` if the async generator expression contains a direct call to `eval`.
#[inline]
#[must_use]
pub const fn contains_direct_eval(&self) -> bool {
self.contains_direct_eval
}
}

impl ToIndentedString for AsyncGeneratorExpression {
Expand Down
7 changes: 7 additions & 0 deletions core/ast/src/function/class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,13 @@ impl ClassMethodDefinition {
pub const fn scopes(&self) -> &FunctionScopes {
&self.scopes
}

/// Returns `true` if the class method definition contains a direct call to `eval`.
#[inline]
#[must_use]
pub const fn contains_direct_eval(&self) -> bool {
self.contains_direct_eval
}
}

impl ToIndentedString for ClassMethodDefinition {
Expand Down
14 changes: 14 additions & 0 deletions core/ast/src/function/generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@ impl GeneratorDeclaration {
pub const fn scopes(&self) -> &FunctionScopes {
&self.scopes
}

/// Returns `true` if the generator declaration contains a direct call to `eval`.
#[inline]
#[must_use]
pub const fn contains_direct_eval(&self) -> bool {
self.contains_direct_eval
}
}

impl ToIndentedString for GeneratorDeclaration {
Expand Down Expand Up @@ -205,6 +212,13 @@ impl GeneratorExpression {
pub const fn scopes(&self) -> &FunctionScopes {
&self.scopes
}

/// Returns `true` if the generator expression contains a direct call to `eval`.
#[inline]
#[must_use]
pub const fn contains_direct_eval(&self) -> bool {
self.contains_direct_eval
}
}

impl ToIndentedString for GeneratorExpression {
Expand Down
14 changes: 14 additions & 0 deletions core/ast/src/function/ordinary_function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@ impl FunctionDeclaration {
pub const fn scopes(&self) -> &FunctionScopes {
&self.scopes
}

/// Returns `true` if the function declaration contains a direct call to `eval`.
#[inline]
#[must_use]
pub const fn contains_direct_eval(&self) -> bool {
self.contains_direct_eval
}
}

impl ToIndentedString for FunctionDeclaration {
Expand Down Expand Up @@ -207,6 +214,13 @@ impl FunctionExpression {
&self.scopes
}

/// Returns `true` if the function expression contains a direct call to `eval`.
#[inline]
#[must_use]
pub const fn contains_direct_eval(&self) -> bool {
self.contains_direct_eval
}

/// Analyze the scope of the function expression.
pub fn analyze_scope(&mut self, strict: bool, scope: &Scope, interner: &Interner) -> bool {
if !collect_bindings(self, strict, false, scope, interner) {
Expand Down
Loading
Loading