fmla

package
v0.0.0-...-3948e75 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2020 License: BSD-3-Clause Imports: 24 Imported by: 0

Documentation

Overview

Package fmla generates functions from formulae.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Package

func Package(cfg Config) (gen.Files, error)

func ParametersVariableNames

func ParametersVariableNames(params ...Parameter) []ast.Variable

ParametersVariableNames gathers all variable names for the given list of parameters.

func ParametersVariables

func ParametersVariables(params ...Parameter) map[ast.Variable]Variable

ParametersVariables gathers variables for the given list of parameters.

Types

type Action

type Action uint8

Action specifies the read/write operation of a function parameter.

const (
	R  Action = 0x1
	W  Action = 0x2
	RW Action = R | W
)

Possible Action types.

func (Action) Contains

func (a Action) Contains(s Action) bool

Contains reports whether a supports all actions in s.

type Asm

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

func NewAsm

func NewAsm(cfg fp.Config) *Asm

func (*Asm) Context

func (a *Asm) Context() *build.Context

func (*Asm) Function

func (a *Asm) Function(name string, p *ast.Program, outputs []ast.Variable) error

func (*Asm) Lookup

func (a *Asm) Lookup(name string, repr Representation)

type AsmFunction

type AsmFunction struct {
	Function

	// AsmName is the name of the assembly function implementing the formula.
	// Typically this will be unexported.
	AsmName string
}

AsmFunction is a Function implemented in assembly under the hood.

func NewAsmFunctionDefault

func NewAsmFunctionDefault(f Function) AsmFunction

type Component

type Component interface {
	// contains filtered or unexported methods
}

type Config

type Config struct {
	PackageName string
	Field       fp.Config
	Components  []Component
}

type Constant

type Constant struct {
	VariableName string
	ElementType  types.Type
	Value        *big.Int
}

func (Constant) Action

func (c Constant) Action() Action

func (Constant) AliasSets

func (c Constant) AliasSets(p Parameter) [][]ast.Variable

func (Constant) Name

func (c Constant) Name() string

func (Constant) Type

func (c Constant) Type() types.Type

func (Constant) Variables

func (c Constant) Variables() map[ast.Variable]Variable

type Function

type Function struct {
	Name     string
	Receiver Parameter
	Params   []Parameter
	Results  []Parameter
	Globals  []Parameter
	Formula  *ast.Program
}

func (Function) AliasSets

func (f Function) AliasSets() [][]ast.Variable

AliasSets returns groups of variable names with a may-alias relationship, meaning there is a possibility they are pointers to the same memory locations.

func (*Function) HasResults

func (f *Function) HasResults() bool

HasResults reports whether f has return values.

func (Function) Inputs

func (f Function) Inputs() []Parameter

Inputs returns all read parameters.

func (*Function) IsVoid

func (f *Function) IsVoid() bool

IsVoid reports whether f is void. That is, it returns true if the function has no return values.

func (Function) Outputs

func (f Function) Outputs() []Parameter

Outputs returns all write parameters.

func (Function) Parameters

func (f Function) Parameters() []Parameter

Parameters returns all parameters.

func (Function) ParametersWithAction

func (f Function) ParametersWithAction(a Action) []Parameter

ParametersWithAction returns all parameters supporting action a.

func (Function) Program

func (f Function) Program() (*ast.Program, error)

Program returns the program to be implemented by this function.

func (Function) Symbols

func (f Function) Symbols() map[string]bool

Symbols returns the set of names defined by the function parameters.

func (Function) Variables

func (f Function) Variables() map[ast.Variable]Variable

Variables builds a map from program variable names to the Go code that references their corresponding function parameters.

type Lookup

type Lookup struct {
	Name string
	Repr Representation
}

Lookup is a table lookup function for a given point representation.

type Parameter

type Parameter interface {
	Name() string
	Action() Action
	Type() types.Type
	Variables() map[ast.Variable]Variable
	AliasSets(Parameter) [][]ast.Variable
}

func Condition

func Condition(name string, a Action) Parameter

Condition returns a condition variable parameter.

func Point

func Point(name string, a Action, r Representation, indicies ...int) Parameter

func Pointer

func Pointer(name string, a Action, t types.Type) Parameter

Pointer represents a parameter passed as a pointer.

func Value

func Value(name string, a Action, t types.Type) Parameter

Value returns a basic parameter passed by value.

type Representation

type Representation struct {
	Name        string
	ElementType types.Type
	Coordinates []string
}

func (Representation) Equals

func (r Representation) Equals(other Representation) bool

func (Representation) Type

func (r Representation) Type() types.Type

type Variable

type Variable interface {
	Pointer() string
	Value() string
}

Jump to

Keyboard shortcuts

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