forked from google/starlark-go
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
syntax: expose Binding concept (google#171)
This refactoring exposes the concept of Binding, which was previously internal to the resolver. Previously the Scope and Index fields of the binding were copied into each Ident; now the relationship is indirect. A Binding is the entity created by the first binding occurrence of a name, and the binding ties together all uses of that name. This change is a preparation for fixing issue google#170, which requires that we mark the bindings that need to be allocated indirectly in closure cells. Currently, in the absence of an indirect relationship there is no way to mark a binding so that all Idents are affected. This change leads to a minor simplification in lookupLexical, which used to synthesize a new Ident, when logically it is creating only a new binding. Unfortunately, Binding and Scope must be declared in the syntax package even though they logically belong to the resolver, because the (resolved) syntax trees refer to them. (If you're familiar with the go/types package, syntax.Binding corresponds to types.Var. go/types solves its analogous dependency problem by putting resolver-derived facts in an external map, not the syntax tree, which is expensive. So perhaps it's more accurate to say Binding corresponds to the deprecated ast.Object.)
- Loading branch information
Showing
6 changed files
with
187 additions
and
160 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.