Version: v1.0.0 Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Jan 10, 2019 License: Apache-2.0 Imports: 20 Imported by: 0




This section is empty.


View Source
var (
	ErrFnIsNil      = errors.New("function is nil")
	ErrIncompatType = errors.New("incompatible type")


This section is empty.


type Block

type Block struct {

	Callee          *funcs.Instance // Instance of this function.
	callctx.Context                 // Function context.
	Env             *Environment    // Program environment.

	Loop      *loop.Detector // Loop detector.
	*Exported                // Local variables.
	// contains filtered or unexported fields

Block is an analyser of ssa.BasicBlock.

func NewBlock

func NewBlock(fn *funcs.Instance, ctx callctx.Context, env *Environment) *Block

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

func (*Block) SetLogger

func (b *Block) SetLogger(l *Logger)

SetLogger sets logger for Block.

type BlockData

type BlockData struct {
	// contains filtered or unexported fields

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

type ErrChanBufSzNonStatic struct {
	Pos token.Position

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

func (e *Exported) Export(k store.Key)

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

func (e *Exported) FindExported(ctx callctx.Context, v store.Value) store.Key

FindExported returns name that points the same value v but using an exported name.

func (*Exported) String

func (e *Exported) String() string

func (*Exported) Unexport

func (e *Exported) Unexport(k store.Key)

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.

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

func NewFunction(call *funcs.Call, ctx callctx.Context, env *Environment) *Function

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

func (f *Function) EnterFunc(fn *ssa.Function)

EnterFunc enters a function and perform a context switch. This should be the entry point of a function call.

func (*Function) ExitFunc

func (f *Function) ExitFunc(fn *ssa.Function)

ExitFunc finalises analysis of a function.

func (*Function) SetLogger

func (f *Function) SetLogger(l *Logger)

SetLogger sets logger for Function and its child block.Analyser.

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.

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 LogSetter

type LogSetter interface {

type Logger

type Logger struct {
	// contains filtered or unexported fields

Logger encapsulates a Logger and module which it belongs to. Use this through SetLogger() of visitor.

func (*Logger) Module

func (l *Logger) Module() string

Module returns (stylised) module name.

type Package

type Package struct {
	Env *Environment // Program environment

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

func (p *Package) InitGlobals(pkg *ssa.Package)

InitGlobals initialises package-global varables in environment.

func (*Package) SetLogger

func (p *Package) SetLogger(l *Logger)

SetLogger sets logger for Package.

func (*Package) VisitInit

func (p *Package) VisitInit(pkg *ssa.Package)

VisitInit visits init function(s) in the package with a fresh context.

type Poser

type Poser interface {
	Pos() token.Pos

type Unexported

type Unexported struct {
	Value store.Value

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto