Documentation
¶
Index ¶
- Constants
- func Arrayify(typ ast.Expr, len ast.Expr) *ast.ArrayType
- func ChangeReceiverNames(file *ast.File)
- func CollectFuncNames(file *ast.File) map[string]*ast.FuncDecl
- func ExpandFuncPtrCalls(x *ast.CallExpr, retvals []ast.Expr, retTypes []types.Type, ti *types.Info, ...) []ast.Stmt
- func FindParam(fn *ast.FuncDecl, name string) (*ast.Field, int)
- func FindStmt(a []ast.Stmt, x ast.Stmt) int
- func GetFuncName(expr ast.Expr) string
- func GetTypeBase(t types.Type) types.Type
- func IndexOfValue[T comparable](a []T, x T) int
- func InsertToIndex[T any](a []T, index int, value T) []T
- func IsFuncPtr(expr ast.Expr, typ *types.Info) bool
- func IsMapType(expr ast.Expr, typ *types.Info) bool
- func MakeAssign(create bool) *ast.AssignStmt
- func MakeBasicLit(tok token.Token, value string) *ast.BasicLit
- func MakeBitNotExpr(e ast.Expr) *ast.UnaryExpr
- func MakeEnumType(name string, names []string, values []int64)
- func MakeFunc(name string, recv *types.Var, params, results *types.Tuple, variadic bool)
- func MakeFuncPtrArgCall(arg ast.Expr, by_ref bool, pretyp types.Type, ti *types.Info) *ast.ExprStmt
- func MakeIndex(index, x ast.Expr) *ast.IndexExpr
- func MakeIntConst(name string, num int64)
- func MakeIntVar(name string)
- func MakeNamedType(name string, typ types.Type, methods []*types.Func, ...)
- func MakeParams(param_names []string, param_types []types.Type) *types.Tuple
- func MakeParenExpr(e ast.Expr) *ast.ParenExpr
- func MakeReference(x ast.Expr) *ast.UnaryExpr
- func MakeRet(param_types []types.Type) *types.Tuple
- func MakeTypeAlias(name string, typ types.Type, strong bool, builtins map[string]types.Object)
- func MakeVarDecl(names []*ast.Ident, val ast.Expr, typ types.Type, ti *types.Info) *ast.DeclStmt
- func MergeRetTypes(file *ast.File)
- func MutateAndNotExpr(file *ast.File)
- func MutateAssignDefStmts(owner_list *[]ast.Stmt, index int, s ast.Stmt, bm BlockMutator, ctxt any)
- func MutateAssignStmts(owner_list *[]ast.Stmt, index int, s ast.Stmt, bm BlockMutator, ctxt any)
- func MutateBlock(b *ast.BlockStmt, mutator StmtMutator, ctxt any)
- func MutateFuncLit(owner_list *[]ast.Stmt, index int, s ast.Stmt, bm BlockMutator, ctxt any)
- func MutateFuncLitExprs(e *ast.Expr, ctxt any)
- func MutateNoRetCallStmts(owner_list *[]ast.Stmt, index int, s ast.Stmt, bm BlockMutator, ctxt any)
- func MutateRangeStmts(owner_list *[]ast.Stmt, index int, s ast.Stmt, bm BlockMutator, ctxt any)
- func MutateRetStmts(owner_list *[]ast.Stmt, index int, s ast.Stmt, bm BlockMutator, ctxt any)
- func MutateRetTypes(retvals **ast.FieldList, curr_params *ast.FieldList, obj_name string) []*ast.Field
- func NameAnonFuncs(file *ast.File)
- func PrettyPrintAST(n ast.Node) string
- func PrintAST(n ast.Node) string
- func PtrizeExpr(x ast.Expr) *ast.StarExpr
- func TypeToASTExpr(typ types.Type) ast.Expr
- func ValueToTypeExpr(val ast.Expr, ti *types.Info) ast.Expr
- type AstTransmitter
- func (a *AstTransmitter) AnalyzeIllegalCode(file *ast.File) bool
- func (a *AstTransmitter) MutateAssignDecls(file *ast.File)
- func (a *AstTransmitter) MutateAssigns(file *ast.File)
- func (a *AstTransmitter) MutateNoRetCalls(file *ast.File)
- func (a *AstTransmitter) MutateRanges(file *ast.File)
- func (a *AstTransmitter) MutateRetExprs(file *ast.File)
- func (a *AstTransmitter) PrintErr(p token.Pos, msg string)
- func (a *AstTransmitter) PrintErrs()
- type BlockMutator
- type StmtMutator
Constants ¶
const ( ERR_STR = "[ERROR]" WARN_STR = "[WARNING]" FMT_STR = "%-100s %s\n" )
Variables ¶
This section is empty.
Functions ¶
func ChangeReceiverNames ¶
func ExpandFuncPtrCalls ¶
func GetFuncName ¶
func IndexOfValue ¶
func IndexOfValue[T comparable](a []T, x T) int
func InsertToIndex ¶
func MakeAssign ¶
func MakeAssign(create bool) *ast.AssignStmt
func MakeEnumType ¶
func MakeFuncPtrArgCall ¶
func MakeIntConst ¶
func MakeIntVar ¶
func MakeIntVar(name string)
func MakeNamedType ¶
func MakeTypeAlias ¶
func MakeVarDecl ¶
func MutateAndNotExpr ¶
* Pass #4 - Mutate AND-NOT expressions. * So we basically turn `a &^ b` into `a & ^(b)` * which then becomes `a & ~(b)` in SourcePawn. * * Ditto for the `a &^= b` as well * `a &= ^(b)` becoming `a &= ~(b)`
func MutateAssignDefStmts ¶
func MutateAssignStmts ¶
func MutateBlock ¶
func MutateBlock(b *ast.BlockStmt, mutator StmtMutator, ctxt any)
func MutateFuncLit ¶
/ func(params){code}(args) => func _srcgo_func#(params){code} ... _srcgo_func#(args)
func MutateFuncLitExprs ¶
func MutateNoRetCallStmts ¶
func MutateRangeStmts ¶
func MutateRetStmts ¶
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 NameAnonFuncs ¶
* Pass #2 - Name Anonymous Functions * Any unnamed function literal is to be named so they can be generated * as an incrementally named function in SourcePawn. * * This AST pass has to be second because we later * mutate the multi-return types for functions! * * So best get to naming the lambdas before things get really serious!
func PrettyPrintAST ¶
Types ¶
type AstTransmitter ¶
type AstTransmitter struct { Errors []error FileSet *token.FileSet TypeInfo *types.Info Userdata any TmpVar uint DebugMode bool }
func MakeAstTransmitter ¶
func (*AstTransmitter) AnalyzeIllegalCode ¶
func (a *AstTransmitter) AnalyzeIllegalCode(file *ast.File) bool
* Pass #1 - Analyze Illegal Code * checks for ANY Go constructs that cannot be faithfully recreated in SourcePawn.
func (*AstTransmitter) MutateAssignDecls ¶
func (a *AstTransmitter) MutateAssignDecls(file *ast.File)
Case Studies of Changing assignment definitions: * * a,b,c := f() * * if not func ptr: * var a,b,c type * a = f(&b, &c) * * if func ptr: * var a,b,c type * Call_StartFunction(nil, f) * Call_PushCellRef(&b) * Call_PushCellRef(&c) * Call_Finish(&a) *
func (*AstTransmitter) MutateAssigns ¶
func (a *AstTransmitter) MutateAssigns(file *ast.File)
Case Studies of Changing non-defining assignments: *
func (*AstTransmitter) MutateNoRetCalls ¶
func (a *AstTransmitter) MutateNoRetCalls(file *ast.File)
func (*AstTransmitter) MutateRanges ¶
func (a *AstTransmitter) MutateRanges(file *ast.File)
func (*AstTransmitter) MutateRetExprs ¶
func (a *AstTransmitter) MutateRetExprs(file *ast.File)
Case Studies of Returning statements to transform: * * return m3() /// func m3() (type, type, type) * * return int, float, m1() /// func m1() type
func (*AstTransmitter) PrintErrs ¶
func (a *AstTransmitter) PrintErrs()
type BlockMutator ¶
type BlockMutator func(b *ast.BlockStmt, mutator StmtMutator, ctxt any)