ASTMod

package module
v0.0.0-...-eeb70d5 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ASTCtxt struct {
	TypeInfo                   *types.Info
	NewDecls                   []ast.Decl
	FuncMap                    map[string]*ast.FuncDecl
	CurrFunc                   *ast.FuncDecl
	FSet                       *token.FileSet
	BuiltInTypes               map[string]types.Object
	Err                        func(err error)
	RangeIter, TmpVar, TmpFunc uint
}

Functions

func AddSrcGoTypes

func AddSrcGoTypes()

func AnalyzeIllegalCode

func AnalyzeIllegalCode(file *ast.File)

func Arrayify

func Arrayify(typ ast.Expr, len ast.Expr) *ast.ArrayType

func ChangeRecvrNames

func ChangeRecvrNames(file *ast.File)

func ExpandFuncPtrCalls

func ExpandFuncPtrCalls(x *ast.CallExpr, retvals []ast.Expr, retTypes []types.Type) []ast.Stmt

func FindExpr

func FindExpr(a []ast.Expr, x ast.Expr) int

func FindParam

func FindParam(fn *ast.FuncDecl, name string) (*ast.Field, int)

func FindStmt

func FindStmt(a []ast.Stmt, x ast.Stmt) int

func GetFuncName

func GetFuncName(expr ast.Expr) string

func GetTypeBase

func GetTypeBase(t types.Type) types.Type

func InsertDecl

func InsertDecl(a []ast.Decl, index int, value ast.Decl) []ast.Decl

func InsertExpr

func InsertExpr(a []ast.Expr, index int, value ast.Expr) []ast.Expr

func InsertStmt

func InsertStmt(a []ast.Stmt, index int, value ast.Stmt) []ast.Stmt

func IsFuncPtr

func IsFuncPtr(expr ast.Expr) bool

func IsMapType

func IsMapType(expr ast.Expr) bool

func MakeAssign

func MakeAssign(create bool) *ast.AssignStmt

func MakeBasicLit

func MakeBasicLit(tok token.Token, value string) *ast.BasicLit

func MakeBitNotExpr

func MakeBitNotExpr(e ast.Expr) *ast.UnaryExpr

func MakeEnumType

func MakeEnumType(name string, names []string, values []int64)

func MakeFunc

func MakeFunc(name string, recv *types.Var, params, results *types.Tuple, variadic bool)

func MakeFuncPtrArgCall

func MakeFuncPtrArgCall(arg ast.Expr, by_ref bool, pretyp types.Type) *ast.ExprStmt

func MakeIndex

func MakeIndex(index, x ast.Expr) *ast.IndexExpr

func MakeIntConst

func MakeIntConst(name string, num int64)

func MakeIntVar

func MakeIntVar(name string)

func MakeNamedType

func MakeNamedType(name string, typ types.Type, methods []*types.Func)

func MakeParams

func MakeParams(param_names []string, param_types []types.Type) *types.Tuple

func MakeParenExpr

func MakeParenExpr(e ast.Expr) *ast.ParenExpr

func MakeReference

func MakeReference(x ast.Expr) *ast.UnaryExpr

func MakeRet

func MakeRet(param_types []types.Type) *types.Tuple

func MakeTypeAlias

func MakeTypeAlias(name string, typ types.Type, strong bool)

func MakeVarDecl

func MakeVarDecl(names []*ast.Ident, val ast.Expr, typ types.Type) *ast.DeclStmt

func MergeRetVals

func MergeRetVals(file *ast.File)

func MutateAndNotExpr

func MutateAndNotExpr(file *ast.File)

/ a &^ b ==> a & ^(b) ==> a & ~(b) in sp.

func MutateAssignDefStmts

func MutateAssignDefStmts(owner_list *[]ast.Stmt, index int, s ast.Stmt, bm BlockMutator)

func MutateAssignDefs

func MutateAssignDefs(file *ast.File)

func MutateAssignStmts

func MutateAssignStmts(owner_list *[]ast.Stmt, index int, s ast.Stmt, bm BlockMutator)

func MutateAssigns

func MutateAssigns(file *ast.File)

func MutateBlock

func MutateBlock(b *ast.BlockStmt, mutator StmtMutator)

func MutateFuncLit

func MutateFuncLit(owner_list *[]ast.Stmt, index int, s ast.Stmt, bm BlockMutator)

/ func(params){code}(args) => func _srcgo_func#(params){code} ... _srcgo_func#(args)

func MutateFuncLitExprs

func MutateFuncLitExprs(e *ast.Expr)

func MutateNoRetCallStmts

func MutateNoRetCallStmts(owner_list *[]ast.Stmt, index int, s ast.Stmt, bm BlockMutator)

func MutateNoRetCalls

func MutateNoRetCalls(file *ast.File)

func MutateRangeStmts

func MutateRangeStmts(owner_list *[]ast.Stmt, index int, s ast.Stmt, bm BlockMutator)

func MutateRanges

func MutateRanges(file *ast.File)

func MutateRetStmts

func MutateRetStmts(owner_list *[]ast.Stmt, index int, s ast.Stmt, bm BlockMutator)

func MutateRetTypes

func MutateRetTypes(retvals **ast.FieldList, curr_params *ast.FieldList, obj_name string) []*ast.Field

*

  • Modifies the return values of a function by mutating them into references and moving them to the parameters.
  • Example Go code: func f() (int, float) {}
  • Result Go code: func f(f_param1 *float) int {}

func MutateRets

func MutateRets(file *ast.File)

func NameAnonFuncs

func NameAnonFuncs(file *ast.File)

func PrettyPrintAST

func PrettyPrintAST(n ast.Node) string

func PrintAST

func PrintAST(n ast.Node) string

func PrintSrcGoErr

func PrintSrcGoErr(p token.Pos, msg string)

func PtrizeExpr

func PtrizeExpr(x ast.Expr) *ast.StarExpr

func SetUpSrcGo

func SetUpSrcGo(fset *token.FileSet, info *types.Info, err_fn func(err error))

func TypeToASTExpr

func TypeToASTExpr(typ types.Type) ast.Expr

func ValueToTypeExpr

func ValueToTypeExpr(val ast.Expr) ast.Expr

/ Turn a value expr into a type expr.

Types

type BlockMutator

type BlockMutator func(b *ast.BlockStmt, mutator StmtMutator)

type StmtMutator

type StmtMutator func(owner_list *[]ast.Stmt, index int, s ast.Stmt, bm BlockMutator)

Jump to

Keyboard shortcuts

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