state

package
v0.1.16 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2025 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsNil

func IsNil(expr ast.Expr, info *types.Info) bool

IsNil checks if an expression is the built-in `nil` identifier.

Types

type StateTracker

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

StateTracker manages the state of variables within different scopes.

func NewStateTracker

func NewStateTracker() *StateTracker

NewStateTracker creates a new state tracker.

func (*StateTracker) EnterScope

func (st *StateTracker) EnterScope()

EnterScope creates a new, nested scope.

func (*StateTracker) GetState

func (st *StateTracker) GetState(obj types.Object) VarState

GetState retrieves the state of a variable, searching from the innermost scope outwards.

func (*StateTracker) LeaveScope

func (st *StateTracker) LeaveScope()

LeaveScope exits the current scope, discarding its state.

func (*StateTracker) SetState

func (st *StateTracker) SetState(obj types.Object, state VarState)

SetState sets the state of a variable in the current scope.

func (*StateTracker) UpdateStateFromCondition

func (st *StateTracker) UpdateStateFromCondition(cond ast.Expr, info *types.Info, then bool)

UpdateStateFromCondition intelligently updates variable states based on an if-condition.

type VarState

type VarState int

VarState represents the tracked state of a variable.

const (
	StateUnknown VarState = iota
	StateNil
	StateNonNil
	StateClosed // For channels
)

Jump to

Keyboard shortcuts

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