ast

package
v0.0.0-...-a011eca Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2022 License: BSD-3-Clause, GPL-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AllDeps  = iota // Follow all AST edges
	DataDeps        // Follow only consumer-producer edges
)

Options for computing dependencies

Variables

This section is empty.

Functions

func Deps

func Deps(roots []Node) graph.Graph

Deps constructs the data dependencies between a set of commands.

Types

type Bundle

type Bundle struct {
	From []Node
}

A Bundle is an unordered collection of expressions

func (*Bundle) NodeString

func (a *Bundle) NodeString() string

NodeString implements graph pretty printing

type Command

type Command struct {
	From    []Node      // Inputs
	Request Request     // Requirements for device selection
	Inst    interface{} // Command-specific data
	Output  []Inst      // Output from compilation
}

A Command is high-level instruction. Both UseComp and Bundles are currently issued only by the ast, maker, and codegen areas of code. Command is different: the instruction trace is populated by commandInst objects, each of which contain a Command object. However, at that stage some of the fields of Command are not correctly populated, and so these are modified by the maker at the same point at which UseComp objects are issued.

func FindReachingCommands

func FindReachingCommands(nodes []Node) []*Command

FindReachingCommands returns the set of commands that have a path to the given nodes without any intervening commands.

func (*Command) NodeString

func (a *Command) NodeString() string

NodeString implements graph pretty printing

type Device

type Device interface {
	CanCompile(Request) bool // Can this device compile this request

	// Compile produces a single-entry, single-exit DAG of instructions where
	// insts[0] is the entry point and insts[len(insts)-1] is the exit point
	Compile(ctx context.Context, cmds []Node) (insts []Inst, err error)
}

A Device is a scheduling plugin

type Graph

type Graph struct {
	Nodes []Node
	// contains filtered or unexported fields
}

A Graph is a view of the AST as a graph

func ToGraph

func ToGraph(opt ToGraphOpt) *Graph

ToGraph creates a graph from a list of roots. Include any referenced ast nodes in the resulting graph.

func (*Graph) Node

func (a *Graph) Node(i int) graph.Node

Node implements a Graph

func (*Graph) NumNodes

func (a *Graph) NumNodes() int

NumNodes implements a Graph

func (*Graph) NumOuts

func (a *Graph) NumOuts(n graph.Node) int

NumOuts implements a Graph

func (*Graph) Out

func (a *Graph) Out(n graph.Node, i int) graph.Node

Out implements a Graph

func (*Graph) SetOut

func (a *Graph) SetOut(n Node, i int, x Node)

SetOut updates the ith output of node n

type IncubateInst

type IncubateInst struct {
	// Time for which to incubate component
	Time wunit.Time
	// Temperature at which to incubate component
	Temp wunit.Temperature
	// Rate at which to shake incubator (force is device dependent)
	ShakeRate wunit.Rate
	// Radius at which ShakeRate is defined
	ShakeRadius wunit.Length

	// Time for which to pre-heat incubator
	PreTemp wunit.Temperature
	// Temperature at which to pre-heat incubator
	PreTime wunit.Time
	// Rate at which to pre-heat incubator
	PreShakeRate wunit.Rate
	// Radius at which PreShakeRate is defined
	PreShakeRadius wunit.Length
}

An IncubateInst is a high-level command to incubate a component

type Inst

type Inst interface {
	// Device that this instruction was generated for
	Device() Device
	// DependsOn returns instructions that this instruction depends on
	DependsOn() []Inst
	// SetDependsOn sets to the list of dependencies to only the args
	SetDependsOn(...Inst)
	// AppendDependsOn adds to the args to the existing list of dependencies
	AppendDependsOn(...Inst)
}

An Inst is a instruction

type Insts

type Insts []Inst

func (Insts) SequentialOrder

func (insts Insts) SequentialOrder()

SequentialOrder takes a slice of instructions and modifies them in-place, resetting to sequential dependencies.

type Location

type Location interface{}

A Location is a physical place

type NameValue

type NameValue struct {
	Name  string
	Value string
}

A NameValue is a name-value pair

type Node

type Node interface {
	graph.Node
	NodeString() string
}

A Node is the input to code generation. An abstract syntax tree generated via execution of an Antha protocol.

The basic design philosophy is to capture the semantics of the Antha language while reducing the cases for code generation. A secondary goal is to ease the creation of the AST at runtime (e.g., online, incremental generation of nodes).

Conveniently, a tree naturally expresses the single-use (i.e., destructive update) aspect of physical things, so the code generation keeps this representation longer than a traditional compiler flow would.

type PromptInst

type PromptInst struct {
	Message string
}

A PromptInst is a high-level command to prompt a human

type QPCRInstruction

type QPCRInstruction struct {
	ID           string
	ComponentIn  []*wtype.Liquid
	ComponentOut []*wtype.Liquid
	Definition   string
	Barcode      string
	Command      string
	TagAs        string
}

QPCRInstruction is a high-level instruction to perform a QPCR analysis.

func NewQPCRInstruction

func NewQPCRInstruction() *QPCRInstruction

NewQPCRInstruction creates a new QPCRInstruction

func (QPCRInstruction) String

func (ins QPCRInstruction) String() string

type Request

type Request struct {
	Selector []NameValue
}

A Request is set of required device capabilities

func Meet

func Meet(reqs ...Request) (req Request)

Meet computes greatest lower bound of a set of requests

func (Request) Contains

func (reqA Request) Contains(reqB Request) bool

Contains returns if request A is greater than or equal to request B

type ToGraphOpt

type ToGraphOpt struct {
	Roots     []Node // Roots of program
	WhichDeps int    // Edges to follow when building graph
}

A ToGraphOpt are options for ToGraph

type UseComp

type UseComp struct {
	From  []Node
	Value *wtype.Liquid
}

A UseComp is a use of a liquid component

func (*UseComp) NodeString

func (a *UseComp) NodeString() string

NodeString implements graph pretty printing

Jump to

Keyboard shortcuts

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