mirror of
https://github.com/MercuryWorkshop/scramjet.git
synced 2025-05-14 06:50:01 -04:00
fix syntax error in tryset
This commit is contained in:
parent
3ebbc5e430
commit
a5486de863
1 changed files with 34 additions and 34 deletions
|
@ -56,8 +56,8 @@ impl<'a> Visit<'a> for Rewriter {
|
||||||
// self.jschanges.push(JsChange::GenericChange {
|
// self.jschanges.push(JsChange::GenericChange {
|
||||||
// span: it.span,
|
// span: it.span,
|
||||||
// text: format!(
|
// text: format!(
|
||||||
// "({}(typeof {} == 'undefined' || {}, (()=>{{ try {{return arguments}} catch(_){{}} }})()))",
|
// "({}({}, (()=>{{ try {{return arguments}} catch(_){{}} }})()))",
|
||||||
// self.wrapfn, it.name, it.name
|
// self.config.wrapfn, it.name
|
||||||
// ),
|
// ),
|
||||||
// });
|
// });
|
||||||
if UNSAFE_GLOBALS.contains(&it.name.to_string().as_str()) {
|
if UNSAFE_GLOBALS.contains(&it.name.to_string().as_str()) {
|
||||||
|
@ -144,21 +144,21 @@ impl<'a> Visit<'a> for Rewriter {
|
||||||
// do not walk further, we don't want to rewrite the identifiers
|
// do not walk further, we don't want to rewrite the identifiers
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "debug")]
|
// #[cfg(feature = "debug")]
|
||||||
fn visit_try_statement(&mut self, it: &oxc_ast::ast::TryStatement<'a>) {
|
// fn visit_try_statement(&mut self, it: &oxc_ast::ast::TryStatement<'a>) {
|
||||||
// for debugging we need to know what the error was
|
// // for debugging we need to know what the error was
|
||||||
|
//
|
||||||
if let Some(h) = &it.handler {
|
// if let Some(h) = &it.handler {
|
||||||
if let Some(name) = &h.param {
|
// if let Some(name) = &h.param {
|
||||||
if let Some(name) = name.pattern.get_identifier() {
|
// if let Some(name) = name.pattern.get_identifier() {
|
||||||
self.jschanges.push(JsChange::GenericChange {
|
// self.jschanges.push(JsChange::GenericChange {
|
||||||
span: Span::new(h.body.span.start + 1, h.body.span.start + 1),
|
// span: Span::new(h.body.span.start + 1, h.body.span.start + 1),
|
||||||
text: format!("$scramerr({});", name),
|
// text: format!("$scramerr({});", name),
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
fn visit_object_expression(&mut self, it: &oxc_ast::ast::ObjectExpression<'a>) {
|
fn visit_object_expression(&mut self, it: &oxc_ast::ast::ObjectExpression<'a>) {
|
||||||
for prop in &it.properties {
|
for prop in &it.properties {
|
||||||
|
@ -183,7 +183,7 @@ impl<'a> Visit<'a> for Rewriter {
|
||||||
walk::walk_object_expression(self, it);
|
walk::walk_object_expression(self, it);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_return_statement(&mut self, it: &oxc_ast::ast::ReturnStatement<'a>) {
|
// fn visit_return_statement(&mut self, it: &oxc_ast::ast::ReturnStatement<'a>) {
|
||||||
// if let Some(arg) = &it.argument {
|
// if let Some(arg) = &it.argument {
|
||||||
// self.jschanges.push(JsChange::GenericChange {
|
// self.jschanges.push(JsChange::GenericChange {
|
||||||
// span: Span::new(it.span.start + 6, it.span.start + 6),
|
// span: Span::new(it.span.start + 6, it.span.start + 6),
|
||||||
|
@ -194,8 +194,8 @@ impl<'a> Visit<'a> for Rewriter {
|
||||||
// text: format!("))"),
|
// text: format!("))"),
|
||||||
// });
|
// });
|
||||||
// }
|
// }
|
||||||
walk::walk_return_statement(self, it);
|
// // walk::walk_return_statement(self, it);
|
||||||
}
|
// }
|
||||||
|
|
||||||
fn visit_unary_expression(&mut self, it: &oxc_ast::ast::UnaryExpression<'a>) {
|
fn visit_unary_expression(&mut self, it: &oxc_ast::ast::UnaryExpression<'a>) {
|
||||||
if matches!(it.operator, UnaryOperator::Typeof) {
|
if matches!(it.operator, UnaryOperator::Typeof) {
|
||||||
|
@ -403,7 +403,7 @@ pub fn rewrite(js: &str, url: Url, config: Config) -> Vec<u8> {
|
||||||
|
|
||||||
buffer.extend_from_slice(
|
buffer.extend_from_slice(
|
||||||
format!(
|
format!(
|
||||||
"((t)=>$scramjet$tryset({},\"{}\",t)||{}{}t)({})",
|
"((t)=>$scramjet$tryset({},\"{}\",t)||({}{}t))({})",
|
||||||
name,
|
name,
|
||||||
fmt_op(*op),
|
fmt_op(*op),
|
||||||
name,
|
name,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue