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