dillon1000/react

Commit

[rust] Partial handling of identifiers

Fundamentally this PR is about lowering identifiers during construction of HIR. 
For now i'm punting on context variables and assuming all variables are either 
global, module-scoped, or locals. The implementation involves a few pieces: 

* `estree::Identifer` gets extended with optional binding information. The idea 
is that _some_ name resolution mechanism will populate this. Eventually our own, 
but we can also borrow data from another source... 

* `estree-swc` now configures SWC's (possibly broken?) name resolution mechanism 
and sets the above binding data when translating identifiers from swc into our 
estree format. 

* hir `Builder` tracks identifiers based on `(name, BindingId)` pairs, and 
assigns a unique `hir::Identifier` instance for each pair. `Identifiers` are 
clone-able (shared). 

* Tangential: i updated the printer to handle more instruction variants, 
including the now-ported LoadGlobal instr. 

I don't love this but it's a start. Long-term we definitely should have our own 
name resolution mechanism which we run on the estree prior to lowering to HIR.
Browse files
Changed paths14 files
First-parent comparison
M compiler/forget/crates/build-hir/src/build.rs ModifiedM compiler/forget/crates/build-hir/src/builder.rs ModifiedM compiler/forget/crates/estree-swc/src/lib.rs ModifiedM compiler/forget/crates/estree/src/lib.rs ModifiedM compiler/forget/crates/estree/src/snapshots/[email protected] ModifiedM compiler/forget/crates/estree/src/snapshots/[email protected] ModifiedM compiler/forget/crates/estree/src/snapshots/[email protected] ModifiedM compiler/forget/crates/estree/src/snapshots/[email protected] ModifiedA compiler/forget/crates/fixtures/tests/fixtures/identifiers.js AddedM compiler/forget/crates/fixtures/tests/fixtures_test.rs ModifiedA compiler/forget/crates/fixtures/tests/snapshots/[email protected] AddedR compiler/forget/crates/fixtures/tests/snapshots/fixtures_test__fixtures.snap →compiler/forget/crates/fixtures/tests/snapshots/[email protected] RenamedM compiler/forget/crates/hir/src/instruction.rs ModifiedM compiler/forget/crates/hir/src/print.rs Modified
Patch

Files changed

Rendering syntax-highlighted changes…