pry

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2025 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrChanSendFailed occurs when a channel is full or there are no receivers
	// available.
	ErrChanSendFailed = errors.New("failed to send, channel full or no receivers")

	// ErrBranchBreak is an internal error thrown when a for loop breaks.
	ErrBranchBreak = errors.New("branch break")
	// ErrBranchContinue is an internal error thrown when a for loop continues.
	ErrBranchContinue = errors.New("branch continue")
)
View Source
var ErrChanRecvFailed = errors.New("receive failed: channel closed")

ErrChanRecvFailed occurs when a channel is closed.

View Source
var ErrChanRecvInSelect = errors.New("receive failed: in select")

ErrChanRecvInSelect is an internal error that is used to indicate it's in a select statement.

View Source
var ErrDivisionByZero = errors.New("division by zero")

Functions

func Apply

func Apply(scope *Scope)

Apply drops into a pry shell in the location required.

func ComputeBinaryOp

func ComputeBinaryOp(xI, yI interface{}, op token.Token) (interface{}, error)

ComputeBinaryOp executes the corresponding binary operation (+, -, etc) on two interfaces.

func DeAssign

func DeAssign(tok token.Token) token.Token

DeAssign takes a *_ASSIGN token and returns the corresponding * token.

func Fuzz

func Fuzz(data []byte) int

Fuzz is used for go-fuzz testing.

func Highlight

func Highlight(s string) string

Highlight highlights a string of go code for outputting to bash.

func NewHistory

func NewHistory() (*ioHistory, error)

NewHistory constructs ioHistory instance

func Pry

func Pry(v ...interface{})

Pry does nothing. It only exists so running code without prygo doesn't throw an error.

func StringToType

func StringToType(str string) (reflect.Type, error)

StringToType returns the reflect.Type corresponding to the type string provided. Ex: StringToType("int")

func Type

func Type(t interface{}) reflect.Type

Type returns the reflect type of the passed object.

func ValuesToInterfaces

func ValuesToInterfaces(vals []reflect.Value) []interface{}

ValuesToInterfaces converts a slice of []reflect.Value to []interface{}

Types

type Defer

type Defer struct {
	// contains filtered or unexported fields
}

type Func

type Func struct {
	Def *ast.FuncLit
}

Func represents an interpreted function definition.

type InterpretError

type InterpretError struct {
	// contains filtered or unexported fields
}

InterpretError is an error returned by the interpreter and shouldn't be passed to the user or running code.

func Append

func Append(arr interface{}, elems ...interface{}) (interface{}, *InterpretError)

Append is a runtime replacement for the append function

func Close

func Close(t interface{}) (interface{}, *InterpretError)

Close is a runtime replacement for the "close" function.

func Len

func Len(t interface{}) (interface{}, *InterpretError)

Len is a runtime replacement for the len function

func Make

func Make(t interface{}, args ...interface{}) (interface{}, *InterpretError)

Make is a runtime replacement for the make function

func (*InterpretError) Error

func (a *InterpretError) Error() error

type JSImporter

type JSImporter struct {
	Dir map[string]map[string]*ast.File
	// contains filtered or unexported fields
}

JSImporter contains all the information needed to implement a types.Importer in a javascript environment.

func (*JSImporter) Import

func (i *JSImporter) Import(path string) (*types.Package, error)

type Package

type Package struct {
	Name      string
	Functions map[string]interface{}
}

Package represents a Go package for use with pry

func (Package) Get

func (p Package) Get(key string) (interface{}, bool)

func (Package) Keys

func (p Package) Keys() []string

type Scope

type Scope struct {
	Vals   map[string]interface{}
	Parent *Scope
	Files  map[string]*ast.File

	sync.Mutex
	// contains filtered or unexported fields
}

Scope is a string-interface key-value pair that represents variables/functions in scope.

func NewScope

func NewScope() *Scope

NewScope creates a new initialized scope

func (*Scope) CheckStatement

func (scope *Scope) CheckStatement(node ast.Node) (errs []error)

CheckStatement checks if a statement is type safe

func (*Scope) ComputeUnaryOp

func (scope *Scope) ComputeUnaryOp(xI interface{}, op token.Token) (interface{}, error)

ComputeUnaryOp computes the corresponding unary (+x, -x) operation on an interface.

func (*Scope) ConfigureTypes

func (scope *Scope) ConfigureTypes(path string, line int) error

ConfigureTypes configures the scope type checker

func (*Scope) Defer

func (scope *Scope) Defer(d *Defer) error

func (*Scope) ExecuteFunc

func (scope *Scope) ExecuteFunc(funExpr ast.Expr, args []interface{}) (interface{}, error)

func (*Scope) Get

func (scope *Scope) Get(name string) (interface{}, bool)

Get walks the scope and finds the value of interest

func (*Scope) GetPointer

func (scope *Scope) GetPointer(name string) (val interface{}, exists bool)

GetPointer walks the scope and finds the pointer to the value of interest

func (*Scope) Interpret

func (scope *Scope) Interpret(expr ast.Node) (interface{}, error)

Interpret interprets an ast.Node and returns the value.

func (*Scope) InterpretString

func (scope *Scope) InterpretString(exprStr string) (v interface{}, err error)

InterpretString interprets a string of go code and returns the result.

func (*Scope) Keys

func (scope *Scope) Keys() (keys []string)

Keys returns all keys in scope

func (*Scope) NewChild

func (scope *Scope) NewChild() *Scope

NewChild creates a scope under the existing scope.

func (*Scope) ParseString

func (scope *Scope) ParseString(exprStr string) (ast.Node, int, error)

ParseString parses go code into the ast nodes.

func (*Scope) Render

func (scope *Scope) Render(x ast.Node) string

Render renders an ast node

func (*Scope) Set

func (scope *Scope) Set(name string, val interface{})

Set walks the scope and sets a value in a parent scope if it exists, else current.

func (*Scope) SuggestionsGoCode

func (scope *Scope) SuggestionsGoCode(line string, index int) ([]string, error)

SuggestionsGoCode is a suggestion engine that uses gocode for autocomplete.

func (*Scope) SuggestionsPry

func (s *Scope) SuggestionsPry(line string, index int) ([]string, error)

func (*Scope) TypeCheck

func (scope *Scope) TypeCheck() (*types.Info, []error)

TypeCheck does type checking and returns the info object

Directories

Path Synopsis
safebuffer is a goroutine safe bytes.Buffer.
safebuffer is a goroutine safe bytes.Buffer.

Jump to

Keyboard shortcuts

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