elvish/eval/scope.go
Qi Xiao 357a6d91e2 Introduce a module map as part of the lexical scope.
This commit only deals with the type change, but doesn't actually use the
module map.
2017-09-20 13:43:28 +01:00

27 lines
581 B
Go

package eval
// Scope represents a lexical scope. It holds variables and imports.
type Scope struct {
Names Namespace
Uses map[string]Namespace
}
func makeScope() Scope {
return Scope{Namespace{}, map[string]Namespace{}}
}
// Namespace is a map from names to variables.
type Namespace map[string]Variable
// staticScope represents static information of a staticScope.
// TODO(xiaq): Represent Scope.Uses as well.
type staticScope map[string]bool
func makeStaticScope(s Namespace) staticScope {
sc := staticScope{}
for name := range s {
sc[name] = true
}
return sc
}