
If the argument of 'source' ends in '.star' it will be interpreted as a starlark script. If the argument of 'source' is '-' an interactive starlark repl will be started. For documentation on how the starlark execution environment works see Documentation/cli/starlark.md. The starlark API is autogenerated from the JSON-RPC API by script/gen-starlark-bindings.go. In general for each JSON-RPC API a single global starlark function is created. When one of those functions is called (through a starlark script) the arguments are converted to go structs using reflection. See unmarshalStarlarkValue in pkg/terminal/starbind/conv.go. If there are no type conversion errors the JSON-RPC call is executed. The return value of the JSON-RPC call is converted back into a starlark value by interfaceToStarlarkValue (same file): * primitive types (such as integers, floats or strings) are converted by creating the corresponding starlark value. * compound types (such as structs and slices) are converted by wrapping their reflect.Value object into a type that implements the relevant starlark interfaces. * api.Variables are treated specially so that their Value field can be of the proper type instead of always being a string. Implements #1415, #1443
19 lines
732 B
Go
19 lines
732 B
Go
package starlark
|
|
|
|
// This file defines an experimental API for the debugging tools.
|
|
// Some of these declarations expose details of internal packages.
|
|
// (The debugger makes liberal use of exported fields of unexported types.)
|
|
// Breaking changes may occur without notice.
|
|
|
|
// Local returns the value of the i'th local variable.
|
|
// It may be nil if not yet assigned.
|
|
//
|
|
// Local may be called only for frames whose Callable is a *Function (a
|
|
// function defined by Starlark source code), and only while the frame
|
|
// is active; it will panic otherwise.
|
|
//
|
|
// This function is provided only for debugging tools.
|
|
//
|
|
// THIS API IS EXPERIMENTAL AND MAY CHANGE WITHOUT NOTICE.
|
|
func (fr *Frame) Local(i int) Value { return fr.locals[i] }
|