35fddddb78
This change implements a significant amount of the top-level package and module binding logic, including module and class members. It also begins whittling away at the legacy binder logic (which I expect will disappear entirely in the next checkin). The scope abstraction has been rewritten in terms of the new tokens and symbols layers. Each scope has a symbol table that associates names with bound symbols, which can be used during lookup. This accomplishes lexical scoping of the symbol names, by pushing and popping at the appropriate times. I envision all name resolution to happen during this single binding pass so that we needn't reconstruct lexical scoping more than once. Note that we need to do two passes at the top-level, however. We must first bind module-level member names to their symbols *before* we bind any method bodies, otherwise legal intra-module references might turn up empty-handed during this binding pass. There is also a type table that associates types with ast.Nodes. This is how we avoid needing a complete shadow tree of nodes, and/or avoid needing to mutate the nodes in place. Every node with a type gets an entry in the type table. For example, variable declarations, expressions, and so on, each get an entry. This ensures that we can access type symbols throughout the subsequent passes without needing to reconstruct scopes or emulating lexical scoping (as described above). This is a work in progress, so there are a number of important TODOs in there associated with symbol table management and body binding. |
||
---|---|---|
.. | ||
apply.go | ||
build.go | ||
compile.go | ||
describe.go | ||
get.go | ||
mu.go | ||
plan.go | ||
version.go |