Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

starlark: add debug API for Locals and FreeVars #539

Merged
merged 1 commit into from
Apr 11, 2024
Merged

Commits on Apr 11, 2024

  1. starlark: add debug API for Locals and FreeVars

    This change adds the following new API to allow debugging tools
    and built-in functions access to the internals of Function values
    and call frames:
    
    package starlark
    
    type Binding struct {
           Name string
           Pos  syntax.Position
    }
    
    func (fr *frame) NumLocals() int
    func (fr *frame) Local(i int) (Binding, Value)
    
    type DebugFrame interface {
        ...
        NumLocals() int
        Local(i int) (Binding, Value)
    }
    
    func (fn *Function) NumFreeVars() int
    func (fn *Function) FreeVar(i int) (Binding, Value)
    
    This is strictly a breaking change, but the changed functions
    (the Local methods) were previously documented as experimental.
    The fix is straightforward.
    
    Also, a test of DebugFrame to write an 'env' function in
    a similar vein to Python's 'dir' function.
    
    Fixes #538
    adonovan committed Apr 11, 2024
    Configuration menu
    Copy the full SHA
    9ceffb1 View commit details
    Browse the repository at this point in the history