transpiler

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package transpiler walks a parsed Go AST and emits SimplicityHL source code.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Constant

type Constant struct {
	Name  string
	Type  string
	Value string
}

Constant represents a Go const declaration mapped to a param module entry.

type EitherFieldInfo added in v0.1.1

type EitherFieldInfo struct {
	LeftFieldNames []string // snake_case names of left branch fields
	LeftType       string   // combined left type (tuple if multiple)
	RightFieldName string   // snake_case name of right branch field
	RightType      string   // right branch type
}

EitherFieldInfo tracks field names for Either struct types

type Function

type Function struct {
	Name       string
	Parameters []Parameter
	ReturnType string
	Body       string
}

Function represents a user-defined helper function.

type JetCall added in v0.1.1

type JetCall struct {
	VarName    string // Variable name being assigned (empty if inline)
	JetName    string // Simplicity jet name
	Args       string // Comma-separated arguments
	ReturnType string // Return type from jet registry
	IsWitness  bool   // True if argument should come from witness
}

JetCall represents a jet function call in the code.

type MatchCase added in v0.1.1

type MatchCase struct {
	Pattern   string   // "Left", "Right", "Some", "None"
	VarName   string   // The variable name bound in the case
	VarType   string   // The type of the bound variable
	BodyStmts []string // Statements in the case body
}

MatchCase represents a single case in a type switch or match expression

type MatchExpression added in v0.1.1

type MatchExpression struct {
	Scrutinee     string      // The expression being matched
	ScrutineeType string      // The type of the scrutinee (e.g., "Either<u256, [u8; 64]>")
	Cases         []MatchCase // The cases
	IsBoolMatch   bool        // true for boolean if/else (true/false patterns)
}

MatchExpression represents a complete match/type-switch

type Parameter

type Parameter struct {
	Name string
	Type string
}

Parameter represents a function parameter.

type Transpiler

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

Transpiler converts Go AST to SimplicityHL.

func New

func New() *Transpiler

New creates a new transpiler instance

func (*Transpiler) ToSimplicityHL

func (t *Transpiler) ToSimplicityHL(file *ast.File) (string, error)

ToSimplicityHL transpiles Go AST to SimplicityHL code.

type UnrolledLoop added in v0.1.1

type UnrolledLoop struct {
	IndexVar   string
	Iterations int
	BodyStmts  [][]string // Body statements for each iteration
}

UnrolledLoop represents a for loop that has been unrolled

type WitnessValue

type WitnessValue struct {
	Name       string
	Type       string
	Value      string
	GoTypeName string // Original Go struct type name, for Either field lookup
}

WitnessValue represents a witness variable declaration.

Jump to

Keyboard shortcuts

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