edit

package
v1.1.13 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitPkgFlag added in v1.1.1

func InitPkgFlag(pkg *Package)

Types

type Decl

type Decl struct {
	Kind  DeclKind
	Ident *ast.Ident
	Type  ast.Expr // might be nil

	Value             ast.Expr // only for var, might be nil
	ResolvedValueType types.Type

	Decl *ast.GenDecl

	// Pending var refs for rewrite
	// for var only
	VarRefs []*VarRef

	// for Func
	FuncDecl *FuncDecl

	// for Type
	Methods map[string]*FuncDecl
	File    *File
}

type DeclKind

type DeclKind int
const (
	DeclKindUnknown DeclKind = iota
	DeclKindVar
	DeclKindConst
	DeclKindType
	DeclKindFunc // not including methods
)

type Field

type Field struct {
	Name      string
	NameIdent *ast.Ident // could be nil for anonymous field
	Type      ast.Expr
}

type Fields

type Fields []*Field

func (Fields) Names

func (f Fields) Names() []string

type File

type File struct {
	File *load.File
	// the file index
	Index int

	Edit *goedit.Edit

	Decls []*Decl

	TrapFuncs      []*FuncInfo
	TrapVars       []*VarInfo
	InterfaceTypes []*InterfaceType
}

func (*File) HasEdit

func (c *File) HasEdit() bool

type FuncDecl added in v1.1.1

type FuncDecl struct {
	Name    string
	RecvPtr bool
	Syntax  *ast.FuncDecl
}

type FuncInfo

type FuncInfo struct {
	InfoVar      string
	FuncDecl     *ast.FuncDecl
	IdentityName string
	RecvPtr      bool
	RecvGeneric  bool
	RecvType     *ast.Ident

	Receiver *Field
	Params   Fields
	Results  Fields
}

type InterfaceType

type InterfaceType struct {
	InfoVar string
	Name    string
	Ident   *ast.Ident
	Type    *ast.InterfaceType
}

type Package

type Package struct {
	LoadPackage *load.Package
	Files       []*File

	Decls map[string]*Decl

	Collected bool

	// Main indicates the package is
	// within the main module
	// NOTE: this does not consider go.mod
	// boundaries, it only consider the
	// prefix of the package path.
	Main bool

	// Initial indicates whether
	// the packages are loaded via
	// package args specified by user
	Initial bool

	// Xgo indicates whether
	// the package is xgo/runtime
	Xgo bool

	// AllowInstrument indicates whether
	// the package is allowed to be instrumented
	AllowInstrument bool
}

type Packages

type Packages struct {
	Fset     *token.FileSet
	Packages []*Package

	PackageByPath map[string]*Package

	LoadOptions load.LoadOptions
}

func New added in v1.1.1

func New(packages *load.Packages) *Packages

func (*Packages) Add added in v1.1.1

func (c *Packages) Add(packages *load.Packages)

func (*Packages) CloneWithPackages added in v1.1.1

func (p *Packages) CloneWithPackages(packages []*Package) *Packages

func (*Packages) Filter

func (p *Packages) Filter(f func(pkg *Package) bool) []*Package

func (*Packages) LoadPackage added in v1.1.1

func (c *Packages) LoadPackage(pkgPath string) (*Package, bool, error)

func (*Packages) LoadPackages added in v1.1.1

func (c *Packages) LoadPackages(pkgPaths []string) error

func (*Packages) Merge added in v1.1.1

func (c *Packages) Merge(pkgs *Packages, override bool)

type VarInfo

type VarInfo struct {
	InfoVar string
	Name    string
	Decl    *Decl
}

type VarRef added in v1.1.1

type VarRef struct {
	File *File
	// the prefiex & token, if any
	Addr *ast.UnaryExpr
	// call get() or get_addr()
	NeedPtr   bool
	NameStart token.Pos
	// the end position of the name
	NameEnd token.Pos
	// FieldAccess indicates this is &variable.Field pattern
	// In this case, keep the & and use _xgo_get() instead of _xgo_get_addr()
	FieldAccess bool
}

Jump to

Keyboard shortcuts

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