Documentation ¶
Index ¶
- Constants
- func AddAutoAssignExists(b Builder, lhs *Variable)
- func AddCheckReturn(b Builder, cond ast.Expr, ev *Variable)
- func AddErrorReturn(b Builder, ev *Variable)
- func AddReturnStmt(b Builder, results *VariableList)
- func AddSuccessReturn(b Builder)
- func AppendExpr(list ast.Expr, item ast.Expr) ast.Expr
- func CamelString(src string) string
- func CondExpr(op token.Token, exprs ...ast.Expr) ast.Expr
- func DotExpr(x ast.Expr, dot ast.Expr) ast.Expr
- func FollowTPaths(bd Builder, srcV, dstV *Variable, ev *Variable, paths []*parser.TPath)
- func GenNameFromType(typ ast.Expr) string
- func GetStructHolder(t parser.Type) parser.Type
- func IncreaseName(name string) string
- func LenExpr(a ast.Expr) ast.Expr
- func NewAstIdent(name string) *ast.Ident
- func NewSelectorExpr(x ast.Expr, sel *ast.Ident) *ast.SelectorExpr
- func StructAssign(bd Builder, srcV, dstV *Variable, srcFields, dstFields *FieldList, ...)
- func TryDirectAssign(bd Builder, srcV, dstV *Variable, ev *Variable, knownTpaths []*parser.TPath) bool
- func TypeConversionExpr(typeExpr ast.Expr, val ast.Expr) ast.Expr
- func VariableName(name string) string
- type BlockBuilder
- func (b *BlockBuilder) Add(ab Builder)
- func (b *BlockBuilder) Block() *BlockBuilder
- func (b *BlockBuilder) Bytes() []byte
- func (b BlockBuilder) File() *parser.File
- func (b BlockBuilder) Outer() Builder
- func (b BlockBuilder) Package() *parser.Package
- func (b *BlockBuilder) StmtList() []ast.Stmt
- func (b *BlockBuilder) String() string
- func (b BlockBuilder) Variables() *VariableList
- type BufferBuilder
- type Builder
- type CallStmtBuilder
- func (b CallStmtBuilder) Add(bd Builder)
- func (b CallStmtBuilder) Block() *BlockBuilder
- func (b *CallStmtBuilder) Bytes() []byte
- func (b *CallStmtBuilder) Call(vl *VariableList, ignores []int) *VariableList
- func (b CallStmtBuilder) File() *parser.File
- func (b CallStmtBuilder) Outer() Builder
- func (b CallStmtBuilder) Package() *parser.Package
- func (b *CallStmtBuilder) Stmt() ast.Stmt
- func (b CallStmtBuilder) String() string
- func (b CallStmtBuilder) Variables() *VariableList
- type CreateVarGetter
- type DefineStmtBuilder
- func (b DefineStmtBuilder) Add(bd Builder)
- func (b DefineStmtBuilder) Block() *BlockBuilder
- func (b DefineStmtBuilder) Bytes() []byte
- func (b DefineStmtBuilder) File() *parser.File
- func (b DefineStmtBuilder) Outer() Builder
- func (b DefineStmtBuilder) Package() *parser.Package
- func (b *DefineStmtBuilder) Stmt() ast.Stmt
- func (b DefineStmtBuilder) String() string
- func (b DefineStmtBuilder) Variables() *VariableList
- type ErrorWrapper
- type Field
- type FieldList
- type FileBuilder
- func (b *FileBuilder) Add(ab Builder)
- func (b *FileBuilder) AddFuncDecl(fd *ast.FuncDecl)
- func (b *FileBuilder) AddImport(name, path string)
- func (b *FileBuilder) Block() *BlockBuilder
- func (b *FileBuilder) Bytes() []byte
- func (b FileBuilder) File() *parser.File
- func (b FileBuilder) Outer() Builder
- func (b FileBuilder) Package() *parser.Package
- func (b *FileBuilder) String() string
- func (b FileBuilder) Variables() *VariableList
- type ForRangeBuilder
- func (b ForRangeBuilder) Add(bd Builder)
- func (b *ForRangeBuilder) Block() *BlockBuilder
- func (b *ForRangeBuilder) Bytes() []byte
- func (b ForRangeBuilder) File() *parser.File
- func (b ForRangeBuilder) Outer() Builder
- func (b ForRangeBuilder) Package() *parser.Package
- func (b *ForRangeBuilder) Stmt() ast.Stmt
- func (b ForRangeBuilder) String() string
- func (b ForRangeBuilder) Variables() *VariableList
- type FuncBufferBuilder
- func (b FuncBufferBuilder) Add(bd Builder)
- func (b *FuncBufferBuilder) Block() *BlockBuilder
- func (b *FuncBufferBuilder) Bytes() []byte
- func (b *FuncBufferBuilder) Decl() *ast.FuncDecl
- func (b FuncBufferBuilder) File() *parser.File
- func (b FuncBufferBuilder) Outer() Builder
- func (b FuncBufferBuilder) Package() *parser.Package
- func (b *FuncBufferBuilder) Printf(format string, args ...interface{})
- func (b *FuncBufferBuilder) String() string
- func (b FuncBufferBuilder) Variables() *VariableList
- type FuncBuilder
- func (b *FuncBuilder) Add(ab Builder)
- func (b *FuncBuilder) Block() *BlockBuilder
- func (b *FuncBuilder) Bytes() []byte
- func (b FuncBuilder) File() *parser.File
- func (b *FuncBuilder) HasResults() bool
- func (b FuncBuilder) Outer() Builder
- func (b FuncBuilder) Package() *parser.Package
- func (b *FuncBuilder) Receiver() *Variable
- func (b *FuncBuilder) String() string
- func (b *FuncBuilder) Variables() *VariableList
- type IfStmtBuilder
- func (b IfStmtBuilder) Add(bd Builder)
- func (b *IfStmtBuilder) Block() *BlockBuilder
- func (b *IfStmtBuilder) Bytes() []byte
- func (b *IfStmtBuilder) Else() *BlockBuilder
- func (b IfStmtBuilder) File() *parser.File
- func (b IfStmtBuilder) Outer() Builder
- func (b IfStmtBuilder) Package() *parser.Package
- func (b *IfStmtBuilder) SetInitCond(init StmtBuilder, cond ast.Expr) *IfStmtBuilder
- func (b *IfStmtBuilder) Stmt() ast.Stmt
- func (b IfStmtBuilder) String() string
- func (b IfStmtBuilder) Variables() *VariableList
- type Mode
- type Printer
- type ReturnStmtBuilder
- func (b ReturnStmtBuilder) Add(bd Builder)
- func (b ReturnStmtBuilder) Block() *BlockBuilder
- func (b ReturnStmtBuilder) Bytes() []byte
- func (b ReturnStmtBuilder) File() *parser.File
- func (b ReturnStmtBuilder) Outer() Builder
- func (b ReturnStmtBuilder) Package() *parser.Package
- func (b *ReturnStmtBuilder) Stmt() ast.Stmt
- func (b ReturnStmtBuilder) String() string
- func (b ReturnStmtBuilder) Variables() *VariableList
- type ScopeLevel
- type StmtBuilder
- type StmtListBuilder
- type StructAssignBuilder
- func (b StructAssignBuilder) File() *parser.File
- func (b StructAssignBuilder) Outer() Builder
- func (b StructAssignBuilder) Package() *parser.Package
- func (b *StructAssignBuilder) Stmts() []ast.Stmt
- func (b *StructAssignBuilder) TryAssign(srcV, dstV *Variable) bool
- func (b StructAssignBuilder) Variables() *VariableList
- type StructSetterBuilder
- func (b StructSetterBuilder) File() *parser.File
- func (b StructSetterBuilder) Outer() Builder
- func (b StructSetterBuilder) Package() *parser.Package
- func (b *StructSetterBuilder) Stmts() []ast.Stmt
- func (b *StructSetterBuilder) TryAssign(srcV, dstV *Variable) bool
- func (b StructSetterBuilder) Variables() *VariableList
- func (b *StructSetterBuilder) WithAssigner(assigner func(*Field) func(Builder, *Variable, ast.Expr)) *StructSetterBuilder
- func (b *StructSetterBuilder) WithCallFunc(callFunc func(*Field) parser.Type) *StructSetterBuilder
- func (b *StructSetterBuilder) WithCheckDiff() *StructSetterBuilder
- type TPathBuilder
- func (b TPathBuilder) File() *parser.File
- func (bd *TPathBuilder) Follow(srcV, dstV *Variable, paths []*parser.TPath)
- func (b TPathBuilder) Outer() Builder
- func (b TPathBuilder) Package() *parser.Package
- func (b *TPathBuilder) Stmts() []ast.Stmt
- func (b TPathBuilder) Variables() *VariableList
- func (b *TPathBuilder) WithAssigner(assigner func(Builder, *Variable, ast.Expr)) *TPathBuilder
- func (b *TPathBuilder) WithTargetSetter(fnt parser.Type) *TPathBuilder
- type VarAssignBuilder
- func (b VarAssignBuilder) Add(bd Builder)
- func (b VarAssignBuilder) Block() *BlockBuilder
- func (b VarAssignBuilder) Bytes() []byte
- func (b VarAssignBuilder) File() *parser.File
- func (b VarAssignBuilder) Outer() Builder
- func (b VarAssignBuilder) Package() *parser.Package
- func (b VarAssignBuilder) String() string
- func (b VarAssignBuilder) Variables() *VariableList
- type VarGetter
- type VarListGetter
- type Variable
- func AddAppendStmt(b Builder, v *Variable, element *Variable) *Variable
- func AddVariableAssign(b Builder, v *Variable, value ast.Expr) *Variable
- func AddVariableDecl(b Builder, v *Variable) *Variable
- func GetVariable(b Builder, t parser.Type, mode Mode, scope ScopeLevel) *Variable
- func GetVariableWithSkip(b Builder, t parser.Type, mode Mode, scope ScopeLevel, skip int) *Variable
- func NewVariable(pt parser.Type) *Variable
- func (v *Variable) AddressExpr() ast.Expr
- func (v *Variable) AutoName() *Variable
- func (v *Variable) CheckEqualExpr(isEqual bool, y ast.Expr) ast.Expr
- func (v *Variable) CheckNilExpr(isNil bool) ast.Expr
- func (v *Variable) Copy() *Variable
- func (v *Variable) DotExpr(name string) ast.Expr
- func (v *Variable) DotTypeInFile(dotSrc string, file *parser.File) parser.Type
- func (v *Variable) DotVariable(dotString string, file *parser.File) *Variable
- func (v *Variable) Expr() ast.Expr
- func (v *Variable) Ident() ast.Expr
- func (v *Variable) IncreaseName()
- func (v *Variable) IndexExpr(index ast.Expr) ast.Expr
- func (v *Variable) IsAnonymous() bool
- func (v *Variable) IsReadOnly() bool
- func (v *Variable) IsReadable() bool
- func (v *Variable) IsVisible() bool
- func (v *Variable) IsWriteOnly() bool
- func (v *Variable) IsWriteable() bool
- func (v *Variable) Mode() Mode
- func (v *Variable) Name() string
- func (v *Variable) PointerValueExpr() ast.Expr
- func (v *Variable) ReadOnly() *Variable
- func (v *Variable) ReadWrite() *Variable
- func (v *Variable) SetExpr(expr ast.Expr)
- func (v *Variable) SetExprSrc(str string)
- func (v *Variable) SetMode(mode Mode)
- func (v *Variable) SetName(name string)
- func (v *Variable) StringKeyItemExpr(key string) ast.Expr
- func (v *Variable) TypeConversionExpr(typ ast.Expr) ast.Expr
- func (v *Variable) WithExpr(expr ast.Expr) *Variable
- func (v *Variable) WithMode(mode Mode) *Variable
- func (v *Variable) WithName(name string) *Variable
- func (v *Variable) WriteOnly() *Variable
- type VariableList
- func (vl *VariableList) Add(v *Variable) bool
- func (vl *VariableList) Check(name string) bool
- func (vl *VariableList) Concat(vl2 *VariableList) *VariableList
- func (vl *VariableList) CreateGetter(mode Mode) VarGetter
- func (vl *VariableList) ForEach(run func(int, *Variable))
- func (vl *VariableList) Get(name string) *Variable
- func (vl *VariableList) GetByType(pt parser.Type, mode Mode) *Variable
- func (vl *VariableList) GetByTypeAndName(pt parser.Type, name string) *Variable
- func (vl *VariableList) Getter(mode Mode) VarGetter
- func (vl *VariableList) Insert(v *Variable, pos int) bool
- func (vl *VariableList) IsEmpty() bool
- func (vl *VariableList) Names() []string
- func (vl *VariableList) Print()
- func (vl *VariableList) ResultGetter(ignores []int) VarGetter
Examples ¶
Constants ¶
View Source
const ( ANY_MODE = iota READ_MODE WRITE_MODE RW_MODE )
Variables ¶
This section is empty.
Functions ¶
func AddAutoAssignExists ¶
use exists variable assign to var
func AddErrorReturn ¶
func AddReturnStmt ¶
func AddReturnStmt(b Builder, results *VariableList)
func AddSuccessReturn ¶
func AddSuccessReturn(b Builder)
func FollowTPaths ¶
func GenNameFromType ¶
func IncreaseName ¶
func NewAstIdent ¶
func NewSelectorExpr ¶
func StructAssign ¶
func StructAssign(bd Builder, srcV, dstV *Variable, srcFields, dstFields *FieldList, knownTpaths []*parser.TPath)
Example ¶
// fmt.Println(code) p := parser.NewParser() file := p.ParseFileContent("test", code) pkg := parser.NewPackage(p, "fake", "./fake.go", "", []*parser.File{file}) file = pkg.Files[0] fileBuilder := NewFile(nil, file) tx := file.ReduceTypeSrc("X") // ty := file.ReduceTypeSrc("Y") ta := file.ReduceTypeSrc("A") tb := file.ReduceTypeSrc("B") tc := file.ReduceTypeSrc("C") var fnt parser.Type var bd *FuncBuilder var src *Variable var dst *Variable var assignBuilder *StructAssignBuilder //A => B fnt = fakeFunctionType(ta, tb, "test1") bd = NewFunction(fileBuilder, nil, fnt, nil) src = GetVariable(bd, ta, READ_MODE, Scope_Function) assignBuilder = NewStructAssign(bd, "pc", nil, nil) dst = NewVariable(tb).AutoName().WriteOnly() _ = assignBuilder.TryAssign(src, dst) bd.Add(assignBuilder) AddSuccessReturn(bd) fmt.Printf("%s\n", string(bd.Bytes())) //A => C log.Printf("test2") fnt = fakeFunctionType(ta, tc, "test2") bd = NewFunction(fileBuilder, nil, fnt, nil) src = GetVariable(bd, ta, READ_MODE, Scope_Function) assignBuilder = NewStructAssign(bd, "pc", nil, nil) dst = NewVariable(tc).AutoName().WriteOnly() _ = assignBuilder.TryAssign(src, dst) bd.Add(assignBuilder) AddSuccessReturn(bd) fmt.Printf("%s\n", string(bd.Bytes())) //A => x log.Printf("test3") fnt = fakeFunctionType(ta, tx, "test3") bd = NewFunction(fileBuilder, nil, fnt, nil) src = GetVariable(bd, ta, READ_MODE, Scope_Function) assignBuilder = NewStructAssign(bd, "pc", nil, nil) dst = NewVariable(tx).AutoName().WriteOnly() _ = assignBuilder.TryAssign(src, dst) bd.Add(assignBuilder) AddSuccessReturn(bd) fmt.Printf("%s\n", string(bd.Bytes())) //x => A fnt = fakeFunctionType(tx, ta, "test4") bd = NewFunction(fileBuilder, nil, fnt, nil) src = GetVariable(bd, tx, READ_MODE, Scope_Function) assignBuilder = NewStructAssign(bd, "pc", nil, nil) dst = NewVariable(ta).AutoName().WriteOnly() _ = assignBuilder.TryAssign(src, dst) bd.Add(assignBuilder) AddSuccessReturn(bd) fmt.Printf("%s\n", string(bd.Bytes())) //x => **A srcType := parser.TypeWithPointer(parser.TypeWithPointer(ta)) dstType := tx fnt = fakeFunctionType(dstType, srcType, "test5") bd = NewFunction(fileBuilder, nil, fnt, nil) src = GetVariable(bd, dstType, READ_MODE, Scope_Function) assignBuilder = NewStructAssign(bd, "pc", nil, nil) dst = NewVariable(srcType).AutoName().WriteOnly() _ = assignBuilder.TryAssign(src, dst) bd.Add(assignBuilder) AddSuccessReturn(bd) fmt.Printf("%s\n", string(bd.Bytes())) //*x => **B srcType = parser.TypeWithPointer(parser.TypeWithPointer(tb)) dstType = parser.TypeWithPointer(tx) fnt = fakeFunctionType(dstType, srcType, "test6") bd = NewFunction(fileBuilder, nil, fnt, nil) src = GetVariable(bd, dstType, READ_MODE, Scope_Function) assignBuilder = NewStructAssign(bd, "pc", nil, nil) dst = NewVariable(srcType).AutoName().WriteOnly() _ = assignBuilder.TryAssign(src, dst) bd.Add(assignBuilder) AddSuccessReturn(bd) fmt.Printf("%s\n", string(bd.Bytes()))
Output: func test1(t A) (B, error) { b := B{} if t.PX != nil { b.TheX = *t.PX } if t.PY != nil { b.TheY = *t.PY } return b, nil } func test2(t A) (C, error) { c := C{} if t.PY != nil { c.Y = *t.PY } if t.PX != nil { x := *t.PX c.T = int(x) } return c, nil } func test3(t A) (X, error) { var x X if t.PX != nil { x = *t.PX } return x, nil } func test4(t X) (A, error) { a := A{} a.PX = &t return a, nil } func test5(t X) (**A, error) { a := &A{} a.PX = &t a1 := &a return a1, nil } func test6(t *X) (**B, error) { b := &B{} if t != nil { b.TheX = *t } b1 := &b return b1, nil }
func TryDirectAssign ¶
func VariableName ¶
Types ¶
type BlockBuilder ¶
func (*BlockBuilder) Add ¶
func (b *BlockBuilder) Add(ab Builder)
func (*BlockBuilder) Block ¶
func (b *BlockBuilder) Block() *BlockBuilder
func (*BlockBuilder) Bytes ¶
func (b *BlockBuilder) Bytes() []byte
func (*BlockBuilder) StmtList ¶
func (b *BlockBuilder) StmtList() []ast.Stmt
func (*BlockBuilder) String ¶
func (b *BlockBuilder) String() string
func (BlockBuilder) Variables ¶
func (b BlockBuilder) Variables() *VariableList
type BufferBuilder ¶
type BufferBuilder interface { Builder }
type Builder ¶
type Builder interface { Outer() Builder Variables() *VariableList Block() *BlockBuilder Add(Builder) Bytes() []byte String() string // contains filtered or unexported methods }
func NewIfBuilderWithSrc ¶
type CallStmtBuilder ¶
type CallStmtBuilder struct {
// contains filtered or unexported fields
}
func NewCallStmt ¶
func NewCallStmt(outer Builder, fnt parser.Type) *CallStmtBuilder
func (CallStmtBuilder) Block ¶
func (b CallStmtBuilder) Block() *BlockBuilder
func (*CallStmtBuilder) Bytes ¶
func (b *CallStmtBuilder) Bytes() []byte
func (*CallStmtBuilder) Call ¶
func (b *CallStmtBuilder) Call(vl *VariableList, ignores []int) *VariableList
func (*CallStmtBuilder) Stmt ¶
func (b *CallStmtBuilder) Stmt() ast.Stmt
func (CallStmtBuilder) Variables ¶
func (b CallStmtBuilder) Variables() *VariableList
type CreateVarGetter ¶
type CreateVarGetter struct { NewVars *VariableList // contains filtered or unexported fields }
func (*CreateVarGetter) Getted ¶
func (getter *CreateVarGetter) Getted() *VariableList
type DefineStmtBuilder ¶
type DefineStmtBuilder struct {
// contains filtered or unexported fields
}
func (DefineStmtBuilder) Block ¶
func (b DefineStmtBuilder) Block() *BlockBuilder
func (*DefineStmtBuilder) Stmt ¶
func (b *DefineStmtBuilder) Stmt() ast.Stmt
func (DefineStmtBuilder) Variables ¶
func (b DefineStmtBuilder) Variables() *VariableList
type ErrorWrapper ¶
type ErrorWrapper interface { WrapError(b Builder, ev *Variable) *VariableList Wrap(b Builder, ev *Variable) *Variable }
func NewErrorWrapper ¶
func NewErrorWrapper(input interface{}) ErrorWrapper
type FieldList ¶
func NewFieldList ¶
func (*FieldList) ContainPathToType ¶
func (*FieldList) GetFieldByName ¶
type FileBuilder ¶
type FileBuilder struct {
// contains filtered or unexported fields
}
func (*FileBuilder) Add ¶
func (b *FileBuilder) Add(ab Builder)
func (*FileBuilder) AddFuncDecl ¶
func (b *FileBuilder) AddFuncDecl(fd *ast.FuncDecl)
func (*FileBuilder) AddImport ¶
func (b *FileBuilder) AddImport(name, path string)
func (*FileBuilder) Block ¶
func (b *FileBuilder) Block() *BlockBuilder
func (*FileBuilder) Bytes ¶
func (b *FileBuilder) Bytes() []byte
func (*FileBuilder) String ¶
func (b *FileBuilder) String() string
func (FileBuilder) Variables ¶
func (b FileBuilder) Variables() *VariableList
type ForRangeBuilder ¶
type ForRangeBuilder struct {
// contains filtered or unexported fields
}
func NewForRange ¶
func NewForRange(outer Builder, key *Variable, value *Variable, over *Variable) *ForRangeBuilder
func (*ForRangeBuilder) Block ¶
func (b *ForRangeBuilder) Block() *BlockBuilder
func (*ForRangeBuilder) Bytes ¶
func (b *ForRangeBuilder) Bytes() []byte
func (*ForRangeBuilder) Stmt ¶
func (b *ForRangeBuilder) Stmt() ast.Stmt
func (ForRangeBuilder) Variables ¶
func (b ForRangeBuilder) Variables() *VariableList
type FuncBufferBuilder ¶
type FuncBufferBuilder struct {
// contains filtered or unexported fields
}
func NewFuncBuffer ¶
func NewFuncBuffer(outer Builder, name string) *FuncBufferBuilder
func (*FuncBufferBuilder) Block ¶
func (b *FuncBufferBuilder) Block() *BlockBuilder
func (*FuncBufferBuilder) Bytes ¶
func (b *FuncBufferBuilder) Bytes() []byte
func (*FuncBufferBuilder) Decl ¶
func (b *FuncBufferBuilder) Decl() *ast.FuncDecl
func (*FuncBufferBuilder) Printf ¶
func (b *FuncBufferBuilder) Printf(format string, args ...interface{})
func (*FuncBufferBuilder) String ¶
func (b *FuncBufferBuilder) String() string
func (FuncBufferBuilder) Variables ¶
func (b FuncBufferBuilder) Variables() *VariableList
type FuncBuilder ¶
func NewFunction ¶
func NewFunction(outer Builder, receiver parser.Type, fnt parser.Type, ew ErrorWrapper) *FuncBuilder
func (*FuncBuilder) Add ¶
func (b *FuncBuilder) Add(ab Builder)
func (*FuncBuilder) Block ¶
func (b *FuncBuilder) Block() *BlockBuilder
func (*FuncBuilder) Bytes ¶
func (b *FuncBuilder) Bytes() []byte
func (*FuncBuilder) HasResults ¶
func (b *FuncBuilder) HasResults() bool
func (*FuncBuilder) Receiver ¶
func (b *FuncBuilder) Receiver() *Variable
func (*FuncBuilder) String ¶
func (b *FuncBuilder) String() string
func (*FuncBuilder) Variables ¶
func (b *FuncBuilder) Variables() *VariableList
type IfStmtBuilder ¶
type IfStmtBuilder struct {
// contains filtered or unexported fields
}
func NewIfStmt ¶
func NewIfStmt(outer Builder) *IfStmtBuilder
func (*IfStmtBuilder) Block ¶
func (b *IfStmtBuilder) Block() *BlockBuilder
func (*IfStmtBuilder) Bytes ¶
func (b *IfStmtBuilder) Bytes() []byte
func (*IfStmtBuilder) Else ¶
func (b *IfStmtBuilder) Else() *BlockBuilder
func (*IfStmtBuilder) SetInitCond ¶
func (b *IfStmtBuilder) SetInitCond(init StmtBuilder, cond ast.Expr) *IfStmtBuilder
func (*IfStmtBuilder) Stmt ¶
func (b *IfStmtBuilder) Stmt() ast.Stmt
func (IfStmtBuilder) Variables ¶
func (b IfStmtBuilder) Variables() *VariableList
type ReturnStmtBuilder ¶
type ReturnStmtBuilder struct {
// contains filtered or unexported fields
}
func NewReturnStmt ¶
func NewReturnStmt(outer Builder, results *VariableList) *ReturnStmtBuilder
func (ReturnStmtBuilder) Block ¶
func (b ReturnStmtBuilder) Block() *BlockBuilder
func (*ReturnStmtBuilder) Stmt ¶
func (b *ReturnStmtBuilder) Stmt() ast.Stmt
func (ReturnStmtBuilder) Variables ¶
func (b ReturnStmtBuilder) Variables() *VariableList
type ScopeLevel ¶
type ScopeLevel int
const ( Scope_Local ScopeLevel = iota Scope_Function Scope_File )
type StmtBuilder ¶
type StmtListBuilder ¶
type StructAssignBuilder ¶
type StructAssignBuilder struct { *BlockBuilder // contains filtered or unexported fields }
func NewStructAssign ¶
func (*StructAssignBuilder) Stmts ¶
func (b *StructAssignBuilder) Stmts() []ast.Stmt
func (*StructAssignBuilder) TryAssign ¶
func (b *StructAssignBuilder) TryAssign(srcV, dstV *Variable) bool
func (StructAssignBuilder) Variables ¶
func (b StructAssignBuilder) Variables() *VariableList
type StructSetterBuilder ¶
type StructSetterBuilder struct { *BlockBuilder // contains filtered or unexported fields }
func NewStructSetter ¶
func (*StructSetterBuilder) Stmts ¶
func (b *StructSetterBuilder) Stmts() []ast.Stmt
func (*StructSetterBuilder) TryAssign ¶
func (b *StructSetterBuilder) TryAssign(srcV, dstV *Variable) bool
func (StructSetterBuilder) Variables ¶
func (b StructSetterBuilder) Variables() *VariableList
func (*StructSetterBuilder) WithAssigner ¶
func (b *StructSetterBuilder) WithAssigner(assigner func(*Field) func(Builder, *Variable, ast.Expr)) *StructSetterBuilder
func (*StructSetterBuilder) WithCallFunc ¶
func (b *StructSetterBuilder) WithCallFunc(callFunc func(*Field) parser.Type) *StructSetterBuilder
func (*StructSetterBuilder) WithCheckDiff ¶
func (b *StructSetterBuilder) WithCheckDiff() *StructSetterBuilder
type TPathBuilder ¶
type TPathBuilder struct { *BlockBuilder // contains filtered or unexported fields }
func NewTPathBuilder ¶
func NewTPathBuilder(outer Builder, ev *Variable, checkDiff bool) *TPathBuilder
func (*TPathBuilder) Follow ¶
func (bd *TPathBuilder) Follow(srcV, dstV *Variable, paths []*parser.TPath)
func (*TPathBuilder) Stmts ¶
func (b *TPathBuilder) Stmts() []ast.Stmt
func (TPathBuilder) Variables ¶
func (b TPathBuilder) Variables() *VariableList
func (*TPathBuilder) WithAssigner ¶
func (b *TPathBuilder) WithAssigner(assigner func(Builder, *Variable, ast.Expr)) *TPathBuilder
func (*TPathBuilder) WithTargetSetter ¶
func (b *TPathBuilder) WithTargetSetter(fnt parser.Type) *TPathBuilder
type VarAssignBuilder ¶
type VarAssignBuilder struct {
// contains filtered or unexported fields
}
func (VarAssignBuilder) Block ¶
func (b VarAssignBuilder) Block() *BlockBuilder
func (VarAssignBuilder) Variables ¶
func (b VarAssignBuilder) Variables() *VariableList
type VarGetter ¶
type VarGetter interface { Get(int, parser.Type) *Variable Getted() *VariableList }
func NewCreateVarGetter ¶
func NewCreateVarGetter(exists *VariableList, mode Mode) VarGetter
func NewVarListGetter ¶
func NewVarListGetter(vl *VariableList, mode Mode) VarGetter
func VarGetterWithIgnore ¶
type VarListGetter ¶
type VarListGetter struct {
// contains filtered or unexported fields
}
func (*VarListGetter) Getted ¶
func (getter *VarListGetter) Getted() *VariableList
type Variable ¶
func AddVariableAssign ¶
add assignment
func GetVariable ¶
func GetVariableWithSkip ¶
func NewVariable ¶
func (*Variable) AddressExpr ¶
func (*Variable) CheckEqualExpr ¶
func (*Variable) DotTypeInFile ¶
func (*Variable) DotVariable ¶
func (*Variable) IncreaseName ¶
func (v *Variable) IncreaseName()
func (*Variable) IsAnonymous ¶
func (*Variable) IsReadOnly ¶
func (*Variable) IsReadable ¶
func (*Variable) IsWriteOnly ¶
func (*Variable) IsWriteable ¶
func (*Variable) PointerValueExpr ¶
func (*Variable) SetExprSrc ¶
type VariableList ¶
type VariableList struct {
List []*Variable
}
func AddCallStmt ¶
func AddCallStmt(b Builder, params *VariableList, fnt parser.Type) *VariableList
func AddCallStmtWithIgnores ¶
func AddCallStmtWithIgnores(b Builder, params *VariableList, fnt parser.Type, ignores []int) *VariableList
func NewVariableList ¶
func NewVariableList() *VariableList
func (*VariableList) Add ¶
func (vl *VariableList) Add(v *Variable) bool
func (*VariableList) Check ¶
func (vl *VariableList) Check(name string) bool
func (*VariableList) Concat ¶
func (vl *VariableList) Concat(vl2 *VariableList) *VariableList
func (*VariableList) CreateGetter ¶
func (vl *VariableList) CreateGetter(mode Mode) VarGetter
func (*VariableList) ForEach ¶
func (vl *VariableList) ForEach(run func(int, *Variable))
func (*VariableList) Get ¶
func (vl *VariableList) Get(name string) *Variable
func (*VariableList) GetByType ¶
func (vl *VariableList) GetByType(pt parser.Type, mode Mode) *Variable
func (*VariableList) GetByTypeAndName ¶
func (vl *VariableList) GetByTypeAndName(pt parser.Type, name string) *Variable
func (*VariableList) Getter ¶
func (vl *VariableList) Getter(mode Mode) VarGetter
func (*VariableList) IsEmpty ¶
func (vl *VariableList) IsEmpty() bool
func (*VariableList) Names ¶
func (vl *VariableList) Names() []string
func (*VariableList) Print ¶
func (vl *VariableList) Print()
func (*VariableList) ResultGetter ¶
func (vl *VariableList) ResultGetter(ignores []int) VarGetter
Click to show internal directories.
Click to hide internal directories.