1*4947cdc7SCole Faustpackage starlark 2*4947cdc7SCole Faust 3*4947cdc7SCole Faustimport "go.starlark.net/syntax" 4*4947cdc7SCole Faust 5*4947cdc7SCole Faust// This file defines an experimental API for the debugging tools. 6*4947cdc7SCole Faust// Some of these declarations expose details of internal packages. 7*4947cdc7SCole Faust// (The debugger makes liberal use of exported fields of unexported types.) 8*4947cdc7SCole Faust// Breaking changes may occur without notice. 9*4947cdc7SCole Faust 10*4947cdc7SCole Faust// Local returns the value of the i'th local variable. 11*4947cdc7SCole Faust// It may be nil if not yet assigned. 12*4947cdc7SCole Faust// 13*4947cdc7SCole Faust// Local may be called only for frames whose Callable is a *Function (a 14*4947cdc7SCole Faust// function defined by Starlark source code), and only while the frame 15*4947cdc7SCole Faust// is active; it will panic otherwise. 16*4947cdc7SCole Faust// 17*4947cdc7SCole Faust// This function is provided only for debugging tools. 18*4947cdc7SCole Faust// 19*4947cdc7SCole Faust// THIS API IS EXPERIMENTAL AND MAY CHANGE WITHOUT NOTICE. 20*4947cdc7SCole Faustfunc (fr *frame) Local(i int) Value { return fr.locals[i] } 21*4947cdc7SCole Faust 22*4947cdc7SCole Faust// DebugFrame is the debugger API for a frame of the interpreter's call stack. 23*4947cdc7SCole Faust// 24*4947cdc7SCole Faust// Most applications have no need for this API; use CallFrame instead. 25*4947cdc7SCole Faust// 26*4947cdc7SCole Faust// Clients must not retain a DebugFrame nor call any of its methods once 27*4947cdc7SCole Faust// the current built-in call has returned or execution has resumed 28*4947cdc7SCole Faust// after a breakpoint as this may have unpredictable effects, including 29*4947cdc7SCole Faust// but not limited to retention of object that would otherwise be garbage. 30*4947cdc7SCole Fausttype DebugFrame interface { 31*4947cdc7SCole Faust Callable() Callable // returns the frame's function 32*4947cdc7SCole Faust Local(i int) Value // returns the value of the (Starlark) frame's ith local variable 33*4947cdc7SCole Faust Position() syntax.Position // returns the current position of execution in this frame 34*4947cdc7SCole Faust} 35*4947cdc7SCole Faust 36*4947cdc7SCole Faust// DebugFrame returns the debugger interface for 37*4947cdc7SCole Faust// the specified frame of the interpreter's call stack. 38*4947cdc7SCole Faust// Frame numbering is as for Thread.CallFrame. 39*4947cdc7SCole Faust// 40*4947cdc7SCole Faust// This function is intended for use in debugging tools. 41*4947cdc7SCole Faust// Most applications should have no need for it; use CallFrame instead. 42*4947cdc7SCole Faustfunc (thread *Thread) DebugFrame(depth int) DebugFrame { return thread.frameAt(depth) } 43