Documentation
¶
Overview ¶
Package resolve annotates a parsed module: every identifier gets a reference, every binding a slot, and every scope its size. It enforces the scope rules the parser leaves to it: no redeclaration in one scope, no declaration shadowing an import or a prelude name, and a function on a type belongs to a type of its own module.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PreludeHelp ¶ added in v0.3.0
PreludeHelp is the help for a declaration that takes the prelude name name.
Types ¶
type Binding ¶
type Binding struct {
Name string
Pos ast.Pos
Node ast.Node
// Type is set for a type declared in a block, Import for an import's binding.
Type, Import bool
}
Binding is a name a scope declares and the node that declares it.
type Error ¶
type Error struct {
Pos ast.Pos
Msg string
Code codes.Code
// Help says how to fix the error, when the message does not.
Help string
}
Error is a scope error. It is a syntax error in the sense of section 10.
type Info ¶
type Info struct {
// Defs maps each identifier to the node that declares it: a *ast.NameTarget, a *ast.Param,
// a *ast.FuncDecl, a *ast.TypeDecl, a *ast.Import that binds a namespace, a *ast.ImportName,
// or the *ast.Lambda whose x it is. A prelude name or an unbound one has no entry.
Defs map[*ast.Ident]ast.Node
// Uses maps each declaring node to the identifiers that refer to it, in source order.
Uses map[ast.Node][]*ast.Ident
// Scopes maps the node that opens a scope to it: the *ast.File for the module's, a
// function's or lambda's body *ast.Block for its parameters and locals, a *ast.Block, the
// body of a for loop for its variable, and the body of a select clause for its binding.
Scopes map[ast.Node]*Scope
}
Info is what the resolver learned about a module's names: where each identifier is declared and the names each scope holds.
type Options ¶
type Options struct {
// Session allows a top-level name to be declared again, replacing the earlier binding.
Session bool
// Fields carries the module fields of earlier inputs in a session, so a later input can
// refer to them and redeclare them. It is updated in place.
Fields *ast.ModuleScope
// Extra names the prelude binds in this program, such as host namespaces.
Extra []string
// Info, when set, is filled with what the resolver learned about the module's names, for an
// editor.
Info *Info
}
Options adjusts the rules for a session.