Documentation ¶
Overview ¶
Package resolve defines a name-resolution pass for Starlark abstract syntax trees.
The resolver sets the Locals and FreeVars arrays of each DefStmt and the LocalIndex field of each syntax.Ident that refers to a local or free variable. It also sets the Locals array of a File for locals bound by comprehensions outside any function. Identifiers for global variables do not get an index.
Index ¶
Constants ¶
const ( Undefined = syntax.UndefinedScope Local = syntax.LocalScope Cell = syntax.CellScope Free = syntax.FreeScope Global = syntax.GlobalScope Predeclared = syntax.PredeclaredScope Universal = syntax.UniversalScope )
Variables ¶
var ( AllowNestedDef = false // allow def statements within function bodies AllowLambda = false // allow lambda expressions AllowFloat = false // allow floating point literals, the 'float' built-in, and x / y AllowSet = false // allow the 'set' built-in AllowGlobalReassign = false // allow reassignment to globals declared in same file (deprecated) AllowRecursion = false // allow while statements and recursive functions AllowBitwise = true // obsolete; bitwise operations (&, |, ^, ~, <<, and >>) are always enabled )
global options These features are either not standard Starlark (yet), or deprecated features of the BUILD language, so we put them behind flags.
Functions ¶
func File ¶
File resolves the specified file.
The isPredeclared and isUniversal predicates report whether a name is a pre-declared identifier (visible in the current module) or a universal identifier (visible in every module). Clients should typically pass predeclared.Has for the first and starlark.Universe.Has for the second, where predeclared is the module's StringDict of predeclared names and starlark.Universe is the standard set of built-ins. The isUniverse predicate is supplied a parameter to avoid a cyclic dependency upon starlark.Universe, not because users should ever need to redefine it.