generator

package
v0.6.4 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssignmentToString

func AssignmentToString(f *model.Function, a model.Assignment) string

AssignmentToString returns the string representation of the assignment.

Types

type Generator

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

Generator represents a code generator.

func NewGenerator

func NewGenerator(code model.Code) *Generator

NewGenerator creates a new generator with the given code.

func (*Generator) FuncToString

func (g *Generator) FuncToString(f *model.Function) string

FuncToString generates the string representation of a given Function. The generated string can be used to represent the Function as Go code. The function generates a doc comment (if any), the function signature, the variable declarations (if any), the assignment statements, and the return statement. The function uses ManipulatorToString to generate the string representation of manipulators.

func (*Generator) Generate

func (g *Generator) Generate(outPath string, output, dryRun bool) ([]byte, error)

Generate generates the code into a file with the given path. It returns the generated code as a byte slice.

func (*Generator) ManipulatorToString

func (g *Generator) ManipulatorToString(m *model.Manipulator, src, dst model.Var) string

ManipulatorToString returns a string representation of the given Manipulator. It generates a function call that performs the manipulation and returns the result as a string. Parameters: - m: the Manipulator to be converted into a string representation. - src: the source Var that corresponds to the Manipulator's first argument. - dst: the destination Var that corresponds to the Manipulator's second argument. Returns: - a string that represents the function call to the Manipulator.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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