functioncontracts

package
v0.0.0-...-ba14292 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2024 License: Apache-2.0 Imports: 16 Imported by: 2

Documentation

Overview

Package functioncontracts implements a sub-analyzer to analyze function contracts in a package, i.e., parsing specified function contracts written as special comments before function declarations, or automatically inferring function contracts from the function body.

Index

Constants

This section is empty.

Variables

View Source
var Analyzer = &analysis.Analyzer{
	Name:       "nilaway_function_contracts_analyzer",
	Doc:        _doc,
	Run:        analysishelper.WrapRun(run),
	ResultType: reflect.TypeOf((*analysishelper.Result[Map])(nil)),
	FactTypes:  []analysis.Fact{new(Contracts)},
	Requires:   []*analysis.Analyzer{config.Analyzer, buildssa.Analyzer},
}

Analyzer here is the analyzer than reads function contracts. It returns the map generated from reading the function contracts in the source code.

Functions

This section is empty.

Types

type Contract

type Contract struct {
	// Ins is the list of input contract values, where the index is the index of the parameter.
	Ins []ContractVal
	// Outs is the list of output contract values, where the index is the index of the return.
	Outs []ContractVal
}

Contract represents a function contract.

type ContractVal

type ContractVal string

ContractVal represents the possible value appearing in a function contract.

const (
	// NonNil has keyword "nonnil".
	NonNil ContractVal = "nonnil"
	// False has keyword "false".
	False ContractVal = "false"
	// True has keyword "true".
	True ContractVal = "true"
	// Any has keyword "_".
	Any ContractVal = "_"
)

type Contracts

type Contracts []Contract

Contracts represents the list of contracts for a function.

func (*Contracts) AFact

func (*Contracts) AFact()

AFact enables use of the facts passing mechanism in Go's analysis framework.

type Map

type Map map[*types.Func]Contracts

Map stores the mappings from *types.Func to associated function contracts.

Jump to

Keyboard shortcuts

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