printer

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2025 License: CC0-1.0 Imports: 4 Imported by: 0

Documentation

Overview

Package printer outputs WGSL code from an AST.

The printer can operate in two modes: - Pretty: Human-readable output with indentation - Minified: Minimal whitespace output

Following the esbuild pattern, minification decisions are made during printing rather than as a separate AST transformation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	// MinifyWhitespace removes unnecessary whitespace
	MinifyWhitespace bool

	// MinifyIdentifiers uses short names for identifiers
	MinifyIdentifiers bool

	// MinifySyntax applies syntax-level optimizations
	MinifySyntax bool

	// TreeShaking enables dead code elimination (skip dead declarations)
	TreeShaking bool

	// Renamer provides minified names (nil for no renaming)
	Renamer Renamer

	// SourceMapGen is the source map generator (nil to disable)
	SourceMapGen *sourcemap.Generator
}

Options controls printer output.

type Printer

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

Printer outputs WGSL code.

func New

func New(options Options, symbols []ast.Symbol) *Printer

New creates a new printer.

func (*Printer) Print

func (p *Printer) Print(module *ast.Module) string

Print outputs the module as a string.

type Renamer

type Renamer interface {
	NameForSymbol(ref ast.Ref) string
}

Renamer provides minified names for symbols.

Jump to

Keyboard shortcuts

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