Documentation
¶
Overview ¶
Package graph provides control-flow graph analysis.
It enables reachability analysis between source code positions and limitation to a forward-only flow to approximate code reading.
The original algorithm was written by Alan Donovan for golang.org/x/tools/go/cfg.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BlockInterval ¶
type BlockInterval struct {
Start, End token.Pos // The range of the block in the source file.
Successors []int // Indices of successor blocks in the intervals slice.
}
BlockInterval represents a range in the source file with successor block indices for control-flow analysis.
type LabelTarget ¶
type LabelTarget struct {
// contains filtered or unexported fields
}
LabelTarget represents the control flow targets for a labeled statement. A label can be the target of break, continue, or goto statements.
func NewLabelTarget ¶
func NewLabelTarget(body *block.Block) *LabelTarget
NewLabelTarget creates a new label target with the given body source range. The break and continue targets are set later based on the statement type.
func (*LabelTarget) Body ¶
func (l *LabelTarget) Body() *block.Block
Body returns the source range of the labeled statement itself.
func (*LabelTarget) BranchTarget ¶
func (l *LabelTarget) BranchTarget(tok token.Token) *block.Block
BranchTarget returns the block that a branch statement should jump to based on the branch token type (BREAK, CONTINUE, or GOTO).
func (*LabelTarget) SetBreak ¶
func (l *LabelTarget) SetBreak(b *block.Block)
SetBreak sets the break target block for the labeled statement.
func (*LabelTarget) SetContinue ¶
func (l *LabelTarget) SetContinue(c *block.Block)
SetContinue sets the continue target block for the labeled statement.