mirror of
https://github.com/swc-project/swc.git
synced 2024-12-30 00:52:29 +03:00
3d204b44f0
swc_ecma_utils: - `collect_decls`: More parallel. swc_ecma_transforms_macros: - Add `Parallel`, which is helper for `#[parallel]`. - Add `ParExplode`, which is helper for `#[parallel(explode)]`. swc_ecma_transforms_macros: - Add `#[parllel]`. swc_ecma_transforms_compat: - `sticky_regex`: Parallel. - `typeof_symbol`: Parallel. - `for_of`: Remove exponential visit. - `regenerator`: Remove exponential visit. - `object_spread`: Parallel. - `instance_of`: Parallel. - `duplicate_keys`: Parallel. - `logical_assignments`: Parallel. - `template_literal`: Parallel. - `block_scoped_functions`: Migrate to `VisitMut`. - `for_of`: Migrate to `VisitMut`. - `destructuring`: Reduce `Visit`. - `arrow`: Migrate to `VisitMut`. - `function_name`: Parallel. - `reserved_words`: Parallel. - `for_of`: Parallel. swc_ecma_transforms_module: - `import_analyzer`: Migrate to `VisitMut`. swc_ecma_transforms_react: - `jsx_src`: Parallel. - `jsx_self`: Migrate to `VisitMut`. - `jsx_self`: Parallel. swc_ecma_transforms_proposal: - `export_default_from`: Migrate to `VisitMut`. swc_ecma_transforms_optimization: - `inline_globals`: Parallel. - `json_parse`: Migrate to `VisitMut`. - `json_parse`: Parallel.
45 lines
969 B
Rust
45 lines
969 B
Rust
use swc_ecma_ast::*;
|
|
use swc_ecma_transforms_base::perf::{ParExplode, Parallel};
|
|
use swc_ecma_transforms_macros::parallel;
|
|
use swc_ecma_visit::{Fold, VisitMut};
|
|
|
|
#[derive(Default, Clone, Copy)]
|
|
struct ExampleVisitMut;
|
|
|
|
impl Parallel for ExampleVisitMut {
|
|
fn merge(&mut self, _: Self) {}
|
|
|
|
fn create(&self) -> Self {
|
|
Self
|
|
}
|
|
}
|
|
|
|
impl ParExplode for ExampleVisitMut {
|
|
fn after_one_stmt(&mut self, _: &mut Vec<Stmt>) {}
|
|
|
|
fn after_one_module_item(&mut self, _: &mut Vec<ModuleItem>) {}
|
|
}
|
|
|
|
#[parallel(explode)]
|
|
impl VisitMut for ExampleVisitMut {}
|
|
|
|
#[derive(Default, Clone, Copy)]
|
|
struct ExampleFold;
|
|
|
|
impl Parallel for ExampleFold {
|
|
fn merge(&mut self, _: Self) {}
|
|
|
|
fn create(&self) -> Self {
|
|
Self
|
|
}
|
|
}
|
|
|
|
impl ParExplode for ExampleFold {
|
|
fn after_one_stmt(&mut self, _: &mut Vec<swc_ecma_ast::Stmt>) {}
|
|
|
|
fn after_one_module_item(&mut self, _: &mut Vec<ModuleItem>) {}
|
|
}
|
|
|
|
#[parallel(explode)]
|
|
impl Fold for ExampleFold {}
|