frame

package
v0.0.0-...-30bfde3 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	VisitPreOrder  = iota
	VisitPostOrder = iota
)
View Source
const SDKPackage = `_g_sdk "github.com/Unixeno/gootprint/sdk"` // trace sdk used in import statement
View Source
const SDKPackagePrefix = "_g_sdk." // the prefix to access trace sdk package

Variables

This section is empty.

Functions

func NewBaseEnv

func NewBaseEnv(filename string) *baseEnv

func NewBaseFrame

func NewBaseFrame(path string) *baseFrame

func Visit

func Visit(frame Frame, order int, callback func(Frame))

Types

type CaseFrame

type CaseFrame struct {
	// contains filtered or unexported fields
}

CaseFrame switch, select

func NewCaseFrame

func NewCaseFrame(path string) *CaseFrame

func (CaseFrame) Append

func (frame CaseFrame) Append(inner Frame)

func (CaseFrame) BodyBeginning

func (frame CaseFrame) BodyBeginning() int

func (CaseFrame) BodyEnding

func (frame CaseFrame) BodyEnding() int

func (*CaseFrame) GenBeginning

func (frame *CaseFrame) GenBeginning(genEnv *baseEnv, content []byte) []byte

func (*CaseFrame) GenEnding

func (frame *CaseFrame) GenEnding(genEnv *baseEnv, content []byte) []byte

func (*CaseFrame) GenEnv

func (frame *CaseFrame) GenEnv(genEnv *baseEnv) []byte

func (CaseFrame) GetInner

func (frame CaseFrame) GetInner(index int) Frame

func (CaseFrame) HeadBeginning

func (frame CaseFrame) HeadBeginning() int

func (CaseFrame) IsReturn

func (frame CaseFrame) IsReturn() bool

func (CaseFrame) Len

func (frame CaseFrame) Len() int

func (CaseFrame) Path

func (frame CaseFrame) Path() string

func (CaseFrame) SetPosLine

func (frame CaseFrame) SetPosLine(headBegin, bodyBegin, bodyEnd int)

func (CaseFrame) SetReturn

func (frame CaseFrame) SetReturn(line int)

func (CaseFrame) SetUnreachable

func (frame CaseFrame) SetUnreachable()

func (CaseFrame) String

func (frame CaseFrame) String() string

func (CaseFrame) Unreachable

func (frame CaseFrame) Unreachable() bool

type Context

type Context struct {
	// contains filtered or unexported fields
}

func NewFrameContext

func NewFrameContext(filename, packageName string, bodyBegin, bodyEnd int) *Context

func (*Context) GenerateEnv

func (root *Context) GenerateEnv() []byte

func (*Context) GenerateLine

func (root *Context) GenerateLine(line int, content []byte) []byte

func (*Context) GetCurrent

func (root *Context) GetCurrent() Frame

func (*Context) GetIndexName

func (root *Context) GetIndexName() string

func (*Context) GetInnerName

func (root *Context) GetInnerName(suffix string) string

func (*Context) Import

func (root *Context) Import(path string)

func (*Context) Pop

func (root *Context) Pop()

func (*Context) PostOrderDump

func (root *Context) PostOrderDump()

func (*Context) PreOrderDump

func (root *Context) PreOrderDump()

func (*Context) PrepareGenerate

func (root *Context) PrepareGenerate()

func (*Context) Push

func (root *Context) Push(frame Frame)

func (*Context) Stats

func (root *Context) Stats() Stats

type ForFrame

type ForFrame struct {
	// contains filtered or unexported fields
}

func NewForFrame

func NewForFrame(path string) *ForFrame

func (ForFrame) Append

func (frame ForFrame) Append(inner Frame)

func (ForFrame) BodyBeginning

func (frame ForFrame) BodyBeginning() int

func (ForFrame) BodyEnding

func (frame ForFrame) BodyEnding() int

func (*ForFrame) GenBeginning

func (frame *ForFrame) GenBeginning(genEnv *baseEnv, content []byte) []byte

func (*ForFrame) GenEnding

func (frame *ForFrame) GenEnding(genEnv *baseEnv, content []byte) []byte

func (*ForFrame) GenEnv

func (frame *ForFrame) GenEnv(genEnv *baseEnv) []byte

func (ForFrame) GetInner

func (frame ForFrame) GetInner(index int) Frame

func (ForFrame) HeadBeginning

func (frame ForFrame) HeadBeginning() int

func (ForFrame) IsReturn

func (frame ForFrame) IsReturn() bool

func (ForFrame) Len

func (frame ForFrame) Len() int

func (ForFrame) Path

func (frame ForFrame) Path() string

func (ForFrame) SetPosLine

func (frame ForFrame) SetPosLine(headBegin, bodyBegin, bodyEnd int)

func (ForFrame) SetReturn

func (frame ForFrame) SetReturn(line int)

func (ForFrame) SetUnreachable

func (frame ForFrame) SetUnreachable()

func (ForFrame) String

func (frame ForFrame) String() string

func (ForFrame) Unreachable

func (frame ForFrame) Unreachable() bool

type Frame

type Frame interface {
	HeadBeginning() int                           // line number of the block beginning,
	BodyBeginning() int                           // line number of {
	BodyEnding() int                              // line number of }, or the return statement
	SetReturn(line int)                           // mark the frame has an explicit return
	SetUnreachable()                              // set block ending is unreachable
	Unreachable() bool                            // whether a frame ending is unreachable
	Path() string                                 // unique frame path
	IsReturn() bool                               // whether this block contains an explicit return statement
	GetInner(index int) Frame                     // get inner frame
	Len() int                                     // amount of inner frames
	Append(Frame)                                 // append an inner frame
	SetPosLine(headBegin, bodyBegin, bodyEnd int) // set line number

	GenBeginning(genEnv *baseEnv, content []byte) []byte // generator function for BodyBeginning
	GenEnding(genEnv *baseEnv, content []byte) []byte    // generator function for BodyEnding
	GenEnv(genEnv *baseEnv) []byte                       // generator function for env at end of file

	fmt.Stringer
}

type FuncFrame

type FuncFrame struct {
	// contains filtered or unexported fields
}

func NewFuncFrame

func NewFuncFrame(path string) *FuncFrame

func (FuncFrame) Append

func (frame FuncFrame) Append(inner Frame)

func (FuncFrame) BodyBeginning

func (frame FuncFrame) BodyBeginning() int

func (FuncFrame) BodyEnding

func (frame FuncFrame) BodyEnding() int

func (*FuncFrame) GenBeginning

func (frame *FuncFrame) GenBeginning(genEnv *baseEnv, content []byte) []byte

func (*FuncFrame) GenEnding

func (frame *FuncFrame) GenEnding(genEnv *baseEnv, content []byte) []byte

func (*FuncFrame) GenEnv

func (frame *FuncFrame) GenEnv(genEnv *baseEnv) []byte

func (FuncFrame) GetInner

func (frame FuncFrame) GetInner(index int) Frame

func (FuncFrame) HeadBeginning

func (frame FuncFrame) HeadBeginning() int

func (FuncFrame) IsReturn

func (frame FuncFrame) IsReturn() bool

func (FuncFrame) Len

func (frame FuncFrame) Len() int

func (*FuncFrame) MarkResult

func (frame *FuncFrame) MarkResult()

MarkResult mark a function has result

func (FuncFrame) Path

func (frame FuncFrame) Path() string

func (FuncFrame) SetPosLine

func (frame FuncFrame) SetPosLine(headBegin, bodyBegin, bodyEnd int)

func (FuncFrame) SetReturn

func (frame FuncFrame) SetReturn(line int)

func (FuncFrame) SetUnreachable

func (frame FuncFrame) SetUnreachable()

func (*FuncFrame) String

func (frame *FuncFrame) String() string

func (FuncFrame) Unreachable

func (frame FuncFrame) Unreachable() bool

type GoFuncFrame

type GoFuncFrame struct {
	// contains filtered or unexported fields
}

func NewGoFuncFrame

func NewGoFuncFrame(path string) *GoFuncFrame

func (GoFuncFrame) Append

func (frame GoFuncFrame) Append(inner Frame)

func (GoFuncFrame) BodyBeginning

func (frame GoFuncFrame) BodyBeginning() int

func (GoFuncFrame) BodyEnding

func (frame GoFuncFrame) BodyEnding() int

func (*GoFuncFrame) GenBeginning

func (frame *GoFuncFrame) GenBeginning(genEnv *baseEnv, content []byte) []byte

func (*GoFuncFrame) GenEnding

func (frame *GoFuncFrame) GenEnding(genEnv *baseEnv, content []byte) []byte

func (*GoFuncFrame) GenEnv

func (frame *GoFuncFrame) GenEnv(genEnv *baseEnv) []byte

func (GoFuncFrame) GetInner

func (frame GoFuncFrame) GetInner(index int) Frame

func (GoFuncFrame) HeadBeginning

func (frame GoFuncFrame) HeadBeginning() int

func (GoFuncFrame) IsReturn

func (frame GoFuncFrame) IsReturn() bool

func (GoFuncFrame) Len

func (frame GoFuncFrame) Len() int

func (GoFuncFrame) Path

func (frame GoFuncFrame) Path() string

