mirror of
https://github.com/aphrody-labs/oxc.git
synced 2026-10-14 22:29:17 +00:00
feat(ast)!: remove conversion to Box from AST builder methods (#25038)
AST builder methods accepted an `IntoIn<ArenaBox<T>>` for all params where an `ArenaBox<T>` is required. You could pass a plain `T`, and the builder method would automatically allocate space for it, and copy it into the arena. This was originally intended as a convenience, but in fact it's a footgun - it encourages allocating late, holding types on the stack during other work, which results in register pressure, and churn of copying to/from the stack. Remove the automatic conversion. All places where we were using auto-allocation are already fixed in previous PRs #25034, #25035, #25036, #25037. Additional benefits of this change: 1. AST builder methods become less polymorphic which should help with compile times. 2. We can get rid of the `NONE` type, which was a hacky workaround, necessary for passing as params where an `IntoIn<Option<ArenaBox<T>>>` is required. Now these all become plain `None`. Most of the diff in this PR is just replacing `NONE` with `None` all over the place. Note: AST builder methods still define params which are `ArenaVec`s as `IntoIn<ArenaVec<T>>`, as this does add genuine value - it allows passing `[]` instead of the much more verbose `ArenaVec::new_in(self)`.
This commit is contained in:
1 parent
7251e52a69
commit
7e1199cbbb
51 files changed
+1589
-2672
No files matched your search
@@ -18,7 +18,7 @@ use oxc_syntax::{number::NumberBase, operator::UnaryOperator, scope::ScopeId};
|
||||
|
||||
use crate::ast::*;
|
||||
|
||||
use super::{GetAstBuilder, NONE};
|
||||
use super::GetAstBuilder;
|
||||
|
||||
impl<'a> Expression<'a> {
|
||||
/// Build an [`Expression`] representing the number `0`.
|
||||
@@ -78,7 +78,7 @@ impl<'a> FormalParameter<'a> {
|
||||
builder: &B,
|
||||
) -> Self {
|
||||
let builder = builder.builder();
|
||||
FormalParameter::new(span, [], pattern, NONE, NONE, false, None, false, false, builder)
|
||||
FormalParameter::new(span, [], pattern, None, None, false, None, false, false, builder)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,19 +95,15 @@ impl<'a> Function<'a> {
|
||||
/// * `body`: The function body.
|
||||
/// * `scope_id`
|
||||
#[inline]
|
||||
pub fn boxed_plain_with_scope_id<B: GetAstBuilder<'a>, T1, T2>(
|
||||
pub fn boxed_plain_with_scope_id<B: GetAstBuilder<'a>>(
|
||||
r#type: FunctionType,
|
||||
span: Span,
|
||||
id: Option<BindingIdentifier<'a>>,
|
||||
params: T1,
|
||||
body: T2,
|
||||
params: ArenaBox<'a, FormalParameters<'a>>,
|
||||
body: ArenaBox<'a, FunctionBody<'a>>,
|
||||
scope_id: ScopeId,
|
||||
builder: &B,
|
||||
) -> ArenaBox<'a, Self>
|
||||
where
|
||||
T1: IntoIn<'a, ArenaBox<'a, FormalParameters<'a>>>,
|
||||
T2: IntoIn<'a, ArenaBox<'a, FunctionBody<'a>>>,
|
||||
{
|
||||
) -> ArenaBox<'a, Self> {
|
||||
let builder = builder.builder();
|
||||
Function::boxed_with_scope_id_and_pure_and_pife(
|
||||
span,
|
||||
@@ -116,11 +112,11 @@ impl<'a> Function<'a> {
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
NONE,
|
||||
NONE,
|
||||
None,
|
||||
None,
|
||||
params,
|
||||
NONE,
|
||||
Some(body.into_in(builder.allocator())),
|
||||
None,
|
||||
Some(body),
|
||||
scope_id,
|
||||
false,
|
||||
false,
|
||||
@@ -145,28 +141,21 @@ impl<'a> Function<'a> {
|
||||
/// * `body`: The function body.
|
||||
/// * `scope_id`
|
||||
#[inline]
|
||||
pub fn boxed_with_scope_id<B: GetAstBuilder<'a>, T1, T2, T3, T4, T5>(
|
||||
pub fn boxed_with_scope_id<B: GetAstBuilder<'a>>(
|
||||
span: Span,
|
||||
r#type: FunctionType,
|
||||
id: Option<BindingIdentifier<'a>>,
|
||||
generator: bool,
|
||||
r#async: bool,
|
||||
declare: bool,
|
||||
type_parameters: T1,
|
||||
this_param: T2,
|
||||
params: T3,
|
||||
return_type: T4,
|
||||
body: T5,
|
||||
type_parameters: Option<ArenaBox<'a, TSTypeParameterDeclaration<'a>>>,
|
||||
this_param: Option<ArenaBox<'a, TSThisParameter<'a>>>,
|
||||
params: ArenaBox<'a, FormalParameters<'a>>,
|
||||
return_type: Option<ArenaBox<'a, TSTypeAnnotation<'a>>>,
|
||||
body: Option<ArenaBox<'a, FunctionBody<'a>>>,
|
||||
scope_id: ScopeId,
|
||||
builder: &B,
|
||||
) -> ArenaBox<'a, Self>
|
||||
where
|
||||
T1: IntoIn<'a, Option<ArenaBox<'a, TSTypeParameterDeclaration<'a>>>>,
|
||||
T2: IntoIn<'a, Option<ArenaBox<'a, TSThisParameter<'a>>>>,
|
||||
T3: IntoIn<'a, ArenaBox<'a, FormalParameters<'a>>>,
|
||||
T4: IntoIn<'a, Option<ArenaBox<'a, TSTypeAnnotation<'a>>>>,
|
||||
T5: IntoIn<'a, Option<ArenaBox<'a, FunctionBody<'a>>>>,
|
||||
{
|
||||
) -> ArenaBox<'a, Self> {
|
||||
let builder = builder.builder();
|
||||
Function::boxed_with_scope_id_and_pure_and_pife(
|
||||
span,
|
||||
@@ -213,7 +202,7 @@ impl<'a> ExportNamedDeclaration<'a> {
|
||||
specifiers,
|
||||
source,
|
||||
ImportOrExportKind::Value,
|
||||
NONE,
|
||||
None,
|
||||
builder,
|
||||
)
|
||||
}
|
||||
@@ -237,7 +226,7 @@ impl<'a> ExportNamedDeclaration<'a> {
|
||||
[],
|
||||
None,
|
||||
ImportOrExportKind::Value,
|
||||
NONE,
|
||||
None,
|
||||
builder,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -70,12 +70,12 @@
|
||||
//! (e.g. `builder.statement_expression(span, expr)`) and primitives (e.g. `builder.vec()`,`builder.ident(str)`).
|
||||
//! Those methods have now been removed. Use the AST type builder methods described above instead.
|
||||
//!
|
||||
//! [`AstBuilder`] and [`NONE`] are no longer re-exported from the crate root either -
|
||||
//! import them from this module instead.
|
||||
//! [`AstBuilder`] is no longer re-exported from the crate root either -
|
||||
//! import it from this module instead.
|
||||
//!
|
||||
//! Explanation of the motivation for this change here: <https://github.com/oxc-project/oxc/issues/23043>.
|
||||
|
||||
use oxc_allocator::{Allocator, ArenaBox, ArenaVec, FromIn, GetAllocator};
|
||||
use oxc_allocator::{Allocator, GetAllocator};
|
||||
use oxc_syntax::node::NodeId;
|
||||
|
||||
mod custom;
|
||||
@@ -163,24 +163,3 @@ impl<'a> GetAllocator<'a> for AstBuilder<'a> {
|
||||
self.allocator
|
||||
}
|
||||
}
|
||||
|
||||
/// Type that can be used in any AST builder method call which requires either:
|
||||
///
|
||||
/// * `IntoIn<'a, Option<Box<'a, T>>`.
|
||||
/// * `IntoIn<'a, Option<Vec<'a, T>>`.
|
||||
///
|
||||
/// Pass `NONE` instead of `None::<Box<'a, T>>`.
|
||||
#[expect(clippy::upper_case_acronyms)]
|
||||
pub struct NONE;
|
||||
|
||||
impl<'a, T> FromIn<'a, NONE> for Option<ArenaBox<'a, T>> {
|
||||
fn from_in(_: NONE, _: &'a Allocator) -> Self {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, T> FromIn<'a, NONE> for Option<ArenaVec<'a, T>> {
|
||||
fn from_in(_: NONE, _: &'a Allocator) -> Self {
|
||||
None
|
||||
}
|
||||
}
|
||||
+1290
-2314
File diff suppressed because it is too large.
Load diff
@@ -1,5 +1,5 @@
|
||||
use oxc_allocator::{Allocator, ArenaBox, ArenaVec, CloneIn, GetAllocator};
|
||||
use oxc_ast::{ast::*, builder::NONE};
|
||||
use oxc_ast::ast::*;
|
||||
use oxc_span::{ContentEq, GetSpan, SPAN};
|
||||
|
||||
use crate::{
|
||||
@@ -205,7 +205,7 @@ impl<'a> IsolatedDeclarations<'a> {
|
||||
function.this_param.clone_in(self.allocator()),
|
||||
params,
|
||||
return_type,
|
||||
NONE,
|
||||
None,
|
||||
self,
|
||||
);
|
||||
|
||||
@@ -239,7 +239,7 @@ impl<'a> IsolatedDeclarations<'a> {
|
||||
r#type,
|
||||
[],
|
||||
key,
|
||||
NONE,
|
||||
None,
|
||||
None,
|
||||
false,
|
||||
r#static,
|
||||
@@ -304,7 +304,7 @@ impl<'a> IsolatedDeclarations<'a> {
|
||||
}
|
||||
MethodDefinitionKind::Get | MethodDefinitionKind::Constructor => {
|
||||
let params =
|
||||
FormalParameters::boxed(SPAN, FormalParameterKind::Signature, [], NONE, self);
|
||||
FormalParameters::boxed(SPAN, FormalParameterKind::Signature, [], None, self);
|
||||
self.transform_class_method_definition(method, params, None)
|
||||
}
|
||||
MethodDefinitionKind::Set => {
|
||||
@@ -695,7 +695,7 @@ impl<'a> IsolatedDeclarations<'a> {
|
||||
r#type,
|
||||
[],
|
||||
ident,
|
||||
NONE,
|
||||
None,
|
||||
None,
|
||||
false,
|
||||
false,
|
||||
@@ -734,7 +734,7 @@ impl<'a> IsolatedDeclarations<'a> {
|
||||
kind: BindingPattern<'a>,
|
||||
) -> ArenaBox<'a, FormalParameters<'a>> {
|
||||
let parameter =
|
||||
FormalParameter::new(SPAN, [], kind, NONE, NONE, false, None, false, false, self);
|
||||
FormalParameters::boxed(SPAN, FormalParameterKind::Signature, [parameter], NONE, self)
|
||||
FormalParameter::new(SPAN, [], kind, None, None, false, None, false, false, self);
|
||||
FormalParameters::boxed(SPAN, FormalParameterKind::Signature, [parameter], None, self)
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
use oxc_allocator::{ArenaBox, ArenaVec, CloneIn, GetAllocator};
|
||||
use oxc_ast::{ast::*, builder::NONE};
|
||||
use oxc_ast::ast::*;
|
||||
use oxc_span::{SPAN, Span};
|
||||
|
||||
use crate::{
|
||||
@@ -33,7 +33,7 @@ impl<'a> IsolatedDeclarations<'a> {
|
||||
func.this_param.clone_in(self.allocator()),
|
||||
params,
|
||||
return_type,
|
||||
NONE,
|
||||
None,
|
||||
self,
|
||||
)
|
||||
}
|
||||
@@ -116,7 +116,7 @@ impl<'a> IsolatedDeclarations<'a> {
|
||||
// not used afterwards, so move it in directly instead of cloning again.
|
||||
pattern,
|
||||
type_annotation,
|
||||
NONE,
|
||||
None,
|
||||
optional,
|
||||
None,
|
||||
false,
|
||||
@@ -130,7 +130,7 @@ impl<'a> IsolatedDeclarations<'a> {
|
||||
[],
|
||||
pattern,
|
||||
param.type_annotation.clone_in(self.allocator()),
|
||||
NONE,
|
||||
None,
|
||||
param.optional,
|
||||
None,
|
||||
false,
|
||||
|
||||
@@ -12,7 +12,7 @@ use rustc_hash::{FxHashMap, FxHashSet};
|
||||
use oxc_allocator::{Allocator, ArenaVec, CloneIn, GetAllocator};
|
||||
use oxc_ast::{
|
||||
ast::*,
|
||||
builder::{AstBuilder, GetAstBuilder, NONE},
|
||||
builder::{AstBuilder, GetAstBuilder},
|
||||
};
|
||||
use oxc_ast_visit::Visit;
|
||||
use oxc_diagnostics::{Diagnostics, OxcDiagnostic};
|
||||
@@ -433,7 +433,7 @@ impl<'a> IsolatedDeclarations<'a> {
|
||||
[],
|
||||
None,
|
||||
kind,
|
||||
NONE,
|
||||
None,
|
||||
self,
|
||||
));
|
||||
} else if self.scope.is_ts_module_block() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use oxc_allocator::{ArenaBox, ArenaVec, CloneIn, GetAllocator, ReplaceWith};
|
||||
use oxc_ast::{ast::*, builder::NONE};
|
||||
use oxc_ast::ast::*;
|
||||
use oxc_span::{GetSpan, SPAN};
|
||||
use oxc_str::Str;
|
||||
|
||||
@@ -18,7 +18,7 @@ impl<'a> IsolatedDeclarations<'a> {
|
||||
[],
|
||||
None,
|
||||
ImportOrExportKind::Value,
|
||||
NONE,
|
||||
None,
|
||||
self,
|
||||
))
|
||||
}
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
use oxc_allocator::{ArenaVec, CloneIn, GetAllocator};
|
||||
use oxc_ast::{
|
||||
ast::{
|
||||
ArrayExpression, ArrayExpressionElement, ArrowFunctionExpression, Expression, Function,
|
||||
ObjectExpression, ObjectPropertyKind, PropertyKey, PropertyKind, TSLiteral,
|
||||
TSMethodSignatureKind, TSSignature, TSTupleElement, TSType, TSTypeAnnotation,
|
||||
TSTypeOperatorOperator,
|
||||
},
|
||||
builder::NONE,
|
||||
use oxc_ast::ast::{
|
||||
ArrayExpression, ArrayExpressionElement, ArrowFunctionExpression, Expression, Function,
|
||||
ObjectExpression, ObjectPropertyKind, PropertyKey, PropertyKind, TSLiteral,
|
||||
TSMethodSignatureKind, TSSignature, TSTupleElement, TSType, TSTypeAnnotation,
|
||||
TSTypeOperatorOperator,
|
||||
};
|
||||
use oxc_span::{ContentEq, GetSpan, SPAN, Span};
|
||||
use oxc_syntax::identifier::is_identifier_name;
|
||||
@@ -61,7 +58,7 @@ impl<'a> IsolatedDeclarations<'a> {
|
||||
TSType::new_ts_function_type(
|
||||
func.span,
|
||||
func.type_parameters.clone_in(self.allocator()),
|
||||
NONE,
|
||||
None,
|
||||
params,
|
||||
return_type,
|
||||
self,
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
use oxc_allocator::{ArenaBox, ArenaVec, GetAllocator};
|
||||
use oxc_ast::{
|
||||
ast::*,
|
||||
builder::{GetAstBuilder, NONE},
|
||||
};
|
||||
use oxc_ast::{ast::*, builder::GetAstBuilder};
|
||||
use oxc_ast_visit::VisitJs;
|
||||
use oxc_ecmascript::BoundNames;
|
||||
use oxc_span::{SPAN, Span};
|
||||
@@ -81,7 +78,7 @@ impl<'a> KeepVar<'a> {
|
||||
)
|
||||
},
|
||||
);
|
||||
VariableDeclarator::new(span, kind, id, NONE, None, false, ast)
|
||||
VariableDeclarator::new(span, kind, id, None, None, false, ast)
|
||||
}),
|
||||
ast,
|
||||
);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use crate::TraverseCtx;
|
||||
use oxc_allocator::{ArenaVec, TakeIn};
|
||||
use oxc_ast::{ast::*, builder::NONE};
|
||||
use oxc_ast::ast::*;
|
||||
use oxc_compat::ESFeature;
|
||||
use oxc_ecmascript::{
|
||||
constant_evaluation::{ConstantEvaluation, ConstantValue, DetermineValueType},
|
||||
@@ -284,7 +284,7 @@ impl<'a> PeepholeOptimizations {
|
||||
ctx,
|
||||
);
|
||||
return Some(Expression::new_call_expression(
|
||||
expr.span, callee, NONE, args, false, ctx,
|
||||
expr.span, callee, None, args, false, ctx,
|
||||
));
|
||||
}
|
||||
// `a ? b(c) : b(e)` -> `b(a ? c : e)`
|
||||
@@ -308,7 +308,7 @@ impl<'a> PeepholeOptimizations {
|
||||
);
|
||||
args[0] = Argument::from(cond_expr);
|
||||
return Some(Expression::new_call_expression(
|
||||
expr.span, callee, NONE, args, false, ctx,
|
||||
expr.span, callee, None, args, false, ctx,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ use std::borrow::Cow;
|
||||
use cow_utils::CowUtils;
|
||||
|
||||
use oxc_allocator::{ArenaBox, ArenaVec, GetAllocator, TakeIn};
|
||||
use oxc_ast::{ast::*, builder::NONE};
|
||||
use oxc_ast::ast::*;
|
||||
use oxc_compat::ESFeature;
|
||||
use oxc_ecmascript::{
|
||||
StringCharAt, StringCharAtResult, ToBigInt, ToIntegerIndex,
|
||||
@@ -193,7 +193,7 @@ impl<'a> PeepholeOptimizations {
|
||||
let new_expr = Expression::new_call_expression(
|
||||
original_span,
|
||||
new_root_callee.take_in(ctx),
|
||||
NONE,
|
||||
None,
|
||||
ArenaVec::from_iter_in(
|
||||
collected_arguments.into_iter().rev().flat_map(|arg| arg.take_in(ctx)),
|
||||
ctx,
|
||||
@@ -263,7 +263,7 @@ impl<'a> PeepholeOptimizations {
|
||||
Some(Expression::new_call_expression(
|
||||
span,
|
||||
callee.take_in(ctx),
|
||||
NONE,
|
||||
None,
|
||||
args.take_in(ctx),
|
||||
false,
|
||||
ctx,
|
||||
|
||||
@@ -2,7 +2,7 @@ use std::iter::repeat_with;
|
||||
|
||||
use crate::generated::ancestor::Ancestor;
|
||||
use oxc_allocator::{ArenaVec, CloneIn, GetAllocator, TakeIn};
|
||||
use oxc_ast::{ast::*, builder::NONE};
|
||||
use oxc_ast::ast::*;
|
||||
use oxc_compat::ESFeature;
|
||||
use oxc_ecmascript::{
|
||||
BoundNames, ToJsString, ToNumber,
|
||||
@@ -992,7 +992,7 @@ impl<'a> PeepholeOptimizations {
|
||||
Expression::new_call_expression(
|
||||
SPAN,
|
||||
callee,
|
||||
NONE,
|
||||
None,
|
||||
[Argument::new_numeric_literal(SPAN, offset, None, NumberBase::Decimal, ctx)],
|
||||
false,
|
||||
ctx,
|
||||
@@ -1002,7 +1002,7 @@ impl<'a> PeepholeOptimizations {
|
||||
};
|
||||
|
||||
let new_decl =
|
||||
VariableDeclarator::new(SPAN, var_init.kind, r_id_pat, NONE, Some(arr), false, ctx);
|
||||
VariableDeclarator::new(SPAN, var_init.kind, r_id_pat, None, Some(arr), false, ctx);
|
||||
// The old declarators (`e`, `a`, and `r`'s original init) are
|
||||
// replaced wholesale — walk them so refs inside (e.g. `e` in
|
||||
// `Array(e > 1 ? e - 1 : 0)`) reach `PassChanges`. The moved-out
|
||||
@@ -1251,7 +1251,7 @@ impl<'a> PeepholeOptimizations {
|
||||
let callee = callee.take_in(ctx);
|
||||
let args = args.take_in(ctx);
|
||||
let new_value = Expression::new_call_expression(
|
||||
*span, callee, NONE, args, false, ctx,
|
||||
*span, callee, None, args, false, ctx,
|
||||
);
|
||||
ctx.replace_expression(expr, new_value);
|
||||
}
|
||||
@@ -1270,7 +1270,7 @@ impl<'a> PeepholeOptimizations {
|
||||
let callee = callee.take_in(ctx);
|
||||
let args = args.take_in(ctx);
|
||||
let new_value =
|
||||
Expression::new_call_expression(*span, callee, NONE, args, false, ctx);
|
||||
Expression::new_call_expression(*span, callee, None, args, false, ctx);
|
||||
ctx.replace_expression(expr, new_value);
|
||||
}
|
||||
} else {
|
||||
@@ -1344,7 +1344,7 @@ impl<'a> PeepholeOptimizations {
|
||||
let new_value = Expression::new_call_expression_with_pure(
|
||||
e.span,
|
||||
e.callee.take_in(ctx),
|
||||
NONE,
|
||||
None,
|
||||
e.arguments.take_in(ctx),
|
||||
false,
|
||||
e.pure,
|
||||
@@ -1770,7 +1770,7 @@ impl<'a> PeepholeOptimizations {
|
||||
false,
|
||||
ctx,
|
||||
),
|
||||
NONE,
|
||||
None,
|
||||
[Argument::new_string_literal(
|
||||
expr.span(),
|
||||
Str::from_str_in(delimiter, ctx),
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use oxc_allocator::ArenaBox;
|
||||
use oxc_ast::{ast::*, builder::NONE};
|
||||
use oxc_ast::ast::*;
|
||||
use oxc_span::FileExtension;
|
||||
use oxc_syntax::precedence::Precedence;
|
||||
|
||||
@@ -238,7 +238,7 @@ impl<'a, C: Config> ParserImpl<'a, C> {
|
||||
ident.span,
|
||||
FormalParameterKind::ArrowFormalParameters,
|
||||
[formal_parameter],
|
||||
NONE,
|
||||
None,
|
||||
self,
|
||||
);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use oxc_allocator::{ArenaBox, ArenaVec, GetAllocator};
|
||||
use oxc_ast::{ast::*, builder::NONE};
|
||||
use oxc_ast::ast::*;
|
||||
use oxc_span::GetSpan;
|
||||
use rustc_hash::FxHashMap;
|
||||
|
||||
@@ -466,7 +466,7 @@ impl<'a, C: Config> ParserImpl<'a, C> {
|
||||
[],
|
||||
None,
|
||||
ImportOrExportKind::Value,
|
||||
NONE,
|
||||
None,
|
||||
self,
|
||||
);
|
||||
if self.ctx.has_top_level() {
|
||||
@@ -496,7 +496,7 @@ impl<'a, C: Config> ParserImpl<'a, C> {
|
||||
[],
|
||||
None,
|
||||
ImportOrExportKind::Value,
|
||||
NONE,
|
||||
None,
|
||||
self,
|
||||
);
|
||||
if self.ctx.has_top_level() {
|
||||
@@ -665,7 +665,7 @@ impl<'a, C: Config> ParserImpl<'a, C> {
|
||||
[],
|
||||
None,
|
||||
export_kind,
|
||||
NONE,
|
||||
None,
|
||||
self,
|
||||
);
|
||||
if self.ctx.has_top_level() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use oxc_allocator::{ArenaBox, ArenaVec};
|
||||
use oxc_ast::{ast::*, builder::NONE};
|
||||
use oxc_ast::ast::*;
|
||||
use oxc_span::GetSpan;
|
||||
use oxc_syntax::operator::UnaryOperator;
|
||||
|
||||
@@ -1472,7 +1472,7 @@ impl<'a, C: Config> ParserImpl<'a, C> {
|
||||
computed,
|
||||
/* optional */ false,
|
||||
kind,
|
||||
NONE,
|
||||
None,
|
||||
this_param,
|
||||
params,
|
||||
return_type,
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
use cow_utils::CowUtils;
|
||||
use oxc_ast::AstKind;
|
||||
use oxc_ast::ast::*;
|
||||
use oxc_ast::builder::{AstBuilder, NONE};
|
||||
use oxc_ast::builder::AstBuilder;
|
||||
use oxc_diagnostics::{Diagnostics, OxcDiagnostic};
|
||||
use oxc_span::{GetSpan, SPAN, Span};
|
||||
use rustc_hash::{FxHashMap, FxHashSet};
|
||||
@@ -2118,10 +2118,10 @@ fn ox_build_function<'a>(
|
||||
codegen.generator,
|
||||
codegen.is_async,
|
||||
false,
|
||||
NONE,
|
||||
NONE,
|
||||
None,
|
||||
None,
|
||||
codegen.params.clone_in_with_semantic_ids(ast.allocator()),
|
||||
NONE,
|
||||
None,
|
||||
Some(codegen.body.clone_in_with_semantic_ids(ast.allocator())),
|
||||
ast,
|
||||
)
|
||||
@@ -2139,9 +2139,9 @@ fn ox_build_compiled_expression<'a>(
|
||||
SPAN,
|
||||
false,
|
||||
codegen.is_async,
|
||||
NONE,
|
||||
None,
|
||||
codegen.params.clone_in_with_semantic_ids(ast.allocator()),
|
||||
NONE,
|
||||
None,
|
||||
codegen.body.clone_in_with_semantic_ids(ast.allocator()),
|
||||
ast,
|
||||
),
|
||||
@@ -2214,7 +2214,7 @@ fn ox_build_gated_const_decl<'a>(
|
||||
SPAN,
|
||||
VariableDeclarationKind::Const,
|
||||
BindingPattern::new_binding_identifier(SPAN, ox_atom(ast, name), ast),
|
||||
NONE,
|
||||
None,
|
||||
Some(gating_expression.clone_in_with_semantic_ids(ast.allocator())),
|
||||
false,
|
||||
ast,
|
||||
@@ -2316,7 +2316,7 @@ impl<'a> OxcVisitor<'a, '_> {
|
||||
[],
|
||||
None,
|
||||
ImportOrExportKind::Value,
|
||||
NONE,
|
||||
None,
|
||||
ast,
|
||||
);
|
||||
} else {
|
||||
@@ -2378,10 +2378,10 @@ impl<'a> oxc_ast_visit::VisitMut<'a> for OxcVisitor<'a, '_> {
|
||||
func.generator,
|
||||
func.r#async,
|
||||
false,
|
||||
NONE,
|
||||
NONE,
|
||||
None,
|
||||
None,
|
||||
func.params.clone_in_with_semantic_ids(ast.allocator()),
|
||||
NONE,
|
||||
None,
|
||||
func.body.clone_in_with_semantic_ids(ast.allocator()),
|
||||
ast,
|
||||
);
|
||||
@@ -2499,7 +2499,7 @@ fn ox_gating_call<'a>(ast: &AstBuilder<'a>, callee_name: &str) -> Expression<'a>
|
||||
Expression::new_call_expression(
|
||||
SPAN,
|
||||
Expression::new_identifier(SPAN, ox_atom(ast, callee_name), ast),
|
||||
NONE,
|
||||
None,
|
||||
[],
|
||||
false,
|
||||
ast,
|
||||
@@ -2741,7 +2741,7 @@ fn ox_add_imports_to_program<'a>(
|
||||
Some(specifiers),
|
||||
source,
|
||||
None,
|
||||
NONE,
|
||||
None,
|
||||
ImportOrExportKind::Value,
|
||||
ast,
|
||||
);
|
||||
@@ -2756,11 +2756,11 @@ fn ox_add_imports_to_program<'a>(
|
||||
BindingPattern::new_binding_identifier(SPAN, ox_atom(ast, &spec.name), ast);
|
||||
props.push(BindingProperty::new(SPAN, key, value, false, false, ast));
|
||||
}
|
||||
let object_pattern = BindingPattern::new_object_pattern(SPAN, props, NONE, ast);
|
||||
let object_pattern = BindingPattern::new_object_pattern(SPAN, props, None, ast);
|
||||
let require_call = Expression::new_call_expression(
|
||||
SPAN,
|
||||
Expression::new_identifier(SPAN, "require", ast),
|
||||
NONE,
|
||||
None,
|
||||
[Argument::new_string_literal(SPAN, ox_atom(ast, module_name), None, ast)],
|
||||
false,
|
||||
ast,
|
||||
@@ -2769,7 +2769,7 @@ fn ox_add_imports_to_program<'a>(
|
||||
SPAN,
|
||||
VariableDeclarationKind::Const,
|
||||
object_pattern,
|
||||
NONE,
|
||||
None,
|
||||
Some(require_call),
|
||||
false,
|
||||
ast,
|
||||
|
||||
+30
-31
@@ -120,7 +120,7 @@ pub fn codegen_function<'a>(
|
||||
let use_memo_cache = oxc_ast::ast::Expression::new_call_expression(
|
||||
SPAN,
|
||||
oxc_ast::ast::Expression::new_identifier(SPAN, memo_cache_name, ast),
|
||||
NONE,
|
||||
None,
|
||||
[oxc_ast::ast::Argument::from(ox_number(ast, cache_count as f64))],
|
||||
false,
|
||||
ast,
|
||||
@@ -133,7 +133,7 @@ pub fn codegen_function<'a>(
|
||||
ox_str(ast, &cache_name),
|
||||
ast,
|
||||
),
|
||||
NONE,
|
||||
None,
|
||||
Some(use_memo_cache),
|
||||
false,
|
||||
ast,
|
||||
@@ -219,7 +219,6 @@ fn ox_codegen_outlined<'a>(
|
||||
use oxc_allocator::GetAllocator;
|
||||
use oxc_allocator::IntoIn;
|
||||
use oxc_ast::ast as oxc;
|
||||
use oxc_ast::builder::NONE;
|
||||
use oxc_span::SPAN;
|
||||
|
||||
// Temp value tracking. Maps a temporary's declaration to its emitted oxc value
|
||||
@@ -407,7 +406,7 @@ fn ox_symbol_for<'a>(ast: &oxc_ast::builder::AstBuilder<'a>, name: &str) -> oxc:
|
||||
oxc_ast::ast::Expression::new_call_expression(
|
||||
SPAN,
|
||||
callee,
|
||||
NONE,
|
||||
None,
|
||||
[oxc::Argument::from(oxc_ast::ast::Expression::new_string_literal(
|
||||
SPAN,
|
||||
ox_str(ast, name),
|
||||
@@ -504,8 +503,8 @@ fn ox_convert_parameters<'a>(
|
||||
SPAN,
|
||||
[],
|
||||
binding,
|
||||
NONE,
|
||||
NONE,
|
||||
None,
|
||||
None,
|
||||
false,
|
||||
None,
|
||||
false,
|
||||
@@ -520,7 +519,7 @@ fn ox_convert_parameters<'a>(
|
||||
SPAN,
|
||||
[],
|
||||
rest_elem,
|
||||
NONE,
|
||||
None,
|
||||
&cx.ast,
|
||||
));
|
||||
}
|
||||
@@ -727,7 +726,7 @@ fn ox_codegen_reactive_scope<'a>(
|
||||
ox_str(&cx.ast, &name),
|
||||
&cx.ast,
|
||||
),
|
||||
NONE,
|
||||
None,
|
||||
None,
|
||||
false,
|
||||
&cx.ast,
|
||||
@@ -1033,7 +1032,7 @@ fn ox_codegen_terminal<'a>(
|
||||
let ident = &cx.env.identifiers[binding.identifier];
|
||||
cx.temp.insert(ident.declaration_id, None);
|
||||
let pattern = ox_binding_for_identifier(cx, binding.identifier)?;
|
||||
Some(oxc_ast::ast::CatchParameter::new(SPAN, pattern, NONE, &cx.ast))
|
||||
Some(oxc_ast::ast::CatchParameter::new(SPAN, pattern, None, &cx.ast))
|
||||
}
|
||||
None => None,
|
||||
};
|
||||
@@ -1045,7 +1044,7 @@ fn ox_codegen_terminal<'a>(
|
||||
SPAN,
|
||||
try_block,
|
||||
Some(handler),
|
||||
NONE,
|
||||
None,
|
||||
&cx.ast,
|
||||
)))
|
||||
}
|
||||
@@ -1078,7 +1077,7 @@ fn ox_codegen_for_in<'a>(
|
||||
SPAN,
|
||||
var_decl_kind,
|
||||
lval,
|
||||
NONE,
|
||||
None,
|
||||
None,
|
||||
false,
|
||||
&cx.ast,
|
||||
@@ -1130,7 +1129,7 @@ fn ox_codegen_for_of<'a>(
|
||||
SPAN,
|
||||
var_decl_kind,
|
||||
lval,
|
||||
NONE,
|
||||
None,
|
||||
None,
|
||||
false,
|
||||
&cx.ast,
|
||||
@@ -1486,7 +1485,7 @@ fn ox_make_var_decl<'a>(
|
||||
init: Option<oxc::Expression<'a>>,
|
||||
) -> oxc::Statement<'a> {
|
||||
let declarator =
|
||||
oxc_ast::ast::VariableDeclarator::new(SPAN, kind, id, NONE, init, false, &cx.ast);
|
||||
oxc_ast::ast::VariableDeclarator::new(SPAN, kind, id, None, init, false, &cx.ast);
|
||||
oxc::Statement::VariableDeclaration(oxc_ast::ast::VariableDeclaration::boxed(
|
||||
SPAN,
|
||||
kind,
|
||||
@@ -1796,7 +1795,7 @@ fn ox_codegen_base_instruction_value<'a>(
|
||||
Ok(OxValue::Expression(oxc_ast::ast::Expression::new_new_expression(
|
||||
SPAN,
|
||||
callee_expr,
|
||||
NONE,
|
||||
None,
|
||||
arguments,
|
||||
&cx.ast,
|
||||
)))
|
||||
@@ -1986,7 +1985,7 @@ fn ox_codegen_base_instruction_value<'a>(
|
||||
}
|
||||
let quasi = ox_template_literal(cx, quasis, exprs);
|
||||
Ok(OxValue::Expression(oxc_ast::ast::Expression::new_tagged_template_expression(
|
||||
SPAN, tag_expr, NONE, quasi, &cx.ast,
|
||||
SPAN, tag_expr, None, quasi, &cx.ast,
|
||||
)))
|
||||
}
|
||||
InstructionValue::TemplateLiteral { subexprs, quasis, .. } => {
|
||||
@@ -2554,10 +2553,10 @@ fn ox_codegen_function_expression<'a>(
|
||||
fn_result.generator,
|
||||
fn_result.is_async,
|
||||
false,
|
||||
NONE,
|
||||
NONE,
|
||||
None,
|
||||
None,
|
||||
fn_result.params,
|
||||
NONE,
|
||||
None,
|
||||
Some(fn_result.body),
|
||||
&cx.ast,
|
||||
);
|
||||
@@ -2611,7 +2610,7 @@ fn ox_build_arrow<'a>(
|
||||
expression: bool,
|
||||
) -> oxc::Expression<'a> {
|
||||
oxc_ast::ast::Expression::new_arrow_function_expression(
|
||||
SPAN, expression, is_async, NONE, params, NONE, body, &cx.ast,
|
||||
SPAN, expression, is_async, None, params, None, body, &cx.ast,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -2690,10 +2689,10 @@ fn ox_codegen_object_expression<'a>(
|
||||
fn_result.generator,
|
||||
fn_result.is_async,
|
||||
false,
|
||||
NONE,
|
||||
NONE,
|
||||
None,
|
||||
None,
|
||||
fn_result.params,
|
||||
NONE,
|
||||
None,
|
||||
Some(fn_result.body),
|
||||
&cx.ast,
|
||||
);
|
||||
@@ -2776,7 +2775,7 @@ fn ox_codegen_jsx_expression<'a>(
|
||||
|
||||
let is_self_closing = children.is_none();
|
||||
let opening =
|
||||
oxc_ast::ast::JSXOpeningElement::boxed(SPAN, opening_name, NONE, attributes, &cx.ast);
|
||||
oxc_ast::ast::JSXOpeningElement::boxed(SPAN, opening_name, None, attributes, &cx.ast);
|
||||
let closing = if is_self_closing {
|
||||
None
|
||||
} else {
|
||||
@@ -3040,7 +3039,7 @@ fn ox_dispatcher_guard_stmt<'a>(
|
||||
let call = oxc_ast::ast::Expression::new_call_expression(
|
||||
SPAN,
|
||||
oxc_ast::ast::Expression::new_identifier(SPAN, guard_name, ast),
|
||||
NONE,
|
||||
None,
|
||||
[oxc_ast::ast::Argument::from(ox_number(ast, kind as u8 as f64))],
|
||||
false,
|
||||
ast,
|
||||
@@ -3068,7 +3067,7 @@ fn ox_create_hook_guard<'a>(
|
||||
[ox_dispatcher_guard_stmt(ast, guard_name, after)],
|
||||
ast,
|
||||
);
|
||||
oxc_ast::ast::Statement::new_try_statement(SPAN, try_block, NONE, Some(finalizer), ast)
|
||||
oxc_ast::ast::Statement::new_try_statement(SPAN, try_block, None, Some(finalizer), ast)
|
||||
}
|
||||
|
||||
/// Build a call expression for `CallExpression`/`MethodCall`, matching TS
|
||||
@@ -3083,7 +3082,7 @@ fn ox_create_call_expression<'a>(
|
||||
) -> oxc::Expression<'a> {
|
||||
let ast = &cx.ast;
|
||||
let call_expr =
|
||||
oxc_ast::ast::Expression::new_call_expression(SPAN, callee, NONE, arguments, false, ast);
|
||||
oxc_ast::ast::Expression::new_call_expression(SPAN, callee, None, arguments, false, ast);
|
||||
// The hook-kind lookup only runs with guards enabled, keeping the default
|
||||
// codegen path free of per-call shape probing.
|
||||
let Some(guard_name) = cx.env.hook_guard_name.as_deref() else {
|
||||
@@ -3107,7 +3106,7 @@ fn ox_create_call_expression<'a>(
|
||||
SPAN,
|
||||
oxc_ast::ast::FormalParameterKind::FormalParameter,
|
||||
[],
|
||||
NONE,
|
||||
None,
|
||||
ast,
|
||||
);
|
||||
let iife = oxc_ast::ast::Function::new(
|
||||
@@ -3117,17 +3116,17 @@ fn ox_create_call_expression<'a>(
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
NONE,
|
||||
NONE,
|
||||
None,
|
||||
None,
|
||||
params,
|
||||
NONE,
|
||||
None,
|
||||
Some(body),
|
||||
ast,
|
||||
);
|
||||
oxc_ast::ast::Expression::new_call_expression(
|
||||
SPAN,
|
||||
oxc::Expression::FunctionExpression(oxc_allocator::ArenaBox::new_in(iife, ast)),
|
||||
NONE,
|
||||
None,
|
||||
[],
|
||||
false,
|
||||
ast,
|
||||
|
||||
@@ -92,7 +92,7 @@ use indexmap::IndexMap;
|
||||
use rustc_hash::{FxBuildHasher, FxHashSet};
|
||||
|
||||
use oxc_allocator::{ArenaBox, ArenaVec, ReplaceWith, TakeIn};
|
||||
use oxc_ast::{ast::*, builder::NONE};
|
||||
use oxc_ast::ast::*;
|
||||
use oxc_ast_visit::{VisitJsMut, walk_js_mut::walk_expression};
|
||||
use oxc_data_structures::stack::{NonEmptyStack, SparseStack};
|
||||
use oxc_semantic::{ReferenceFlags, SymbolId};
|
||||
@@ -665,7 +665,7 @@ impl<'a> ArrowFunctionConverter<'a> {
|
||||
arrow_function_expr.r#async,
|
||||
false,
|
||||
arrow_function_expr.type_parameters,
|
||||
NONE,
|
||||
None,
|
||||
arrow_function_expr.params,
|
||||
arrow_function_expr.return_type,
|
||||
Some(body),
|
||||
@@ -797,7 +797,7 @@ impl<'a> ArrowFunctionConverter<'a> {
|
||||
arguments.push(Argument::from(assign_value.take_in(ctx)));
|
||||
}
|
||||
let call =
|
||||
Expression::new_call_expression(expr.span(), callee, NONE, arguments, false, ctx);
|
||||
Expression::new_call_expression(expr.span(), callee, None, arguments, false, ctx);
|
||||
Some(call)
|
||||
}
|
||||
|
||||
@@ -838,7 +838,7 @@ impl<'a> ArrowFunctionConverter<'a> {
|
||||
let callee =
|
||||
MemberExpression::new_static_member_expression(SPAN, object, property, false, ctx);
|
||||
let callee = Expression::from(callee);
|
||||
Some(Expression::new_call_expression(call.span, callee, NONE, arguments, false, ctx))
|
||||
Some(Expression::new_call_expression(call.span, callee, None, arguments, false, ctx))
|
||||
}
|
||||
|
||||
/// Transform an `AssignmentExpression` whose assignment target is a `super` member expression.
|
||||
@@ -924,8 +924,8 @@ impl<'a> ArrowFunctionConverter<'a> {
|
||||
SPAN,
|
||||
[],
|
||||
param_binding.create_binding_pattern(ctx),
|
||||
NONE,
|
||||
NONE,
|
||||
None,
|
||||
None,
|
||||
false,
|
||||
None,
|
||||
false,
|
||||
@@ -954,8 +954,8 @@ impl<'a> ArrowFunctionConverter<'a> {
|
||||
SPAN,
|
||||
[],
|
||||
param_binding.create_binding_pattern(ctx),
|
||||
NONE,
|
||||
NONE,
|
||||
None,
|
||||
None,
|
||||
false,
|
||||
None,
|
||||
false,
|
||||
@@ -981,19 +981,19 @@ impl<'a> ArrowFunctionConverter<'a> {
|
||||
SPAN,
|
||||
FormalParameterKind::ArrowFormalParameters,
|
||||
items,
|
||||
NONE,
|
||||
None,
|
||||
ctx,
|
||||
);
|
||||
let statement = Statement::new_expression_statement(SPAN, init, ctx);
|
||||
let body = FunctionBody::boxed(SPAN, [], [statement], ctx);
|
||||
let init = Expression::new_arrow_function_expression_with_scope_id_and_pure_and_pife(
|
||||
SPAN, true, false, NONE, params, NONE, body, scope_id, false, false, ctx,
|
||||
SPAN, true, false, None, params, None, body, scope_id, false, false, ctx,
|
||||
);
|
||||
VariableDeclarator::new(
|
||||
SPAN,
|
||||
VariableDeclarationKind::Var,
|
||||
binding.create_binding_pattern(ctx),
|
||||
NONE,
|
||||
None,
|
||||
Some(init),
|
||||
false,
|
||||
ctx,
|
||||
@@ -1170,7 +1170,7 @@ impl<'a> ArrowFunctionConverter<'a> {
|
||||
SPAN,
|
||||
VariableDeclarationKind::Var,
|
||||
arguments_var.create_binding_pattern(ctx),
|
||||
NONE,
|
||||
None,
|
||||
Some(init),
|
||||
false,
|
||||
ctx,
|
||||
@@ -1231,7 +1231,7 @@ impl<'a> ArrowFunctionConverter<'a> {
|
||||
SPAN,
|
||||
VariableDeclarationKind::Var,
|
||||
this_var.create_binding_pattern(ctx),
|
||||
NONE,
|
||||
None,
|
||||
init,
|
||||
false,
|
||||
ctx,
|
||||
|
||||
@@ -71,10 +71,7 @@ use rustc_hash::FxHashMap;
|
||||
use serde::Deserialize;
|
||||
|
||||
use oxc_allocator::{ArenaBox, ArenaVec};
|
||||
use oxc_ast::{
|
||||
ast::{Argument, CallExpression, Expression, IdentifierName},
|
||||
builder::NONE,
|
||||
};
|
||||
use oxc_ast::ast::{Argument, CallExpression, Expression, IdentifierName};
|
||||
use oxc_semantic::{ReferenceFlags, SymbolFlags};
|
||||
use oxc_span::SPAN;
|
||||
use oxc_str::{Str, static_ident};
|
||||
@@ -276,7 +273,7 @@ pub fn helper_call<'a>(
|
||||
) -> ArenaBox<'a, CallExpression<'a>> {
|
||||
let callee = helper_load(helper, ctx);
|
||||
let pure = helper.pure();
|
||||
CallExpression::boxed_with_pure(SPAN, callee, NONE, arguments, false, pure, ctx)
|
||||
CallExpression::boxed_with_pure(SPAN, callee, None, arguments, false, pure, ctx)
|
||||
}
|
||||
|
||||
/// Same as [`helper_call`], but returns a `CallExpression` wrapped in an `Expression`.
|
||||
@@ -289,7 +286,7 @@ pub fn helper_call_expr<'a>(
|
||||
) -> Expression<'a> {
|
||||
let callee = helper_load(helper, ctx);
|
||||
let pure = helper.pure();
|
||||
Expression::new_call_expression_with_pure(SPAN, callee, NONE, arguments, false, pure, ctx)
|
||||
Expression::new_call_expression_with_pure(SPAN, callee, None, arguments, false, pure, ctx)
|
||||
}
|
||||
|
||||
/// Load a helper function and return a callee expression.
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
use indexmap::{IndexMap, map::Entry as IndexMapEntry};
|
||||
|
||||
use oxc_allocator::ArenaVec;
|
||||
use oxc_ast::{ast::*, builder::NONE};
|
||||
use oxc_ast::ast::*;
|
||||
use oxc_semantic::ReferenceFlags;
|
||||
use oxc_span::SPAN;
|
||||
use oxc_str::{Str, static_ident};
|
||||
@@ -164,7 +164,7 @@ impl<'a> ModuleImportsStore<'a> {
|
||||
Some(specifiers),
|
||||
StringLiteral::new(SPAN, source, None, ctx),
|
||||
None,
|
||||
NONE,
|
||||
None,
|
||||
ImportOrExportKind::Value,
|
||||
ctx,
|
||||
)
|
||||
@@ -191,8 +191,8 @@ impl<'a> ModuleImportsStore<'a> {
|
||||
let id = local.create_binding_pattern(ctx);
|
||||
let var_kind = VariableDeclarationKind::Var;
|
||||
let decl = {
|
||||
let init = Expression::new_call_expression(SPAN, callee, NONE, args, false, ctx);
|
||||
let decl = VariableDeclarator::new(SPAN, var_kind, id, NONE, Some(init), false, ctx);
|
||||
let init = Expression::new_call_expression(SPAN, callee, None, args, false, ctx);
|
||||
let decl = VariableDeclarator::new(SPAN, var_kind, id, None, Some(init), false, ctx);
|
||||
[decl]
|
||||
};
|
||||
Statement::new_variable_declaration(SPAN, var_kind, decl, false, ctx)
|
||||
|
||||
@@ -15,10 +15,7 @@
|
||||
//! ```
|
||||
|
||||
use oxc_allocator::ArenaVec;
|
||||
use oxc_ast::{
|
||||
ast::*,
|
||||
builder::{AstBuilder, NONE},
|
||||
};
|
||||
use oxc_ast::{ast::*, builder::AstBuilder};
|
||||
use oxc_data_structures::stack::SparseStack;
|
||||
use oxc_span::SPAN;
|
||||
use oxc_traverse::{BoundIdentifier, ast_operations::GatherNodeParts};
|
||||
@@ -153,7 +150,7 @@ impl<'a> VarDeclarationsStore<'a> {
|
||||
SPAN,
|
||||
VariableDeclarationKind::Var,
|
||||
ident,
|
||||
NONE,
|
||||
None,
|
||||
init,
|
||||
false,
|
||||
ast,
|
||||
@@ -173,7 +170,7 @@ impl<'a> VarDeclarationsStore<'a> {
|
||||
SPAN,
|
||||
VariableDeclarationKind::Let,
|
||||
ident,
|
||||
NONE,
|
||||
None,
|
||||
init,
|
||||
false,
|
||||
ast,
|
||||
|
||||
@@ -52,7 +52,7 @@ use oxc_allocator::{
|
||||
Address, ArenaBox, ArenaVec, CloneIn, GetAddress, GetAllocator, ReplaceWith, TakeIn,
|
||||
UnstableAddress,
|
||||
};
|
||||
use oxc_ast::{ast::*, builder::NONE};
|
||||
use oxc_ast::ast::*;
|
||||
use oxc_ast_visit::{VisitJs, VisitMut};
|
||||
use oxc_data_structures::stack::NonEmptyStack;
|
||||
use oxc_semantic::{ScopeFlags, ScopeId, SymbolFlags};
|
||||
@@ -413,7 +413,7 @@ impl<'a> LegacyDecorator<'a> {
|
||||
PropertyDefinitionType::PropertyDefinition,
|
||||
[],
|
||||
PropertyKey::new_private_identifier(SPAN, storage_name, ctx),
|
||||
NONE,
|
||||
None,
|
||||
accessor.value.take(),
|
||||
false,
|
||||
is_static,
|
||||
@@ -499,7 +499,7 @@ impl<'a> LegacyDecorator<'a> {
|
||||
|
||||
let (params, body_stmt) = if is_getter {
|
||||
let params =
|
||||
FormalParameters::boxed(SPAN, FormalParameterKind::FormalParameter, [], NONE, ctx);
|
||||
FormalParameters::boxed(SPAN, FormalParameterKind::FormalParameter, [], None, ctx);
|
||||
let field_expr = Expression::new_private_field_expression(
|
||||
SPAN,
|
||||
create_object(ctx),
|
||||
@@ -519,8 +519,8 @@ impl<'a> LegacyDecorator<'a> {
|
||||
SPAN,
|
||||
[],
|
||||
value_binding.create_binding_pattern(ctx),
|
||||
NONE,
|
||||
NONE,
|
||||
None,
|
||||
None,
|
||||
false,
|
||||
None,
|
||||
false,
|
||||
@@ -531,7 +531,7 @@ impl<'a> LegacyDecorator<'a> {
|
||||
SPAN,
|
||||
FormalParameterKind::FormalParameter,
|
||||
[param],
|
||||
NONE,
|
||||
None,
|
||||
ctx,
|
||||
);
|
||||
let assign = Expression::new_assignment_expression(
|
||||
@@ -1017,7 +1017,7 @@ impl<'a> LegacyDecorator<'a> {
|
||||
SPAN,
|
||||
VariableDeclarationKind::Let,
|
||||
binding.create_spanned_binding_pattern(binding_span, ctx),
|
||||
NONE,
|
||||
None,
|
||||
Some(initializer),
|
||||
false,
|
||||
ctx,
|
||||
@@ -1463,7 +1463,7 @@ impl<'a> LegacyDecorator<'a> {
|
||||
let exported = ModuleExportName::new_identifier_name(SPAN, class_binding.name, ctx);
|
||||
let specifiers = [ExportSpecifier::new(SPAN, local, exported, kind, ctx)];
|
||||
let export_class_reference = ModuleDeclaration::new_export_named_declaration(
|
||||
SPAN, None, specifiers, None, kind, NONE, ctx,
|
||||
SPAN, None, specifiers, None, kind, None, ctx,
|
||||
);
|
||||
Statement::from(export_class_reference)
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
//! * Exponentiation operator specification: <https://tc39.es/ecma262/#sec-exp-operator>
|
||||
|
||||
use oxc_allocator::{ArenaVec, CloneIn, GetAllocator, ReplaceWith, TakeIn};
|
||||
use oxc_ast::{ast::*, builder::NONE};
|
||||
use oxc_ast::ast::*;
|
||||
use oxc_semantic::ReferenceFlags;
|
||||
use oxc_span::{SPAN, Span};
|
||||
use oxc_str::static_ident;
|
||||
@@ -550,7 +550,7 @@ impl<'a> ExponentiationOperator<'a> {
|
||||
let property = IdentifierName::new(SPAN, "pow", ctx);
|
||||
let callee = Expression::new_static_member_expression(span, object, property, false, ctx);
|
||||
let arguments = ArenaVec::from_array_in([Argument::from(left), Argument::from(right)], ctx);
|
||||
Expression::new_call_expression(span, callee, NONE, arguments, false, ctx)
|
||||
Expression::new_call_expression(span, callee, None, arguments, false, ctx)
|
||||
}
|
||||
|
||||
/// Create a temporary variable.
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
use std::{borrow::Cow, mem};
|
||||
|
||||
use oxc_allocator::{ArenaBox, ArenaStringBuilder, ArenaVec, GetAllocator, ReplaceWith, TakeIn};
|
||||
use oxc_ast::{ast::*, builder::NONE};
|
||||
use oxc_ast::ast::*;
|
||||
use oxc_ast_visit::VisitJs;
|
||||
use oxc_semantic::{ReferenceFlags, ScopeFlags, ScopeId, SymbolFlags};
|
||||
use oxc_span::{GetSpan, SPAN};
|
||||
@@ -292,7 +292,7 @@ impl<'a> AsyncGeneratorExecutor<'a> {
|
||||
(callee, ArenaVec::new_in(ctx))
|
||||
};
|
||||
|
||||
let expression = Expression::new_call_expression(SPAN, callee, NONE, arguments, false, ctx);
|
||||
let expression = Expression::new_call_expression(SPAN, callee, None, arguments, false, ctx);
|
||||
let statement = Statement::new_return_statement(SPAN, Some(expression), ctx);
|
||||
|
||||
// Modify the wrapper function
|
||||
@@ -411,7 +411,7 @@ impl<'a> AsyncGeneratorExecutor<'a> {
|
||||
|
||||
// Construct the IIFE
|
||||
let callee = Expression::FunctionExpression(wrapper_function.take_in_box(ctx));
|
||||
Expression::new_call_expression_with_pure(span, callee, NONE, [], false, true, ctx)
|
||||
Expression::new_call_expression_with_pure(span, callee, None, [], false, true, ctx)
|
||||
}
|
||||
|
||||
/// Transforms async function declarations into generator functions wrapped in the asyncToGenerator helper.
|
||||
@@ -604,7 +604,7 @@ impl<'a> AsyncGeneratorExecutor<'a> {
|
||||
);
|
||||
// Construct the IIFE
|
||||
let callee = Expression::FunctionExpression(wrapper_function);
|
||||
Expression::new_call_expression(arrow_span, callee, NONE, [], false, ctx)
|
||||
Expression::new_call_expression(arrow_span, callee, None, [], false, ctx)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -703,10 +703,10 @@ impl<'a> AsyncGeneratorExecutor<'a> {
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
NONE,
|
||||
NONE,
|
||||
None,
|
||||
None,
|
||||
params,
|
||||
NONE,
|
||||
None,
|
||||
Some(body),
|
||||
scope_id,
|
||||
ctx,
|
||||
@@ -753,7 +753,7 @@ impl<'a> AsyncGeneratorExecutor<'a> {
|
||||
false,
|
||||
ctx,
|
||||
);
|
||||
let argument = Expression::new_call_expression(SPAN, callee, NONE, arguments, false, ctx);
|
||||
let argument = Expression::new_call_expression(SPAN, callee, None, arguments, false, ctx);
|
||||
Statement::new_return_statement(SPAN, Some(argument), ctx)
|
||||
}
|
||||
|
||||
@@ -810,7 +810,7 @@ impl<'a> AsyncGeneratorExecutor<'a> {
|
||||
SPAN,
|
||||
VariableDeclarationKind::Var,
|
||||
bound_ident.create_binding_pattern(ctx),
|
||||
NONE,
|
||||
None,
|
||||
Some(init),
|
||||
false,
|
||||
ctx,
|
||||
@@ -873,13 +873,13 @@ impl<'a> AsyncGeneratorExecutor<'a> {
|
||||
));
|
||||
}
|
||||
|
||||
FormalParameters::boxed(SPAN, FormalParameterKind::FormalParameter, parameters, NONE, ctx)
|
||||
FormalParameters::boxed(SPAN, FormalParameterKind::FormalParameter, parameters, None, ctx)
|
||||
}
|
||||
|
||||
/// Creates an empty [FormalParameters] with [FormalParameterKind::FormalParameter].
|
||||
#[inline]
|
||||
fn create_empty_params(ctx: &TraverseCtx<'a>) -> ArenaBox<'a, FormalParameters<'a>> {
|
||||
FormalParameters::boxed(SPAN, FormalParameterKind::FormalParameter, [], NONE, ctx)
|
||||
FormalParameters::boxed(SPAN, FormalParameterKind::FormalParameter, [], None, ctx)
|
||||
}
|
||||
|
||||
/// Creates a [`BoundIdentifier`] for the id of the function.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//! This module is responsible for transforming `for await` to `for` statement
|
||||
|
||||
use oxc_allocator::{ArenaVec, TakeIn};
|
||||
use oxc_ast::{ast::*, builder::NONE};
|
||||
use oxc_ast::ast::*;
|
||||
use oxc_semantic::{ScopeFlags, ScopeId, SymbolFlags};
|
||||
use oxc_span::{SPAN, Span};
|
||||
use oxc_str::static_ident;
|
||||
@@ -230,7 +230,7 @@ impl<'a> AsyncGeneratorFunctions<'a> {
|
||||
SPAN,
|
||||
VariableDeclarationKind::Var,
|
||||
iterator_abrupt_completion.create_binding_pattern(ctx),
|
||||
NONE,
|
||||
None,
|
||||
Some(Expression::new_boolean_literal(SPAN, false, ctx)),
|
||||
false,
|
||||
ctx,
|
||||
@@ -245,7 +245,7 @@ impl<'a> AsyncGeneratorFunctions<'a> {
|
||||
SPAN,
|
||||
VariableDeclarationKind::Var,
|
||||
iterator_had_error_key.create_binding_pattern(ctx),
|
||||
NONE,
|
||||
None,
|
||||
Some(Expression::new_boolean_literal(SPAN, false, ctx)),
|
||||
false,
|
||||
ctx,
|
||||
@@ -260,7 +260,7 @@ impl<'a> AsyncGeneratorFunctions<'a> {
|
||||
SPAN,
|
||||
VariableDeclarationKind::Var,
|
||||
iterator_error_key.create_binding_pattern(ctx),
|
||||
NONE,
|
||||
None,
|
||||
None,
|
||||
false,
|
||||
ctx,
|
||||
@@ -286,7 +286,7 @@ impl<'a> AsyncGeneratorFunctions<'a> {
|
||||
SPAN,
|
||||
VariableDeclarationKind::Var,
|
||||
iterator_key.create_binding_pattern(ctx),
|
||||
NONE,
|
||||
None,
|
||||
Some(iterator),
|
||||
false,
|
||||
ctx,
|
||||
@@ -295,7 +295,7 @@ impl<'a> AsyncGeneratorFunctions<'a> {
|
||||
SPAN,
|
||||
VariableDeclarationKind::Var,
|
||||
step_key.create_binding_pattern(ctx),
|
||||
NONE,
|
||||
None,
|
||||
None,
|
||||
false,
|
||||
ctx,
|
||||
@@ -330,7 +330,7 @@ impl<'a> AsyncGeneratorFunctions<'a> {
|
||||
false,
|
||||
ctx,
|
||||
),
|
||||
NONE,
|
||||
None,
|
||||
[],
|
||||
false,
|
||||
ctx,
|
||||
@@ -385,7 +385,7 @@ impl<'a> AsyncGeneratorFunctions<'a> {
|
||||
);
|
||||
Some(CatchClause::boxed_with_scope_id(
|
||||
SPAN,
|
||||
Some(CatchParameter::new(SPAN, err_ident.create_binding_pattern(ctx), NONE, ctx)),
|
||||
Some(CatchParameter::new(SPAN, err_ident.create_binding_pattern(ctx), None, ctx)),
|
||||
{
|
||||
BlockStatement::boxed_with_scope_id(
|
||||
SPAN,
|
||||
@@ -466,7 +466,7 @@ impl<'a> AsyncGeneratorFunctions<'a> {
|
||||
false,
|
||||
ctx,
|
||||
),
|
||||
NONE,
|
||||
None,
|
||||
[],
|
||||
false,
|
||||
ctx,
|
||||
@@ -513,7 +513,7 @@ impl<'a> AsyncGeneratorFunctions<'a> {
|
||||
};
|
||||
BlockStatement::boxed_with_scope_id(SPAN, [if_statement], finally_scope_id, ctx)
|
||||
};
|
||||
Statement::new_try_statement(SPAN, block, NONE, Some(finally), ctx)
|
||||
Statement::new_try_statement(SPAN, block, None, Some(finally), ctx)
|
||||
};
|
||||
|
||||
let block_statement =
|
||||
|
||||
@@ -32,7 +32,7 @@ use std::{iter, mem};
|
||||
use serde::Deserialize;
|
||||
|
||||
use oxc_allocator::{Address, ArenaBox, ArenaVec, GetAddress, GetAllocator, ReplaceWith, TakeIn};
|
||||
use oxc_ast::{ast::*, builder::NONE};
|
||||
use oxc_ast::ast::*;
|
||||
use oxc_diagnostics::OxcDiagnostic;
|
||||
use oxc_ecmascript::{BoundNames, ToJsString, WithoutGlobalReferenceInformation};
|
||||
use oxc_semantic::{ScopeFlags, ScopeId, SymbolFlags};
|
||||
@@ -215,7 +215,7 @@ impl<'a> ObjectRestSpread<'a> {
|
||||
let mut new_decls = vec![];
|
||||
|
||||
if let Some(id) = reference_builder.binding.take() {
|
||||
new_decls.push(VariableDeclarator::new(SPAN, state.kind, id, NONE, None, false, ctx));
|
||||
new_decls.push(VariableDeclarator::new(SPAN, state.kind, id, None, None, false, ctx));
|
||||
}
|
||||
|
||||
let data = Self::walk_assignment_target(&mut assign_expr.left, &mut new_decls, state, ctx);
|
||||
@@ -457,7 +457,7 @@ impl<'a> ObjectRestSpread<'a> {
|
||||
let bound_identifier = ctx.generate_uid_in_current_hoist_scope("ref");
|
||||
let id = bound_identifier.create_binding_pattern(ctx);
|
||||
let kind = VariableDeclarationKind::Var;
|
||||
decls.push(VariableDeclarator::new(SPAN, kind, id, NONE, None, false, ctx));
|
||||
decls.push(VariableDeclarator::new(SPAN, kind, id, None, None, false, ctx));
|
||||
exprs.push(Expression::new_assignment_expression(
|
||||
SPAN,
|
||||
AssignmentOperator::Assign,
|
||||
@@ -691,7 +691,7 @@ impl<'a> ObjectRestSpread<'a> {
|
||||
let id = bound_identifier.create_binding_pattern(ctx);
|
||||
let kind = VariableDeclarationKind::Var;
|
||||
let declarations = ArenaVec::from_value_in(
|
||||
VariableDeclarator::new(SPAN, kind, id, NONE, None, false, ctx),
|
||||
VariableDeclarator::new(SPAN, kind, id, None, None, false, ctx),
|
||||
ctx,
|
||||
);
|
||||
let decl = VariableDeclaration::boxed(SPAN, kind, declarations, false, ctx);
|
||||
@@ -815,7 +815,7 @@ impl<'a> ObjectRestSpread<'a> {
|
||||
});
|
||||
let init = bound_identifier.create_read_expression(ctx);
|
||||
let declarations = ArenaVec::from_value_in(
|
||||
VariableDeclarator::new(SPAN, kind, id, NONE, Some(init), false, ctx),
|
||||
VariableDeclarator::new(SPAN, kind, id, None, Some(init), false, ctx),
|
||||
ctx,
|
||||
);
|
||||
VariableDeclaration::boxed(SPAN, kind, declarations, false, ctx)
|
||||
@@ -881,7 +881,7 @@ impl<'a> ObjectRestSpread<'a> {
|
||||
SPAN,
|
||||
state.kind,
|
||||
id,
|
||||
NONE,
|
||||
None,
|
||||
Some(reference_builder.create_read_expression(ctx)),
|
||||
false,
|
||||
ctx,
|
||||
@@ -939,7 +939,7 @@ impl<'a> ObjectRestSpread<'a> {
|
||||
lhs.span(),
|
||||
decl.kind,
|
||||
lhs,
|
||||
NONE,
|
||||
None,
|
||||
Some(rhs),
|
||||
false,
|
||||
ctx,
|
||||
@@ -957,13 +957,13 @@ impl<'a> ObjectRestSpread<'a> {
|
||||
|
||||
// Insert the original declarator by copying its data out.
|
||||
if !remove_empty_object_pattern {
|
||||
let mut binding_pattern = BindingPattern::new_object_pattern(decl.span, [], NONE, ctx);
|
||||
let mut binding_pattern = BindingPattern::new_object_pattern(decl.span, [], None, ctx);
|
||||
mem::swap(&mut binding_pattern, &mut decl.id);
|
||||
let decl = VariableDeclarator::new(
|
||||
decl.span,
|
||||
decl.kind,
|
||||
binding_pattern,
|
||||
NONE,
|
||||
None,
|
||||
Some(reference_builder.create_read_expression(ctx)),
|
||||
false,
|
||||
ctx,
|
||||
@@ -1006,7 +1006,7 @@ impl<'a> ObjectRestSpread<'a> {
|
||||
|
||||
let init = bound_identifier.create_read_expression(ctx);
|
||||
let mut decl =
|
||||
VariableDeclarator::new(SPAN, state.kind, id, NONE, Some(init), false, ctx);
|
||||
VariableDeclarator::new(SPAN, state.kind, id, None, Some(init), false, ctx);
|
||||
let mut decls = self
|
||||
.transform_variable_declarator(&mut decl, ctx)
|
||||
.into_iter()
|
||||
@@ -1078,7 +1078,7 @@ impl<'a> ObjectRestSpread<'a> {
|
||||
SPAN,
|
||||
state.kind,
|
||||
p,
|
||||
NONE,
|
||||
None,
|
||||
Some(lhs),
|
||||
false,
|
||||
ctx,
|
||||
@@ -1181,7 +1181,7 @@ impl<'a> SpreadPair<'a> {
|
||||
SPAN,
|
||||
kind,
|
||||
bound_identifier.create_binding_pattern(ctx),
|
||||
NONE,
|
||||
None,
|
||||
Some(key_expression),
|
||||
false,
|
||||
ctx,
|
||||
@@ -1203,7 +1203,7 @@ impl<'a> SpreadPair<'a> {
|
||||
Argument::from(helper_load(Helper::ToPropertyKey, ctx)),
|
||||
ctx,
|
||||
);
|
||||
Expression::new_call_expression(SPAN, callee, NONE, arguments, false, ctx)
|
||||
Expression::new_call_expression(SPAN, callee, None, arguments, false, ctx)
|
||||
} else {
|
||||
key_expression
|
||||
};
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
//! * Babel plugin implementation: <https://github.com/babel/babel/tree/v7.26.2/packages/babel-plugin-transform-optional-catch-binding>
|
||||
//! * Optional catch binding TC39 proposal: <https://github.com/tc39/proposal-optional-catch-binding>
|
||||
|
||||
use oxc_ast::{ast::*, builder::NONE};
|
||||
use oxc_ast::ast::*;
|
||||
use oxc_semantic::SymbolFlags;
|
||||
use oxc_span::SPAN;
|
||||
use oxc_traverse::Traverse;
|
||||
@@ -61,7 +61,7 @@ impl<'a> Traverse<'a, TransformState<'a>> for OptionalCatchBinding {
|
||||
SymbolFlags::CatchVariable | SymbolFlags::FunctionScopedVariable,
|
||||
);
|
||||
let binding_pattern = binding.create_binding_pattern(ctx);
|
||||
let param = CatchParameter::new(SPAN, binding_pattern, NONE, ctx);
|
||||
let param = CatchParameter::new(SPAN, binding_pattern, None, ctx);
|
||||
clause.param = Some(param);
|
||||
}
|
||||
}
|
||||
@@ -26,7 +26,7 @@
|
||||
//! * "export ns from" TC39 proposal: <https://github.com/tc39/proposal-export-ns-from>
|
||||
|
||||
use oxc_allocator::{ArenaVec, TakeIn};
|
||||
use oxc_ast::{ast::*, builder::NONE};
|
||||
use oxc_ast::ast::*;
|
||||
use oxc_semantic::SymbolFlags;
|
||||
use oxc_span::SPAN;
|
||||
use oxc_traverse::Traverse;
|
||||
@@ -83,7 +83,7 @@ impl<'a> Traverse<'a, TransformState<'a>> for ExportNamespaceFrom {
|
||||
Some(ArenaVec::from_value_in(import_specifier, ctx)),
|
||||
source,
|
||||
None,
|
||||
NONE,
|
||||
None,
|
||||
export_kind,
|
||||
ctx,
|
||||
);
|
||||
@@ -101,7 +101,7 @@ impl<'a> Traverse<'a, TransformState<'a>> for ExportNamespaceFrom {
|
||||
[export_specifier],
|
||||
None,
|
||||
export_kind,
|
||||
NONE,
|
||||
None,
|
||||
ctx,
|
||||
);
|
||||
new_statements.push(Statement::ExportNamedDeclaration(export_named_decl));
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
//! * Nullish coalescing TC39 proposal: <https://github.com/tc39-transfer/proposal-nullish-coalescing>
|
||||
|
||||
use oxc_allocator::{ArenaBox, ReplaceWith};
|
||||
use oxc_ast::{ast::*, builder::NONE};
|
||||
use oxc_ast::ast::*;
|
||||
use oxc_semantic::{ScopeFlags, SymbolFlags};
|
||||
use oxc_span::SPAN;
|
||||
use oxc_syntax::operator::{AssignmentOperator, BinaryOperator, LogicalOperator};
|
||||
@@ -146,12 +146,12 @@ impl<'a> NullishCoalescingOperator {
|
||||
// so the temporary variable can be injected in correct scope
|
||||
let id = binding.create_binding_pattern(ctx);
|
||||
let param =
|
||||
FormalParameter::new(SPAN, [], id, NONE, NONE, false, None, false, false, ctx);
|
||||
FormalParameter::new(SPAN, [], id, None, None, false, None, false, false, ctx);
|
||||
let params = FormalParameters::boxed(
|
||||
SPAN,
|
||||
FormalParameterKind::ArrowFormalParameters,
|
||||
[param],
|
||||
NONE,
|
||||
None,
|
||||
ctx,
|
||||
);
|
||||
let body = FunctionBody::boxed(
|
||||
@@ -165,9 +165,9 @@ impl<'a> NullishCoalescingOperator {
|
||||
SPAN,
|
||||
true,
|
||||
false,
|
||||
NONE,
|
||||
None,
|
||||
params,
|
||||
NONE,
|
||||
None,
|
||||
body,
|
||||
current_scope_id,
|
||||
false,
|
||||
@@ -175,7 +175,7 @@ impl<'a> NullishCoalescingOperator {
|
||||
ctx,
|
||||
);
|
||||
// `(x) => x;` -> `((x) => x)();`
|
||||
new_expr = Expression::new_call_expression(SPAN, arrow_function, NONE, [], false, ctx);
|
||||
new_expr = Expression::new_call_expression(SPAN, arrow_function, None, [], false, ctx);
|
||||
} else {
|
||||
ctx.state.var_declarations.insert_var(&binding, &ctx.ast);
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
use std::mem;
|
||||
|
||||
use oxc_allocator::{CloneIn, GetAllocator, ReplaceWith, TakeIn};
|
||||
use oxc_ast::{ast::*, builder::NONE};
|
||||
use oxc_ast::ast::*;
|
||||
use oxc_span::{GetSpan, SPAN, Span};
|
||||
use oxc_traverse::{Ancestor, BoundIdentifier, MaybeBoundIdentifier, Traverse};
|
||||
|
||||
@@ -403,7 +403,7 @@ impl<'a> OptionalChaining<'a> {
|
||||
let callee =
|
||||
MemberExpression::new_static_member_expression(SPAN, expr, property, false, ctx);
|
||||
let callee = Expression::from(callee);
|
||||
Expression::new_call_expression(SPAN, callee, NONE, [context], false, ctx)
|
||||
Expression::new_call_expression(SPAN, callee, None, [context], false, ctx)
|
||||
}
|
||||
|
||||
/// Recursively transform chain expression elements
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
//! Transform of class itself.
|
||||
|
||||
use oxc_allocator::{Address, ArenaVec, GetAddress, TakeIn, UnstableAddress};
|
||||
use oxc_ast::{ast::*, builder::NONE};
|
||||
use oxc_ast::ast::*;
|
||||
use oxc_span::SPAN;
|
||||
use oxc_str::{Ident, static_ident};
|
||||
use oxc_syntax::{
|
||||
@@ -901,7 +901,7 @@ fn create_new_weakmap<'a>(
|
||||
let symbol_id = *symbol_id
|
||||
.get_or_insert_with(|| ctx.scoping().find_binding(ctx.current_scope_id(), weak_map));
|
||||
let ident = ctx.create_ident_expr(SPAN, weak_map, symbol_id, ReferenceFlags::Read);
|
||||
Expression::new_new_expression_with_pure(SPAN, ident, NONE, [], true, ctx)
|
||||
Expression::new_new_expression_with_pure(SPAN, ident, None, [], true, ctx)
|
||||
}
|
||||
|
||||
/// Create `new WeakSet()` expression.
|
||||
@@ -909,5 +909,5 @@ fn create_new_weakset<'a>(ctx: &mut TraverseCtx<'a>) -> Expression<'a> {
|
||||
let weak_set = static_ident!("WeakSet");
|
||||
let symbol_id = ctx.scoping().find_binding(ctx.current_scope_id(), weak_set);
|
||||
let ident = ctx.create_ident_expr(SPAN, weak_set, symbol_id, ReferenceFlags::Read);
|
||||
Expression::new_new_expression_with_pure(SPAN, ident, NONE, [], true, ctx)
|
||||
Expression::new_new_expression_with_pure(SPAN, ident, None, [], true, ctx)
|
||||
}
|
||||
@@ -104,7 +104,7 @@ use std::iter;
|
||||
use oxc_allocator::{ArenaVec, ReplaceWith};
|
||||
use rustc_hash::FxHashMap;
|
||||
|
||||
use oxc_ast::{ast::*, builder::NONE};
|
||||
use oxc_ast::ast::*;
|
||||
use oxc_ast_visit::{VisitJsMut, VisitMut, walk_js_mut};
|
||||
use oxc_span::SPAN;
|
||||
use oxc_str::Ident;
|
||||
@@ -237,7 +237,7 @@ impl<'a> ClassProperties<'a> {
|
||||
ctx.generate_uid("args", constructor_scope_id, SymbolFlags::FunctionScopedVariable);
|
||||
let rest_element =
|
||||
BindingRestElement::new(SPAN, args_binding.create_binding_pattern(ctx), ctx);
|
||||
params_rest = Some(FormalParameterRest::boxed(SPAN, [], rest_element, NONE, ctx));
|
||||
params_rest = Some(FormalParameterRest::boxed(SPAN, [], rest_element, None, ctx));
|
||||
stmts.push(Statement::new_expression_statement(
|
||||
SPAN,
|
||||
create_super_call(&args_binding, ctx),
|
||||
@@ -320,11 +320,11 @@ impl<'a> ClassProperties<'a> {
|
||||
SPAN,
|
||||
true,
|
||||
false,
|
||||
NONE,
|
||||
None,
|
||||
{
|
||||
let rest_element =
|
||||
BindingRestElement::new(SPAN, args_binding.create_binding_pattern(ctx), ctx);
|
||||
let rest = FormalParameterRest::boxed(SPAN, [], rest_element, NONE, ctx);
|
||||
let rest = FormalParameterRest::boxed(SPAN, [], rest_element, None, ctx);
|
||||
FormalParameters::boxed(
|
||||
SPAN,
|
||||
FormalParameterKind::ArrowFormalParameters,
|
||||
@@ -333,7 +333,7 @@ impl<'a> ClassProperties<'a> {
|
||||
ctx,
|
||||
)
|
||||
},
|
||||
NONE,
|
||||
None,
|
||||
FunctionBody::boxed(SPAN, [], body, ctx),
|
||||
super_func_scope_id,
|
||||
false,
|
||||
@@ -349,7 +349,7 @@ impl<'a> ClassProperties<'a> {
|
||||
SPAN,
|
||||
VariableDeclarationKind::Var,
|
||||
super_binding.create_binding_pattern(ctx),
|
||||
NONE,
|
||||
None,
|
||||
Some(super_func),
|
||||
false,
|
||||
ctx,
|
||||
@@ -399,10 +399,10 @@ impl<'a> ClassProperties<'a> {
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
NONE,
|
||||
NONE,
|
||||
FormalParameters::boxed(SPAN, FormalParameterKind::FormalParameter, [], NONE, ctx),
|
||||
NONE,
|
||||
None,
|
||||
None,
|
||||
FormalParameters::boxed(SPAN, FormalParameterKind::FormalParameter, [], None, ctx),
|
||||
None,
|
||||
Some(FunctionBody::boxed(SPAN, directives, body_stmts, ctx)),
|
||||
super_func_scope_id,
|
||||
false,
|
||||
@@ -601,7 +601,7 @@ impl<'a> ConstructorParamsSuperReplacer<'a, '_> {
|
||||
false,
|
||||
ctx,
|
||||
),
|
||||
NONE,
|
||||
None,
|
||||
[Argument::from(super_call)],
|
||||
false,
|
||||
ctx,
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
use std::mem;
|
||||
|
||||
use oxc_allocator::{ArenaBox, ArenaVec, ReplaceWith, TakeIn};
|
||||
use oxc_ast::{ast::*, builder::NONE};
|
||||
use oxc_ast::ast::*;
|
||||
use oxc_span::SPAN;
|
||||
use oxc_str::static_ident;
|
||||
use oxc_syntax::{reference::ReferenceId, symbol::SymbolId};
|
||||
@@ -1830,7 +1830,7 @@ impl<'a> ClassProperties<'a> {
|
||||
ctx,
|
||||
);
|
||||
let arguments = ArenaVec::from_value_in(Argument::from(context), ctx);
|
||||
Expression::new_call_expression(field_expr.span, callee, NONE, arguments, false, ctx)
|
||||
Expression::new_call_expression(field_expr.span, callee, None, arguments, false, ctx)
|
||||
}
|
||||
|
||||
/// Transform private field in assignment pattern.
|
||||
@@ -1929,7 +1929,7 @@ impl<'a> ClassProperties<'a> {
|
||||
};
|
||||
let callee = create_member_callee(callee, static_ident!("has"), span, ctx);
|
||||
let argument = Argument::from(self.create_check_in_rhs(right, ctx));
|
||||
Expression::new_call_expression(span, callee, NONE, [argument], false, ctx)
|
||||
Expression::new_call_expression(span, callee, None, [argument], false, ctx)
|
||||
}
|
||||
|
||||
/// Duplicate object to be used in get/set pair.
|
||||
@@ -2215,7 +2215,7 @@ impl<'a> ClassProperties<'a> {
|
||||
ArenaVec::from_array_in([Argument::from(object), Argument::from(value)], ctx);
|
||||
let callee = create_member_callee(prop_ident, static_ident!("call"), span, ctx);
|
||||
// `_prop.call(_assertClassBrand(Class, object), value)`
|
||||
Expression::new_call_expression(span, callee, NONE, arguments, false, ctx)
|
||||
Expression::new_call_expression(span, callee, None, arguments, false, ctx)
|
||||
} else {
|
||||
// `_privateFieldSet(_prop, object, value)`
|
||||
self.create_private_field_set(prop_ident, object, value, ctx)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
//! Transform of class property declarations (instance or static properties).
|
||||
|
||||
use oxc_allocator::{ArenaBox, ArenaVec};
|
||||
use oxc_ast::{ast::*, builder::NONE};
|
||||
use oxc_ast::ast::*;
|
||||
use oxc_span::{SPAN, Span};
|
||||
use oxc_str::static_ident;
|
||||
use oxc_syntax::reference::ReferenceFlags;
|
||||
@@ -404,6 +404,6 @@ impl<'a> ClassProperties<'a> {
|
||||
],
|
||||
ctx,
|
||||
);
|
||||
Expression::new_call_expression(span, callee, NONE, arguments, false, ctx)
|
||||
Expression::new_call_expression(span, callee, None, arguments, false, ctx)
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
use std::path::Path;
|
||||
|
||||
use oxc_ast::{ast::*, builder::AstBuilder, builder::NONE};
|
||||
use oxc_ast::{ast::*, builder::AstBuilder};
|
||||
use oxc_span::SPAN;
|
||||
use oxc_traverse::BoundIdentifier;
|
||||
|
||||
@@ -20,7 +20,7 @@ pub(super) fn create_variable_declaration<'a>(
|
||||
SPAN,
|
||||
kind,
|
||||
binding.create_binding_pattern(ctx),
|
||||
NONE,
|
||||
None,
|
||||
Some(init),
|
||||
false,
|
||||
ctx,
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
use itoa::Buffer as ItoaBuffer;
|
||||
|
||||
use oxc_allocator::TakeIn;
|
||||
use oxc_ast::{ast::*, builder::NONE};
|
||||
use oxc_ast::ast::*;
|
||||
use oxc_span::SPAN;
|
||||
use oxc_syntax::scope::{ScopeFlags, ScopeId};
|
||||
use oxc_traverse::Traverse;
|
||||
@@ -119,7 +119,7 @@ impl ClassStaticBlock {
|
||||
PropertyDefinitionType::PropertyDefinition,
|
||||
[],
|
||||
key,
|
||||
NONE,
|
||||
None,
|
||||
Some(expr),
|
||||
false,
|
||||
true,
|
||||
|
||||
@@ -38,7 +38,7 @@ use std::mem;
|
||||
use rustc_hash::FxHashMap;
|
||||
|
||||
use oxc_allocator::{Address, ArenaBox, ArenaVec, GetAddress, ReplaceWith, TakeIn};
|
||||
use oxc_ast::{ast::*, builder::NONE};
|
||||
use oxc_ast::ast::*;
|
||||
use oxc_ecmascript::BoundNames;
|
||||
use oxc_semantic::{NodeId, ScopeFlags, ScopeId, SymbolFlags, SymbolId};
|
||||
use oxc_span::{SPAN, Span};
|
||||
@@ -109,7 +109,7 @@ impl<'a> Traverse<'a, TransformState<'a>> for ExplicitResourceManagement<'a> {
|
||||
SPAN,
|
||||
variable_decl_kind,
|
||||
binding_pattern,
|
||||
NONE,
|
||||
None,
|
||||
Some(temp_id.create_read_expression(ctx)),
|
||||
false,
|
||||
ctx,
|
||||
@@ -434,7 +434,7 @@ impl<'a> Traverse<'a, TransformState<'a>> for ExplicitResourceManagement<'a> {
|
||||
span,
|
||||
VariableDeclarationKind::Var,
|
||||
var_id.create_spanned_binding_pattern(span, ctx),
|
||||
NONE,
|
||||
None,
|
||||
Some(expr),
|
||||
false,
|
||||
ctx,
|
||||
@@ -457,7 +457,7 @@ impl<'a> Traverse<'a, TransformState<'a>> for ExplicitResourceManagement<'a> {
|
||||
)],
|
||||
None,
|
||||
ImportOrExportKind::Value,
|
||||
NONE,
|
||||
None,
|
||||
ctx,
|
||||
));
|
||||
}
|
||||
@@ -557,7 +557,7 @@ impl<'a> Traverse<'a, TransformState<'a>> for ExplicitResourceManagement<'a> {
|
||||
export_specifiers,
|
||||
None,
|
||||
export_kind,
|
||||
NONE,
|
||||
None,
|
||||
ctx,
|
||||
));
|
||||
}
|
||||
@@ -725,7 +725,7 @@ impl<'a> ExplicitResourceManagement<'a> {
|
||||
false,
|
||||
ctx,
|
||||
),
|
||||
NONE,
|
||||
None,
|
||||
[Argument::from(old_init)],
|
||||
false,
|
||||
ctx,
|
||||
@@ -754,11 +754,11 @@ impl<'a> ExplicitResourceManagement<'a> {
|
||||
SPAN,
|
||||
VariableDeclarationKind::Var,
|
||||
using_ctx.create_binding_pattern(ctx),
|
||||
NONE,
|
||||
None,
|
||||
Some(Expression::new_call_expression(
|
||||
SPAN,
|
||||
callee,
|
||||
NONE,
|
||||
None,
|
||||
[],
|
||||
false,
|
||||
ctx,
|
||||
@@ -867,7 +867,7 @@ impl<'a> ExplicitResourceManagement<'a> {
|
||||
false,
|
||||
ctx,
|
||||
),
|
||||
NONE,
|
||||
None,
|
||||
[Argument::from(old_init)],
|
||||
false,
|
||||
ctx,
|
||||
@@ -889,8 +889,8 @@ impl<'a> ExplicitResourceManagement<'a> {
|
||||
SPAN,
|
||||
VariableDeclarationKind::Var,
|
||||
using_ctx.create_binding_pattern(ctx),
|
||||
NONE,
|
||||
Some(Expression::new_call_expression(SPAN, callee, NONE, [], false, ctx)),
|
||||
None,
|
||||
Some(Expression::new_call_expression(SPAN, callee, None, [], false, ctx)),
|
||||
false,
|
||||
ctx,
|
||||
)],
|
||||
@@ -936,7 +936,7 @@ impl<'a> ExplicitResourceManagement<'a> {
|
||||
);
|
||||
|
||||
let catch_parameter =
|
||||
CatchParameter::new(SPAN, ident.create_binding_pattern(ctx), NONE, ctx);
|
||||
CatchParameter::new(SPAN, ident.create_binding_pattern(ctx), None, ctx);
|
||||
|
||||
// `_usingCtx.e = _;`
|
||||
let stmt = Statement::new_expression_statement(
|
||||
@@ -986,7 +986,7 @@ impl<'a> ExplicitResourceManagement<'a> {
|
||||
false,
|
||||
ctx,
|
||||
),
|
||||
NONE,
|
||||
None,
|
||||
[],
|
||||
false,
|
||||
ctx,
|
||||
@@ -1020,7 +1020,7 @@ impl<'a> ExplicitResourceManagement<'a> {
|
||||
SPAN,
|
||||
VariableDeclarationKind::Var,
|
||||
binding.create_spanned_binding_pattern(original_span, ctx),
|
||||
NONE,
|
||||
None,
|
||||
Some(class_expr),
|
||||
false,
|
||||
ctx,
|
||||
|
||||
@@ -89,10 +89,7 @@
|
||||
//! * Babel plugin implementation: <https://github.com/babel/babel/tree/v7.26.2/packages/babel-helper-builder-react-jsx>
|
||||
|
||||
use oxc_allocator::{ArenaBox, ArenaStringBuilder, ArenaVec, GetAllocator, ReplaceWith};
|
||||
use oxc_ast::{
|
||||
ast::*,
|
||||
builder::{AstBuilder, NONE},
|
||||
};
|
||||
use oxc_ast::{ast::*, builder::AstBuilder};
|
||||
use oxc_ecmascript::PropName;
|
||||
use oxc_span::{SPAN, Span};
|
||||
use oxc_str::{Ident, Str};
|
||||
@@ -808,7 +805,7 @@ impl<'a> JsxImpl<'a> {
|
||||
|
||||
let callee = self.get_create_element(has_key_after_props_spread, need_jsxs, ctx);
|
||||
Expression::new_call_expression_with_pure(
|
||||
span, callee, NONE, arguments, false, self.pure, ctx,
|
||||
span, callee, None, arguments, false, self.pure, ctx,
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
//!
|
||||
//! * Babel plugin implementation: <https://github.com/babel/babel/blob/v7.26.2/packages/babel-plugin-transform-react-jsx-source/src/index.ts>
|
||||
|
||||
use oxc_ast::{ast::*, builder::NONE};
|
||||
use oxc_ast::ast::*;
|
||||
use oxc_data_structures::rope::{Rope, get_line_column};
|
||||
use oxc_span::SPAN;
|
||||
use oxc_syntax::{number::NumberBase, symbol::SymbolFlags};
|
||||
@@ -199,7 +199,7 @@ impl<'a> JsxSource<'a> {
|
||||
SPAN,
|
||||
VariableDeclarationKind::Var,
|
||||
id,
|
||||
NONE,
|
||||
None,
|
||||
Some(init),
|
||||
false,
|
||||
ctx,
|
||||
|
||||
@@ -11,11 +11,7 @@ use oxc_allocator::{
|
||||
ArenaStringBuilder, ArenaVec, CloneIn, GetAddress, GetAllocator, ReplaceWith, TakeIn,
|
||||
UnstableAddress,
|
||||
};
|
||||
use oxc_ast::{
|
||||
ast::*,
|
||||
builder::{AstBuilder, NONE},
|
||||
match_expression,
|
||||
};
|
||||
use oxc_ast::{ast::*, builder::AstBuilder, match_expression};
|
||||
use oxc_ast_visit::{
|
||||
VisitJs,
|
||||
walk_js::{walk_call_expression, walk_declaration},
|
||||
@@ -182,7 +178,7 @@ impl<'a> Traverse<'a, TransformState<'a>> for ReactRefresh<'a> {
|
||||
SPAN,
|
||||
VariableDeclarationKind::Var,
|
||||
binding.create_binding_pattern(ctx),
|
||||
NONE,
|
||||
None,
|
||||
None,
|
||||
false,
|
||||
ctx,
|
||||
@@ -195,7 +191,7 @@ impl<'a> Traverse<'a, TransformState<'a>> for ReactRefresh<'a> {
|
||||
];
|
||||
Statement::new_expression_statement(
|
||||
SPAN,
|
||||
Expression::new_call_expression(SPAN, callee, NONE, arguments, false, ctx),
|
||||
Expression::new_call_expression(SPAN, callee, None, arguments, false, ctx),
|
||||
ctx,
|
||||
)
|
||||
});
|
||||
@@ -243,7 +239,7 @@ impl<'a> Traverse<'a, TransformState<'a>> for ReactRefresh<'a> {
|
||||
|
||||
let binding = BoundIdentifier::from_binding_ident(&binding_identifier);
|
||||
let callee = binding.create_read_expression(ctx);
|
||||
let expr = Expression::new_call_expression(func.span, callee, NONE, arguments, false, ctx);
|
||||
let expr = Expression::new_call_expression(func.span, callee, None, arguments, false, ctx);
|
||||
let statement = Statement::new_expression_statement(func.span, expr, ctx);
|
||||
|
||||
// Get the address of the statement containing this `FunctionDeclaration`
|
||||
@@ -459,7 +455,7 @@ impl<'a> ReactRefresh<'a> {
|
||||
Expression::new_call_expression(
|
||||
span,
|
||||
binding.create_read_expression(ctx),
|
||||
NONE,
|
||||
None,
|
||||
arguments,
|
||||
false,
|
||||
ctx,
|
||||
@@ -653,7 +649,7 @@ impl<'a> ReactRefresh<'a> {
|
||||
if !custom_hooks_in_scope.is_empty() {
|
||||
// function () { return custom_hooks_in_scope }
|
||||
let formal_parameters =
|
||||
FormalParameters::boxed(SPAN, FormalParameterKind::FormalParameter, [], NONE, ctx);
|
||||
FormalParameters::boxed(SPAN, FormalParameterKind::FormalParameter, [], None, ctx);
|
||||
let function_body = FunctionBody::boxed(
|
||||
SPAN,
|
||||
[],
|
||||
@@ -672,10 +668,10 @@ impl<'a> ReactRefresh<'a> {
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
NONE,
|
||||
NONE,
|
||||
None,
|
||||
None,
|
||||
formal_parameters,
|
||||
NONE,
|
||||
None,
|
||||
Some(function_body),
|
||||
scope_id,
|
||||
false,
|
||||
@@ -689,7 +685,7 @@ impl<'a> ReactRefresh<'a> {
|
||||
let init = Expression::new_call_expression(
|
||||
SPAN,
|
||||
self.refresh_sig.to_expression(ctx),
|
||||
NONE,
|
||||
None,
|
||||
[],
|
||||
false,
|
||||
ctx,
|
||||
@@ -702,7 +698,7 @@ impl<'a> ReactRefresh<'a> {
|
||||
Expression::new_call_expression(
|
||||
SPAN,
|
||||
binding.create_read_expression(ctx),
|
||||
NONE,
|
||||
None,
|
||||
[],
|
||||
false,
|
||||
ctx,
|
||||
@@ -896,7 +892,7 @@ impl<'a> ReactRefresh<'a> {
|
||||
Expression::new_call_expression(
|
||||
SPAN,
|
||||
binding.create_read_expression(ctx),
|
||||
NONE,
|
||||
None,
|
||||
arguments,
|
||||
false,
|
||||
ctx,
|
||||
|
||||
@@ -64,10 +64,7 @@ use rustc_hash::FxHasher;
|
||||
use serde::Deserialize;
|
||||
|
||||
use oxc_allocator::{ArenaVec, ReplaceWith, TakeIn};
|
||||
use oxc_ast::{
|
||||
ast::*,
|
||||
builder::{AstBuilder, NONE},
|
||||
};
|
||||
use oxc_ast::{ast::*, builder::AstBuilder};
|
||||
use oxc_data_structures::{inline_string::InlineString, slice_iter::SliceIter};
|
||||
use oxc_semantic::SymbolId;
|
||||
use oxc_span::SPAN;
|
||||
@@ -464,7 +461,7 @@ impl<'a> StyledComponents<'a> {
|
||||
let property = IdentifierName::new(SPAN, "withConfig", ctx);
|
||||
let callee =
|
||||
Expression::new_static_member_expression(SPAN, object, property, false, ctx);
|
||||
Expression::new_call_expression(SPAN, callee, NONE, arguments, false, ctx)
|
||||
Expression::new_call_expression(SPAN, callee, None, arguments, false, ctx)
|
||||
});
|
||||
} else {
|
||||
return false;
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
use std::iter;
|
||||
|
||||
use oxc_allocator::{ArenaVec, ReplaceWith};
|
||||
use oxc_ast::{ast::*, builder::NONE};
|
||||
use oxc_ast::ast::*;
|
||||
use oxc_semantic::SymbolFlags;
|
||||
use oxc_span::SPAN;
|
||||
use oxc_traverse::{BoundIdentifier, Traverse};
|
||||
@@ -233,7 +233,7 @@ impl<'a> TaggedTemplateTransform {
|
||||
SPAN,
|
||||
VariableDeclarationKind::Var,
|
||||
binding.create_binding_pattern(ctx),
|
||||
NONE,
|
||||
None,
|
||||
None,
|
||||
false,
|
||||
ctx,
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
//! (actually these would be improvements on ESBuild, not Babel)
|
||||
|
||||
use oxc_allocator::GetAllocator;
|
||||
use oxc_ast::{ast::*, builder::NONE};
|
||||
use oxc_ast::ast::*;
|
||||
use oxc_regular_expression::{
|
||||
RegexUnsupportedPatterns, has_unsupported_regular_expression_pattern,
|
||||
};
|
||||
@@ -176,6 +176,6 @@ impl<'a> RegExp {
|
||||
),
|
||||
];
|
||||
|
||||
*expr = Expression::new_new_expression(regexp.span, callee, NONE, arguments, ctx);
|
||||
*expr = Expression::new_new_expression(regexp.span, callee, None, arguments, ctx);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
use rustc_hash::FxHashSet;
|
||||
|
||||
use oxc_allocator::{ArenaVec, ReplaceWith, TakeIn};
|
||||
use oxc_ast::{ast::*, builder::NONE};
|
||||
use oxc_ast::ast::*;
|
||||
use oxc_semantic::{ScopeFlags, ScopeId};
|
||||
use oxc_span::SPAN;
|
||||
use oxc_str::Ident;
|
||||
@@ -352,7 +352,7 @@ impl<'a> TypeScript<'a> {
|
||||
PropertyDefinitionType::PropertyDefinition,
|
||||
[],
|
||||
key,
|
||||
NONE,
|
||||
None,
|
||||
None,
|
||||
false,
|
||||
false,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use std::cell::Cell;
|
||||
|
||||
use oxc_allocator::{ArenaVec, TakeIn};
|
||||
use oxc_ast::{ast::*, builder::NONE};
|
||||
use oxc_ast::ast::*;
|
||||
use oxc_ast_visit::{VisitJsMut, walk_js_mut};
|
||||
use oxc_data_structures::stack::NonEmptyStack;
|
||||
use oxc_semantic::{ScopeFlags, ScopeId};
|
||||
@@ -187,12 +187,12 @@ impl<'a> TypeScriptEnum {
|
||||
let id = param_binding.create_binding_pattern(ctx);
|
||||
|
||||
// ((Foo) => {
|
||||
let param = FormalParameter::new(SPAN, [], id, NONE, NONE, false, None, false, false, ctx);
|
||||
let param = FormalParameter::new(SPAN, [], id, None, None, false, None, false, false, ctx);
|
||||
let params = FormalParameters::boxed(
|
||||
SPAN,
|
||||
FormalParameterKind::ArrowFormalParameters,
|
||||
[param],
|
||||
NONE,
|
||||
None,
|
||||
ctx,
|
||||
);
|
||||
|
||||
@@ -218,10 +218,10 @@ impl<'a> TypeScriptEnum {
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
NONE,
|
||||
NONE,
|
||||
None,
|
||||
None,
|
||||
params,
|
||||
NONE,
|
||||
None,
|
||||
Some(body),
|
||||
func_scope_id,
|
||||
false,
|
||||
@@ -257,7 +257,7 @@ impl<'a> TypeScriptEnum {
|
||||
let call_expression = Expression::new_call_expression_with_pure(
|
||||
span,
|
||||
callee,
|
||||
NONE,
|
||||
None,
|
||||
arguments,
|
||||
false,
|
||||
!has_potential_side_effect,
|
||||
@@ -299,7 +299,7 @@ impl<'a> TypeScriptEnum {
|
||||
span,
|
||||
kind,
|
||||
binding,
|
||||
NONE,
|
||||
None,
|
||||
Some(call_expression),
|
||||
false,
|
||||
ctx,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use oxc_allocator::{ArenaBox, TakeIn};
|
||||
use oxc_ast::{ast::*, builder::NONE};
|
||||
use oxc_ast::ast::*;
|
||||
use oxc_semantic::{Reference, SymbolFlags};
|
||||
use oxc_span::SPAN;
|
||||
use oxc_str::static_ident;
|
||||
@@ -173,11 +173,11 @@ impl<'a> TypeScriptModule {
|
||||
let argument = Argument::StringLiteral(str_lit);
|
||||
(
|
||||
VariableDeclarationKind::Const,
|
||||
Expression::new_call_expression(SPAN, callee, NONE, [argument], false, ctx),
|
||||
Expression::new_call_expression(SPAN, callee, None, [argument], false, ctx),
|
||||
)
|
||||
}
|
||||
};
|
||||
let decl = VariableDeclarator::new(SPAN, kind, binding, NONE, Some(init), false, ctx);
|
||||
let decl = VariableDeclarator::new(SPAN, kind, binding, None, Some(init), false, ctx);
|
||||
|
||||
Some(Declaration::new_variable_declaration(SPAN, kind, [decl], false, ctx))
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use oxc_allocator::{ArenaBox, ArenaVec, ReplaceWith, TakeIn};
|
||||
use oxc_ast::{ast::*, builder::NONE};
|
||||
use oxc_ast::ast::*;
|
||||
use oxc_ecmascript::BoundNames;
|
||||
use oxc_span::{SPAN, Span};
|
||||
use oxc_syntax::{
|
||||
@@ -328,7 +328,7 @@ impl<'a> TypeScriptNamespace {
|
||||
let kind = VariableDeclarationKind::Let;
|
||||
let decl = {
|
||||
let pattern = binding.create_spanned_binding_pattern(binding_span, ctx);
|
||||
VariableDeclarator::new(span, kind, pattern, NONE, None, false, ctx)
|
||||
VariableDeclarator::new(span, kind, pattern, None, None, false, ctx)
|
||||
};
|
||||
Declaration::new_variable_declaration(span, kind, [decl], false, ctx)
|
||||
}
|
||||
@@ -353,7 +353,7 @@ impl<'a> TypeScriptNamespace {
|
||||
SPAN,
|
||||
FormalParameterKind::FormalParameter,
|
||||
[item],
|
||||
NONE,
|
||||
None,
|
||||
ctx,
|
||||
)
|
||||
};
|
||||
@@ -440,7 +440,7 @@ impl<'a> TypeScriptNamespace {
|
||||
)
|
||||
};
|
||||
|
||||
let expr = Expression::new_call_expression(span, callee, NONE, [argument], false, ctx);
|
||||
let expr = Expression::new_call_expression(span, callee, None, [argument], false, ctx);
|
||||
Statement::new_expression_statement(span, expr, ctx)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use std::iter;
|
||||
|
||||
use oxc_allocator::{ArenaBox, ArenaVec};
|
||||
use oxc_ast::{ast::*, builder::NONE};
|
||||
use oxc_ast::ast::*;
|
||||
use oxc_semantic::{ReferenceFlags, ScopeFlags, ScopeId, SymbolFlags};
|
||||
use oxc_span::{GetSpan, SPAN};
|
||||
use oxc_str::{Ident, static_ident};
|
||||
@@ -29,7 +29,7 @@ pub fn create_bind_call<'a>(
|
||||
) -> Expression<'a> {
|
||||
let callee = create_member_callee(callee, static_ident!("bind"), span, ctx);
|
||||
let this = Argument::from(this);
|
||||
Expression::new_call_expression(span, callee, NONE, [this], false, ctx)
|
||||
Expression::new_call_expression(span, callee, None, [this], false, ctx)
|
||||
}
|
||||
|
||||
/// `object` -> `object.call(...arguments)`.
|
||||
@@ -41,7 +41,7 @@ pub fn create_call_call<'a>(
|
||||
) -> Expression<'a> {
|
||||
let callee = create_member_callee(callee, static_ident!("call"), span, ctx);
|
||||
let this = Argument::from(this);
|
||||
Expression::new_call_expression(span, callee, NONE, [this], false, ctx)
|
||||
Expression::new_call_expression(span, callee, None, [this], false, ctx)
|
||||
}
|
||||
|
||||
/// Wrap an `Expression` in an arrow function IIFE (immediately invoked function expression)
|
||||
@@ -70,12 +70,12 @@ pub fn wrap_statements_in_arrow_function_iife<'a>(
|
||||
ctx: &TraverseCtx<'a>,
|
||||
) -> Expression<'a> {
|
||||
let kind = FormalParameterKind::ArrowFormalParameters;
|
||||
let params = FormalParameters::boxed(SPAN, kind, [], NONE, ctx);
|
||||
let params = FormalParameters::boxed(SPAN, kind, [], None, ctx);
|
||||
let body = FunctionBody::boxed(SPAN, [], stmts, ctx);
|
||||
let arrow = Expression::new_arrow_function_expression_with_scope_id_and_pure_and_pife(
|
||||
SPAN, false, false, NONE, params, NONE, body, scope_id, false, false, ctx,
|
||||
SPAN, false, false, None, params, None, body, scope_id, false, false, ctx,
|
||||
);
|
||||
Expression::new_call_expression(span, arrow, NONE, [], false, ctx)
|
||||
Expression::new_call_expression(span, arrow, None, [], false, ctx)
|
||||
}
|
||||
|
||||
/// `object` -> `object.prototype`.
|
||||
@@ -147,7 +147,7 @@ pub fn create_super_call<'a>(
|
||||
Expression::new_call_expression(
|
||||
SPAN,
|
||||
Expression::new_super(SPAN, ctx),
|
||||
NONE,
|
||||
None,
|
||||
[Argument::new_spread_element(SPAN, args_binding.create_read_expression(ctx), ctx)],
|
||||
false,
|
||||
ctx,
|
||||
@@ -172,7 +172,7 @@ pub fn create_class_constructor<'a, 'c>(
|
||||
let args_binding = ctx.generate_uid("args", scope_id, SymbolFlags::FunctionScopedVariable);
|
||||
let rest_element =
|
||||
BindingRestElement::new(SPAN, args_binding.create_binding_pattern(ctx), ctx);
|
||||
params_rest = Some(FormalParameterRest::boxed(SPAN, [], rest_element, NONE, ctx));
|
||||
params_rest = Some(FormalParameterRest::boxed(SPAN, [], rest_element, None, ctx));
|
||||
ArenaVec::from_iter_in(
|
||||
iter::once(Statement::new_expression_statement(
|
||||
SPAN,
|
||||
@@ -238,8 +238,8 @@ pub fn create_class_method<'a>(
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
NONE,
|
||||
NONE,
|
||||
None,
|
||||
None,
|
||||
params,
|
||||
return_type,
|
||||
Some(FunctionBody::boxed(SPAN, [], stmts, ctx)),
|
||||
|
||||
@@ -5,7 +5,7 @@ use cow_utils::CowUtils;
|
||||
use oxc_allocator::{Allocator, ArenaVec, GetAllocator};
|
||||
use oxc_ast::{
|
||||
ast::*,
|
||||
builder::{AstBuilder, GetAstBuilder, NONE},
|
||||
builder::{AstBuilder, GetAstBuilder},
|
||||
};
|
||||
use oxc_semantic::Scoping;
|
||||
use oxc_span::SPAN;
|
||||
@@ -221,7 +221,7 @@ impl<'a> InjectGlobalVariables<'a> {
|
||||
StringLiteral::new(SPAN, Str::from_str_in(&inject.source, self), None, self);
|
||||
let kind = ImportOrExportKind::Value;
|
||||
let import_decl = ModuleDeclaration::new_import_declaration(
|
||||
SPAN, specifiers, source, None, NONE, kind, self,
|
||||
SPAN, specifiers, source, None, None, kind, self,
|
||||
);
|
||||
Statement::from(import_decl)
|
||||
});
|
||||
|
||||
@@ -51,7 +51,7 @@ use itoa::Buffer as ItoaBuffer;
|
||||
use rustc_hash::{FxHashMap, FxHashSet};
|
||||
|
||||
use oxc_allocator::{Allocator, ArenaBox, ArenaVec, GetAllocator, ReplaceWith};
|
||||
use oxc_ast::{ast::*, builder::NONE};
|
||||
use oxc_ast::ast::*;
|
||||
use oxc_ecmascript::BoundNames;
|
||||
use oxc_semantic::{ReferenceFlags, ScopeFlags, Scoping, SymbolFlags, SymbolId};
|
||||
use oxc_span::SPAN;
|
||||
@@ -264,7 +264,7 @@ impl<'a> ModuleRunnerTransform<'a> {
|
||||
let arguments = options.into_iter().map(Argument::from);
|
||||
let arguments =
|
||||
ArenaVec::from_iter_in(iter::once(Argument::from(source)).chain(arguments), ctx);
|
||||
Expression::new_call_expression(span, callee, NONE, arguments, false, ctx)
|
||||
Expression::new_call_expression(span, callee, None, arguments, false, ctx)
|
||||
});
|
||||
}
|
||||
|
||||
@@ -522,7 +522,7 @@ impl<'a> ModuleRunnerTransform<'a> {
|
||||
Expression::new_identifier(SPAN, static_ident!("__vite_ssr_exportAll__"), ctx);
|
||||
let ident = Argument::from(ident);
|
||||
// `export * from 'vue'` -> `__vite_ssr_exportAll__(__vite_ssr_import_0__);`
|
||||
let call = Expression::new_call_expression(SPAN, callee, NONE, [ident], false, ctx);
|
||||
let call = Expression::new_call_expression(SPAN, callee, None, [ident], false, ctx);
|
||||
let export = Statement::new_expression_statement(span, call, ctx);
|
||||
// names from `export *` cannot be known, so add it right after the import.
|
||||
hoist_imports.extend([import, export]);
|
||||
@@ -725,11 +725,11 @@ impl<'a> ModuleRunnerTransform<'a> {
|
||||
static_ident!("__vite_ssr_import__"),
|
||||
ReferenceFlags::Read,
|
||||
);
|
||||
let call = Expression::new_call_expression(SPAN, callee, NONE, arguments, false, ctx);
|
||||
let call = Expression::new_call_expression(SPAN, callee, None, arguments, false, ctx);
|
||||
let init = Expression::new_await_expression(SPAN, call, ctx);
|
||||
|
||||
let kind = VariableDeclarationKind::Const;
|
||||
let declarator = VariableDeclarator::new(SPAN, kind, pattern, NONE, Some(init), false, ctx);
|
||||
let declarator = VariableDeclarator::new(SPAN, kind, pattern, None, Some(init), false, ctx);
|
||||
let declaration =
|
||||
Declaration::new_variable_declaration(span, kind, [declarator], false, ctx);
|
||||
Statement::from(declaration)
|
||||
@@ -743,7 +743,7 @@ impl<'a> ModuleRunnerTransform<'a> {
|
||||
let object =
|
||||
ctx.create_unbound_ident_expr(SPAN, static_ident!("Object"), ReferenceFlags::Read);
|
||||
let member = create_member_callee(object, static_ident!("defineProperty"), ctx);
|
||||
Expression::new_call_expression(SPAN, member, NONE, arguments, false, ctx)
|
||||
Expression::new_call_expression(SPAN, member, None, arguments, false, ctx)
|
||||
}
|
||||
|
||||
// `key: value` or `key() {}`
|
||||
@@ -771,7 +771,7 @@ impl<'a> ModuleRunnerTransform<'a> {
|
||||
ctx: &mut TraverseCtx<'a>,
|
||||
) -> Expression<'a> {
|
||||
let kind = FormalParameterKind::FormalParameter;
|
||||
let params = FormalParameters::boxed(SPAN, kind, [], NONE, ctx);
|
||||
let params = FormalParameters::boxed(SPAN, kind, [], None, ctx);
|
||||
let statement = Statement::new_return_statement(SPAN, Some(expr), ctx);
|
||||
let body = FunctionBody::boxed(SPAN, [], [statement], ctx);
|
||||
let r#type = FunctionType::FunctionExpression;
|
||||
@@ -783,10 +783,10 @@ impl<'a> ModuleRunnerTransform<'a> {
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
NONE,
|
||||
NONE,
|
||||
None,
|
||||
None,
|
||||
params,
|
||||
NONE,
|
||||
None,
|
||||
Some(body),
|
||||
scope_id,
|
||||
false,
|
||||
@@ -855,7 +855,7 @@ impl<'a> ModuleRunnerTransform<'a> {
|
||||
let pattern = binding.create_binding_pattern(ctx);
|
||||
let kind = VariableDeclarationKind::Const;
|
||||
let declarator =
|
||||
VariableDeclarator::new(SPAN, kind, pattern, NONE, Some(right), false, ctx);
|
||||
VariableDeclarator::new(SPAN, kind, pattern, None, Some(right), false, ctx);
|
||||
let declaration =
|
||||
Declaration::new_variable_declaration(span, kind, [declarator], false, ctx);
|
||||
Statement::from(declaration)
|
||||
|
||||
@@ -124,7 +124,7 @@ struct Param<'d> {
|
||||
/// * `Some(GenericType::Into)` if is generic and uses `Into`
|
||||
/// e.g. `name: S1 where S1: Into<Str<'a>>`.
|
||||
/// * `Some(GenericType::IntoIn)` if is generic and uses `IntoIn`
|
||||
/// e.g. `type_annotation: T1 where T1: IntoIn<'a, Box<'a, TSTypeAnnotation<'a>>>`.
|
||||
/// e.g. `params: T1 where T1: IntoIn<'a, ArenaVec<'a, TSTypeParameter<'a>>>`.
|
||||
generic_type: Option<GenericType>,
|
||||
}
|
||||
|
||||
@@ -313,8 +313,8 @@ fn generate_builder_methods_for_struct_impl(
|
||||
///
|
||||
/// ```
|
||||
/// // ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ generic params
|
||||
/// pub fn new<B: GetAstBuilder<'a>, T1>(span: Span, function: T1, builder: &B) -> Self
|
||||
/// where T1: IntoIn<'a, Box<'a, Function<'a>>>
|
||||
/// pub fn new<B: GetAstBuilder<'a>, T1>(span: Span, params: T1, builder: &B) -> Self
|
||||
/// where T1: IntoIn<'a, ArenaVec<'a, TSTypeParameter<'a>>>
|
||||
/// // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ where clause
|
||||
/// ```
|
||||
fn get_struct_params<'s>(
|
||||
@@ -328,7 +328,7 @@ fn get_struct_params<'s>(
|
||||
TokenStream, // `where` clause
|
||||
bool, // Has default fields
|
||||
) {
|
||||
let mut generic_count = 0u32;
|
||||
let mut vec_generic_count = 0u32;
|
||||
let mut str_generic_count = 0u32;
|
||||
let mut has_default_fields = false;
|
||||
|
||||
@@ -362,13 +362,9 @@ fn get_struct_params<'s>(
|
||||
str_generic_count += 1;
|
||||
Some((format_ident!("S{str_generic_count}"), GenericType::Into))
|
||||
}
|
||||
TypeDef::Box(_) | TypeDef::Vec(_) => {
|
||||
generic_count += 1;
|
||||
Some((format_ident!("T{generic_count}"), GenericType::IntoIn))
|
||||
}
|
||||
TypeDef::Option(option_def) if option_def.inner_type(schema).is_box() => {
|
||||
generic_count += 1;
|
||||
Some((format_ident!("T{generic_count}"), GenericType::IntoIn))
|
||||
TypeDef::Vec(_) => {
|
||||
vec_generic_count += 1;
|
||||
Some((format_ident!("T{vec_generic_count}"), GenericType::IntoIn))
|
||||
}
|
||||
_ => None,
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user