Documentation ¶
Index ¶
- Variables
- type Block
- type BlockData
- type Environment
- type ErrChanBufSzNonStatic
- type Exported
- type Function
- type Instruction
- func (v *Instruction) SetLogger(l *Logger)
- func (v *Instruction) VisitAlloc(instr *ssa.Alloc)
- func (v *Instruction) VisitBinOp(instr *ssa.BinOp)
- func (v *Instruction) VisitCall(instr *ssa.Call)
- func (v *Instruction) VisitChangeInterface(instr *ssa.ChangeInterface)
- func (v *Instruction) VisitChangeType(instr *ssa.ChangeType)
- func (v *Instruction) VisitConvert(instr *ssa.Convert)
- func (v *Instruction) VisitDebugRef(instr *ssa.DebugRef)
- func (v *Instruction) VisitDefer(instr *ssa.Defer)
- func (v *Instruction) VisitExtract(instr *ssa.Extract)
- func (v *Instruction) VisitField(instr *ssa.Field)
- func (v *Instruction) VisitFieldAddr(instr *ssa.FieldAddr)
- func (v *Instruction) VisitGo(instr *ssa.Go)
- func (v *Instruction) VisitIf(instr *ssa.If)
- func (v *Instruction) VisitIndex(instr *ssa.Index)
- func (v *Instruction) VisitIndexAddr(instr *ssa.IndexAddr)
- func (v *Instruction) VisitInstr(instr ssa.Instruction)
- func (v *Instruction) VisitJump(instr *ssa.Jump)
- func (v *Instruction) VisitLookup(instr *ssa.Lookup)
- func (v *Instruction) VisitMakeChan(instr *ssa.MakeChan)
- func (v *Instruction) VisitMakeClosure(instr *ssa.MakeClosure)
- func (v *Instruction) VisitMakeInterface(instr *ssa.MakeInterface)
- func (v *Instruction) VisitMakeMap(instr *ssa.MakeMap)
- func (v *Instruction) VisitMakeSlice(instr *ssa.MakeSlice)
- func (v *Instruction) VisitMapUpdate(instr *ssa.MapUpdate)
- func (v *Instruction) VisitNext(instr *ssa.Next)
- func (v *Instruction) VisitPanic(instr *ssa.Panic)
- func (v *Instruction) VisitPhi(instr *ssa.Phi)
- func (v *Instruction) VisitRange(instr *ssa.Range)
- func (v *Instruction) VisitReturn(instr *ssa.Return)
- func (v *Instruction) VisitRunDefers(instr *ssa.RunDefers)
- func (v *Instruction) VisitSelect(instr *ssa.Select)
- func (v *Instruction) VisitSend(instr *ssa.Send)
- func (v *Instruction) VisitSlice(instr *ssa.Slice)
- func (v *Instruction) VisitStore(instr *ssa.Store)
- func (v *Instruction) VisitTypeAssert(instr *ssa.TypeAssert)
- func (v *Instruction) VisitUnOp(instr *ssa.UnOp)
- type LogSetter
- type Logger
- type Package
- type Poser
- type Unexported
Constants ¶
This section is empty.
Variables ¶
var ( ErrFnIsNil = errors.New("function is nil") ErrIncompatType = errors.New("incompatible type") )
Functions ¶
This section is empty.
Types ¶
type Block ¶
type Block struct { *block.VisitGraph Callee *funcs.Instance // Instance of this function. callctx.Context // Function context. Env *Environment // Program environment. Loop *loop.Detector // Loop detector. *Exported // Local variables. *Logger // contains filtered or unexported fields }
Block is an analyser of ssa.BasicBlock.
func (*Block) CurrBlk ¶
func (b *Block) CurrBlk() *ssa.BasicBlock
func (*Block) EnterBlk ¶
func (b *Block) EnterBlk(blk *ssa.BasicBlock)
func (*Block) ExitBlk ¶
func (b *Block) ExitBlk(blk *ssa.BasicBlock)
func (*Block) JumpBlk ¶
func (b *Block) JumpBlk(curr *ssa.BasicBlock, next *ssa.BasicBlock)
func (*Block) PrevBlk ¶
func (b *Block) PrevBlk() *ssa.BasicBlock
type Environment ¶
type Environment struct { Prog *migo.Program Info *gssa.Info Globals *store.Store Errors chan error SkipPkg map[*ssa.Package]bool VisitedFunc map[*ssa.CallCommon]bool }
Environment captures the global environment of the program shared across functions.
func NewEnvironment ¶
func NewEnvironment(info *gssa.Info) Environment
NewEnvironment initialises a new environment.
func (Environment) HandleErrors ¶
func (env Environment) HandleErrors()
type ErrChanBufSzNonStatic ¶
func (ErrChanBufSzNonStatic) Error ¶
func (e ErrChanBufSzNonStatic) Error() string
type Exported ¶
type Exported struct {
// contains filtered or unexported fields
}
Exported is a holder of visible local names in a function.
func (*Exported) Export ¶
Export puts a local variable k in the set of exported names. Only exported names can appear in a MiGo function.
Precondition: e only has unique elements.
func (*Exported) FindExported ¶
FindExported returns name that points the same value v but using an exported name.
type Function ¶
type Function struct { Callee *funcs.Instance // Instance of this function. callctx.Context // Function context. Env *Environment // Program environment. block.Analyser // Function body analyser. *Exported *Logger }
Function is a visitor for functions. It does not deal with the body of the functions, but serves as a location for context switching.
func NewFunction ¶
NewFunction creates a new function visitor.
NewFunction takes two parameters to setup the call environment.
- Function definition: call
- Caller context: ctx
- Program environment: env
They contain the global, and caller local variables respectively. In particular, the caller context contains the caller *ssa.Function and its corresponding call function.
func (*Function) EnterFunc ¶
EnterFunc enters a function and perform a context switch. This should be the entry point of a function call.
type Instruction ¶
type Instruction struct { Callee *funcs.Instance // Instance of this function. callctx.Context // Function context. Env *Environment // Program environment. MiGo *migo.Function // MiGo function definition of current block. *Exported // Local variables. *Logger }
Instruction is a visitor for related instructions within a block.
func NewInstruction ¶
func NewInstruction(callee *funcs.Instance, ctx callctx.Context, env *Environment, migoFn *migo.Function) *Instruction
func (*Instruction) SetLogger ¶
func (v *Instruction) SetLogger(l *Logger)
SetLogger sets logger for Instruction.
func (*Instruction) VisitAlloc ¶
func (v *Instruction) VisitAlloc(instr *ssa.Alloc)
func (*Instruction) VisitBinOp ¶
func (v *Instruction) VisitBinOp(instr *ssa.BinOp)
func (*Instruction) VisitCall ¶
func (v *Instruction) VisitCall(instr *ssa.Call)
func (*Instruction) VisitChangeInterface ¶
func (v *Instruction) VisitChangeInterface(instr *ssa.ChangeInterface)
func (*Instruction) VisitChangeType ¶
func (v *Instruction) VisitChangeType(instr *ssa.ChangeType)
func (*Instruction) VisitConvert ¶
func (v *Instruction) VisitConvert(instr *ssa.Convert)
func (*Instruction) VisitDebugRef ¶
func (v *Instruction) VisitDebugRef(instr *ssa.DebugRef)
func (*Instruction) VisitDefer ¶
func (v *Instruction) VisitDefer(instr *ssa.Defer)
func (*Instruction) VisitExtract ¶
func (v *Instruction) VisitExtract(instr *ssa.Extract)
func (*Instruction) VisitField ¶
func (v *Instruction) VisitField(instr *ssa.Field)
func (*Instruction) VisitFieldAddr ¶
func (v *Instruction) VisitFieldAddr(instr *ssa.FieldAddr)
func (*Instruction) VisitGo ¶
func (v *Instruction) VisitGo(instr *ssa.Go)
func (*Instruction) VisitIf ¶
func (v *Instruction) VisitIf(instr *ssa.If)
func (*Instruction) VisitIndex ¶
func (v *Instruction) VisitIndex(instr *ssa.Index)
func (*Instruction) VisitIndexAddr ¶
func (v *Instruction) VisitIndexAddr(instr *ssa.IndexAddr)
func (*Instruction) VisitInstr ¶
func (v *Instruction) VisitInstr(instr ssa.Instruction)
func (*Instruction) VisitJump ¶
func (v *Instruction) VisitJump(instr *ssa.Jump)
func (*Instruction) VisitLookup ¶
func (v *Instruction) VisitLookup(instr *ssa.Lookup)
func (*Instruction) VisitMakeChan ¶
func (v *Instruction) VisitMakeChan(instr *ssa.MakeChan)
func (*Instruction) VisitMakeClosure ¶
func (v *Instruction) VisitMakeClosure(instr *ssa.MakeClosure)
func (*Instruction) VisitMakeInterface ¶
func (v *Instruction) VisitMakeInterface(instr *ssa.MakeInterface)
func (*Instruction) VisitMakeMap ¶
func (v *Instruction) VisitMakeMap(instr *ssa.MakeMap)
func (*Instruction) VisitMakeSlice ¶
func (v *Instruction) VisitMakeSlice(instr *ssa.MakeSlice)
func (*Instruction) VisitMapUpdate ¶
func (v *Instruction) VisitMapUpdate(instr *ssa.MapUpdate)
func (*Instruction) VisitNext ¶
func (v *Instruction) VisitNext(instr *ssa.Next)
func (*Instruction) VisitPanic ¶
func (v *Instruction) VisitPanic(instr *ssa.Panic)
func (*Instruction) VisitPhi ¶
func (v *Instruction) VisitPhi(instr *ssa.Phi)
func (*Instruction) VisitRange ¶
func (v *Instruction) VisitRange(instr *ssa.Range)
func (*Instruction) VisitReturn ¶
func (v *Instruction) VisitReturn(instr *ssa.Return)
func (*Instruction) VisitRunDefers ¶
func (v *Instruction) VisitRunDefers(instr *ssa.RunDefers)
func (*Instruction) VisitSelect ¶
func (v *Instruction) VisitSelect(instr *ssa.Select)
func (*Instruction) VisitSend ¶
func (v *Instruction) VisitSend(instr *ssa.Send)
func (*Instruction) VisitSlice ¶
func (v *Instruction) VisitSlice(instr *ssa.Slice)
func (*Instruction) VisitStore ¶
func (v *Instruction) VisitStore(instr *ssa.Store)
func (*Instruction) VisitTypeAssert ¶
func (v *Instruction) VisitTypeAssert(instr *ssa.TypeAssert)
func (*Instruction) VisitUnOp ¶
func (v *Instruction) VisitUnOp(instr *ssa.UnOp)
type Logger ¶
type Logger struct { *zap.SugaredLogger // contains filtered or unexported fields }
Logger encapsulates a Logger and module which it belongs to. Use this through SetLogger() of visitor.
type Package ¶
type Package struct { Env *Environment // Program environment *Logger }
Package is a visitor for package variables and initialisation. None of the data are stored in the visitor (global variables are in shared environment) so this can be reused for all packages.
func NewPackage ¶
func NewPackage(env *Environment) *Package
func (*Package) InitGlobals ¶
InitGlobals initialises package-global varables in environment.