func (GoFuncFrame) SetPosLine

func (frame GoFuncFrame) SetPosLine(headBegin, bodyBegin, bodyEnd int)

func (GoFuncFrame) SetReturn

func (frame GoFuncFrame) SetReturn(line int)

func (*GoFuncFrame) SetTarget

func (frame *GoFuncFrame) SetTarget(target string)

func (GoFuncFrame) SetUnreachable

func (frame GoFuncFrame) SetUnreachable()

func (GoFuncFrame) String

func (frame GoFuncFrame) String() string

func (GoFuncFrame) Unreachable

func (frame GoFuncFrame) Unreachable() bool

type IfElseFrame

type IfElseFrame struct {
	// contains filtered or unexported fields
}

func NewIfElseFrame

func NewIfElseFrame(path string) *IfElseFrame

func (IfElseFrame) Append

func (frame IfElseFrame) Append(inner Frame)

func (IfElseFrame) BodyBeginning

func (frame IfElseFrame) BodyBeginning() int

func (IfElseFrame) BodyEnding

func (frame IfElseFrame) BodyEnding() int

func (*IfElseFrame) GenBeginning

func (frame *IfElseFrame) GenBeginning(genEnv *baseEnv, content []byte) []byte

func (*IfElseFrame) GenEnding

func (frame *IfElseFrame) GenEnding(genEnv *baseEnv, content []byte) []byte

func (*IfElseFrame) GenEnv

func (frame *IfElseFrame) GenEnv(genEnv *baseEnv) []byte

func (IfElseFrame) GetInner

func (frame IfElseFrame) GetInner(index int) Frame

func (IfElseFrame) HeadBeginning

func (frame IfElseFrame) HeadBeginning() int

func (IfElseFrame) IsReturn

func (frame IfElseFrame) IsReturn() bool

func (IfElseFrame) Len

func (frame IfElseFrame) Len() int

func (IfElseFrame) Path

func (frame IfElseFrame) Path() string

func (IfElseFrame) SetPosLine

func (frame IfElseFrame) SetPosLine(headBegin, bodyBegin, bodyEnd int)

func (IfElseFrame) SetReturn

func (frame IfElseFrame) SetReturn(line int)

func (IfElseFrame) SetUnreachable

func (frame IfElseFrame) SetUnreachable()

func (IfElseFrame) String

func (frame IfElseFrame) String() string

func (IfElseFrame) Unreachable

func (frame IfElseFrame) Unreachable() bool

type PackageFrame

type PackageFrame struct {
	// contains filtered or unexported fields
}

func NewPackageFrame

func NewPackageFrame(filename, packageName string, packageBegin, packageEnd int) *PackageFrame

func (PackageFrame) Append

func (frame PackageFrame) Append(inner Frame)

func (PackageFrame) BodyBeginning

func (frame PackageFrame) BodyBeginning() int

func (PackageFrame) BodyEnding

func (frame PackageFrame) BodyEnding() int

func (*PackageFrame) GenBeginning

func (frame *PackageFrame) GenBeginning(genEnv *baseEnv, content []byte) []byte

func (*PackageFrame) GenEnding

func (frame *PackageFrame) GenEnding(genEnv *baseEnv, content []byte) []byte

func (*PackageFrame) GenEnv

func (frame *PackageFrame) GenEnv(genEnv *baseEnv) []byte

func (PackageFrame) GetInner

func (frame PackageFrame) GetInner(index int) Frame

func (PackageFrame) HeadBeginning

func (frame PackageFrame) HeadBeginning() int

func (*PackageFrame) Import

func (frame *PackageFrame) Import(path string)

func (PackageFrame) IsReturn

func (frame PackageFrame) IsReturn() bool

func (PackageFrame) Len

func (frame PackageFrame) Len() int

func (PackageFrame) Path

func (frame PackageFrame) Path() string

func (PackageFrame) SetPosLine

func (frame PackageFrame) SetPosLine(headBegin, bodyBegin, bodyEnd int)

func (PackageFrame) SetReturn

func (frame PackageFrame) SetReturn(line int)

func (PackageFrame) SetUnreachable

func (frame PackageFrame) SetUnreachable()

func (PackageFrame) String

func (frame PackageFrame) String() string

func (PackageFrame) Unreachable

func (frame PackageFrame) Unreachable() bool

type Stats

type Stats struct {
	IfAmount       int
	ForAmount      int
	CaseAmount     int // include select, switch and typed switch
	FuncAmount     int
	GoFuncAmount   int
	InjectionPoint int // number of point to inject track code
	Lines          int // number of lines of code
}

func (*Stats) Add

func (s *Stats) Add(b Stats)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL