Skip to content

Commit

Permalink
fixup for rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
kdy1 committed Jul 10, 2024
1 parent 0a0310d commit 8c045fb
Show file tree
Hide file tree
Showing 20 changed files with 69 additions and 283 deletions.
7 changes: 0 additions & 7 deletions crates/swc_ecma_ast/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,14 +336,9 @@ impl Expr {
exprs.remove(0)
} else {
SeqExpr {
Expr::Seq(Box::new(SeqExpr {
span: DUMMY_SP,
exprs,
}
Box::new(SeqExpr {
span: DUMMY_SP,
exprs,
})
.into()
}
}
Expand Down Expand Up @@ -609,8 +604,6 @@ impl From<ImportWith> for ObjectLit {
PropOrSpread::Prop(Prop::KeyValue(Box::new(KeyValueProp {
key: PropName::Ident(item.key),
value: Lit::Str(item.value).into(),
value: Expr::Lit(Box::new(Lit::Str(item.value))),
value: Box::new(Lit::Str(item.value)).into(),
})))
})
.collect(),
Expand Down
1 change: 1 addition & 0 deletions crates/swc_ecma_ast/src/pat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ impl Clone for Pat {
impl Default for Pat {
fn default() -> Self {
Invalid { span: DUMMY_SP }.into()
Pat::Invalid(Invalid { span: DUMMY_SP })
}
}
impl Take for Pat {
Expand Down
8 changes: 0 additions & 8 deletions crates/swc_ecma_compat_bugfixes/src/edge_default_param.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,6 @@ impl VisitMut for EdgeDefaultParam {
right: value.clone(),
}
.into(),
value: Box::new(
AssignPat {
span: *span,
left: key.clone().into(),
right: value.clone(),
}
.into(),
),
});

n.props[idx] = prop;
Expand Down
10 changes: 0 additions & 10 deletions crates/swc_ecma_compat_bugfixes/src/template_literal_caching.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,6 @@ impl Fold for TemplateLiteralCaching {
}
.into(),
),
Some(Expr::Arrow(ArrowExpr {
span: DUMMY_SP,
params: vec![t.clone().into()],
body: Box::new(BlockStmtOrExpr::Expr(t.into())),
is_async: false,
is_generator: false,
..Default::default()
})),
)
}

Expand All @@ -113,7 +105,6 @@ impl Fold for TemplateLiteralCaching {
let t = private_ident!("t");
self.create_binding(t.clone(), None);
let inline_cache: Expr = BinExpr {
let inline_cache = BinExpr {
span: DUMMY_SP,
op: op!("||"),
left: t.clone().into(),
Expand All @@ -126,7 +117,6 @@ impl Fold for TemplateLiteralCaching {
.into(),
}
.into();
});

// The original tag function becomes a plain function call.
// The expressions omitted from the cached Strings tag are
Expand Down
51 changes: 5 additions & 46 deletions crates/swc_ecma_compat_es2015/src/block_scoping/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ impl BlockScoping {
let mut env_hoister =
FnEnvHoister::new(SyntaxContext::empty().apply_mark(self.unresolved_mark));
body_stmt.visit_mut_with(&mut env_hoister);
let mut inits: Vec<Expr> = vec![];
let mut inits: Vec<Box<Expr>> = vec![];

for mut var in env_hoister.to_decl() {
if let Some(init) = var.init.take() {
Expand Down Expand Up @@ -591,7 +591,7 @@ impl VisitMut for BlockScoping {
if self.var_decl_kind == VarDeclKind::Var {
var.init = None
} else {
var.init = Some(var.span().into())
var.init = Some(Expr::undefined(var.span()))
}
}
}
Expand Down Expand Up @@ -828,37 +828,6 @@ impl VisitMut for FlowHelper<'_> {
}
.into(),
),
arg: Some(Box::new(Expr::Object(ObjectLit {
span,
props: vec![PropOrSpread::Prop(Box::new(Prop::KeyValue(KeyValueProp {
key: PropName::Ident(Ident::new_no_ctxt("v".into(), DUMMY_SP)),
value: s.arg.take().unwrap_or_else(|| {
Box::new(Expr::Unary(UnaryExpr {
span: DUMMY_SP,
op: op!("void"),
arg: Expr::undefined(DUMMY_SP),
}))
}),
})))],
}))),
arg: Some(
ObjectLit {
span,
props: vec![PropOrSpread::Prop(Box::new(Prop::KeyValue(
KeyValueProp {
key: PropName::Ident(Ident::new_no_ctxt("v".into(), DUMMY_SP)),
value: s.arg.take().unwrap_or_else(|| {
Box::new(Expr::Unary(UnaryExpr {
span: DUMMY_SP,
op: op!("void"),
arg: Expr::undefined(DUMMY_SP),
}))
}),
},
)))],
}
.into(),
),
});
}
_ => node.visit_mut_children_with(self),
Expand Down Expand Up @@ -902,9 +871,9 @@ struct MutationHandler<'a> {
}

impl MutationHandler<'_> {
fn make_reassignment(&self, orig: Option<Expr>) -> Expr {
fn make_reassignment(&self, orig: Option<Box<Expr>>) -> Expr {
if self.map.is_empty() {
return *orig.unwrap_or_else(|| DUMMY_SP.into());
return *orig.unwrap_or_else(|| Expr::undefined(DUMMY_SP));
}

let mut exprs = Vec::with_capacity(self.map.len() + 1);
Expand All @@ -919,18 +888,8 @@ impl MutationHandler<'_> {
}
.into(),
);
exprs.push(Box::new(Expr::Assign(AssignExpr {
span: DUMMY_SP,
left: Ident::new(id.0.clone(), DUMMY_SP, id.1).into(),
op: op!("="),
right: Box::new(Expr::Ident(Ident::new(id.0.clone(), DUMMY_SP, *ctxt))),
})));
right: Box::new(Expr::Ident(Ident::new(id.0.clone(), DUMMY_SP, *ctxt))),
}
.into(),
);
}
exprs.push(orig.unwrap_or_else(|| DUMMY_SP.into()));
exprs.push(orig.unwrap_or_else(|| Expr::undefined(DUMMY_SP)));

SeqExpr {
span: DUMMY_SP,
Expand Down
3 changes: 1 addition & 2 deletions crates/swc_ecma_compat_es2015/src/classes/constructor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,6 @@ impl VisitMut for ConstructorFolder<'_> {
left: call,
op: op!("||"),
right: Box::new(ThisExpr { span: DUMMY_SP }.into()),
right: Box::new(Expr::This(ThisExpr { span: DUMMY_SP })),
}
.into()
} else {
Expand Down Expand Up @@ -366,7 +365,7 @@ pub(super) enum ReturningMode {
Returning {
/// Mark for `_this`
mark: Mark,
arg: Option<Expr>,
arg: Option<Box<Expr>>,
},

/// `super()` call
Expand Down
9 changes: 4 additions & 5 deletions crates/swc_ecma_compat_es2015/src/classes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ pub struct Config {

struct Data {
key_prop: Box<PropName>,
method: Option<Expr>,
set: Option<Expr>,
get: Option<Expr>,
method: Option<Box<Expr>>,
set: Option<Box<Expr>>,
get: Option<Box<Expr>>,
}

#[swc_trace]
Expand Down Expand Up @@ -966,7 +966,6 @@ where
.map(Some)
.collect(),
}
.into()
.as_arg()
}

Expand Down Expand Up @@ -1277,7 +1276,7 @@ fn is_always_initialized(body: &[Stmt]) -> bool {
!v.found
}

fn escape_keywords(mut e: Expr) -> Expr {
fn escape_keywords(mut e: Box<Expr>) -> Box<Expr> {
if let Expr::Fn(f) = &mut *e {
if let Some(i) = &mut f.ident {
let sym = Ident::verify_symbol(&i.sym);
Expand Down
25 changes: 0 additions & 25 deletions crates/swc_ecma_compat_es2015/src/computed_props.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,6 @@ impl VisitMut for ComputedProps {
}
.into(),
),
right: Box::new(Expr::Object(ObjectLit {
span: DUMMY_SP,
props: obj_props,
})),
}
.into()
},
Expand Down Expand Up @@ -219,21 +215,6 @@ impl VisitMut for ComputedProps {
}
.into(),
),
right: Box::new(Expr::Bin(BinExpr {
span,
left: mutator_elem.clone().into(),
op: op!("||"),
right: Box::new(Expr::Object(ObjectLit {
span,
left: mutator_elem.clone().into(),
op: op!("||"),
right: Box::new(Expr::Object(ObjectLit {
span,
props: vec![],
})),
}
.into(),
),
}
.into(),
);
Expand All @@ -253,10 +234,6 @@ impl VisitMut for ComputedProps {
}
.into(),
),
right: Box::new(Expr::Fn(FnExpr {
ident: None,
function,
})),
}
.into(),
);
Expand Down Expand Up @@ -350,7 +327,6 @@ impl VisitMut for ComputedProps {
// Last value
exprs.push(obj_ident.into());
*expr = SeqExpr {
*expr = Expr::Seq(SeqExpr {
span: DUMMY_SP,
exprs,
}
Expand Down Expand Up @@ -434,7 +410,6 @@ fn prop_name_to_expr(p: PropName, loose: bool) -> (Expr, bool) {
match p {
PropName::Ident(i) => (
if loose {
Expr::Ident(i.into())
i.into()
} else {
Lit::Str(Str {
Expand Down
Loading

0 comments on commit 8c045fb

Please sign in to comment.