scriptdefs

package
v1.171.0 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2026 License: Apache-2.0 Imports: 2 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package scriptdefs reads what a script defines and what the platform calls in it, from its syntax alone: every def by a key that tells two nested defs of one name apart, the def a name refers to where it is written (#2848), and the calls the platform makes after the module runs. The script flow graph reads a script through it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EntryCalls

func EntryCalls(file *syntax.File) []*syntax.CallExpr

EntryCalls are the calls the platform makes after the module runs: main() for a run; in a script with no main(), handle(req) for an endpoint's request (#2172, #2315), or a form's form_spec(req) then form_submit(req, values), in the order a person meets them (#2176). None when it makes none.

Types

type Table

type Table struct {
	// Funcs is every def by its key, and KeyOf each def's key.
	Funcs map[string]*syntax.DefStmt
	KeyOf map[*syntax.DefStmt]string
	// ParentOf is the key of the function a nested def is written in, by the
	// nested def's key.
	ParentOf map[string]string
}

Table is every def of a script by its key: a module-level def by its name, a nested one by the key of the function it is written in, a dot and its name. Two nested defs of one name in two functions are two functions, which a table keyed by the bare name made one: the last in the file (#2848).

func Collect

func Collect(stmts []syntax.Stmt) *Table

Collect reads every def in stmts, nested ones included, under its key.

func (*Table) Resolve

func (t *Table) Resolve(scope, name string) (string, *syntax.DefStmt)

Resolve is the def a name written in the function of key scope ("" at module level) refers to, and its key: a def nested in that function, then in each function enclosing it, then a module-level def, as Starlark resolves a name. A def nested in another function is not visible outside it. It is nil, with an empty key, for a name no def holds there.

Jump to

Keyboard shortcuts

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