ssa2ast

package
v0.0.0-...-40491cb Latest Latest
Warning

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

Go to latest
Published: May 7, 2024 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnsupported = errors.New("unsupported")

	MarkerInstr = &ssa.Panic{}
)

Functions

func Convert

func Convert(ssaFunc *ssa.Function, cfg *ConverterConfig) (*ast.FuncDecl, error)

Types

type AstBlock

type AstBlock struct {
	Index   int
	HasRefs bool
	Body    []ast.Stmt
	Phi     []ast.Stmt
	Exit    ast.Stmt
}

type AstFunc

type AstFunc struct {
	Vars   map[string]types.Type
	Blocks []*AstBlock
}

type ConverterConfig

type ConverterConfig struct {
	// ImportNameResolver function to get the actual import name.
	// Because converting works at function level, only the caller knows actual name of the import.
	ImportNameResolver ImportNameResolver

	// NamePrefix prefix added to all new local variables. Must be reasonably unique
	NamePrefix string

	// SsaValueRemap is used to replace ssa.Value with the specified ssa.Expr.
	// Note: Replacing ssa.Expr does not guarantee the correctness of the generated code.
	// When using it, strictly adhere to the value types.
	SsaValueRemap map[ssa.Value]ast.Expr

	// MarkerInstrCallback is called every time a MarkerInstr instruction is encountered.
	// Callback result is inserted into ast as is
	MarkerInstrCallback func(vars map[string]types.Type) []ast.Stmt
}

func DefaultConfig

func DefaultConfig() *ConverterConfig

type ImportNameResolver

type ImportNameResolver func(pkg *types.Package) *ast.Ident

type NameType

type NameType int

type TypeConverter

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

func NewTypeConverted

func NewTypeConverted(resolver ImportNameResolver) *TypeConverter

func (*TypeConverter) Convert

func (tc *TypeConverter) Convert(t types.Type) (ast.Expr, error)

Jump to

Keyboard shortcuts

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