model

package
v0.0.0-...-dc6f9f8 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2018 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const KoIndent = "\t" // used to be 3 spaces
View Source
const MainFlowLabel = "█"

MainFlowLabel is the label of the function field, carrying the “main” input flow. It is a symbol that cannot come from the syntactic path.

Variables

This section is empty.

Functions

func EqualPath

func EqualPath(p, q Path) bool

func FuncFullPath

func FuncFullPath(pkgPath, name string) string

func NearestSyntax

func NearestSyntax(span *Span) syntax.Syntax

func Uint64ToBytes

func Uint64ToBytes(u uint64) []byte

Types

type Augment

type Augment struct{}

Augment attaches to a lambda, in field <MainFlowLabel>, all other fields.

func (Augment) String

func (x Augment) String() string

type Chamber

type Chamber string

func (Chamber) SheathID

func (chamber Chamber) SheathID() *ID

func (Chamber) SheathLabel

func (chamber Chamber) SheathLabel() *string

func (Chamber) SheathString

func (chamber Chamber) SheathString() *string

type Enter

type Enter struct{}

func (Enter) String

func (x Enter) String() string

type Error

type Error struct {
	Span  *Span  `ko:"name=span"`
	File  string `ko:"name=file"` // file in compiler code, generating error
	Line  int    `ko:"name=line"` // line in compiler code, generating error
	Msg   string `ko:"name=msg"`
	Cause error  `ko:"name=cause"`
}

func NewSpanErrorf

func NewSpanErrorf(skip int, span *Span, cause error, format string, arg ...interface{}) *Error

func (*Error) Error

func (e *Error) Error() string

type Func

type Func struct {
	Doc  string `ko:"name=doc"`
	ID   ID     `ko:"name=id"`
	Name string `ko:"name=name"`
	Pkg  string `ko:"name=pkg"`
	// Slice of all steps in complete topological order, aligning with the gather relationship.
	// Equivalently, this is a reverse-time ordering of the steps.
	Step []*Step `ko:"name=step"`
	// Spread maps a step to its downstream users.
	Spread map[*Step][]*Step `ko:"name=spread"`
	// Enter points to a step included in Step.
	Enter *Step `ko:"name=enter"`
	// Field points to steps included in Step.
	Field map[string]*Step `ko:"name=field"`
	// Name of monadic argument (if not empty)
	Monadic string `ko:"name=monadic"`
	// Leave points to a step included in Step.
	Leave         *Step `ko:"name=leave"`
	syntax.Syntax `ko:"name=syntax"`
}

Func describes a circuit.

func NearestFunc

func NearestFunc(span *Span) *Func

func (*Func) Args

func (f *Func) Args() []string

func (*Func) BodyString

func (f *Func) BodyString() string

func (*Func) DocLong

func (f *Func) DocLong() string

func (*Func) DocShort

func (f *Func) DocShort() string

func (*Func) FullPath

func (f *Func) FullPath() string

func (*Func) FuncID

func (f *Func) FuncID() ID

func (*Func) IsGlobal

func (f *Func) IsGlobal() bool

IsGlobal returns true if Name starts with a capital letter non-underscore character.

func (*Func) SheathID

func (f *Func) SheathID() *ID

func (*Func) SheathLabel

func (f *Func) SheathLabel() *string

func (*Func) SheathString

func (f *Func) SheathString() *string

func (*Func) SortedFieldNames

func (f *Func) SortedFieldNames() []string

func (*Func) StepByLabel

func (f *Func) StepByLabel(label string) []*Step

func (*Func) String

func (f *Func) String() string

type Gather

type Gather struct {
	Field string `ko:"name=field"`
	// output of steps feed into this parameter
	Step *Step `ko:"name=step"`
}

Gather describes a link between two steps.

type Hypervisor

type Hypervisor interface{}

type ID

type ID struct {
	Data uint64 `ko:"name=data"`
}

func Blend

func Blend(id ...ID) ID

func BlendStrings

func BlendStrings(ss ...string) ID

func BytesID

func BytesID(b []byte) ID

func FuncID

func FuncID(pkgPath, name string) ID

func IDFromProtoData

func IDFromProtoData(d uint64) ID

func InterfaceID

func InterfaceID(v interface{}) ID

func PtrID

func PtrID(id ID) *ID

func StringID

func StringID(s string) ID

func ValueID

func ValueID(v reflect.Value) ID

func (ID) Format

func (id ID) Format(width int) string

func (ID) ProtoData

func (id ID) ProtoData() uint64

func (ID) String

func (id ID) String() string

type Invoke

type Invoke struct{}

Invoke invokes the lambda passed as field <MainFlowLabel>.

func (Invoke) String

func (x Invoke) String() string

type Leave

type Leave struct{}

func (Leave) String

func (x Leave) String() string
type Link struct {
	Name    string `ko:"name=name"`
	Monadic bool   `ko:"monadic=true"`
}

Field <MainFlowLabel> carries the function argument structure.

func (Link) String

func (x Link) String() string

type Logic

type Logic interface {
	String() string
}

Logics are designators of transformation logic. Logics are the types:

Enter{}, Leave{}, Number{}, Select{}, Augment{}, Invoke{}

Unresolved logics:

Operator{}, PkgFunc{}

type Number

type Number struct {
	// Value is one of: bool, LexString, LexInteger or LexFloat.
	Value interface{} `ko:"name=value"`
}

func (Number) String

func (x Number) String() string

type Operator

type Operator struct {
	Path []string `ko:"name=path"`
}

Operator is a logic described by a syntactic reference.

func (Operator) String

func (x Operator) String() string

type Outline

type Outline string

func (Outline) SheathID

func (outline Outline) SheathID() *ID

func (Outline) SheathLabel

func (outline Outline) SheathLabel() *string

func (Outline) SheathString

func (outline Outline) SheathString() *string

type Package

type Package map[string]*Func

Package is a collection of functions identified by name.

func (Package) BodyString

func (pkg Package) BodyString() string

func (Package) DocFunc

func (pkg Package) DocFunc(name string) (string, bool)

DocFunc returns the documentation for the function with given name in the given package. The returned boolean is true when the function is found or false otherwise.

func (Package) DocPackage

func (pkg Package) DocPackage() string

DocPackage returns the documentation of the given package.

func (Package) SortedFuncNames

func (pkg Package) SortedFuncNames() []string

SortedFuncNames returns a sort list of function names in the given package.

func (Package) String

func (pkg Package) String() string

func (Package) SweepSteps

func (pkg Package) SweepSteps(sweep func(*Step) error) error

type Path

type Path []string

func ChamberPath

func ChamberPath(span *Span) Path

func JoinPath

func JoinPath(path ...Path) Path

func (Path) Extend

func (p Path) Extend(q ...string) Path

func (Path) Reverse

func (p Path) Reverse() Path

func (Path) Slash

func (p Path) Slash() string

func (Path) String

func (p Path) String() string

type PkgFunc

type PkgFunc struct {
	Pkg  string `ko:"name=pkg"`
	Func string `ko:"name=func"`
}

PkgFunc is a placeholder logic describing a function, to be deferred, by package and name. Upon resolution, it is replaced by a Defer{*Func}.

func (PkgFunc) String

func (x PkgFunc) String() string

type Repo

type Repo map[string]Package

Repo captures the chain transform: package path -> function name -> function.

func CombineRepo

func CombineRepo(first, second Repo) Repo

CombineRepo creates a new Repo containing all packages from the given Repo's combined. If a package is contained in both Repo's, the package from the second repo wins.

func (Repo) BodyString

func (repo Repo) BodyString() string

func (Repo) DocFunc

func (repo Repo) DocFunc(pkgPath, funcName string) (string, bool)

DocFunc returns the documentation for the function with given name in the package with given name in the given repo. The returned boolean is true when the function is found or false otherwise.

func (Repo) DocPackage

func (repo Repo) DocPackage(pkgPath string) (string, bool)

DocPackage returns the documentation for the package with given name in the given repo. The returned boolean is true when the package is found or false otherwise.

func (Repo) Has

func (repo Repo) Has(pkg string) bool

Has returns true if the given package is contained in the given Repo or false otherwise.

func (Repo) Lookup

func (repo Repo) Lookup(pkg string, fu string) *Func

