react
react copied to clipboard
compiler: distinguish globals/imports/module-locals
Stack from ghstack (oldest at bottom):
- #29190
- #29189
- -> #29188
We currently use LoadGlobal
and StoreGlobal
to represent any read (or write) of a variable defined outside the component or hook that is being compiled. This is mostly fine, but for a lot of things we want to do going forward (resolving types across modules, for example) it helps to understand the actual source of a variable.
This PR is an incremental step in that direction. We continue to use LoadGlobal/StoreGlobal, but LoadGlobal now has a binding:NonLocalBinding
instead of just the name of the global. The NonLocalBinding type tells us whether it was an import (and which kind, the source module name etc), a module-local binding, or a true global. By keeping the LoadGlobal/StoreGlobal instructions, most code that deals with "anything not declared locally" doesn't have to care about the difference. However, code that does want to know the source of the value can figure it out.