Documentation ¶
Overview ¶
Package transpiler handles the conversion between the Clang AST and the Go AST.
Index ¶
- Variables
- func ConvertToGoFlagFormat(str string) string
- func ConvertValueToPointer(nodes []ast.Node, p *program.Program) (expr goast.Expr, ok bool)
- func CreateSliceFromReference(goType string, expr goast.Expr) goast.Expr
- func GenerateFuncType(fields, returns []string) *goast.FuncType
- func GetPointerAddress(expr goast.Expr, cType string, sizeof int) (rs goast.Expr, postStmts []goast.Stmt, err error)
- func GetUnsafeConvertDecls(p *program.Program)
- func PntBitCast(expr goast.Expr, cFrom, cTo string, p *program.Program) (rs goast.Expr, toCtype string, postStmts []goast.Stmt, err error)
- func PntCmpPnt(p *program.Program, val1 goast.Expr, val1Type string, val2 goast.Expr, ...) (rs goast.Expr, postStmts []goast.Stmt, err error)
- func ResolveCgoType(p *program.Program, goType string, expr goast.Expr) (a goast.Expr, err error)
- func SubTwoPnts(val1 goast.Expr, val1Type string, val2 goast.Expr, val2Type string, sizeof int) (rs goast.Expr, postStmts []goast.Stmt, err error)
- func TranspileAST(fileName, packageName string, withOutsideStructs bool, p *program.Program, ...) (source string, err error)
- func VaListInit(p *program.Program, name string) []goast.Decl
Constants ¶
This section is empty.
Variables ¶
var AddOutsideStruct bool
Functions ¶
func ConvertToGoFlagFormat ¶
ConvertToGoFlagFormat convert format flags from C to Go
func ConvertValueToPointer ¶
func CreateSliceFromReference ¶
CreateSliceFromReference - create a slice, like : (*[1]int)(unsafe.Pointer(&a))[:]
func GenerateFuncType ¶
GenerateFuncType in according to types Type: *ast.FuncType { . Func: 13:7 . Params: *ast.FieldList { . . Opening: 13:12 . . List: []*ast.Field (len = 2) { . . . 0: *ast.Field { . . . . Type: *ast.Ident { . . . . . NamePos: 13:13 . . . . . Name: "int" . . . . } . . . } . . . 1: *ast.Field { . . . . Type: *ast.Ident { . . . . . NamePos: 13:17 . . . . . Name: "int" . . . . } . . . } . . } . } . Results: *ast.FieldList { . . Opening: - . . List: []*ast.Field (len = 1) { . . . 0: *ast.Field { . . . . Type: *ast.Ident { . . . . . NamePos: 13:21 . . . . . Name: "string" . . . . } . . . } . . } . } }
func GetPointerAddress ¶
func GetPointerAddress(expr goast.Expr, cType string, sizeof int) ( rs goast.Expr, postStmts []goast.Stmt, err error)
GetPointerAddress - return goast expression with pointer address.
pnt - goast expression. Foe example: `&a`, `&a[11]`. sizeof - sizeof of C type. rs - result goast expression. postStmts - slice of goast.Stmt for runtime.KeepAlive of pointer, the best way kept that stmts at the end of function. Each stmt has `defer` functions.
func GetUnsafeConvertDecls ¶
func PntBitCast ¶
func PntBitCast(expr goast.Expr, cFrom, cTo string, p *program.Program) ( rs goast.Expr, toCtype string, postStmts []goast.Stmt, err error)
PntBitCast - casting pointers
func PntCmpPnt ¶
func PntCmpPnt( p *program.Program, val1 goast.Expr, val1Type string, val2 goast.Expr, val2Type string, sizeof int, operator token.Token, ) ( rs goast.Expr, postStmts []goast.Stmt, err error, )
postStmts - slice of goast.Stmt for runtime.KeepAlive of pointer,
the best way kept that stmts at the end of function. Each stmt has `defer` functions.
func ResolveCgoType ¶
func SubTwoPnts ¶
func SubTwoPnts( val1 goast.Expr, val1Type string, val2 goast.Expr, val2Type string, sizeof int) (rs goast.Expr, postStmts []goast.Stmt, err error)
SubTwoPnts function for implementation : (pointer1 - pointer2)
Types ¶
This section is empty.