Lookup a function with given package name and given function name. Returns nil if not found.

func (Repo) PkgNames

func (repo Repo) PkgNames() []string

PkgNames returns all package names in the given Repo.

func (Repo) SortedPackagePaths

func (repo Repo) SortedPackagePaths() []string

SortedPackagePaths returns a sorted list of the names of all package contained in the given Repo.

func (Repo) Stats

func (repo Repo) Stats() *RepoStats

func (Repo) String

func (repo Repo) String() string

func (Repo) StringTable

func (repo Repo) StringTable(header string) [][]string

type RepoStats

type RepoStats struct {
	TotalFunc   int64
	TotalStep   int64
	StepPerFunc float64
}

type Select

type Select struct {
	Path []string `ko:"name=path"`
}

Field <MainFlowLabel> carries a value to select from.

func (Select) String

func (x Select) String() string

type Sheath

type Sheath interface {
	SheathID() *ID         // unique identifier
	SheathLabel() *string  // empty or a short identifier string (not necessarily uniquely-identifying)
	SheathString() *string // human-readable line ot text
}

Sheaths are *Func, *Step, MacroSheath, Outline, Chamber, *AssignCache, *GoWeavingCtx

type Span

type Span struct {
	Hypervisor Hypervisor `ko:"name=hypervisor"`
	ID         ID         `ko:"name=id"`
	Parent     *Span      `ko:"name=parent"`
	Sheath     Sheath     `ko:"name=sheath"`
}

func NewSpan

func NewSpan() *Span

func RefineChamber

func RefineChamber(span *Span, ch string) *Span

func RefineFunc

func RefineFunc(span *Span, f *Func) *Span

func RefineOutline

func RefineOutline(span *Span, outline string) *Span

func RefineStep

func RefineStep(span *Span, step *Step) *Span

func (*Span) Attach

func (span *Span) Attach(h Hypervisor) *Span

func (*Span) CommentLine

func (span *Span) CommentLine() string

func (*Span) Errorf

func (span *Span) Errorf(cause error, format string, arg ...interface{}) error

func (*Span) ErrorfSkip

func (span *Span) ErrorfSkip(skip int, cause error, format string, arg ...interface{}) error

func (*Span) Fatalf

func (span *Span) Fatalf(cause error, format string, arg ...interface{})

func (*Span) LabelPath

func (span *Span) LabelPath() Path

func (*Span) Panicf

func (span *Span) Panicf(cause error, format string, arg ...interface{})

func (*Span) Print

func (span *Span) Print(arg ...interface{})

func (*Span) Printf

func (span *Span) Printf(format string, arg ...interface{})

func (*Span) Refine

func (span *Span) Refine(sheath Sheath) *Span

func (*Span) SourceLine

func (span *Span) SourceLine() string

func (*Span) SpanID

func (span *Span) SpanID() ID

func (*Span) Splay

func (span *Span) Splay() tree.Tree

func (*Span) String

func (span *Span) String() string

func (*Span) Trajectory

func (span *Span) Trajectory() string

type Step

type Step struct {
	ID            ID        `ko:"name=id"`
	Label         string    `ko:"name=label"`
	Gather        []*Gather `ko:"name=gather"`
	Logic         Logic     `ko:"name=logic"`
	syntax.Syntax `ko:"name=syntax"`
	Func          *Func `ko:"name=func"` // backlink to func
}

Step describes a step in a circuit.

func NearestStep

func NearestStep(span *Span) *Step

func (*Step) Down

func (s *Step) Down() []kahnsort.Node

func (*Step) SheathID

func (s *Step) SheathID() *ID

func (*Step) SheathLabel

func (s *Step) SheathLabel() *string

func (*Step) SheathString

func (s *Step) SheathString() *string

func (*Step) StepID

func (s *Step) StepID() ID

func (*Step) String

func (s *Step) String() string

type Trajectory

type Trajectory []TrajectoryPoint

func (Trajectory) String

func (traj Trajectory) String() string

type TrajectoryPoint

type TrajectoryPoint struct {
	Span *Span `ko:"name=span"`
}

func (TrajectoryPoint) String

func (p TrajectoryPoint) String() string

Jump to

Keyboard shortcuts

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