For milestone 1, I think it's safe to just layout all the
transformations manually.
In TypeScript, the transformers are collected dynamically and ran on
each ast node; this achieves a single AST pass.
https://github.com/microsoft/TypeScript/blob/main/src/compiler/transformer.ts#L129-L145
To maximize performance and reduce confusion, I think it's safe to
layout all the transformations manually for milestone 1.
The next PR will add transformation context to all presets so we can
start adding "context".
Before this PR for this given case:
```javascript
const _unused = "It's a lie, They gonna use me:(";
try {
throw 0;
} catch {
console.log(_unused);
}
```
We would've generated this:
```javascript
const _unused = "It's a lie, They gonna use me:(";
try {
throw 0;
} catch (_unused) {
console.log(_unused);
}
```
This is incorrect, This PR aims to use the `CreateVars` trait in order
to ensure the variable uniqueness.
Now it would output this:
```javascript
const _unused = "It's a lie, They gonna use me:(";
try {
throw 0;
} catch (_unused2) {
console.log(_unused);
}
```
Should be merged after #2829, Tried a few times to get it done with
graphite stacking but found no success. I guess it either doesn't work
with forks or It is just a skill issue since I'm not familiar with it.
closes: #2829closes: #2830
---------
Co-authored-by: Dmytro Maretskyi <maretskii@gmail.com>
* move `visit` and `visit_mut` modules to a super module called `visit`
* add `walk_mut` module containing walk functions
* update `enter_node` and `leave_node` events to not pass a reference in the `VisitMut` trait
* add `AstType`, a non-referencing version of `AstKind` to use with `VisitMut` trait
* update the `VisitMut` trait's usages.
This will close#2745,
In this PR I attempt to fix this issue using a combination of ideas
discussed in the issue mentioned above, I've created this early draft so
people can pitch in if there is something I should consider doing.
The first goal of this PR is to resolve the issue with the possible
illegal references, As a result of my approach it would also end up with
a bunch of walk_* and walk_*_mut functions to help with the abstraction.
I want to eliminate enter_node and leave_node functions, but I still
haven't started working on it since I first want to familiarize myself
with all of its usage throughout the project. I'm hesitating to do it at
the moment, When we want to do this it would require quite a bit of
refactoring so we should make sure it is probably going to work and end
up being a better implementation.
Preparatory step for #2620.
This PR purely changes names of types and methods:
* `CompactString` -> `CompactStr`
* `Atom::to_compact_string` -> `to_compact_str`
* `Atom::into_compact_string` -> `into_compact_str`
Have split this into a separate PR as the diff is large, but it does absolutely nothing but renaming (I've checked the whole diff twice, so feel free not to check it again!). This should make it easier to see the content of the substantive change in #2620.