Skip to content

v2.transformer #

fn Transformer.new #

fn Transformer.new(files []ast.File, env &types.Environment) &Transformer

struct Transformer #

struct Transformer {
	env &types.Environment
mut:
	flag_enum_names map[string]bool
	// Track variable -> enum type mappings (inferred from assignments)
	var_enum_types map[string]string
	// Track function parameter -> type name mappings
	param_types map[string]string
	// Track variable -> type mappings for string detection
	var_types map[string]string
	// Track function return types
	fn_return_types map[string]string
	// Current module for scope lookups
	cur_module string
}

Transformer performs AST-level transformations to simplify and normalize code before codegen. This avoids duplicating transformation logic across multiple backends (SSA, cleanc, etc.)

fn (Transformer) transform_files #

fn (mut t Transformer) transform_files(files []ast.File) []ast.File

transform_files transforms all files and returns transformed copies