transform

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package transform implements AST source-to-source transformation that automatically threads cleat.HostCalls through the cleat closure.

Developers declare a package-level var h *cleat.HostCalls. Functions in the closure that reference this global get h inserted as a first parameter; call sites are updated to pass h through.

Key types:

  • Config — transformation inputs (analysis, call graph, closure result)
  • Result — transformed files and metadata

Key functions:

  • Run — applies the transformation to the analyzed packages

Package transform implements AST source-to-source transformation that automatically threads cleat.HostCalls through the cleat closure.

Developers declare a package-level var h *cleat.HostCalls (the "context object" pattern). Functions in the cleat closure that reference this global get h inserted as a first parameter. Call sites are updated to pass h through. The global is removed when no longer referenced.

Entry points still declare h as a first parameter — the transform primarily helps with internal helper functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Result    *analyzer.AnalysisResult
	CallGraph *callgraph.Graph
	Closure   *closure.Result
}

Config holds the inputs for the transformation.

type Result

type Result struct {
	Files  map[string][]byte // filename → transformed Go source
	AddedH []string          // fully-qualified names of functions that got h added
	Diffs  []string          // unified diffs of transformed files, computed when requested
}

Result holds the output of the transformation pass.

func Transform

func Transform(cfg *Config) (*Result, error)

Transform modifies ASTs to automatically thread cleat.HostCalls.

Jump to

Keyboard shortcuts

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