Documentation ¶
Index ¶
- Variables
- func IcallStat() (capacity int, allocate int, aviable int)
- func IsConstNil(v ssa.Value) bool
- func IsNil(v reflect.Value) bool
- func PackageList() (list []string)
- func ParseBuiltin(fset *token.FileSet, pkg string) (*ast.File, error)
- func RegisterCustomBuiltin(key string, fn interface{}) error
- func RegisterExternal(key string, i interface{})
- func RegisterFileProcess(ext string, fn SourceProcessFunc)
- func RegisterPackage(pkg *Package)
- func ResetAllIcall()
- func Run(path string, args []string, mode Mode) (exitCode int, err error)
- func RunFile(filename string, src interface{}, args []string, mode Mode) (exitCode int, err error)
- func RunTest(path string, args []string, mode Mode) error
- func SetValue(v reflect.Value, x reflect.Value)
- type Context
- func (ctx *Context) AddImport(path string, dir string) (err error)
- func (ctx *Context) AddImportFile(path string, filename string, src interface{}) (err error)
- func (ctx *Context) IsEvalMode() bool
- func (ctx *Context) LoadAstFile(path string, file *ast.File) (*ssa.Package, error)
- func (ctx *Context) LoadAstPackage(path string, apkg *ast.Package) (*ssa.Package, error)
- func (ctx *Context) LoadDir(dir string, test bool) (pkg *ssa.Package, err error)
- func (ctx *Context) LoadFile(filename string, src interface{}) (*ssa.Package, error)
- func (ctx *Context) LoadInterp(filename string, src interface{}) (*Interp, error)
- func (ctx *Context) NewInterp(mainPkg *ssa.Package) (*Interp, error)
- func (ctx *Context) ParseFile(filename string, src interface{}) (*ast.File, error)
- func (ctx *Context) RegisterExternal(key string, i interface{})
- func (ctx *Context) Run(path string, args []string) (exitCode int, err error)
- func (ctx *Context) RunFile(filename string, src interface{}, args []string) (exitCode int, err error)
- func (ctx *Context) RunFunc(mainPkg *ssa.Package, fnname string, args ...Value) (ret Value, err error)
- func (ctx *Context) RunInterp(interp *Interp, input string, args []string) (exitCode int, err error)
- func (ctx *Context) RunPkg(mainPkg *ssa.Package, input string, args []string) (exitCode int, err error)
- func (ctx *Context) RunTest(dir string, args []string) error
- func (ctx *Context) SetDebug(fn func(*DebugInfo))
- func (ctx *Context) SetEvalMode(b bool)
- func (ctx *Context) SetLeastCallForEnablePool(count int)
- func (ctx *Context) SetPrintOutput(output *bytes.Buffer)
- func (ctx *Context) SetUnsafeSizes(sizes types.Sizes)
- func (ctx *Context) SourcePackage(path string) *SourcePackage
- func (ctx *Context) TestPkg(pkg *ssa.Package, input string, args []string) error
- func (ctx *Context) UnsafeRelease()
- type DebugInfo
- type Eval
- type ExitError
- type FindMethod
- type Importer
- type Interp
- func (i *Interp) Abort()
- func (i *Interp) Exit(code int)
- func (i *Interp) ExitCode() int
- func (i *Interp) FindMethod(mtyp reflect.Type, fn *types.Func) func([]reflect.Value) []reflect.Value
- func (i *Interp) GetConst(key string) (constant.Value, bool)
- func (i *Interp) GetFunc(key string) (interface{}, bool)
- func (i *Interp) GetSymbol(key string) (m ssa.Member, v interface{}, ok bool)
- func (i *Interp) GetType(key string) (reflect.Type, bool)
- func (i *Interp) GetVarAddr(key string) (interface{}, bool)
- func (i *Interp) IcallAlloc() int
- func (i *Interp) MainPkg() *ssa.Package
- func (i *Interp) ResetIcall()
- func (i *Interp) RunFunc(name string, args ...Value) (r Value, err error)
- func (i *Interp) RunInit() (err error)
- func (i *Interp) RunMain() (exitCode int, err error)
- func (i *Interp) UnsafeRelease()
- type Loader
- type Mode
- type Package
- type PanicError
- type Repl
- type SourcePackage
- type SourceProcessFunc
- type Tuple
- type TypedConst
- type TypesLoader
- func (r *TypesLoader) GetPackage(pkg string) *types.Package
- func (r *TypesLoader) Import(path string) (*types.Package, error)
- func (r *TypesLoader) Insert(v reflect.Value)
- func (r *TypesLoader) InsertAlias(p *types.Package, name string, rt reflect.Type)
- func (r *TypesLoader) InsertConst(p *types.Package, name string, typ types.Type, c constant.Value)
- func (r *TypesLoader) InsertFunc(p *types.Package, name string, v reflect.Value)
- func (r *TypesLoader) InsertInterface(p *types.Package, name string, rt reflect.Type)
- func (r *TypesLoader) InsertNamedType(p *types.Package, name string, rt reflect.Type)
- func (r *TypesLoader) InsertTypedConst(p *types.Package, name string, v TypedConst)
- func (r *TypesLoader) InsertUntypedConst(p *types.Package, name string, v UntypedConst)
- func (r *TypesLoader) InsertVar(p *types.Package, name string, v reflect.Value)
- func (r *TypesLoader) Installed(path string) (pkg *Package, ok bool)
- func (r *TypesLoader) LookupPackage(pkgpath string) (*types.Package, bool)
- func (r *TypesLoader) LookupReflect(typ types.Type) (reflect.Type, bool)
- func (r *TypesLoader) LookupType(typ string) types.Type
- func (r *TypesLoader) LookupTypes(typ reflect.Type) (types.Type, bool)
- func (r *TypesLoader) Packages() (pkgs []*types.Package)
- func (r *TypesLoader) SetImport(path string, pkg *types.Package, load func() error) error
- func (r *TypesLoader) ToType(rt reflect.Type) types.Type
- type TypesRecord
- func (r *TypesRecord) EnterInstance(fn *ssa.Function)
- func (r *TypesRecord) LeaveInstance(fn *ssa.Function)
- func (r *TypesRecord) Load(pkg *ssa.Package)
- func (r *TypesRecord) LookupLocalTypes(rt reflect.Type) (typ types.Type, ok bool)
- func (r *TypesRecord) LookupReflect(typ types.Type) (rt reflect.Type, ok bool, nested bool)
- func (r *TypesRecord) LookupTypes(rt reflect.Type) (typ types.Type, ok bool)
- func (r *TypesRecord) Release()
- func (r *TypesRecord) ToType(typ types.Type) (reflect.Type, bool)
- func (r *TypesRecord) ToTypeList(tuple *types.Tuple) ([]reflect.Type, bool)
- type UntypedConst
- type Value
Constants ¶
This section is empty.
Variables ¶
var ( ErrNotFoundMain = errors.New("not found main package") ErrTestFailed = errors.New("test failed") ErrNotFoundPackage = errors.New("not found package") ErrGoexitDeadlock = errors.New("fatal error: no goroutines (main called runtime.Goexit) - deadlock!") ErrNoFunction = errors.New("no function") ErrNoTestFiles = errors.New("[no test files]") )
Functions ¶
func IsConstNil ¶
func PackageList ¶ added in v0.7.4
func PackageList() (list []string)
PackageList return all register packages
func ParseBuiltin ¶ added in v0.7.4
func RegisterCustomBuiltin ¶
func RegisterExternal ¶
func RegisterExternal(key string, i interface{})
RegisterExternal is register external variable address or func
func RegisterFileProcess ¶
func RegisterFileProcess(ext string, fn SourceProcessFunc)
func ResetAllIcall ¶ added in v0.14.1
func ResetAllIcall()
ResetAllIcall is reset all reflectx icall, all interp methods invalid.
Types ¶
type Context ¶
type Context struct { Loader Loader // types loader BuildContext build.Context // build context, default build.Default RunContext context.Context // run context, default unset FileSet *token.FileSet // file set Lookup func(root, path string) (dir string, found bool) // lookup external import Mode Mode // mode BuilderMode ssa.BuilderMode // ssa builder mode // contains filtered or unexported fields }
Context ssa context
func (*Context) AddImportFile ¶ added in v0.8.4
func (*Context) IsEvalMode ¶
func (*Context) LoadAstFile ¶
func (*Context) LoadAstPackage ¶
func (*Context) LoadInterp ¶ added in v0.14.0
func (*Context) RegisterExternal ¶ added in v0.10.0
RegisterExternal register external value must variable address or func.
func (*Context) SetEvalMode ¶ added in v0.8.4
func (*Context) SetLeastCallForEnablePool ¶
SetLeastCallForEnablePool set least call count for enable function pool, default 64
func (*Context) SetPrintOutput ¶
SetPrintOutput is captured builtin print/println output
func (*Context) SetUnsafeSizes ¶ added in v0.8.9
SetUnsafeSizes set the sizing functions for package unsafe.
func (*Context) SourcePackage ¶ added in v0.27.0
func (ctx *Context) SourcePackage(path string) *SourcePackage
func (*Context) UnsafeRelease ¶ added in v0.14.0
func (ctx *Context) UnsafeRelease()
type FindMethod ¶
type Importer ¶
type Importer struct {
// contains filtered or unexported fields
}
func NewImporter ¶
type Interp ¶
type Interp struct {
// contains filtered or unexported fields
}
func (*Interp) FindMethod ¶
func (*Interp) GetVarAddr ¶
func (*Interp) ResetIcall ¶ added in v0.14.1
func (i *Interp) ResetIcall()
ResetIcall is reset reflectx icall, all methods invalid.
func (*Interp) UnsafeRelease ¶ added in v0.14.0
func (i *Interp) UnsafeRelease()
UnsafeRelease is unsafe release interp. interp all invalid.
type Loader ¶
type Loader interface { Import(path string) (*types.Package, error) Installed(path string) (*Package, bool) Packages() []*types.Package LookupReflect(typ types.Type) (reflect.Type, bool) LookupTypes(typ reflect.Type) (types.Type, bool) SetImport(path string, pkg *types.Package, load func() error) error }
Loader types loader interface
func NewTypesLoader ¶
NewTypesLoader install package and readonly
type Mode ¶
type Mode uint
Mode is a bitmask of options affecting the interpreter.
const ( DisableRecover Mode = 1 << iota // Disable recover() in target programs; show interpreter crash instead. DisableCustomBuiltin // Disable load custom builtin func EnableDumpImports // print import packages EnableDumpInstr // Print packages & SSA instruction code EnableTracing // Print a trace of all instructions as they are interpreted. EnablePrintAny // Enable builtin print for any type ( struct/array ) EnableNoStrict // Enable no strict mode ExperimentalSupportGC // experimental support runtime.GC SupportMultipleInterp // Support multiple interp, must manual release interp reflectx icall. CheckGopOverloadFunc // Check and skip gop overload func )
type Package ¶
type Package struct { Interfaces map[string]reflect.Type NamedTypes map[string]reflect.Type AliasTypes map[string]reflect.Type Vars map[string]reflect.Value Funcs map[string]reflect.Value TypedConsts map[string]TypedConst UntypedConsts map[string]UntypedConst Deps map[string]string // path -> name Name string Path string Source string }
func LookupPackage ¶
LookupPackage lookup register pkgs
type PanicError ¶ added in v0.13.0
type PanicError struct { Value value // contains filtered or unexported fields }
If the target program panics, the interpreter panics with this type.
func (PanicError) Error ¶ added in v0.13.0
func (p PanicError) Error() string
func (PanicError) Stack ¶ added in v0.13.0
func (p PanicError) Stack() []byte
type Repl ¶
type Repl struct {
// contains filtered or unexported fields
}
func (*Repl) SetFileName ¶
type SourcePackage ¶ added in v0.27.0
type SourcePackage struct { Context *Context Package *types.Package Info *types.Info Importer types.Importer Files []*ast.File Links []*load.LinkSym Dir string Register bool // register package }
func (*SourcePackage) Load ¶ added in v0.27.0
func (sp *SourcePackage) Load() (err error)
type SourceProcessFunc ¶
type TypesLoader ¶
type TypesLoader struct {
// contains filtered or unexported fields
}
func (*TypesLoader) GetPackage ¶
func (r *TypesLoader) GetPackage(pkg string) *types.Package
func (*TypesLoader) Insert ¶
func (r *TypesLoader) Insert(v reflect.Value)
func (*TypesLoader) InsertAlias ¶
func (*TypesLoader) InsertConst ¶
func (*TypesLoader) InsertFunc ¶
func (*TypesLoader) InsertInterface ¶
func (*TypesLoader) InsertNamedType ¶
func (*TypesLoader) InsertTypedConst ¶
func (r *TypesLoader) InsertTypedConst(p *types.Package, name string, v TypedConst)
func (*TypesLoader) InsertUntypedConst ¶
func (r *TypesLoader) InsertUntypedConst(p *types.Package, name string, v UntypedConst)
func (*TypesLoader) Installed ¶
func (r *TypesLoader) Installed(path string) (pkg *Package, ok bool)
func (*TypesLoader) LookupPackage ¶
func (r *TypesLoader) LookupPackage(pkgpath string) (*types.Package, bool)
func (*TypesLoader) LookupReflect ¶
func (*TypesLoader) LookupType ¶
func (r *TypesLoader) LookupType(typ string) types.Type
func (*TypesLoader) LookupTypes ¶
func (*TypesLoader) Packages ¶
func (r *TypesLoader) Packages() (pkgs []*types.Package)
type TypesRecord ¶
type TypesRecord struct {
// contains filtered or unexported fields
}
func NewTypesRecord ¶
func NewTypesRecord(rctx *reflectx.Context, loader Loader, finder FindMethod, nested map[*types.Named]int) *TypesRecord
func (*TypesRecord) EnterInstance ¶ added in v0.9.8
func (r *TypesRecord) EnterInstance(fn *ssa.Function)
func (*TypesRecord) LeaveInstance ¶ added in v0.9.8
func (r *TypesRecord) LeaveInstance(fn *ssa.Function)
func (*TypesRecord) Load ¶
func (r *TypesRecord) Load(pkg *ssa.Package)
func (*TypesRecord) LookupLocalTypes ¶
func (*TypesRecord) LookupReflect ¶
func (*TypesRecord) LookupTypes ¶
func (*TypesRecord) Release ¶ added in v0.14.0
func (r *TypesRecord) Release()
func (*TypesRecord) ToTypeList ¶
type UntypedConst ¶
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
internal/base
Package base defines shared xtype pieces of the gop command, in particular logging and the Command structure.
|
Package base defines shared xtype pieces of the gop command, in particular logging and the Command structure. |
internal/build
Package build implements the “igop build” command.
|
Package build implements the “igop build” command. |
internal/help
Package help implements the “igop help” command.
|
Package help implements the “igop help” command. |
internal/run
Package run implements the “gop run” command.
|
Package run implements the “gop run” command. |
internal/test
Package test implements the “igop test” command.
|
Package test implements the “igop test” command. |
internal/version
Package build implements the “igop version” command.
|
Package build implements the “igop version” command. |