hfir

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const DiagnosticContractVersion = "v1"

DiagnosticContractVersion versions the diagnostic wire format. This is independent of Graph.Version, which versions the graph schema instead — the two happen to both start at "v1" but track different things.

View Source
const TargetBytecode = "bytecode"

TargetBytecode is the verifier target identity for the standalone bytecode runtime. howlframe.go's hfirTargetBytecode must spell it the same way; the two are tied together by TestVerifyConstructsMatchesBytecodeTargetName.

Variables

This section is empty.

Functions

This section is empty.

Types

type DataEdge

type DataEdge struct {
	Name       string       `json:"name,omitempty"`
	SourceNode NodeID       `json:"source_node,omitempty"`
	Type       ast.TypeInfo `json:"type,omitempty"`
}

type Diagnostic

type Diagnostic struct {
	Code            string     `json:"code"`
	Severity        Severity   `json:"severity"`
	Message         string     `json:"message"`
	Location        Provenance `json:"location"`
	RelatedNode     NodeID     `json:"related_node,omitempty"`
	ContractVersion string     `json:"contract_version"`
	Target          string     `json:"target,omitempty"`
}

func VerifyConstructs

func VerifyConstructs(root *ast.Node, target string) []Diagnostic

VerifyConstructs reports every construct in root that the given target cannot execute, as HFIR_TARGET_INFEASIBLE diagnostics in source order.

This deliberately runs over the AST rather than over Graph node kinds. LowerAST derives a node's Kind from the head symbol of every list, including lists that are not constructs at all - a (let (x 0) body) binding lowers to a node with Kind "x", and a try_let's catch clause lowers to a node with Kind "catch" even though internal/bytecode's try_let case destructures it directly and it never reaches compileNode in head position. A rule matching on Kind would therefore reject correct programs. internal/construct's Scan keeps the parent and child position the AST still carries, so the classification is exact (bugs.md #45).

Only the bytecode target has construct-support rules today. Every other target identity - including the empty target used by -validate, which is target-independent by contract - returns no diagnostics.

type Effect

type Effect struct {
	Type       string `json:"type"`
	Capability string `json:"capability,omitempty"`
}

type Graph

type Graph struct {
	Version   string  `json:"version"`
	Nodes     []*Node `json:"nodes"`
	EntryNode NodeID  `json:"entry_node,omitempty"`
	// contains filtered or unexported fields
}

func LowerAST

func LowerAST(root *ast.Node, module string) (*Graph, error)

func NewGraph

func NewGraph() *Graph

func (*Graph) AddNode

func (g *Graph) AddNode(n *Node) NodeID

func (*Graph) Serialize

func (g *Graph) Serialize() ([]byte, error)

type LoweringContext

type LoweringContext struct {
	Graph  *Graph
	Module string
}

type Node

type Node struct {
	ID           NodeID       `json:"id"`
	Kind         string       `json:"kind"`
	Module       string       `json:"module,omitempty"`
	Provenance   Provenance   `json:"provenance"`
	DataInputs   []DataEdge   `json:"data_inputs,omitempty"`
	ControlEdges []NodeID     `json:"control_edges,omitempty"`
	Effects      []Effect     `json:"effects,omitempty"`
	Type         ast.TypeInfo `json:"type"`
	Value        string       `json:"value,omitempty"`
}

type NodeID

type NodeID string

type Provenance

type Provenance struct {
	Filename string `json:"filename"`
	Line     int    `json:"line"`
	Column   int    `json:"column"`
}

type Severity

type Severity string
const (
	SeverityError   Severity = "ERROR"
	SeverityWarning Severity = "WARNING"
	SeverityInfo    Severity = "INFO"
)

type Verifier

type Verifier struct {
	Graph       *Graph
	Diagnostics []Diagnostic
	Target      string
}

func NewVerifier

func NewVerifier(g *Graph, target string) *Verifier

func (*Verifier) Verify

func (v *Verifier) Verify() []Diagnostic

Jump to

Keyboard shortcuts

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