Documentation ¶
Index ¶
- Constants
- Variables
- func ASTFile(pkg *Package, fname ...string) *ast.Filedeprecated
- func AssignableConv(pkg *Package, V, T types.Type, pv *Element) bool
- func AssignableTo(pkg *Package, V, T types.Type) bool
- func CheckOverloadFunc(sig *types.Signature) (funcs []types.Object, ok bool)deprecated
- func CheckOverloadMethod(sig *types.Signature) (methods []types.Object, ok bool)deprecated
- func CheckSigFuncEx(sig *types.Signature) (types.Type, bool)
- func CheckSigFuncExObjects(sig *types.Signature) (typ types.Type, objs []types.Object)
- func CommentedASTFile(pkg *Package, fname ...string) *printer.CommentedNodesdeprecated
- func ComparableTo(pkg *Package, varg, targ *Element) bool
- func ConvertibleTo(pkg *Package, V, T types.Type) bool
- func Default(pkg *Package, t types.Type) types.Type
- func DefaultConv(pkg *Package, t types.Type, pv *Element) types.Type
- func DerefType(typ types.Type) (types.Type, bool)
- func HasAutoProperty(typ types.Type) bool
- func InferFunc(pkg *Package, fn *Element, sig *types.Signature, targs []types.Type, ...) (types.Type, error)
- func InitBuiltin(pkg *Package, builtin *types.Package, conf *Config)
- func InitThisGopPkg(pkg *types.Package)
- func InitThisGopPkgEx(pkg *types.Package, pos map[string]token.Pos)
- func InsertStmtFront(body *ast.BlockStmt, stmt ast.Stmt)
- func IsFunc(t types.Type) bool
- func IsMethodRecv(recv *types.Var) bool
- func IsTypeEx(t types.Type) (ok bool)
- func Lookup(scope *types.Scope, name string) (obj types.Object)
- func LookupParent(scope *types.Scope, name string, pos token.Pos) (at *types.Scope, obj types.Object)
- func NewArray(elem types.Type, len int64) types.Type
- func NewChan(dir types.ChanDir, elem types.Type) types.Type
- func NewInstruction(pos token.Pos, pkg *types.Package, name string, instr Instruction) *types.TypeName
- func NewMap(key, elem types.Type) types.Type
- func NewOverloadFunc(pos token.Pos, pkg *types.Package, name string, funcs ...types.Object) *types.Func
- func NewOverloadMethod(typ *types.Named, pos token.Pos, pkg *types.Package, name string, ...) *types.Func
- func NewOverloadNamed(pos token.Pos, pkg *types.Package, name string, typs ...*types.Named) *types.TypeName
- func NewPointer(elem types.Type) types.Type
- func NewPosNode(pos token.Pos, end ...token.Pos) ast.Node
- func NewSignature(recv *types.Var, params, results *types.Tuple, variadic bool) *types.Signature
- func NewSlice(elem types.Type) types.Type
- func NewStaticMethod(typ *types.Named, pos token.Pos, pkg *types.Package, name string, ...) *types.Func
- func NewSubst(pos token.Pos, pkg *types.Package, name string, real types.Object) *types.Var
- func NewTemplateRecvMethod(typ *types.Named, pos token.Pos, pkg *types.Package, name string, ...) *types.Func
- func SetDebug(dbgFlags int)
- func TypeAST(pkg *Package, typ types.Type) ast.Expr
- func WriteFile(file string, pkg *Package, fname ...string) (err error)deprecated
- func WriteTo(dst io.Writer, pkg *Package, fname ...string) (err error)deprecated
- type CodeBuilder
- func (p *CodeBuilder) AliasType(name string, typ types.Type, src ...ast.Node) *types.Named
- func (p *CodeBuilder) ArrayLit(typ types.Type, arity int, keyVal ...bool) *CodeBuilder
- func (p *CodeBuilder) ArrayLitEx(typ types.Type, arity int, keyVal bool, src ...ast.Node) *CodeBuilder
- func (p *CodeBuilder) Assign(lhs int, rhs ...int) *CodeBuilder
- func (p *CodeBuilder) AssignOp(op token.Token, src ...ast.Node) *CodeBuilder
- func (p *CodeBuilder) AssignWith(lhs, rhs int, src ...ast.Node) *CodeBuilder
- func (p *CodeBuilder) BackupComments() (*ast.CommentGroup, bool)
- func (p *CodeBuilder) BinaryOp(op token.Token, src ...ast.Node) *CodeBuilder
- func (p *CodeBuilder) Block(src ...ast.Node) *CodeBuilder
- func (p *CodeBuilder) Break(l *Label) *CodeBuilder
- func (p *CodeBuilder) Call(n int, ellipsis ...bool) *CodeBuilder
- func (p *CodeBuilder) CallInlineClosureStart(sig *types.Signature, arity int, ellipsis bool) *CodeBuilder
- func (p *CodeBuilder) CallWith(n int, flags InstrFlags, src ...ast.Node) *CodeBuilder
- func (p *CodeBuilder) CallWithEx(n int, flags InstrFlags, src ...ast.Node) error
- func (p *CodeBuilder) Case(src ...ast.Node) *CodeBuilder
- func (p *CodeBuilder) CommCase(src ...ast.Node) *CodeBuilder
- func (p *CodeBuilder) CommDefaultThen(src ...ast.Node) *CodeBuilder
- func (p *CodeBuilder) Comments() *ast.CommentGroup
- func (p *CodeBuilder) CompareNil(op token.Token, src ...ast.Node) *CodeBuilder
- func (p *CodeBuilder) Continue(l *Label) *CodeBuilder
- func (p *CodeBuilder) Debug(dbg func(cb *CodeBuilder)) *CodeBuilder
- func (p *CodeBuilder) DefaultThen(src ...ast.Node) *CodeBuilder
- func (p *CodeBuilder) Defer() *CodeBuilder
- func (p *CodeBuilder) DefineVarStart(pos token.Pos, names ...string) *CodeBuilder
- func (p *CodeBuilder) Elem(src ...ast.Node) *CodeBuilder
- func (p *CodeBuilder) ElemRef(src ...ast.Node) *CodeBuilder
- func (p *CodeBuilder) Else(src ...ast.Node) *CodeBuilder
- func (p *CodeBuilder) End(src ...ast.Node) *CodeBuilder
- func (p *CodeBuilder) EndConst() *Element
- func (p *CodeBuilder) EndInit(n int) *CodeBuilder
- func (p *CodeBuilder) EndStmt() *CodeBuilder
- func (p *CodeBuilder) Fallthrough() *CodeBuilder
- func (p *CodeBuilder) For(src ...ast.Node) *CodeBuilder
- func (p *CodeBuilder) ForRange(names ...string) *CodeBuilder
- func (p *CodeBuilder) ForRangeEx(names []string, src ...ast.Node) *CodeBuilder
- func (p *CodeBuilder) Func() *Func
- func (p *CodeBuilder) Get(idx int) *Element
- func (p *CodeBuilder) Go() *CodeBuilder
- func (p *CodeBuilder) Goto(l *Label) *CodeBuilder
- func (p *CodeBuilder) If(src ...ast.Node) *CodeBuilder
- func (p *CodeBuilder) InVBlock() bool
- func (p *CodeBuilder) IncDec(op token.Token, src ...ast.Node) *CodeBuilder
- func (p *CodeBuilder) Index(nidx int, twoValue bool, src ...ast.Node) *CodeBuilder
- func (p *CodeBuilder) IndexRef(nidx int, src ...ast.Node) *CodeBuilder
- func (p *CodeBuilder) InternalStack() *InternalStack
- func (p *CodeBuilder) Label(l *Label) *CodeBuilder
- func (p *CodeBuilder) LookupLabel(name string) (l *Label, ok bool)
- func (p *CodeBuilder) MapLit(typ types.Type, arity int, src ...ast.Node) *CodeBuilder
- func (p *CodeBuilder) MapLitEx(typ types.Type, arity int, src ...ast.Node) error
- func (p *CodeBuilder) Member(name string, flag MemberFlag, src ...ast.Node) (kind MemberKind, err error)
- func (p *CodeBuilder) MemberRef(name string, src ...ast.Node) *CodeBuilder
- func (p *CodeBuilder) MemberVal(name string, src ...ast.Node) *CodeBuilder
- func (p *CodeBuilder) NewAutoVar(pos token.Pos, name string, pv **types.Var) *CodeBuilder
- func (p *CodeBuilder) NewClosure(params, results *Tuple, variadic bool) *Func
- func (p *CodeBuilder) NewClosureWith(sig *types.Signature) *Func
- func (p *CodeBuilder) NewConstStart(typ types.Type, names ...string) *CodeBuilder
- func (p *CodeBuilder) NewLabel(pos token.Pos, name string) *Label
- func (p *CodeBuilder) NewType(name string, src ...ast.Node) *TypeDecl
- func (p *CodeBuilder) NewTypeDecls() (ret *TypeDefs, defineHere func())
- func (p *CodeBuilder) NewTypeDefs() *TypeDefs
- func (p *CodeBuilder) NewVar(typ types.Type, names ...string) *CodeBuilder
- func (p *CodeBuilder) NewVarStart(typ types.Type, names ...string) *CodeBuilder
- func (p *CodeBuilder) None() *CodeBuilder
- func (p *CodeBuilder) Pkg() *Package
- func (p *CodeBuilder) Post() *CodeBuilder
- func (p *CodeBuilder) RangeAssignThen(pos token.Pos) *CodeBuilder
- func (p *CodeBuilder) ResetInit()
- func (p *CodeBuilder) ResetStmt()
- func (p *CodeBuilder) Return(n int, src ...ast.Node) *CodeBuilder
- func (p *CodeBuilder) ReturnErr(outer bool) *CodeBuilder
- func (p *CodeBuilder) Scope() *types.Scope
- func (p *CodeBuilder) Select(src ...ast.Node) *CodeBuilder
- func (p *CodeBuilder) Send() *CodeBuilder
- func (p *CodeBuilder) SetBodyHandler(handle func(body *ast.BlockStmt, kind int)) *CodeBuilder
- func (p *CodeBuilder) SetComments(comments *ast.CommentGroup, once bool) *CodeBuilder
- func (p *CodeBuilder) Slice(slice3 bool, src ...ast.Node) *CodeBuilder
- func (p *CodeBuilder) SliceLit(typ types.Type, arity int, keyVal ...bool) *CodeBuilder
- func (p *CodeBuilder) SliceLitEx(typ types.Type, arity int, keyVal bool, src ...ast.Node) *CodeBuilder
- func (p *CodeBuilder) Star(src ...ast.Node) *CodeBuilder
- func (p *CodeBuilder) StructLit(typ types.Type, arity int, keyVal bool, src ...ast.Node) *CodeBuilder
- func (p *CodeBuilder) Switch(src ...ast.Node) *CodeBuilder
- func (p *CodeBuilder) Then(src ...ast.Node) *CodeBuilder
- func (p *CodeBuilder) Typ(typ types.Type, src ...ast.Node) *CodeBuilder
- func (p *CodeBuilder) TypeAssert(typ types.Type, twoValue bool, src ...ast.Node) *CodeBuilder
- func (p *CodeBuilder) TypeAssertThen() *CodeBuilder
- func (p *CodeBuilder) TypeCase(src ...ast.Node) *CodeBuilder
- func (p *CodeBuilder) TypeDefaultThen(src ...ast.Node) *CodeBuilder
- func (p *CodeBuilder) TypeSwitch(name string, src ...ast.Node) *CodeBuilder
- func (p *CodeBuilder) UnaryOp(op token.Token, params ...interface{}) *CodeBuilder
- func (p *CodeBuilder) UntypedBigInt(v *big.Int, src ...ast.Node) *CodeBuilder
- func (p *CodeBuilder) UntypedBigRat(v *big.Rat, src ...ast.Node) *CodeBuilder
- func (p *CodeBuilder) VBlock() *CodeBuilder
- func (p *CodeBuilder) Val(v interface{}, src ...ast.Node) *CodeBuilder
- func (p *CodeBuilder) VarRef(ref interface{}, src ...ast.Node) *CodeBuilder
- func (p *CodeBuilder) VarVal(name string, src ...ast.Node) *CodeBuilder
- func (p *CodeBuilder) ZeroLit(typ types.Type) *CodeBuilder
- type CodeError
- type Config
- type ConstDefs
- func (p *ConstDefs) New(fn F, iotav int, pos token.Pos, typ types.Type, names ...string) *ConstDefs
- func (p *ConstDefs) NewAt(at ValueAt, fn F, iotav int, pos token.Pos, typ types.Type, names ...string) *ConstDefs
- func (p *ConstDefs) NewPos() ValueAt
- func (p *ConstDefs) Next(iotav int, pos token.Pos, names ...string) *ConstDefs
- func (p *ConstDefs) NextAt(at ValueAt, fn F, iotav int, pos token.Pos, names ...string) *ConstDefs
- func (p *ConstDefs) SetComments(doc *ast.CommentGroup) *ConstDefs
- type Contract
- type Element
- type F
- type File
- type Func
- type ImportError
- type InstrFlags
- type Instruction
- type InternalStack
- type Label
- type LoadNamedFunc
- type MatchError
- type MemberFlag
- type MemberKind
- type NodeInterpreter
- type ObjectDocs
- type OverloadType
- type Package
- func (p *Package) ASTFile(fname ...string) *ast.File
- func (p *Package) AliasType(name string, typ types.Type, src ...ast.Node) *types.Nameddeprecated
- func (p *Package) Builtin() PkgRef
- func (p *Package) CB() *CodeBuilder
- func (p *Package) CommentedASTFile(fname ...string) *printer.CommentedNodes
- func (p *Package) ConstStart() *CodeBuilder
- func (p *Package) CurFile() *File
- func (p *Package) File(fname ...string) (file *File, ok bool)
- func (p *Package) ForEachFile(doSth func(fname string, file *File))
- func (p *Package) ForceImport(pkgPath string, src ...ast.Node)
- func (p *Package) Import(pkgPath string, src ...ast.Node) PkgRef
- func (p *Package) Instantiate(orig types.Type, targs []types.Type, src ...ast.Node) types.Type
- func (pkg *Package) MethodToFunc(typ types.Type, name string, src ...ast.Node) (ret *Element, err error)
- func (p *Package) NewAutoParam(name string) *Param
- func (p *Package) NewAutoParamEx(pos token.Pos, name string) *Param
- func (p *Package) NewConstDefs(scope *types.Scope) *ConstDefs
- func (p *Package) NewConstStart(scope *types.Scope, pos token.Pos, typ types.Type, names ...string) *CodeBuilderdeprecated
- func (p *Package) NewFunc(recv *Param, name string, params, results *Tuple, variadic bool) *Func
- func (p *Package) NewFuncDecl(pos token.Pos, name string, sig *types.Signature) *Func
- func (p *Package) NewFuncWith(pos token.Pos, name string, sig *types.Signature, recvTypePos func() token.Pos) (*Func, error)
- func (p *Package) NewParam(pos token.Pos, name string, typ types.Type) *Param
- func (p *Package) NewType(name string, src ...ast.Node) *TypeDecldeprecated
- func (p *Package) NewTypeDefs() *TypeDefs
- func (p *Package) NewVar(pos token.Pos, typ types.Type, names ...string) *VarDecldeprecated
- func (p *Package) NewVarDefs(scope *types.Scope) *VarDefs
- func (p *Package) NewVarEx(scope *types.Scope, pos token.Pos, typ types.Type, names ...string) *VarDecldeprecated
- func (p *Package) NewVarStart(pos token.Pos, typ types.Type, names ...string) *CodeBuilderdeprecated
- func (p *Package) Offsetsof(fields []*types.Var) []int64
- func (p *Package) RestoreCurFile(file *File) (old *File)
- func (p *Package) SetCurFile(fname string, createIfNotExists bool) (old *File, err error)
- func (p *Package) SetRedeclarable(allowRedecl bool)
- func (p *Package) Sizeof(typ types.Type) int64
- func (p *Package) TryImport(pkgPath string) PkgRef
- func (p *Package) Unsafe() PkgRef
- func (p *Package) WriteFile(file string, fname ...string) (err error)
- func (p *Package) WriteTo(dst io.Writer, fname ...string) (err error)
- type Param
- type PkgRef
- type Recorder
- type Ref
- type SubstTypedeprecated
- type TemplateFunc
- type TemplateParamType
- type TemplateSignature
- type Term
- type Tuple
- type TyFuncEx
- type TyInstruction
- type TyOverloadFunc
- type TyOverloadMethod
- type TyOverloadNamed
- type TyState
- type TyStaticMethod
- type TySubst
- type TyTemplateRecvMethod
- type TyTypeEx
- type TypeDecl
- func (p *TypeDecl) Delete()
- func (p *TypeDecl) InitType(pkg *Package, typ types.Type, tparams ...*TypeParam) *types.Named
- func (p *TypeDecl) Inited() bool
- func (p *TypeDecl) SetComments(pkg *Package, doc *ast.CommentGroup) *TypeDecl
- func (p *TypeDecl) State() TyState
- func (p *TypeDecl) Type() *types.Named
- type TypeDefs
- type TypeParam
- type TypeParamList
- type TypeType
- type Union
- type ValueAt
- type ValueDecl
- type VarDecl
- type VarDefs
- func (p *VarDefs) Delete(name string) error
- func (p *VarDefs) New(pos token.Pos, typ types.Type, names ...string) *VarDecl
- func (p *VarDefs) NewAndInit(fn F, pos token.Pos, typ types.Type, names ...string) *VarDefs
- func (p *VarDefs) NewAt(at ValueAt, pos token.Pos, typ types.Type, names ...string) *VarDecl
- func (p *VarDefs) NewPos() ValueAt
- func (p *VarDefs) SetComments(doc *ast.CommentGroup) *VarDefs
Constants ¶
const ( DbgFlagInstruction = 1 << iota DbgFlagImport DbgFlagMatch DbgFlagComments DbgFlagWriteFile DbgFlagSetDebug DbgFlagPersistCache DbgFlagAll = DbgFlagInstruction | DbgFlagImport | DbgFlagMatch | DbgFlagComments | DbgFlagWriteFile | DbgFlagSetDebug | DbgFlagPersistCache )
const ( FlagDepModGop = 1 << iota // depends module github.com/goplus/gop FlagDepModX // depends module github.com/qiniu/x )
Variables ¶
var ( TyByte = types.Universe.Lookup("byte").Type().(*types.Basic) TyRune = types.Universe.Lookup("rune").Type().(*types.Basic) )
var ( TyEmptyInterface = types.NewInterfaceType(nil, nil) TyError = types.Universe.Lookup("error").Type() )
var (
GeneratedHeader = "// Code generated by gogen; DO NOT EDIT.\n\n"
)
GeneratedHeader is the default string that the source file generated by gogen start with. Change it if you want to make it different.
Functions ¶
func AssignableTo ¶
AssignableTo reports whether a value of type V is assignable to a variable of type T.
func CheckSigFuncEx ¶
CheckSigFuncEx retrun hide recv type from func($overloadArgs ...interface{$overloadMethod()}) The return type can be OverloadType (*TyOverloadFunc, *TyOverloadMethod, *TyOverloadNamed) or *TyTemplateRecvMethod.
func CheckSigFuncExObjects ¶
CheckSigFuncExObjects retruns hide recv type and objects from func($overloadArgs ...interface{$overloadMethod()}) The return type can be OverloadType (*TyOverloadFunc, *TyOverloadMethod, *TyOverloadNamed) or *TyTemplateRecvMethod.
func CommentedASTFile
deprecated
func CommentedASTFile(pkg *Package, fname ...string) *printer.CommentedNodes
CommentedASTFile returns commented AST of a file by its fname. If fname is not provided, it returns AST of the default (NOT current) file.
Deprecated: Use pkg.CommentedASTFile instead.
func ComparableTo ¶
func Default ¶
Default returns the default "typed" type for an "untyped" type; it returns the incoming type for all other types. The default type for untyped nil is untyped nil.
func HasAutoProperty ¶
HasAutoProperty checks if specified type is a function without parameters or not.
func InferFunc ¶ added in v1.15.2
func InferFunc(pkg *Package, fn *Element, sig *types.Signature, targs []types.Type, args []*Element, flags InstrFlags) (types.Type, error)
InferFunc attempts to infer and instantiates the generic function instantiation with given func and args.
func InitThisGopPkg ¶
InitThisGopPkg initializes a Go+ package.
func InitThisGopPkgEx ¶ added in v1.15.3
InitThisGopPkg initializes a Go+ package. pos map overload name to postion.
func IsMethodRecv ¶
func LookupParent ¶
func NewArray ¶
NewArray returns a new array type for the given element type and length. A negative length indicates an unknown length.
func NewInstruction ¶
func NewOverloadFunc ¶
func NewOverloadFunc(pos token.Pos, pkg *types.Package, name string, funcs ...types.Object) *types.Func
NewOverloadFunc creates an overload func.
func NewOverloadMethod ¶
func NewOverloadMethod(typ *types.Named, pos token.Pos, pkg *types.Package, name string, methods ...types.Object) *types.Func
NewOverloadMethod creates an overload method.
func NewOverloadNamed ¶
func NewPointer ¶
NewPointer returns a new pointer type for the given element (base) type.
func NewSignature ¶
NewSignature returns a new function type for the given receiver, parameters, and results, either of which may be nil. If variadic is set, the function is variadic, it must have at least one parameter, and the last parameter must be of unnamed slice type.
func NewStaticMethod ¶ added in v1.15.2
func NewTemplateRecvMethod ¶
func NewTemplateRecvMethod(typ *types.Named, pos token.Pos, pkg *types.Package, name string, fn types.Object) *types.Func
NewTemplateRecvMethod - https://github.com/goplus/gop/issues/811
Types ¶
type CodeBuilder ¶
type CodeBuilder struct {
// contains filtered or unexported fields
}
CodeBuilder type
func (*CodeBuilder) ArrayLit ¶
func (p *CodeBuilder) ArrayLit(typ types.Type, arity int, keyVal ...bool) *CodeBuilder
ArrayLit func
func (*CodeBuilder) ArrayLitEx ¶
func (p *CodeBuilder) ArrayLitEx(typ types.Type, arity int, keyVal bool, src ...ast.Node) *CodeBuilder
ArrayLitEx func
func (*CodeBuilder) Assign ¶
func (p *CodeBuilder) Assign(lhs int, rhs ...int) *CodeBuilder
Assign func
func (*CodeBuilder) AssignOp ¶
func (p *CodeBuilder) AssignOp(op token.Token, src ...ast.Node) *CodeBuilder
AssignOp func
func (*CodeBuilder) AssignWith ¶
func (p *CodeBuilder) AssignWith(lhs, rhs int, src ...ast.Node) *CodeBuilder
AssignWith func
func (*CodeBuilder) BackupComments ¶
func (p *CodeBuilder) BackupComments() (*ast.CommentGroup, bool)
func (*CodeBuilder) BinaryOp ¶
func (p *CodeBuilder) BinaryOp(op token.Token, src ...ast.Node) *CodeBuilder
BinaryOp func
func (*CodeBuilder) Block ¶
func (p *CodeBuilder) Block(src ...ast.Node) *CodeBuilder
Block starts a block statement.
func (*CodeBuilder) Call ¶
func (p *CodeBuilder) Call(n int, ellipsis ...bool) *CodeBuilder
Call func
func (*CodeBuilder) CallInlineClosureStart ¶
func (p *CodeBuilder) CallInlineClosureStart(sig *types.Signature, arity int, ellipsis bool) *CodeBuilder
CallInlineClosureStart func
func (*CodeBuilder) CallWith ¶
func (p *CodeBuilder) CallWith(n int, flags InstrFlags, src ...ast.Node) *CodeBuilder
CallWith always panics on error, while CallWithEx returns err if match function call failed.
func (*CodeBuilder) CallWithEx ¶
func (p *CodeBuilder) CallWithEx(n int, flags InstrFlags, src ...ast.Node) error
CallWith always panics on error, while CallWithEx returns err if match function call failed. If an error ocurs, CallWithEx pops all function arguments from the CodeBuilder stack. In most case, you should call CallWith instead of CallWithEx.
func (*CodeBuilder) Case ¶
func (p *CodeBuilder) Case(src ...ast.Node) *CodeBuilder
Case starts case clause of a switch statement.
func (*CodeBuilder) CommCase ¶
func (p *CodeBuilder) CommCase(src ...ast.Node) *CodeBuilder
CommCase starts case clause of a select statement.
func (*CodeBuilder) CommDefaultThen ¶
func (p *CodeBuilder) CommDefaultThen(src ...ast.Node) *CodeBuilder
CommDefaultThen starts default clause of a select statement.
func (*CodeBuilder) Comments ¶
func (p *CodeBuilder) Comments() *ast.CommentGroup
Comments returns the comments of next statement.
func (*CodeBuilder) CompareNil ¶
func (p *CodeBuilder) CompareNil(op token.Token, src ...ast.Node) *CodeBuilder
CompareNil func
func (*CodeBuilder) Debug ¶
func (p *CodeBuilder) Debug(dbg func(cb *CodeBuilder)) *CodeBuilder
Debug func
func (*CodeBuilder) DefaultThen ¶
func (p *CodeBuilder) DefaultThen(src ...ast.Node) *CodeBuilder
DefaultThen starts default clause of a switch statement.
func (*CodeBuilder) DefineVarStart ¶
func (p *CodeBuilder) DefineVarStart(pos token.Pos, names ...string) *CodeBuilder
DefineVarStart func
func (*CodeBuilder) ElemRef ¶
func (p *CodeBuilder) ElemRef(src ...ast.Node) *CodeBuilder
ElemRef func
func (*CodeBuilder) Else ¶
func (p *CodeBuilder) Else(src ...ast.Node) *CodeBuilder
Else starts else body of a if..else statement.
func (*CodeBuilder) EndConst ¶
func (p *CodeBuilder) EndConst() *Element
func (*CodeBuilder) ForRange ¶
func (p *CodeBuilder) ForRange(names ...string) *CodeBuilder
ForRange func
func (*CodeBuilder) ForRangeEx ¶
func (p *CodeBuilder) ForRangeEx(names []string, src ...ast.Node) *CodeBuilder
ForRangeEx func
func (*CodeBuilder) Func ¶
func (p *CodeBuilder) Func() *Func
Func returns current func (nil means in global scope).
func (*CodeBuilder) If ¶
func (p *CodeBuilder) If(src ...ast.Node) *CodeBuilder
Block starts a if statement.
func (*CodeBuilder) InVBlock ¶
func (p *CodeBuilder) InVBlock() bool
InVBlock checks if current statement is in vblock or not.
func (*CodeBuilder) IncDec ¶
func (p *CodeBuilder) IncDec(op token.Token, src ...ast.Node) *CodeBuilder
IncDec func
func (*CodeBuilder) Index ¶
func (p *CodeBuilder) Index(nidx int, twoValue bool, src ...ast.Node) *CodeBuilder
Index func:
- a[i]
- fn[T1, T2, ..., Tn]
- G[T1, T2, ..., Tn]
func (*CodeBuilder) IndexRef ¶
func (p *CodeBuilder) IndexRef(nidx int, src ...ast.Node) *CodeBuilder
IndexRef func
func (*CodeBuilder) InternalStack ¶
func (p *CodeBuilder) InternalStack() *InternalStack
InternalStack: don't call it (only for internal use)
func (*CodeBuilder) LookupLabel ¶
func (p *CodeBuilder) LookupLabel(name string) (l *Label, ok bool)
LookupLabel func
func (*CodeBuilder) MapLit ¶
func (p *CodeBuilder) MapLit(typ types.Type, arity int, src ...ast.Node) *CodeBuilder
MapLit func
func (*CodeBuilder) Member ¶
func (p *CodeBuilder) Member(name string, flag MemberFlag, src ...ast.Node) (kind MemberKind, err error)
Member access member by its name. src should point to the full source node `x.sel`
func (*CodeBuilder) MemberRef ¶
func (p *CodeBuilder) MemberRef(name string, src ...ast.Node) *CodeBuilder
MemberRef func
func (*CodeBuilder) MemberVal ¶
func (p *CodeBuilder) MemberVal(name string, src ...ast.Node) *CodeBuilder
MemberVal func
func (*CodeBuilder) NewAutoVar ¶
func (p *CodeBuilder) NewAutoVar(pos token.Pos, name string, pv **types.Var) *CodeBuilder
NewAutoVar func
func (*CodeBuilder) NewClosure ¶
func (p *CodeBuilder) NewClosure(params, results *Tuple, variadic bool) *Func
NewClosure func
func (*CodeBuilder) NewClosureWith ¶
func (p *CodeBuilder) NewClosureWith(sig *types.Signature) *Func
NewClosureWith func
func (*CodeBuilder) NewConstStart ¶
func (p *CodeBuilder) NewConstStart(typ types.Type, names ...string) *CodeBuilder
NewConstStart func
func (*CodeBuilder) NewType ¶
func (p *CodeBuilder) NewType(name string, src ...ast.Node) *TypeDecl
NewType func
func (*CodeBuilder) NewTypeDecls ¶
func (p *CodeBuilder) NewTypeDecls() (ret *TypeDefs, defineHere func())
NewTypeDecls starts a type declaration block but delay to define it.
func (*CodeBuilder) NewTypeDefs ¶
func (p *CodeBuilder) NewTypeDefs() *TypeDefs
NewTypeDefs starts a type declaration block.
func (*CodeBuilder) NewVar ¶
func (p *CodeBuilder) NewVar(typ types.Type, names ...string) *CodeBuilder
NewVar func
func (*CodeBuilder) NewVarStart ¶
func (p *CodeBuilder) NewVarStart(typ types.Type, names ...string) *CodeBuilder
NewVarStart func
func (*CodeBuilder) RangeAssignThen ¶
func (p *CodeBuilder) RangeAssignThen(pos token.Pos) *CodeBuilder
RangeAssignThen func
func (*CodeBuilder) ResetInit ¶
func (p *CodeBuilder) ResetInit()
ResetInit resets the variable init state of CodeBuilder.
func (*CodeBuilder) ResetStmt ¶
func (p *CodeBuilder) ResetStmt()
ResetStmt resets the statement state of CodeBuilder.
func (*CodeBuilder) Return ¶
func (p *CodeBuilder) Return(n int, src ...ast.Node) *CodeBuilder
Return func
func (*CodeBuilder) ReturnErr ¶
func (p *CodeBuilder) ReturnErr(outer bool) *CodeBuilder
ReturnErr func
func (*CodeBuilder) Select ¶
func (p *CodeBuilder) Select(src ...ast.Node) *CodeBuilder
Select starts a select statement.
func (*CodeBuilder) SetBodyHandler ¶
func (p *CodeBuilder) SetBodyHandler(handle func(body *ast.BlockStmt, kind int)) *CodeBuilder
func (*CodeBuilder) SetComments ¶
func (p *CodeBuilder) SetComments(comments *ast.CommentGroup, once bool) *CodeBuilder
SetComments sets comments to next statement.
func (*CodeBuilder) Slice ¶
func (p *CodeBuilder) Slice(slice3 bool, src ...ast.Node) *CodeBuilder
Slice func
func (*CodeBuilder) SliceLit ¶
func (p *CodeBuilder) SliceLit(typ types.Type, arity int, keyVal ...bool) *CodeBuilder
SliceLit func
func (*CodeBuilder) SliceLitEx ¶
func (p *CodeBuilder) SliceLitEx(typ types.Type, arity int, keyVal bool, src ...ast.Node) *CodeBuilder
SliceLitEx func
func (*CodeBuilder) StructLit ¶
func (p *CodeBuilder) StructLit(typ types.Type, arity int, keyVal bool, src ...ast.Node) *CodeBuilder
StructLit func
func (*CodeBuilder) Switch ¶
func (p *CodeBuilder) Switch(src ...ast.Node) *CodeBuilder
Switch starts a switch statement.
func (*CodeBuilder) Then ¶
func (p *CodeBuilder) Then(src ...ast.Node) *CodeBuilder
Then starts body of a if/switch/for/case statement.
func (*CodeBuilder) Typ ¶
func (p *CodeBuilder) Typ(typ types.Type, src ...ast.Node) *CodeBuilder
Typ func
func (*CodeBuilder) TypeAssert ¶
func (p *CodeBuilder) TypeAssert(typ types.Type, twoValue bool, src ...ast.Node) *CodeBuilder
TypeAssert func
func (*CodeBuilder) TypeAssertThen ¶
func (p *CodeBuilder) TypeAssertThen() *CodeBuilder
TypeAssertThen starts body of a type switch statement.
func (*CodeBuilder) TypeCase ¶
func (p *CodeBuilder) TypeCase(src ...ast.Node) *CodeBuilder
TypeCase starts case body of a type switch statement.
func (*CodeBuilder) TypeDefaultThen ¶
func (p *CodeBuilder) TypeDefaultThen(src ...ast.Node) *CodeBuilder
TypeDefaultThen starts default clause of a type switch statement.
func (*CodeBuilder) TypeSwitch ¶
func (p *CodeBuilder) TypeSwitch(name string, src ...ast.Node) *CodeBuilder
TypeSwitch starts a type switch statement.
<pre> typeSwitch(name) init; expr typeAssertThen type1, type2, ... typeN typeCase(N)
... end
type1, type2, ... typeM typeCase(M)
... end
end </pre>
func (*CodeBuilder) UnaryOp ¶
func (p *CodeBuilder) UnaryOp(op token.Token, params ...interface{}) *CodeBuilder
UnaryOp:
- cb.UnaryOp(op token.Token)
- cb.UnaryOp(op token.Token, twoValue bool)
- cb.UnaryOp(op token.Token, twoValue bool, src ast.Node)
func (*CodeBuilder) UntypedBigInt ¶
func (p *CodeBuilder) UntypedBigInt(v *big.Int, src ...ast.Node) *CodeBuilder
UntypedBigInt func
func (*CodeBuilder) UntypedBigRat ¶
func (p *CodeBuilder) UntypedBigRat(v *big.Rat, src ...ast.Node) *CodeBuilder
UntypedBigRat func
func (*CodeBuilder) VBlock ¶
func (p *CodeBuilder) VBlock() *CodeBuilder
VBlock starts a vblock statement.
func (*CodeBuilder) Val ¶
func (p *CodeBuilder) Val(v interface{}, src ...ast.Node) *CodeBuilder
Val func
func (*CodeBuilder) VarRef ¶
func (p *CodeBuilder) VarRef(ref interface{}, src ...ast.Node) *CodeBuilder
VarRef func: p.VarRef(nil) means underscore (_)
func (*CodeBuilder) VarVal ¶
func (p *CodeBuilder) VarVal(name string, src ...ast.Node) *CodeBuilder
func (*CodeBuilder) ZeroLit ¶
func (p *CodeBuilder) ZeroLit(typ types.Type) *CodeBuilder
ZeroLit func
type Config ¶
type Config struct { // Types provides type information for the package (optional). Types *types.Package // Fset provides source position information for syntax trees and types (optional). // If Fset is nil, Load will use a new fileset, but preserve Fset's value. Fset *token.FileSet // HandleErr is called to handle errors (optional). HandleErr func(err error) // NodeInterpreter is to interpret an ast.Node (optional). NodeInterpreter NodeInterpreter // LoadNamed is called to load a delay-loaded named type (optional). LoadNamed LoadNamedFunc // An Importer resolves import paths to Packages (optional). Importer types.Importer // DefaultGoFile specifies default file name. It can be empty. DefaultGoFile string // PkgPathIox specifies package path of github.com/goplus/gop/builtin/iox PkgPathIox string // NewBuiltin is to create the builin package (optional). NewBuiltin func(pkg *Package, conf *Config) *types.Package // CanImplicitCast checkes can cast V to T implicitly (optional). CanImplicitCast func(pkg *Package, V, T types.Type, pv *Element) bool // untyped bigint, untyped bigrat, untyped bigfloat (optional). UntypedBigInt, UntypedBigRat, UntypedBigFloat *types.Named // A Recorder records selected objects such as methods, etc (optional). Recorder Recorder // (internal) only for testing DbgPositioner dbgPositioner // NoSkipConstant is to disable optimization of skipping constant (optional). NoSkipConstant bool }
Config type
type ConstDefs ¶
type ConstDefs struct { F F // contains filtered or unexported fields }
ConstDefs represents a const declaration block.
func (*ConstDefs) New ¶
New creates constants with specified `typ` (can be nil) and `names`. The values of the constants are given by the callback `fn`.
func (*ConstDefs) NewAt ¶
func (p *ConstDefs) NewAt(at ValueAt, fn F, iotav int, pos token.Pos, typ types.Type, names ...string) *ConstDefs
NewAt creates constants with specified `typ` (can be nil) and `names`. The values of the constants are given by the callback `fn`.
func (*ConstDefs) Next ¶
Next creates constants with specified `names`. The values of the constants are given by the callback `fn` which is specified by the last call to `New`.
func (*ConstDefs) NextAt ¶
NextAt creates constants with specified `names`. The values of the constants are given by the callback `fn`.
func (*ConstDefs) SetComments ¶
func (p *ConstDefs) SetComments(doc *ast.CommentGroup) *ConstDefs
SetComments sets associated documentation.
type Element ¶
func CastFromBool ¶
CastFromBool tries to cast a bool expression into integer. typ must be an integer type.
type F ¶
type F = func(cb *CodeBuilder) int
F represents an initialization callback for constants/variables.
type File ¶
type File struct {
// contains filtered or unexported fields
}
func (*File) CheckGopDeps ¶
CheckGopDeps checks dependencies of Go+ modules. The return flags can be FlagDepModGop and FlagDepModX.
type Func ¶
Func type
func (*Func) Ancestor ¶
Ancestor returns ancestor of a closure function. It returns itself if the specified func is a normal function.
func (*Func) BodyStart ¶
func (p *Func) BodyStart(pkg *Package, src ...ast.Node) *CodeBuilder
BodyStart func
func (*Func) Comments ¶
func (p *Func) Comments() *ast.CommentGroup
Comments returns associated documentation.
func (*Func) SetComments ¶
func (p *Func) SetComments(pkg *Package, doc *ast.CommentGroup) *Func
SetComments sets associated documentation.
type ImportError ¶
func (*ImportError) Error ¶
func (p *ImportError) Error() string
func (*ImportError) Unwrap ¶
func (p *ImportError) Unwrap() error
type InstrFlags ¶
const ( InstrFlagEllipsis InstrFlags = 1 << iota InstrFlagTwoValue )
type Instruction ¶
type InternalStack ¶
type LoadNamedFunc ¶
type MatchError ¶
type MatchError struct { Fset dbgPositioner Src ast.Node Arg types.Type Param types.Type At interface{} // contains filtered or unexported fields }
func (*MatchError) Error ¶
func (p *MatchError) Error() string
func (*MatchError) Message ¶
func (p *MatchError) Message(fileLine string) string
func (*MatchError) Pos ¶
func (p *MatchError) Pos() token.Pos
type MemberFlag ¶
type MemberFlag int
const ( MemberFlagVal MemberFlag = iota MemberFlagMethodAlias MemberFlagAutoProperty MemberFlagRef MemberFlag = -1 )
type MemberKind ¶
type MemberKind int
const ( MemberInvalid MemberKind = iota MemberMethod MemberAutoProperty MemberField )
type NodeInterpreter ¶
type ObjectDocs ¶
type ObjectDocs = map[types.Object]*ast.CommentGroup
ObjectDocs maps an object to its document.
type OverloadType ¶
Go+ overload extended types
type Package ¶
type Package struct { PkgRef Docs ObjectDocs Fset *token.FileSet // contains filtered or unexported fields }
Package type
func NewPackage ¶
NewPackage creates a new package.
func (*Package) ASTFile ¶
ASTFile returns AST of a file by its fname. If fname is not provided, it returns AST of the default (NOT current) file.
func (*Package) CommentedASTFile ¶
func (p *Package) CommentedASTFile(fname ...string) *printer.CommentedNodes
CommentedASTFile returns commented AST of a file by its fname. If fname is not provided, it returns AST of the default (NOT current) file.
func (*Package) ConstStart ¶
func (p *Package) ConstStart() *CodeBuilder
ConstStart starts a constant expression.
func (*Package) File ¶
File returns a file by its name. If `fname` is not provided, it returns the default (NOT current) file.
func (*Package) ForEachFile ¶
ForEachFile walks all files to `doSth`.
func (*Package) ForceImport ¶
ForceImport always imports a package (i.e. `import _ pkgPath`).
func (*Package) Instantiate ¶
func (*Package) MethodToFunc ¶
func (pkg *Package) MethodToFunc(typ types.Type, name string, src ...ast.Node) (ret *Element, err error)
MethodToFunc:
(T).method (*T).method
func (*Package) NewAutoParam ¶
NewAutoParam returns a new variable representing a function result parameter with auto type.
func (*Package) NewAutoParamEx ¶
NewAutoParamEx returns a new variable representing a function result parameter with auto type.
func (*Package) NewConstDefs ¶
NewConstDefs starts a constant declaration block.
func (*Package) NewConstStart
deprecated
func (*Package) NewFuncDecl ¶
NewFuncDecl creates a new function without function body (declaration only).
func (*Package) NewFuncWith ¶
func (p *Package) NewFuncWith( pos token.Pos, name string, sig *types.Signature, recvTypePos func() token.Pos) (*Func, error)
NewFuncWith creates a new function (should have a function body).
func (*Package) NewTypeDefs ¶
NewTypeDefs starts a type declaration block.
func (*Package) NewVar
deprecated
NewVar starts a var declaration block and creates uninitialized variables with specified `typ` (can be nil) and `names`.
Deprecated: This is a shortcut for creating variables. `NewVarDefs` is more powerful and more recommended.
func (*Package) NewVarDefs ¶
NewVarDefs starts a var declaration block.
func (*Package) NewVarEx
deprecated
func (p *Package) NewVarEx(scope *types.Scope, pos token.Pos, typ types.Type, names ...string) *VarDecl
NewVarEx starts a var declaration block and creates uninitialized variables with specified `typ` (can be nil) and `names`.
Deprecated: This is a shortcut for creating variables. `NewVarDefs` is more powerful and more recommended.
func (*Package) NewVarStart
deprecated
NewVarStart creates variables with specified `typ` (can be nil) and `names` and starts to initialize them. You should call `CodeBuilder.EndInit` to end initialization.
Deprecated: This is a shortcut for creating variables. `NewVarDefs` is more powerful and more recommended.
func (*Package) RestoreCurFile ¶
RestoreCurFile sets current file to an `old` file that was returned by `SetCurFile`.
func (*Package) SetCurFile ¶
SetCurFile sets new current file to write. If createIfNotExists is true, then create a new file named `fname` if it not exists. It returns an `old` file to restore in the future (by calling `RestoreCurFile`).
func (*Package) SetRedeclarable ¶
SetRedeclarable sets to allow redeclaration of variables/functions or not.
func (*Package) TryImport ¶
TryImport imports a package by pkgPath. It returns nil if pkgPath not found.
type PkgRef ¶
type PkgRef struct { // Types provides type information for the package. // The NeedTypes LoadMode bit sets this field for packages matching the // patterns; type information for dependencies may be missing or incomplete, // unless NeedDeps and NeedImports are also set. Types *types.Package }
A PkgRef describes a Go package imported by others.
func (PkgRef) EnsureImported
deprecated
func (p PkgRef) EnsureImported()
Deprecated: EnsureImported is nothing to do now.
func (PkgRef) MarkForceUsed ¶
MarkForceUsed marks to import a package always (i.e. `import _ pkgPath`).
type Recorder ¶
type Recorder interface { // Member maps identifiers to the objects they denote. Member(id ast.Node, obj types.Object) // Call maps func to the the objects they denote. Call(fn ast.Node, obj types.Object) }
Recorder represents a gogen event recorder.
type TemplateFunc ¶
TemplateFunc: template function
func NewTemplateFunc ¶
func NewTemplateFunc(pos token.Pos, pkg *types.Package, name string, tsig *TemplateSignature) *TemplateFunc
NewTemplateFunc creates a template function.
func (*TemplateFunc) Type ¶
func (p *TemplateFunc) Type() types.Type
NewTemplateFunc return the type of specified template function.
type TemplateParamType ¶
type TemplateParamType struct {
// contains filtered or unexported fields
}
func NewTemplateParamType ¶
func NewTemplateParamType(idx int, name string, contract Contract) *TemplateParamType
func (*TemplateParamType) String ¶
func (p *TemplateParamType) String() string
func (*TemplateParamType) Underlying ¶
func (p *TemplateParamType) Underlying() types.Type
type TemplateSignature ¶
type TemplateSignature struct {
// contains filtered or unexported fields
}
TemplateSignature: type of template function
func NewTemplateSignature ¶
func NewTemplateSignature( templateParams []*TemplateParamType, recv *types.Var, params, results *types.Tuple, variadic bool, tok ...token.Token) *TemplateSignature
NewTemplateSignature creates type of a template function.
func (*TemplateSignature) String ¶
func (p *TemplateSignature) String() string
func (*TemplateSignature) Underlying ¶
func (p *TemplateSignature) Underlying() types.Type
type Tuple ¶
A Tuple represents an ordered list of variables; a nil *Tuple is a valid (empty) tuple. Tuples are used as components of signatures and to represent the type of multiple assignments; they are not first class types of Go.
type TyInstruction ¶
type TyInstruction struct {
// contains filtered or unexported fields
}
func (*TyInstruction) String ¶
func (p *TyInstruction) String() string
func (*TyInstruction) Underlying ¶
func (p *TyInstruction) Underlying() types.Type
type TyOverloadFunc ¶
TyOverloadFunc: overload function type
func (*TyOverloadFunc) Len ¶
func (p *TyOverloadFunc) Len() int
func (*TyOverloadFunc) String ¶
func (p *TyOverloadFunc) String() string
func (*TyOverloadFunc) Underlying ¶
func (p *TyOverloadFunc) Underlying() types.Type
type TyOverloadMethod ¶
TyOverloadMethod: overload function type
func (*TyOverloadMethod) Len ¶
func (p *TyOverloadMethod) Len() int
func (*TyOverloadMethod) String ¶
func (p *TyOverloadMethod) String() string
func (*TyOverloadMethod) Underlying ¶
func (p *TyOverloadMethod) Underlying() types.Type
type TyOverloadNamed ¶
func CheckOverloadNamed ¶
func CheckOverloadNamed(typ types.Type) (on *TyOverloadNamed, ok bool)
CheckOverloadNamed returns if specified type is a TyOverloadNamed or not.
func (*TyOverloadNamed) Len ¶
func (p *TyOverloadNamed) Len() int
func (*TyOverloadNamed) String ¶
func (p *TyOverloadNamed) String() string
func (*TyOverloadNamed) Underlying ¶
func (p *TyOverloadNamed) Underlying() types.Type
type TyStaticMethod ¶ added in v1.15.2
func (*TyStaticMethod) Obj ¶ added in v1.15.2
func (p *TyStaticMethod) Obj() types.Object
func (*TyStaticMethod) String ¶ added in v1.15.2
func (p *TyStaticMethod) String() string
func (*TyStaticMethod) Underlying ¶ added in v1.15.2
func (p *TyStaticMethod) Underlying() types.Type
type TySubst ¶
func (*TySubst) Underlying ¶
type TyTemplateRecvMethod ¶
func (*TyTemplateRecvMethod) Obj ¶
func (p *TyTemplateRecvMethod) Obj() types.Object
func (*TyTemplateRecvMethod) String ¶
func (p *TyTemplateRecvMethod) String() string
func (*TyTemplateRecvMethod) Underlying ¶
func (p *TyTemplateRecvMethod) Underlying() types.Type
type TypeDecl ¶
type TypeDecl struct {
// contains filtered or unexported fields
}
TypeDecl type
func (*TypeDecl) Delete ¶
func (p *TypeDecl) Delete()
Delete deletes this type. NOTE: It panics if you call InitType after Delete.
func (*TypeDecl) Inited ¶
Inited checkes if InitType is called or not. Will panic if this type is deleted (please use State to check).
func (*TypeDecl) SetComments ¶
func (p *TypeDecl) SetComments(pkg *Package, doc *ast.CommentGroup) *TypeDecl
SetComments sets associated documentation.
type TypeDefs ¶
type TypeDefs struct {
// contains filtered or unexported fields
}
TypeDefs represents a type declaration block.
func (*TypeDefs) Complete ¶
func (p *TypeDefs) Complete()
Complete checks type declarations & marks completed.
func (*TypeDefs) SetComments ¶
func (p *TypeDefs) SetComments(doc *ast.CommentGroup) *TypeDefs
SetComments sets associated documentation.
type TypeParamList ¶
type TypeParamList = types.TypeParamList
type TypeType ¶
type TypeType struct {
// contains filtered or unexported fields
}
func NewTypeType ¶
func (*TypeType) Underlying ¶
type ValueDecl ¶
type ValueDecl struct {
// contains filtered or unexported fields
}
ValueDecl type
func (*ValueDecl) End ¶
func (p *ValueDecl) End(cb *CodeBuilder, src ast.Node)
End is provided for internal usage. Don't call it at any time. Please use (*CodeBuilder).EndInit instead.
func (*ValueDecl) InitStart ¶
func (p *ValueDecl) InitStart(pkg *Package) *CodeBuilder
InitStart initializes a uninitialized variable or constant.
type VarDefs ¶
type VarDefs struct {
// contains filtered or unexported fields
}
VarDefs represents a var declaration block.
func (*VarDefs) Delete ¶
Delete deletes an uninitialized variable who was created by `New`. If the variable is initialized, it fails to delete and returns `syscall.EACCES`. If the variable is not found, it returns `syscall.ENOENT`.
func (*VarDefs) New ¶
New creates uninitialized variables with specified `typ` (can be nil) and `names`.
func (*VarDefs) NewAndInit ¶
NewAndInit creates variables with specified `typ` (can be nil) and `names`, and initializes them by `fn`.
func (*VarDefs) NewAt ¶
NewAt creates uninitialized variables with specified `typ` (can be nil) and `names`.
func (*VarDefs) SetComments ¶
func (p *VarDefs) SetComments(doc *ast.CommentGroup) *VarDefs
SetComments sets associated documentation.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
chore
|
|
go/format
Package format implements standard formatting of Go source.
|
Package format implements standard formatting of Go source. |
go/printer
Package printer implements printing of AST nodes.
|
Package printer implements printing of AST nodes. |
tutorial
|
|