bzlenv

package
v0.0.0-...-fb3792a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 9, 2020 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package bzlenv provides function to create and update a static environment.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CollectLValues

func CollectLValues(node build.Expr) []*build.Ident

CollectLValues returns the list of identifiers that are assigned (assuming that node is a valid LValue). For example, it returns `a`, `b` and `c` for the input `a, (b, c)`.

func WalkOnceWithEnvironment

func WalkOnceWithEnvironment(node build.Expr, env *Environment, fct func(e *build.Expr, env *Environment))

WalkOnceWithEnvironment calls fct on every child of node, while maintaining the Environment of all available symbols.

Types

type Environment

type Environment struct {
	Blocks   []block
	Function *build.DefStmt // enclosing function (or nil on top-level)

	Stack []build.Expr // parents of the current node
	// contains filtered or unexported fields
}

Environment represents a static environment (e.g. information about all available symbols).

func NewEnvironment

func NewEnvironment() *Environment

NewEnvironment creates a new empty Environment.

func (*Environment) Get

func (e *Environment) Get(name string) *NameInfo

Get resolves the name and resolves information about the binding (or nil if it's not defined).

type NameInfo

type NameInfo struct {
	ID         int    // unique identifier
	Name       string // name of the variable (not unique)
	Kind       ValueKind
	Definition build.Expr // node that defines the value
}

NameInfo represents information about a symbol name.

type ValueKind

type ValueKind int

ValueKind describes how a binding was declared.

const (
	Builtin   ValueKind = iota // language builtin
	Imported                   // declared with load()
	Global                     // declared with assignment on top-level
	Function                   // declared with a def
	Parameter                  // function parameter
	Local                      // local variable, defined with assignment or as a loop variable
)

List of ValueKind values.

func (ValueKind) String

func (k ValueKind) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL