lower

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: Apache-2.0 Imports: 17 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package lower provides AST → execution IR lowering. Converts declarative members (TransitionMember, EntryMember) to operational graphs (nodes + edges) that executors consume.

Index

Constants

View Source
const (
	EntryTransitionAccepterSourceMessage = "A transition with an accepter must have a state as its source. " +
		"(SysML v2; pilot validateTransitionUsageTriggerActions)"
	EntryTransitionShorthandEffectMessage = "a shorthand transition out of an entry action may carry a guard at most; " +
		"write `entry action boot; transition boot do action mark then s;` to give the transition an explicit source " +
		"(SysML v2 7.18.3 EntryTransitionMember)"
)
View Source
const (
	ProbabilityFQN     = semantics.ProbabilityFQN
	ProbabilityFeature = semantics.ProbabilityFeature
)

ProbabilityFQN names the OpenSysML metadata type by which a model weights the successions out of a decision node; ProbabilityFeature is the weight it binds.

View Source
const (
	ContinuousDynamicsFQN = "StateSpaceRepresentation::ContinuousStateSpaceDynamics"
	DiscreteDynamicsFQN   = "StateSpaceRepresentation::DiscreteStateSpaceDynamics"
	ZeroCrossingEventFQN  = "StateSpaceRepresentation::ZeroCrossingEventDef"
	IntegrateFQN          = "StateSpaceRepresentation::Integrate"
	EulerFQN              = "StateSpaceIntegration::Euler"
	RK4FQN                = "StateSpaceIntegration::RK4"
	FixedStepDynamicsFQN  = "StateSpaceIntegration::FixedStepDynamics"
)

The library declarations state-space dynamics are lowered against, by qualified name.

View Source
const (
	StateSpaceFeature = "stateSpace"
	InputFeature      = "input"
	OutputFeature     = "output"
	TimeStepFeature   = "timeStep"
	StopTimeFeature   = "stopTime"
	TimeFeature       = "time"
	GuardFeature      = "guard"
	TerminalFeature   = "terminal"
	GetDerivativeCalc = "getDerivative"
	GetDifferenceCalc = "getDifference"
	GetOutputCalc     = "getOutput"
	GetNextStateCalc  = "getNextState"
	IntegrateCalc     = "integrate"
)

The protocol's member names, as StateSpaceRepresentation declares them.

View Source
const (
	// StepMultiplicityNotFixedCode identifies a step that has no exact finite count.
	StepMultiplicityNotFixedCode = "action-step-multiplicity-not-fixed"
	// StepMultiplicityUnsupportedCode identifies a repeated step with unsupported links.
	StepMultiplicityUnsupportedCode = "action-step-multiplicity-unsupported"
	// StepOrderUnsatisfiableCode identifies succession multiplicities that exclude a step count.
	StepOrderUnsatisfiableCode = "action-step-order-unsatisfiable"
	// StepOrderOpenCode identifies a succession that does not establish repeated-step ordering.
	StepOrderOpenCode = "action-step-order-open"
)
View Source
const EntryTransitionTargetFormat = "transition out of the entry action reaches %s, " +
	"which is not a state or junction/choice route the body can start in (SysML v2 7.18.3)"

EntryTransitionTargetFormat reports a transition out of the entry action whose target is a vertex the body cannot start in.

View Source
const NoTransitionSourceMessage = "transition without a source has no member before it to leave: " +
	"it leaves the state declared before it in the same body (SysML v2 7.18.3), and none precedes it"

NoTransitionSourceMessage reports the sourceless shorthand with no member before it to leave, shared by the check reporting it and the lowering backstopping it.

View Source
const NotAVertexFormat = "transition endpoint %s names a %s that is not a vertex of this state machine"

NotAVertexFormat reports an endpoint naming an element outside the machine's vertices, shared by the check reporting it and the lowering backstopping it.

View Source
const ProbabilityTolerance = 1e-6

ProbabilityTolerance is how far the constant weights out of one decision may sum from 1.0 and still be taken as summing to it.

View Source
const StateActionFQN = "States::StateAction"

StateActionFQN names the library state every state specializes, whose content (self, substates, transitions) a consumer of the graph carries natively.

View Source
const TransitionSourceMarkerFormat = transitionSourceLeavesFormat +
	"which is not a state of this state machine (SysML v2 7.18.3): write `transition first <state> … then …;` to leave one"

TransitionSourceMarkerFormat reports the shorthand whose nearest preceding member is a `first start then s;` succession or a `done;` marker, not a state.

View Source
const TransitionSourceNotVertexFormat = transitionSourceLeavesFormat +
	"which is not a state of this state machine (SysML v2 7.18.3)"

TransitionSourceNotVertexFormat reports the shorthand whose nearest preceding member is not a state, shared the same way.

View Source
const TransitionSourcePseudostateFormat = transitionSourceLeavesFormat +
	"which is a pseudostate rather than a state (SysML v2 7.18.3): write `transition first %s … then …;` to leave it"

TransitionSourcePseudostateFormat reports the shorthand whose nearest preceding member is a pseudostate, which only a transition naming it as `first` leaves.

View Source
const TransitionSourceRegionFormat = transitionSourceLeavesFormat +
	"which is an orthogonal region of a parallel state rather than a state of this state machine (SysML v2 7.18.3)"

TransitionSourceRegionFormat reports the shorthand whose nearest preceding member is an orthogonal region of a parallel state, which no transition leaves.

Variables

View Source
var (
	ErrCyclicSpecialization      = errors.New("action specializes itself")
	ErrRedefinedStepMissing      = errors.New("redefined action step not found")
	ErrIncompatibleRedefinedStep = errors.New("redefining feature is not an action step")
	ErrAmbiguousInheritedStep    = errors.New("inherited succession reaches more than one redefining step")
	// ErrSuccessionEndNotPerformed is a succession end chaining to an occurrence the flow does not perform.
	ErrSuccessionEndNotPerformed = errors.New("succession end reaches an occurrence that is not an action, which no step of the flow performs")
)
View Source
var (
	// ErrNoSequence is an occurrence whose body holds neither a lifeline with an
	// event occurrence nor a use of a nested interaction.
	ErrNoSequence = errors.New("no lifeline of the occurrence holds an event occurrence")
	// ErrMessageEndUnowned is a message end naming no event occurrence of a lifeline.
	ErrMessageEndUnowned = errors.New("message end names no event occurrence of a lifeline")
	// ErrSequenceCycle is a set of orders no realization order satisfies.
	ErrSequenceCycle = errors.New("the orders between the events form a cycle")
)
View Source
var ErrNoTransitionSource = errors.New(NoTransitionSourceMessage)

ErrNoTransitionSource marks a transition written without a source that no member precedes in its body.

View Source
var ErrProbability = errors.New("invalid Probability metadata")

ErrProbability is the typed error every ill-formed use of Probability wraps.

View Source
var ErrRecursiveStateTyping = errors.New("recursive state typing")

ErrRecursiveStateTyping reports a state definition whose content contains a state typed by that same definition, which has no finite materialization.

View Source
var ErrUnsupportedStateContent = errors.New("unsupported state machine content")

ErrUnsupportedStateContent reports content of a state machine that lowering cannot represent, rather than dropping it.

View Source
var ErrUnsupportedStateSpace = errors.New("unsupported state-space dynamics")

ErrUnsupportedStateSpace reports a state-space action whose shape the runner cannot execute: a protocol member it does not provide, or one it cannot integrate.

Functions

func AcceptedNames

func AcceptedNames(trigger ast.Node) []string

AcceptedNames lists the names a classified trigger binds when it fires: the payload an accept declares, or a call trigger's parameters, in order.

func ActionEndpointAccepted

func ActionEndpointAccepted(nodes []ast.Node, hasInitial bool, ref ast.Node, source bool) bool

ActionEndpointAccepted reports whether an action endpoint names a lowered node or one of the implicit start/done markers.

func ActionNodes

func ActionNodes(actionDecl ast.Node, scope *symbols.Scope) (nodes []ast.Node, hasInitial bool, err error)

ActionNodes returns the nodes accepted by action lowering and whether the action has an initial node after interpreting `first <node>`.

func BehaviorMembers

func BehaviorMembers(decl ast.Node) ([]ast.Node, error)

BehaviorMembers are the members of a behavior declaration, and an error for a node that declares no behavior.

func BehaviorOrderHasExecutableEnd added in v0.10.0

func BehaviorOrderHasExecutableEnd(model *semantics.Model, order BehaviorOrder) bool

BehaviorOrderHasExecutableEnd reports whether an order can name an object behavior.

func BlockNodes

func BlockNodes(stmts []Statement) []ast.Node

BlockNodes returns the action nodes the blocks among stmts declare, in declaration order: the nodes a body's performance runs as subperformances.

func BodyDivides added in v0.10.0

func BodyDivides(graph *ActionGraph, node ast.Node) bool

BodyDivides reports whether another performance interleaving inside node's performance may change an outcome: two or more of the body's moves depend on a move another performance may make concurrently. With one such move at most, every interleaving reorders only independent moves, so the body runs as one move.

func BodySharesMoves added in v0.10.0

func BodySharesMoves(graph *ActionGraph, node ast.Node) bool

BodySharesMoves reports whether two or more of node's moves may touch what another performance does: alongside moves outside its flow, such a body may be divided by one.

func BodyStatementMembers

func BodyStatementMembers(members []ast.Node) []ast.Node

BodyStatementMembers returns the members of a node body that state work to perform, in declaration order: what a body declares (a parameter, a doc comment) is a feature of the node, not a step of the flow through it.

func CalcBodyWithOrder added in v0.10.0

func CalcBodyWithOrder(owner ast.Node, members []ast.Node, scope *symbols.Scope, resolver *resolve.Resolver, exprs *ExprTable) ([]Statement, *StatementOrder)

CalcBodyWithOrder lowers the body in declaration order with its statement order, results after the steps; one stating a token flow is lowered as a case body is (caseSteps).

func CalcChain added in v0.13.0

func CalcChain(sym *symbols.Symbol, env CalcEnv) []*symbols.Symbol

CalcChain returns the calcs sym takes members from, most general first, then sym; non-calc links and the library's frame contribute nothing, a domain library's calc does.

func CalcKind added in v0.13.0

func CalcKind(sym *symbols.Symbol) string

CalcKind names what sym declares — a calc, an analysis case or a verification case — as diagnostics refer to it.

func CalcStatesComputation added in v0.13.0

func CalcStatesComputation(chain []*symbols.Symbol, env CalcEnv) bool

CalcStatesComputation reports whether a calc chain states a computation: a body that returns or assigns an output, or a binding of the result.

func CarriesObjects added in v0.10.0

func CarriesObjects(node ast.Node) bool

CarriesObjects reports whether node is a control node object flows pass through, by the features it declares: a fork, a join or a merge.

func CaseFlowStart

func CaseFlowStart(graph *ActionGraph) (ast.Node, error)

CaseFlowStart finds the step a flow starts at where no `first` or start node states one: the single step no succession leads to that the flow performs (performedStep). Two such steps leave the start unstated, and none is a cycle; either is reported.

func CheckBehaviorOrderMultiplicity added in v0.10.0

func CheckBehaviorOrderMultiplicity(scope *symbols.Scope, earlier, later ast.Node, earlierMultiplicity, laterMultiplicity *ast.Multiplicity, decl ast.Node, model *semantics.Model) error

CheckBehaviorOrderMultiplicity applies the action-step succession rule at one performance per end.

func ConstraintBodyWithOrder added in v0.10.0

func ConstraintBodyWithOrder(scope *symbols.Scope, members []ast.Node, stmts []Statement) ([]Statement, *StatementOrder)

ConstraintBodyWithOrder returns a constraint body's statements with its successions between statements recorded as precedence.

func DeclaresNodeFeature

func DeclaresNodeFeature(m *ast.Usage) bool

DeclaresNodeFeature reports whether an action member is a parameter or attribute.

func DefaultValueOf added in v0.13.0

func DefaultValueOf(featureSym *symbols.Symbol) ast.Node

DefaultValueOf is the value a feature's declaration binds: a usage's value, a subject's binding or an owned constraint's; nil for none.

func DescribeMember

func DescribeMember(member ast.Node) string

DescribeMember names a state machine member in modelling terms, for a message about content that cannot be lowered where it was written.

func EachUnwrappedDeclMember added in v0.13.0

func EachUnwrappedDeclMember(decl ast.Node) iter.Seq[ast.Node]

EachUnwrappedDeclMember yields what UnwrappedDeclMembers lists without building the list.

func EndpointRef

func EndpointRef(target ast.Node) ast.Node

EndpointRef is the node a connector end names a vertex with: a qualified name or a feature chain, unwrapped from a feature reference; nil for anything else.

func EndpointText

func EndpointText(target ast.Node) string

EndpointText renders an endpoint as written (`c::c1`, `c.c1`), for a message about it.

func ExpressionReader added in v0.13.0

func ExpressionReader(parse func(origin, text string) (ast.Node, bool), resolver *resolve.Resolver) func(origin, text string, scope *symbols.Scope) (*ExprTable, program.ExprID, bool)

ExpressionReader is parse followed by lowering in the scope the text is read in: what a frontend installs on a runtime model, which neither parses nor lowers.

func FeaturePath

func FeaturePath(node ast.Node) string

FeaturePath renders the feature a node names as a dotted path, so a nested port keeps every segment it was written with. It returns "" for a node that names no feature.

func FlowSharesMoves added in v0.10.0

func FlowSharesMoves(graph *ActionGraph) bool

FlowSharesMoves reports whether two or more moves of a performance of graph's flow, its start shot and its subflows' moves included, may touch what another performance does; the attributes and in parameters the performance holds its own values of are not shared.

func FlowStartError added in v0.10.0

func FlowStartError(graph *ActionGraph) error

FlowStartError reports a flow stating steps that nothing can start: one whose successions form a cycle over every step, so no step is unpreceded. A flow with a start, one stating no step, and one whose only unpreceded steps are not composite subactions (`ref` and `perform` usages, control nodes, which are performed only where a succession reaches them) have none.

func GatedFlowAccepted added in v0.10.0

func GatedFlowAccepted(nodes []ast.Node, sourceRef ast.Node, flow *ast.Usage) bool

GatedFlowAccepted reports whether a succession from sourceRef may lead to flow: a succession flow leaving the node sourceRef names, whose delivery the succession gates.

func ImplicitSource

func ImplicitSource(members []ast.Node, transition *ast.TransitionMember) (ast.Node, error)

ImplicitSource returns the body member a transition written without a source leaves, or ErrNoTransitionSource when no member precedes it in members.

func InstantDelay added in v0.10.0

func InstantDelay(trigger ast.Node) (*ast.TimeEvent, bool)

InstantDelay is the time event of an accept or transition trigger that may end the instant: a relative delay written as a number, with or without a unit.

func IsCalcDecl added in v0.13.0

func IsCalcDecl(decl ast.Node) bool

IsCalcDecl reports whether a declaration is a calc definition or usage, or an analysis or verification case, each a calculation (SysML v2 §7.22, §7.23).

func IsCalcUsageSymbol added in v0.13.0

func IsCalcUsageSymbol(sym *symbols.Symbol) bool

IsCalcUsageSymbol reports whether sym declares a calc or case usage, the forms whose outputs are features; a definition is a type, invoked rather than read.

func IsCaseNode

func IsCaseNode(u *ast.Usage) bool

IsCaseNode reports whether a usage is a case nested in a body as a step of it: an analysis usage (SysML v2 §7.22) or a verification usage (§7.23), performed as the calculation it is. Its own body is the case's, run by the case, so the flow it is a node of lowers none of it. A directed one is a parameter, referential and so no subperformance (Kernel Semantic Library `composite step subperformances`).

func IsDeferredKeeper added in v0.10.0

func IsDeferredKeeper(resolver *resolve.Resolver, scope *symbols.Scope, node *ast.Usage) bool

IsDeferredKeeper reports whether an accept node carries a DeferredKeeper annotation, read in the scope the node was written in. Detection is by resolved annotation type, never by the annotation's spelling.

func IsEntryTransition

func IsEntryTransition(source ast.Node) bool

IsEntryTransition reports whether the member a sourceless transition leaves is the entry action of its body, whatever else the transition was written with.

func IsPerformedActionUsage added in v0.10.0

func IsPerformedActionUsage(usage *ast.Usage) bool

IsPerformedActionUsage reports whether usage binds a classifier-level performed action.

func IsPredicateDecl added in v0.13.0

func IsPredicateDecl(decl ast.Node) bool

IsPredicateDecl reports a declaration an invocation applies as a predicate: a constraint or requirement definition or usage, an objective among the latter.

func IsResult

func IsResult(stmt Statement) bool

IsResult reports a statement that returns a value on some path through it: a `return`, or control flow with one inside. The results end a lowered body.

func IsStateSource

func IsStateSource(source ast.Node) bool

IsStateSource reports whether a vertex the shorthand found before it is one it may leave: SysML v2 7.18.3 names the previous state usage, which a pseudostate, a one-ended `first s;` marker and a `done;` marker are not.

func IsStateSourceDecl added in v0.10.0

func IsStateSourceDecl(resolver *resolve.Resolver, scope *symbols.Scope, source ast.Node) bool

IsStateSourceDecl is IsStateSource for a declaration as written: a state usage carrying a StateMachines pseudostate annotation is no transition source, as the pseudostate it lowers to is not.

func IsTerminateUsage

func IsTerminateUsage(node ast.Node) bool

IsTerminateUsage reports a terminate action usage (`action stop terminate;`), which a state body declares as a vertex a transition may end at.

func OperatorKindOf added in v0.13.0

func OperatorKindOf(op program.Operator) ast.OperatorKind

OperatorKindOf is the syntax tree's operator for the IR's.

func OperatorOf added in v0.13.0

func OperatorOf(kind ast.OperatorKind) program.Operator

OperatorOf is the IR's operator for the syntax tree's, which it mirrors by number.

func PerformsActions added in v0.13.0

func PerformsActions(stmts []Statement) bool

PerformsActions reports whether stmts state, at any depth, a step only a performance can take: an action node or `perform`, an accept to wait at, or a terminate to end one.

func PerformsLeafStatements added in v0.10.0

func PerformsLeafStatements(members []ast.Node) bool

PerformsLeafStatements reports whether a nested action node's members are a leaf body performing statements: they state no flow of their own (runsOwnFlow) and write a statement directly among them.

func PerformsSteps

func PerformsSteps(decl ast.Node) bool

PerformsSteps reports whether decl is a behavior whose body performs the action nodes among its members as steps: an analysis case (SysML v2 §7.22) or a verification case (§7.23), each a calculation and an action. A calc's body reads them as declarations only.

func PredicateKind added in v0.13.0

func PredicateKind(sym *symbols.Symbol) string

PredicateKind names the kind of predicate sym declares, as verdicts name it.

func PseudostateMetadata added in v0.10.0

func PseudostateMetadata(resolver *resolve.Resolver, scope *symbols.Scope, usage *ast.Usage) (ast.PseudostateKind, bool)

PseudostateMetadata reports the pseudostate kind usage declares by carrying a StateMachines pseudostate annotation (`#choice state pick;`), for the member scope it was written in. Detection is by resolved annotation type, never by the annotation's spelling.

func ReadsAtStart added in v0.10.0

func ReadsAtStart(graph *ActionGraph, node ast.Node) bool

ReadsAtStart reports whether a performance of node, beginning, evaluates initial values at its start shot before its body runs.

func Returns

func Returns(stmts []Statement) bool

Returns reports whether the statements return a value on some path, so a calculation whose body only computes can be told from one that has no result.

func SendPayload

func SendPayload(m *ast.SendStatement) ast.Node

SendPayload returns the message a send with no argument carries: the value its body binds the payload parameter to (`send { in :>> payload = s; }`).

func SendPayloadParameter

func SendPayloadParameter(m *ast.SendStatement) *ast.Usage

SendPayloadParameter returns the body feature redefining SendAction::payload: by name in a `:>>` clause, else by position as the first parameter of an argument-less send.

func SendTarget

func SendTarget(node ast.Node) (string, bool)

SendTarget renders a send's target and reports whether it is a feature chain (`alpha.inPort`) rather than a name in a namespace (`R`, `P::R`).

func ShadowedKey added in v0.11.0

func ShadowedKey(sym *symbols.Symbol) string

ShadowedKey is the name a performance binds a hidden inherited feature under: the declaring type's name and the feature's, `Base::go`, which no simple name spells.

func StartFlow

func StartFlow(graph *ActionGraph)

StartFlow gives a flow performed whole — a case body's, a state behavior's, an action's — the nodes its performance starts at: the ordered part's start, where no `first` states one its one unpreceded step, and every composite subaction no succession leads to as a concurrent start (startsConcurrently). Where nothing can start a flow stating steps, the graph keeps no start and running it reports why (FlowStartError).

func StatementNode added in v0.11.0

func StatementNode(stmt Statement) ast.Node

StatementNode is the syntax a lowered statement came from, nil for none.

func StatesBehaviorBody

func StatesBehaviorBody(members []ast.Node) bool

StatesBehaviorBody reports whether members state a behavior body rather than only annotating the declaration or binding the behavior's parameters (`exhibit m { in x = y; }`, `exhibit m : M { doc /* … */ }`).

func StatesFlow added in v0.13.0

func StatesFlow(stmts []Statement) bool

StatesFlow reports whether a block among stmts, or an action node of one, states at any depth a token flow or pin connector only a performance can run.

func TerminatedOccurrence added in v0.11.0

func TerminatedOccurrence(m *ast.Usage) *ast.TerminateStatement

TerminatedOccurrence returns the occurrence a terminate action usage names (`action stop terminate process;`), nil when it terminates its own container.

func TransitionGroups

func TransitionGroups(source ast.Node, transitions []*Transition) [][]int

TransitionGroups returns the positions of the transitions out of source that compete for one event: every branch out of a pseudostate, and for a state the completion transitions and the transitions of each trigger spelling, each group in declaration order.

func TriggerKey

func TriggerKey(trans *Transition) string

TriggerKey is the key of the event a transition reacts to: the transitions out of one state sharing it compete for the same occurrences and are checked for their weights as one group; "" keys the completion group. The lowered transition's resolved GroupKey is returned when set.

func TriggerName

func TriggerName(trigger ast.Node) string

TriggerName describes a transition's trigger for a diagnostic and a choice line, as the runtime spells it: the signal or operation accepted, or the event's kind alone.

func TypeText

func TypeText(u *ast.Usage) string

TypeText spells the type a usage declares with `:` as the notation writes it (each segment quoted when it must be), or "" without one.

func UnboundResultHint added in v0.13.0

func UnboundResultHint(chain []*symbols.Symbol) string

UnboundResultHint explains a `return` that declares a result parameter without binding it (`return h;` declares h, it does not return the member h).

func UnwrappedDeclMembers added in v0.13.0

func UnwrappedDeclMembers(decl ast.Node) []ast.Node

UnwrappedDeclMembers is ast.DeclMembers extended to named owned constraints, with the Membership wrappers the parser produces unwrapped.

func VertexDeclsResolving added in v0.10.0

func VertexDeclsResolving(stateMachineDecl ast.Node, scope *symbols.Scope, resolver *resolve.Resolver) (map[ast.Node]bool, error)

VertexDeclsResolving returns every declaration a transition of this state machine may name as an endpoint, as the lowered graph collects them; a nil resolver reads no metadata vertices.

func VertexKind

func VertexKind(decl ast.Node) string

VertexKind names what an endpoint reached in modelling terms, for a message a modeller reads.

func ViaPortPath

func ViaPortPath(node ast.Node) (path string, self bool)

ViaPortPath renders the port a `via` names as the connector ends of the sender's owner write it, and reports whether it was written from `this`: `this.p` is the sender's own port p, whatever the behavior binds `p` to.

func WeightInRange

func WeightInRange(w float64) bool

WeightInRange reports whether a drawn or constant weight is a probability.

Types

type Accept

type Accept struct {
	ParamName    string
	SignalType   *ast.QualifiedName
	ViaPort      string
	ViaSelf      bool // ViaPort was written from `this`, as Send.ViaSelf
	SubsetsEvent ast.Node
	Trigger      ast.Node
	// TriggerExprID is the condition of a change Trigger or the time of a timed one in
	// the table of the flow, lowered in the flow's scope; 0 for a trigger stating none.
	TriggerExprID program.ExprID
	// Scope is the scope the accept was declared in, in which SignalType resolves.
	Scope *symbols.Scope
	// Keeper reports the accept keeps the signal for a state deferring it, as a
	// DeferredKeeper annotation on the node declares (`#MigrationMetadata::DeferredKeeper
	// action receive accept kept : Sig;`): it takes an occurrence no other accept
	// of the state's behavior is ready for.
	Keeper bool
	// Payload is the feature the accept declares its payload as, which the nodes
	// of its body resolve ParamName to where no nearer declaration binds the name.
	Payload *symbols.Symbol
}

Accept is a lowered accept parameter: `action r accept msg : Warning;`. SignalType is the parameter's declared type name as written, nil when it was declared without one, in which case the node accepts a message of any type.

ViaPort is the port named by `accept msg : Warning via p`, empty when the accept named none. A port-routed message is only offered to an accept on the port it arrived at, so the two forms do not consume each other's messages.

SubsetsEvent is the event feature the payload subsets (`accept :> shutDown`), as written, nil for none: the accept waits for that one event.

Trigger is the time or change event of `accept at t` / `accept after d` / `accept when c`, nil when the accept waits for a message instead.

func (Accept) Signal added in v0.13.0

func (a Accept) Signal() (string, bool)

Signal is the last segment of the signal type the accept names, false for an accept naming none.

func (Accept) SignalName added in v0.13.0

func (a Accept) SignalName() string

SignalName is the signal type the accept names, as written.

func (Accept) SubsetsAt added in v0.13.0

func (a Accept) SubsetsAt() Extent

SubsetsAt is where the event the accept's payload subsets was written.

func (Accept) Timed added in v0.13.0

func (a Accept) Timed() bool

Timed reports whether the accept waits on the clock rather than for a message.

func (Accept) TriggerWritten added in v0.13.0

func (a Accept) TriggerWritten() (Trigger, bool)

TriggerWritten describes the accept's trigger, false for an accept stating none.

type ActionEdge

type ActionEdge struct {
	Source ast.Node
	Target ast.Node
	// SourceID and TargetID are Source and Target in the graph's identity table.
	SourceID, TargetID program.NodeID
	Guard              ast.Node
	// GuardID is Guard in the table of the flow the succession was lowered for.
	GuardID            program.ExprID
	Decl               ast.Node
	Probability        *Probability
	Name               string
	SourceMultiplicity *ast.Multiplicity
	TargetMultiplicity *ast.Multiplicity
	// DeclaredOrder marks the succession a block's declaration order synthesizes
	// rather than the model states: the executor's order, not a written one.
	DeclaredOrder bool
	// Carries marks the succession of a succession flow, which delivers a value
	// as well as ordering its ends.
	Carries bool
	// Gate is the succession that leads to a succession flow, whose guard and name the
	// edge takes; nil when the flow follows its source unconditionally.
	Gate ast.Node
	// Else marks the `else <target>;` branch of a decision, taken when no guarded
	// branch of the same decision is (ControlFlowEdge.IsElse).
	Else bool
}

ActionEdge is one succession out of a node: the node it leaves, the target it reaches, the guard it carries and its declaration (nil when implicit). No two edges of a graph compare equal. Probability is the weight its `@Probability` states, nil for an unweighted succession. Name is the name the succession was declared with, "" for an anonymous one.

func (ActionEdge) At added in v0.13.0

func (e ActionEdge) At() Extent

At is where the succession was declared.

func (ActionEdge) Carrying added in v0.13.0

func (e ActionEdge) Carrying(flow ObjectFlow) bool

Carrying reports whether the succession is the one flow's declaration states.

func (ActionEdge) CountsTarget added in v0.13.0

func (e ActionEdge) CountsTarget() bool

CountsTarget reports whether the succession states a multiplicity at its target end.

func (ActionEdge) Declared added in v0.13.0

func (e ActionEdge) Declared() ast.Node

Declared is the declaration the succession is drawn from: the succession flow gating it, else its own.

func (ActionEdge) GateAt added in v0.13.0

func (e ActionEdge) GateAt() Extent

GateAt is where the succession guarding the flow's transfer was declared.

func (ActionEdge) Gated added in v0.13.0

func (e ActionEdge) Gated() bool

Gated reports whether a succession flow gates the succession.

func (ActionEdge) GuardAt added in v0.13.0

func (e ActionEdge) GuardAt() Extent

GuardAt is where the succession's guard was written, the zero Extent for none.

func (ActionEdge) Succession added in v0.13.0

func (e ActionEdge) Succession() ast.Node

Succession is the succession's own declaration, whether or not a flow gates it.

func (ActionEdge) WeightAt added in v0.13.0

func (e ActionEdge) WeightAt() (Extent, bool)

WeightAt is where the succession's probability was written, false for an unweighted one.

type ActionGraph

type ActionGraph struct {
	// Scope is the scope the action's body was declared in, in which every
	// expression written directly among its members resolves its names. A nested
	// node or a body-local block carries its own scope instead.
	Scope *symbols.Scope

	// Attributes are the attribute defaults the action declares, in order.
	Attributes []Attribute

	// Parameters are the directed parameters the action declares itself (`in
	// bread : Bread;`, `out toast : Toast;`, `return r;`), in declaration order:
	// the pins on its own frame. A usage's inherited ones are its type's.
	Parameters []Feature

	// Nodes in the graph (InitialNode, FinalNode, ExecutionNode, etc.)
	Nodes []ast.Node

	// ID is each node's graph-local id, dense from 1 in the order of Nodes.
	ID map[ast.Node]program.NodeID

	// Origins is each node's origin by id; Origins[0] is unused.
	Origins []program.Origin

	// Kinds is each node's kind by id; Kinds[0] is unused.
	Kinds []program.NodeKind

	// Provenance maps the ids back to the declarations they were lowered from.
	Provenance Provenance

	// Edges: source node → successions in declaration order.
	Edges map[ast.Node][]ActionEdge

	// Multiplicities are the declarations on action nodes themselves.
	Multiplicities map[ast.Node]*ast.Multiplicity

	// DataFlows: source node → list of object flows
	DataFlows map[ast.Node][]ObjectFlow

	// Bodies: node → the statements that node executes, in declaration order
	Bodies map[ast.Node][]Statement

	// Features: node → the parameters and attributes the node declares itself,
	// in declaration order; each performance of the node holds its own values.
	Features map[ast.Node][]Feature

	// Scopes: node → the namespace the node owns, which its features resolve in.
	Scopes map[ast.Node]*symbols.Scope

	// Bindings are the bindings with an end at a node's pin (`bind add.a = x;`).
	Bindings []PinBinding

	// ValueBindings are the bindings a node's pins state by their values naming a
	// feature (`in b = bread;`, `in t = heat.t;`, `out x :>> x = y;`), one per pin,
	// in node then declaration order, with the other end resolved as a Binding's
	// is: a view draws them. The executor reads a pin's value as the pin's own,
	// so only an `inout` pin's, which writes back, is in Bindings as well.
	ValueBindings []PinBinding

	// Accepts: node → the message that node waits for
	Accepts map[ast.Node]Accept

	// Subflows: node → the flow the node's own members state, present only for a
	// node that states one. Its subactions are subperformances of the node, so it
	// completes only when that flow does (action_subflow.go).
	Subflows map[ast.Node]*Subflow

	// Enclosing and EnclosingNode are the graph and node a nested flow runs under,
	// whose pins a write under the flow streams from; nil for the outermost flow.
	Enclosing     *ActionGraph
	EnclosingNode ast.Node

	// Initial is the node the flow's ordered part starts at: the one a `first`
	// names, else its one node no succession leads to; nil where neither exists.
	Initial ast.Node

	// Concurrent are the composite subactions no succession leads to, other than
	// Initial, in declaration order: each starts when a performance of the flow
	// does, unordered against Initial and against each other (StartFlow).
	Concurrent []ast.Node

	// Invalid is the error a stated body's flow failed to lower with,
	// reported at initialize().
	Invalid error

	// FinalNodes (may be multiple)
	Finals []ast.Node

	// Connections are the connectors declared in the action body, which is how
	// a `send ... via <port>` finds the ports it reaches.
	Connections []Connection

	// StatementRuns marks the nodes of a block's own flow that stand for a run of
	// statements rather than for an action node (block_graph.go). Such a node is
	// keyed by the first statement of the run, whose name names no step.
	StatementRuns map[ast.Node]bool

	// StatementOrders holds order metadata for body lists lowered as part of a
	// calculation block's own flow.
	StatementOrders map[ast.Node]*StatementOrder

	// UnstatedCaseFlow marks an unordered case body lifted into an action graph.
	UnstatedCaseFlow bool

	// BlockNodes lists, per node, the action nodes its body's blocks (an `if` branch,
	// a loop body) declare, in declaration order: subperformances reached by name from it.
	BlockNodes map[ast.Node][]ast.Node

	// Exprs is the table the graph's ExprIDs index, shared with the flows of its blocks.
	Exprs *ExprTable

	// Performs records the inherited action type a redefining node performs
	// when the node has no own invocation.
	Performs map[ast.Node]PerformedType

	// MergedTypedSubflows records typed action nodes whose body was merged into
	// their subflow, so runtime does not perform the typing a second time.
	MergedTypedSubflows map[ast.Node]PerformedType
	// contains filtered or unexported fields
}

ActionGraph is the execution IR for actions. Nodes represent control flow points, edges represent flow paths.

func BlockFlows

func BlockFlows(stmts []Statement) []*ActionGraph

BlockFlows returns the flows the blocks among stmts state, those of nested blocks stating none of their own included.

func NestedFlow

func NestedFlow(in *ActionGraph, node, next ast.Node) *ActionGraph

NestedFlow returns the flow next is a node of among those a performance of node, a node of in, holds as its own: the flow node owns, or a block flow of its body. nil when next is no such node.

func ToActionGraph

func ToActionGraph(actionDecl ast.Node, scope *symbols.Scope) (*ActionGraph, error)

ToActionGraph converts an action AST (Usage or Definition) to an ActionGraph. scope is the scope the action's body was declared in — the scope the action itself owns — which every expression the graph carries is evaluated in. Returns error if graph is malformed (e.g., no initial node, dangling edges). Without the name-resolution tier's resolver a Probability annotation cannot be told from any other metadata, so none is read; a caller holding one uses ToActionGraphWith.

func ToActionGraphWith

func ToActionGraphWith(actionDecl ast.Node, scope *symbols.Scope, resolver *resolve.Resolver) (*ActionGraph, error)

ToActionGraphWith is ToActionGraph reading the metadata the resolver identifies: a succession's `@Probability { p = ...; }` becomes its edge's weight.

func ToActionInterface

func ToActionInterface(actionDecl ast.Node, scope *symbols.Scope) (*ActionGraph, error)

ToActionInterface lowers only the attributes an action declares, for a performance that runs no body of it: an external tool's. Its flow is empty whatever the body states.

func ToActionNodeFlow added in v0.10.0

func ToActionNodeFlow(node ast.Node, scope *symbols.Scope, resolver *resolve.Resolver) *ActionGraph

ToActionNodeFlow lowers one action node as the sole node of a block flow.

func (*ActionGraph) AcceptOf added in v0.13.0

func (g *ActionGraph) AcceptOf(id program.NodeID) (Accept, bool)

AcceptOf is the message the node waits for, false for a node that accepts none.

func (*ActionGraph) BindingFootprints added in v0.11.0

func (g *ActionGraph) BindingFootprints() map[ast.Node]Footprint

BindingFootprints is node → what binding the node's own features, pins and accepted payload touches, apart from the statements its body runs: what a performance's inputs are bound from and where its outputs go. Computed on first use, as Footprints is.

func (*ActionGraph) BlockNodesOf added in v0.13.0

func (g *ActionGraph) BlockNodesOf(id program.NodeID) []FlowNode

BlockNodesOf are the action nodes the blocks of the node's body declare, in declaration order, each in the block flow it is a node of.

func (*ActionGraph) BodyDividesOf added in v0.13.0

func (g *ActionGraph) BodyDividesOf(id program.NodeID) bool

BodyDividesOf is BodyDivides of the node behind id.

func (*ActionGraph) BodyOf added in v0.13.0

func (g *ActionGraph) BodyOf(id program.NodeID) []Statement

BodyOf are the statements the node executes, in declaration order.

func (*ActionGraph) BodyOrderOf added in v0.13.0

func (g *ActionGraph) BodyOrderOf(id program.NodeID, stmts []Statement) *StatementOrder

BodyOrderOf is BodyStatementOrder of stmts, a body of the node behind id.

func (*ActionGraph) CaseNode added in v0.13.0

func (g *ActionGraph) CaseNode(id program.NodeID) bool

CaseNode reports whether the node behind id is a nested analysis or verification case.

func (*ActionGraph) CheckStep added in v0.10.0

func (g *ActionGraph) CheckStep(node ast.Node, model *semantics.Model) error

CheckStep classifies a declared multiplicity and its incident successions.

func (*ActionGraph) CheckStepOf added in v0.13.0

func (g *ActionGraph) CheckStepOf(id program.NodeID, model *semantics.Model) error

CheckStepOf is CheckStep of the node behind id.

func (*ActionGraph) ConcurrentIDs added in v0.13.0

func (g *ActionGraph) ConcurrentIDs() []program.NodeID

ConcurrentIDs are the composite subactions no succession leads to, in declaration order.

func (*ActionGraph) ControlIDs added in v0.13.0

func (g *ActionGraph) ControlIDs(fp Footprint) []program.NodeID

ControlIDs are the nodes the footprint converges on, 0 for one the graph does not index.

func (*ActionGraph) CrossesPerPerformance added in v0.10.0

func (g *ActionGraph) CrossesPerPerformance(node ast.Node, model *semantics.Model) bool

CrossesPerPerformance reports whether node, a step performed n times, leads its every performance into a join or merge: the edge is bijective, so the control node fires once per performance rather than behind a barrier.

func (*ActionGraph) CrossesPerPerformanceOf added in v0.13.0

func (g *ActionGraph) CrossesPerPerformanceOf(id program.NodeID, model *semantics.Model) bool

CrossesPerPerformanceOf is CrossesPerPerformance of the node behind id.

func (*ActionGraph) DeclScope added in v0.11.0

func (g *ActionGraph) DeclScope(decl ast.Node) *symbols.Scope

DeclScope is the scope a declaration of the graph was written in, where the names its expressions spell resolve: the general's body where inherited, else the action's own.

func (*ActionGraph) DocOf

func (g *ActionGraph) DocOf(decl ast.Node) string

DocOf is the document a declaration of the graph was written in: the general's where inherited, else the action's own; "" outside any document.

func (*ActionGraph) EdgesOf added in v0.13.0

func (g *ActionGraph) EdgesOf(id program.NodeID) []ActionEdge

EdgesOf are the successions out of the node, in declaration order; shared, not to be modified.

func (*ActionGraph) EnclosingNodeID added in v0.13.0

func (g *ActionGraph) EnclosingNodeID() program.NodeID

EnclosingNodeID is the node of Enclosing the flow runs under, 0 for the outermost flow.

func (*ActionGraph) ExpressionOf added in v0.13.0

func (g *ActionGraph) ExpressionOf(id program.NodeID) program.ExprID

ExpressionOf is the expression an action node written `action a = e` computes, 0 for none.

func (*ActionGraph) FeaturesOf added in v0.13.0

func (g *ActionGraph) FeaturesOf(id program.NodeID) []Feature

FeaturesOf are the parameters and attributes the node declares itself, in declaration order.

func (*ActionGraph) FinalIDs added in v0.13.0

func (g *ActionGraph) FinalIDs() []program.NodeID

FinalIDs are the flow's final nodes.

func (*ActionGraph) FlowsOf added in v0.13.0

func (g *ActionGraph) FlowsOf(id program.NodeID) []ObjectFlow

FlowsOf are the object flows out of the node; shared, not to be modified.

func (*ActionGraph) FootprintOf added in v0.13.0

func (g *ActionGraph) FootprintOf(id program.NodeID) (Footprint, bool)

FootprintOf is the footprint of the node behind id, false for a node the graph has none for.

func (*ActionGraph) Footprints

func (g *ActionGraph) Footprints() map[ast.Node]Footprint

Footprints is node → what advancing a token through the node may read, write, send, accept and converge on, for the model checker's independence relation. It is computed from the lowered graph on first use and shared by every caller.

func (*ActionGraph) FormName added in v0.13.0

func (g *ActionGraph) FormName(id program.NodeID) string

FormName names the form of the node behind id for a message refusing it.

func (*ActionGraph) FormOf added in v0.13.0

func (g *ActionGraph) FormOf(id program.NodeID) NodeForm

FormOf is how the node behind id was written.

func (*ActionGraph) HasStepMultiplicity added in v0.10.0

func (g *ActionGraph) HasStepMultiplicity(node ast.Node, model *semantics.Model) bool

HasStepMultiplicity reports whether a node has an owned or effective step multiplicity, including recorded library facts.

func (*ActionGraph) HasStepMultiplicityOf added in v0.13.0

func (g *ActionGraph) HasStepMultiplicityOf(id program.NodeID, model *semantics.Model) bool

HasStepMultiplicityOf is HasStepMultiplicity of the node behind id.

func (*ActionGraph) Incoming added in v0.9.2

func (g *ActionGraph) Incoming(node ast.Node) []ActionEdge

Incoming returns the successions into node, in the declaration order of the nodes they leave. The result is shared: callers must not modify it.

func (*ActionGraph) IncomingOf added in v0.13.0

func (g *ActionGraph) IncomingOf(id program.NodeID) []ActionEdge

IncomingOf are the successions into the node: Incoming by id.

func (*ActionGraph) Inherited

func (g *ActionGraph) Inherited() []Inherited

Inherited lists the declarations the action's content came from besides its own — the actions it specializes, then those its subflows specialize — each once.

func (*ActionGraph) InitialID added in v0.13.0

func (g *ActionGraph) InitialID() program.NodeID

InitialID is the node the flow's ordered part starts at, 0 for none.

func (*ActionGraph) Invokes added in v0.13.0

func (g *ActionGraph) Invokes(id program.NodeID) bool

Invokes reports whether the node behind id performs another action rather than stating a body of its own, as the interpreter decides it.

func (*ActionGraph) MultiplicityText added in v0.10.0

func (g *ActionGraph) MultiplicityText(node ast.Node, model *semantics.Model) string

MultiplicityText returns the source text of node's effective multiplicity.

func (*ActionGraph) MultiplicityTextOf added in v0.13.0

func (g *ActionGraph) MultiplicityTextOf(id program.NodeID, model *semantics.Model) string

MultiplicityTextOf is MultiplicityText of the node behind id.

func (*ActionGraph) NodeIDs added in v0.13.0

func (g *ActionGraph) NodeIDs() []program.NodeID

NodeIDs are the ids of the graph's nodes, in graph order.

func (*ActionGraph) OriginOf added in v0.13.0

func (g *ActionGraph) OriginOf(node ast.Node) program.Origin

OriginOf is the origin of a node of the graph; the zero Origin for one the graph does not index.

func (*ActionGraph) PerformedBy added in v0.13.0

func (g *ActionGraph) PerformedBy(id program.NodeID, resolver *resolve.Resolver, scope *symbols.Scope) []*symbols.Symbol

PerformedBy are the behaviors the node behind id performs or is typed by, resolved in scope.

func (*ActionGraph) Resolver added in v0.12.0

func (g *ActionGraph) Resolver() *resolve.Resolver

Resolver is the resolver the graph was lowered with, nil for none.

func (*ActionGraph) ScopeOf added in v0.13.0

func (g *ActionGraph) ScopeOf(id program.NodeID) *symbols.Scope

ScopeOf is the namespace the node behind id owns, nil for none.

func (*ActionGraph) Semantics added in v0.12.0

func (g *ActionGraph) Semantics() *semantics.Model

Semantics is the semantic model over the graph's resolver, built once and shared by every footprint of the graph; nil without a resolver.

func (*ActionGraph) SiteOf added in v0.13.0

func (g *ActionGraph) SiteOf(id program.NodeID) (Site, bool)

SiteOf is the site of the node behind id, false for no node.

func (*ActionGraph) StartIDs added in v0.13.0

func (g *ActionGraph) StartIDs() []program.NodeID

StartIDs are the nodes a performance of the flow starts at: Starts by id.

func (*ActionGraph) StartUsage

func (g *ActionGraph) StartUsage(node ast.Node) (Effect, bool)

StartUsage returns the start a performed action node stands for (`perform obj.beh.start;`), the last of its body; false for a node that performs otherwise.

func (*ActionGraph) Starts added in v0.10.0

func (g *ActionGraph) Starts() []ast.Node

Starts returns the nodes a performance of the flow starts at: Initial, where the flow has one, then each concurrent start in declaration order.

func (*ActionGraph) StatementList added in v0.10.0

func (graph *ActionGraph) StatementList() ([]Statement, bool)

StatementList returns a graph's sequential statement nodes as one list.

func (*ActionGraph) StatementRun added in v0.13.0

func (g *ActionGraph) StatementRun(id program.NodeID) bool

StatementRun reports whether the node stands for a run of statements of a block's own flow.

func (*ActionGraph) StepCount added in v0.10.0

func (g *ActionGraph) StepCount(node ast.Node, model *semantics.Model) (int64, error)

StepCount returns the fixed number of performances an owned or inherited multiplicity governs; when none does, the step performs once.

func (*ActionGraph) StepCountOf added in v0.13.0

func (g *ActionGraph) StepCountOf(id program.NodeID, model *semantics.Model) (int64, error)

StepCountOf is StepCount of the node behind id.

func (*ActionGraph) StepError added in v0.10.0

func (g *ActionGraph) StepError(node ast.Node, model *semantics.Model, code, reason string, declaration ast.Node) *StepMultiplicityError

StepError constructs the shared diagnostic used when a consumer refuses a repeated step for a reason outside the built-in succession checks.

func (*ActionGraph) StepMultiplicity added in v0.10.0

func (g *ActionGraph) StepMultiplicity(node ast.Node, model *semantics.Model) (*ast.Multiplicity, *symbols.Scope)

func (*ActionGraph) SubflowOf added in v0.13.0

func (g *ActionGraph) SubflowOf(id program.NodeID) *Subflow

SubflowOf is the flow the node's own members state, nil for a node stating none.

func (*ActionGraph) TerminateUsage

func (g *ActionGraph) TerminateUsage(node ast.Node) (Effect, bool)

TerminateUsage returns the terminate a terminate action usage stands for, the last of its node's body after the statements it declares; false for a node that is none.

func (*ActionGraph) TraceLabel added in v0.13.0

func (g *ActionGraph) TraceLabel(id program.NodeID) string

TraceLabel names the node behind id as a trace names it: by its name, else by what it does.

type Assert added in v0.10.0

type Assert struct {
	Node  *ast.Usage
	Sym   *symbols.Symbol // the assertion's symbol, nil where the scope does not declare it
	Scope *symbols.Scope  // the scope the assertion was declared in
}

Assert is an `assert constraint` a succession orders among a flow's steps: the flow reaching it checks the conditions Sym states.

func (Assert) At added in v0.13.0

func (a Assert) At() Extent

At is where the assertion was written, the zero Extent for one lowering supplied.

type Assign

type Assign struct {
	Target string
	// Qualified marks a namespace-qualified target (`Scope::azimuth`): it names
	// the feature on the object its qualifier names, no host binding applies.
	Qualified bool
	// Owner is the qualifier's symbol (`Probe` in `Probe::count`) and Feature the
	// feature it names; both are set only when Qualified is.
	Owner   *symbols.Symbol
	Feature *symbols.Symbol
	// Chain is the chained target the assignment writes through (`s.reading`),
	// nil when the target was a plain name the body's host binds.
	Chain *AssignTarget
	Value ast.Node
	// ValueID is Value in the table of the flow or body the statement was lowered for.
	ValueID program.ExprID
	Node    ast.Node       // the statement itself, for diagnostics
	Scope   *symbols.Scope // the scope the statement was declared in
}

Assign is a lowered assignment: `assign <Target> := <Value>`. Target is the feature written — the target's last segment — empty when the target names no feature.

func (Assign) Chained added in v0.13.0

func (a Assign) Chained() bool

Chained reports an assignment whose target walks a feature chain.

func (Assign) Sides added in v0.13.0

func (a Assign) Sides() (target, value Extent, ok bool)

Sides are where the assignment's target and value were written, false for an assignment lowered from no assignment statement.

type AssignTarget

type AssignTarget struct {
	// Base is the expression the chain starts from, evaluated in the statement's
	// own scope.
	Base ast.Node
	// BaseID is Base in the table of the flow or body the statement was lowered for.
	BaseID program.ExprID
	// Steps are the features walked from Base to the object written, in order.
	Steps []string
	// Text is the target as written (`a.b.c`), for diagnostics.
	Text string
}

AssignTarget is a chained assignment target: `assign a.b.c := v` walks `b` from `a` and writes `c` on the object it reaches.

type Attribute

type Attribute struct {
	Name string
	// Direction is the parameter direction written, DirNone for a plain attribute.
	Direction ast.FeatureDirection
	IsResult  bool // a `return` parameter, what the behavior yields
	// Type is the declared type as written (`Natural`, `Vehicle::Mode`), "" without one.
	Type  string
	Value ast.Node
	// ValueID is Value in the table of the flow or machine the attribute was lowered for.
	ValueID program.ExprID
	Binding bool
	Node    ast.Node // the declaration itself, for diagnostics
	// Scope is the scope the declaration was written in, in which its default
	// resolves; nil where the owner's own scope resolves it.
	Scope *symbols.Scope
	// Optional reports an effective multiplicity with lower bound 0 (`x : Integer[0..1]`):
	// the feature may hold no value at all. The run resolves it, as it does Scope.
	Optional bool
	// Symbol is the feature the attribute declares, which a performance holding it
	// binds its cell by; nil when no scope declares Node.
	Symbol *symbols.Symbol
	// Shadowed marks an inherited feature a same-named member of the specialization
	// hides without redefining it (KerML 1.0 §8.2.3.5.3): both are held, and Name is
	// then the hidden one's owner-qualified key (ShadowedKey).
	Shadowed bool
}

Attribute is a lowered attribute default written among a behavior's members (`attribute h : LengthValue = 500.0 [m];`), whose Value resolves in the graph's own scope.

func (Attribute) At added in v0.13.0

func (a Attribute) At() Extent

At is where the attribute was declared.

func (Attribute) Output

func (a Attribute) Output() bool

Output reports whether the feature is written back rather than read: an `out` or `return` parameter, which no caller and no witness may fix.

type BehaviorOrder added in v0.10.0

type BehaviorOrder struct {
	Decl      ast.Node
	Name      string
	File      string
	Span      source.Span
	Featuring *symbols.Symbol
	Earlier   BehaviorOrderEnd
	Later     BehaviorOrderEnd
	Refusal   *BehaviorOrderRefusal
}

BehaviorOrder is a succession outside a behavior body, ordering performances of the objects it relates.

func BehaviorOrders added in v0.10.0

func BehaviorOrders(model *semantics.Model, roots ...*symbols.Scope) []BehaviorOrder

BehaviorOrders lowers succession declarations owned outside behavior bodies.

type BehaviorOrderEnd added in v0.10.0

type BehaviorOrderEnd struct {
	Path         []*symbols.Symbol
	Multiplicity *ast.Multiplicity
	Span         source.Span
}

BehaviorOrderEnd is one endpoint relative to its featuring instance or package.

type BehaviorOrderRefusal added in v0.10.0

type BehaviorOrderRefusal struct {
	Code   string
	Reason string
	Span   source.Span
}

BehaviorOrderRefusal records why a lowered order cannot constrain execution.

type Binding

type Binding struct {
	Ends  [2]BindingEnd
	Scope *symbols.Scope
	Decl  *ast.Usage
	// Origin is where the connector was written, Kind "binding"; it has no Path.
	Origin program.Origin
	// Multiplicity is the connector's own as written (`binding [1] bind …`), nil when none.
	Multiplicity *ast.Multiplicity
}

Binding is a lowered binding connector with its two endpoint expressions and the scope in which those expressions were declared.

func EndValueBindings added in v0.12.1

func EndValueBindings(decl ast.Node, scope *symbols.Scope) []Binding

EndValueBindings lowers each `=` or `default =` in a connector end's body as a binding of the end's feature to the value expression (SysML v2 §7.13.4, an implicit binding; a default yields to own values).

func NamespaceBindings added in v0.10.0

func NamespaceBindings(scope *symbols.Scope) []Binding

NamespaceBindings lowers the binding connectors a namespace scope owns directly. ToBindings reads a declaration's members, which a package or namespace body is not, so bindings owned there are collected from the scope's own symbols.

func ToBindings

func ToBindings(decl ast.Node, scope *symbols.Scope) []Binding

ToBindings lowers binding connectors directly declared by a type or usage. Namespace-owned bindings are intentionally left to callers to exclude.

func (Binding) Declared added in v0.13.0

func (b Binding) Declared() ast.Node

Declared is the connector the binding was lowered from.

func (*Binding) Intern added in v0.13.0

func (b *Binding) Intern(exprs *ExprTable)

Intern interns the expressions the binding's ends state in exprs, in the scope the binding is evaluated in; one lowered apart from a flow has no ids until it is called.

func (Binding) ThroughEnds added in v0.12.0

func (b Binding) ThroughEnds(roots map[string]string, owned map[string]bool, self Hop) (Binding, bool)

ThroughEnds re-roots a path at what roots maps its head to and leads an expression end, a path through a feature owned names, or one already on a connector object, to the connector at self; false if it cannot.

type BindingEnd

type BindingEnd struct {
	Path string
	Expr ast.Node
	// ExprID is Expr in the table the binding was interned in, 0 before it is.
	ExprID program.ExprID
	// Index selects one element of the feature Path reaches (`xs#(2)`), nil for the whole feature.
	Index ast.Node
	// IndexID is Index in the table the binding was interned in.
	IndexID      program.ExprID
	Multiplicity *ast.Multiplicity
	// Via leads from the binding's holder to the connector object an expression or a path end is
	// read on, empty for the holder itself; Default marks the expression of a `default =` value.
	Via     []Hop
	Default bool
}

BindingEnd is one binding endpoint. Path is the runtime lvalue path, empty for an end that is read as an expression — an indexed end `xs#(2)` selects one element of a feature and is no feature to write through; Expr retains the lossless expression for diagnostics and calc evaluation; Multiplicity is the end multiplicity as written (`bind [0..1] a = b`), nil when none.

func (BindingEnd) HolderPath added in v0.12.1

func (e BindingEnd) HolderPath() string

HolderPath is the feature path the end reaches from the binding's holder: empty for an expression, or a path read on a connector object Via leads to.

func (BindingEnd) Syntax added in v0.13.0

func (e BindingEnd) Syntax() ast.Node

Syntax is the end's expression as written.

type Block

type Block struct {
	Statements []Statement
	Node       ast.Node // the loop or branch the block belongs to
	// Order is the lowered statement order for a calculation or constraint block.
	// Action blocks leave it nil and derive their order from the enclosing graph.
	Order *StatementOrder
	// Scope is the block's own scope, which its declarations, and a loop's
	// condition, resolve in.
	Scope *symbols.Scope
	// Graph is the block's own token flow, present where a member of the block is
	// an action node rather than a statement — a nested action declaration, a
	// `perform` — which only a flow of its own executes with the succession
	// semantics it has (block_graph.go). Statements is empty for such a block: the
	// statements are the bodies of the flow's nodes.
	Graph *ActionGraph
	// Own marks the flow a case body states of its own (case_body.go), which runs
	// in the body's frame rather than a block's so its results read what it left.
	Own bool
	// Stated marks Graph as the token flow the body's successions, control nodes
	// or accepts state; unset, Graph runs the body's steps in declaration order.
	Stated bool
}

Block is a lowered body-local statement list: the body of a loop or of one branch of a conditional. It is a namespace of its own (symbols/builder.go), so the names its Declare statements introduce do not leak out of it.

func (Block) Declared added in v0.13.0

func (block Block) Declared() ast.Node

Declared is the loop or branch the block belongs to.

func (Block) Flows added in v0.13.0

func (block Block) Flows() bool

Flows reports whether the block's statements are a flow of their own.

func (Block) Steps

func (block Block) Steps() []Statement

Steps returns the statements the block runs, wherever they live: its statement list, or the bodies of the nodes of its own token flow, in declaration order.

type CalcEnv added in v0.13.0

type CalcEnv struct {
	Semantics *semantics.Model
	Resolver  *resolve.Resolver
	// Realized reports a library calc the runtime realizes rather than runs as
	// written; it contributes no members to the chain of a calc specializing it.
	Realized func(*symbols.Symbol) bool
}

CalcEnv is what lowering a calc reads beyond the syntax tree: the semantic model and resolver, and which library calcs the runtime realizes itself.

type CalcTrees added in v0.13.0

type CalcTrees struct {
	// Body is the computation the calc states, lowered in the scope of the calc that
	// declares it, in declaration order; BodyOrder is its calculation-statement order.
	Body      []Statement
	BodyOrder *StatementOrder
	// Steps is Body without the bindings of its `out` features, which are
	// evaluated when those features are read rather than run as statements.
	Steps []Statement
	// Nodes are the action nodes the body's flow performs as the steps of a case.
	Nodes    []ast.Node
	Bindings []Binding
	// Exprs is the table the calc's ExprIDs index: each expression lowered in the
	// scope of the calc declaring it.
	Exprs ExprTable
}

CalcTrees is what a lowered calc still keeps as syntax trees beside its program.Calc, until expressions are lowered: the body, the bindings and the table its ExprIDs index.

func ToCalc added in v0.13.0

func ToCalc(sym *symbols.Symbol, env CalcEnv) (*program.Calc, *CalcTrees)

ToCalc lowers the invocation interface of the calc sym — parameters, outputs, body and result, each resolved across the chain; the runtime judges from it whether the calc computes.

func ToCalcSignature added in v0.13.0

func ToCalcSignature(sym *symbols.Symbol, libInputs []*symbols.Symbol, env CalcEnv) (*program.Calc, *CalcTrees, []int)

ToCalcSignature lowers the bodiless effective inputs of a model calc applying an inherited library function, with, per parameter, the index in libInputs of the input it redefines (-1: none).

func ToPredicate added in v0.13.0

func ToPredicate(sym *symbols.Symbol, env CalcEnv) (*program.Calc, *CalcTrees)

ToPredicate lowers the invocation interface of the predicate sym: its parameters, the subject first; its conditions stand for a body.

func (*CalcTrees) Expr added in v0.13.0

func (t *CalcTrees) Expr(id program.ExprID) ast.Node

Expr is the syntax of the expression behind an id, nil for none.

type ChainEnd added in v0.13.0

type ChainEnd int

ChainEnd classifies a succession end written as a feature chain whose first segment names no node of the flow (SysML v2 §7.17.4 admits a chain at either end).

const (
	// ChainEndNone is an end that is no such chain, or one the scope cannot follow.
	ChainEndNone ChainEnd = iota
	// ChainEndAction reaches an action usage: a step performing it on the object reached.
	ChainEndAction
	// ChainEndOccurrence reaches an occurrence usage that is no action: legal
	// notation (§7.13.5) that orders nothing the flow performs.
	ChainEndOccurrence
	// ChainEndValue reaches an attribute or enumeration usage, which is no occurrence.
	ChainEndValue
)

func ClassifyChainEnd added in v0.13.0

func ClassifyChainEnd(nodes []ast.Node, scope *symbols.Scope, resolver *resolve.Resolver, ref ast.Node) (ChainEnd, *symbols.Symbol)

ClassifyChainEnd says what a succession end written in scope reaches when it is a feature chain rooted outside nodes, and the feature it reaches.

type Channel

type Channel struct {
	Signal  string
	Port    string
	Type    *ast.QualifiedName
	Message ast.Node
	Scope   *symbols.Scope
	Via     bool
	Drops   bool
	Own     bool
}

Channel is one message a move sends or waits for: the signal type as written ("" for any) and the port it travels through ("" for none). Type is the accept's type reference and Message the send's message, each resolving in Scope; Via marks a send routed by connections, Drops a machine's dispatch, which may discard a message sent to its object. Own marks a send naming no target, for the sending object.

func (Channel) String

func (c Channel) String() string

type ChannelsMeet added in v0.10.0

type ChannelsMeet func(a Channel, aSends bool, b Channel, bSends bool) bool

ChannelsMeet reports whether a message operation of one move may not commute with one of another: each channel with whether it sends.

type ClassifierBehavior

type ClassifierBehavior struct {
	Kind ClassifierBehaviorKind
	// Name is the name the behavior answers to on the object, which is the
	// effective name of the declaration binding it.
	Name string
	// Decl is the `exhibit`/`perform` declaration itself.
	Decl *ast.Usage
	// StatesBody reports whether Decl states the behavior's body. A declaration
	// that states none names the element that holds one instead.
	StatesBody bool
	// NamesBehavior reports whether Decl names the element holding the body: the
	// reference form (`perform a;`, `exhibit m;`), a `references`/`::>` clause
	// or a typing. A declaration naming none is the body itself
	// (SysML v2 §8.3.16, eventOccurrence; §8.3.17, performedAction/exhibitedState).
	NamesBehavior bool
	// Arguments are the values the declaration binds to the behavior's
	// parameters (`exhibit m { in controller = vehicleController; }`), in
	// declaration order.
	Arguments []Attribute
}

ClassifierBehavior is a behavior every object of a type runs because the type exhibits or performs it: the declaration that binds it, whether that declaration states a body of its own or names an element holding one, and the values it binds to the behavior's parameters.

func ClassifierBehaviorOf

func ClassifierBehaviorOf(member ast.Node) (ClassifierBehavior, bool)

ClassifierBehaviorOf reports the behavior a type's member binds to every object of that type, and false for a member that binds none: a state or action a type merely owns is not one its objects run.

func ClassifierBehaviorsOf

func ClassifierBehaviorsOf(members []ast.Node) []ClassifierBehavior

ClassifierBehaviorsOf reports the behaviors the given members bind, in declaration order.

func StartableBehaviorOf

func StartableBehaviorOf(member ast.Node) (ClassifierBehavior, bool)

StartableBehaviorOf reports the behavior a type's member holds for its objects to start: one the type exhibits or performs, or an action or state usage it merely declares (`action beh : Beh;`), which an object runs once a `perform obj.beh.start` starts it and not before.

type ClassifierBehaviorKind

type ClassifierBehaviorKind int

ClassifierBehaviorKind is how a type binds a behavior to its objects.

const (
	// ExhibitedState is a state machine the type exhibits: `exhibit state m { … }`,
	// `exhibit state m : M;`, `exhibit m;` (SysML v2 §7.16.6, Part::exhibitedStates).
	ExhibitedState ClassifierBehaviorKind = iota
	// PerformedAction is an action the type performs: `perform action a { … }`,
	// `perform action a : A;`, `perform a;` (Part::performedActions).
	PerformedAction
)

func (ClassifierBehaviorKind) String

func (k ClassifierBehaviorKind) String() string

String names the kind in diagnostics.

type Connection

type Connection struct {
	Ends      []string
	Variation string          // variation point the connection is a variant of, empty when it is not
	Variant   string          // name of the variant declaring it, empty when it is not one
	Owner     ConnectionOwner // what declares it, whose selection governs a variant's connection
	Scope     *symbols.Scope  // scope the end paths resolve in, nil when unknown
}

Connection is a lowered connector: the ends it joins, by the name each end resolves to. A `connect a to b` has two ends; a multi-end `connect` has more, and every end is reachable from every other.

A connection a `variant interface` declares joins its ends only where that variant is the one selected, so it carries the variation it belongs to, its own name, and what owns it: routing must ask what that owner bound the variation to before delivering through it (SysML v2 §7.20).

An end keeps the whole path it was written as (`sensor.out`, `p.q`), so a nested port is joined as itself and not as a same-named port elsewhere; Scope is where those paths resolve, which is what routing asks to learn the direction an end's flow features carry.

func ToObjectConnections

func ToObjectConnections(decl ast.Node, scope *symbols.Scope) []Connection

ToObjectConnections lowers the connectors declared in the body of a type an object is of. A `send … via p` of a behavior an object performs routes through the object's connections as well as through the behavior's own, and it is that object's selection that realizes a variant's connection among them.

type ConnectionOwner

type ConnectionOwner int

ConnectionOwner is what a lowered connection belongs to, which decides whose selection governs it when it is a variant's: a behavior activation, or the object performing the behavior.

const (
	// OwnerBehavior marks a connection declared in the behavior's own body.
	OwnerBehavior ConnectionOwner = iota
	// OwnerObject marks a connection declared in the body of a type an object
	// performing the behavior is of.
	OwnerObject
)

type Declare

type Declare struct {
	Name  string
	Value ast.Node
	// ValueID is Value in the table of the flow or body the statement was lowered for.
	ValueID  program.ExprID
	Binding  bool
	BodyData bool           // expression-valued state action execution stored as state data
	Node     ast.Node       // the declaration itself, for diagnostics
	Scope    *symbols.Scope // the scope the declaration was written in
	// Symbol is the feature the declaration introduces, which the block's frame
	// binds its value by; nil when no scope declares Node.
	Symbol *symbols.Symbol
}

Declare is a lowered declaration in a body-local block: `attribute i = 0;` written inside a loop or an `if` branch. The name it declares is a member of that block, so the executor binds it in the block's own frame and discards it when the block exits. Value is nil when the declaration carried none.

type DeclareUsage

type DeclareUsage struct {
	Name  string
	Node  *ast.Usage     // the declaration itself, for diagnostics
	Scope *symbols.Scope // the scope the usage was declared in
}

DeclareUsage is a calc usage declared in a body-local block: `calc p : Pair { in k = h; }` written inside a loop or an `if` branch. It states no step of the computation; it declares the usage and marks where it becomes reachable, so the statements after it read its outputs from one evaluation of its body per execution of the block.

type DeferredSignal added in v0.10.0

type DeferredSignal struct {
	// Type names the signal definition, as the annotation writes it.
	Type *ast.QualifiedName
	// Scope is where Type resolves: the annotated state's body.
	Scope *symbols.Scope
}

DeferredSignal is one signal a state defers, as a DeferredEvent annotation on the state names it: `@MigrationMetadata::DeferredEvent { ref :>> signal : Sig; }`.

func DeferredSignals added in v0.10.0

func DeferredSignals(resolver *resolve.Resolver, scope *symbols.Scope, usage *ast.Usage) []DeferredSignal

DeferredSignals reads the signals a state usage defers, for the scope it was written in: one per DeferredEvent annotation whose body types its `signal`, in declaration order, each with the state's body scope, where the body reads. Detection is by resolved annotation type, never by the annotation's spelling.

type DeferredSubflow added in v0.11.0

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

DeferredSubflow is a typed action body nested in its own type, lowered when a performance of the node first starts: eagerly, unfolding it would never end.

type Effect

type Effect struct {
	Kind  EffectKind
	Node  ast.Node
	Scope *symbols.Scope // the scope the statement was declared in
	// Terminates says what a terminate ends; Target is the action node it names
	// (TerminateNode), TargetExpr the target as written, nil for none. For a
	// start, Target is the behavior started (`obj.beh`) and TargetExpr its `start`.
	Terminates TerminateTarget
	Target     ast.Node
	TargetExpr ast.Node
	// TargetExprID is TargetExpr in the table of the flow or body the statement was lowered for.
	TargetExprID program.ExprID
}

Effect is a statement acting on the world outside the body — perform, accept, terminate, start — lowered so a host rejecting it (a calculation) can say so.

func (Effect) Performed added in v0.13.0

func (e Effect) Performed(resolver *resolve.Resolver, scope *symbols.Scope) []*symbols.Symbol

Performed are the behaviors the effect performs or is typed by, resolved in scope.

func (Effect) TargetAt added in v0.13.0

func (e Effect) TargetAt() Extent

TargetAt is where the effect's target was written.

type EffectKind

type EffectKind int

EffectKind names a statement that acts on the world outside the body it stands in.

const (
	EffectPerform EffectKind = iota
	EffectAccept
	EffectTerminate
	// EffectStart is `perform obj.beh.start;`: the behavior the chain names begins on
	// its object and runs on its own, the statement done once it has started.
	EffectStart
)

func (EffectKind) String

func (k EffectKind) String() string

type EndpointResolver

type EndpointResolver interface {
	// Endpoint returns the declaration an endpoint names, written in scope, and
	// whether it names a vertex at all. target is a name or a feature chain (`c.c1`).
	Endpoint(scope *symbols.Scope, target ast.Node) (decl ast.Node, ok bool)
	// EndpointNames reports whether an endpoint written in scope names any element at
	// all, a vertex or not: one that does not is a name-resolution error.
	EndpointNames(scope *symbols.Scope, target ast.Node) bool
}

EndpointResolver resolves the vertex a transition endpoint names, implemented by the name-resolution tier (*resolve.Resolver) so lowering matches no names itself.

func NewLibraryStateTypes

func NewLibraryStateTypes(resolver *resolve.Resolver) EndpointResolver

NewLibraryStateTypes is the LibraryStateTypes over resolver, nil without one: lowering then names its endpoints from the scope tree alone.

type EntryTransition

type EntryTransition struct {
	// Decl is the member as written: a TransitionMember, a SuccessionEdge, a
	// succession usage or a `first start then s;` marker.
	Decl ast.Node
	// Guard is nil for an unconditional entry transition.
	Guard ast.Node
	// GuardID is Guard in the table of the machine.
	GuardID program.ExprID
	Target  *ast.StateNode
	Via     *ast.PseudostateNode
	// TargetID and ViaID are Target and Via by id, 0 for none.
	TargetID program.StateID
	ViaID    program.PseudoID
	Effect   []StateBehavior
	// Scope is the scope Guard resolves in.
	Scope *symbols.Scope
	// Origin is where the member was written, Kind "entry transition"; it has no Path.
	Origin program.Origin
	// SourceText is the source a TransitionMember names as written (`boot`), "" for the other forms.
	SourceText string
}

EntryTransition is a transition out of a body's entry action. Alternatives are kept in declaration order, the order the guards are tried in.

func (*EntryTransition) At added in v0.13.0

func (t *EntryTransition) At() Extent

At is where the entry transition was declared.

func (*EntryTransition) Declared added in v0.13.0

func (t *EntryTransition) Declared() ast.Node

Declared is the declaration the entry transition was lowered from.

func (*EntryTransition) GuardAt added in v0.13.0

func (t *EntryTransition) GuardAt() Extent

GuardAt is where the entry transition's guard was written, the zero Extent for none.

func (*EntryTransition) TargetVertex added in v0.13.0

func (t *EntryTransition) TargetVertex() (program.VertexRef, string)

TargetVertex is the vertex the entry transition reaches first, its pseudostate when it runs through one, and that vertex's name.

type EntryTransitionShapeError

type EntryTransitionShapeError struct {
	Transition *ast.TransitionMember
}

EntryTransitionShapeError marks a triggered or shorthand effect transition out of the entry action.

func (*EntryTransitionShapeError) Error

func (e *EntryTransitionShapeError) Error() string

type EntryTransitionTargetError

type EntryTransitionTargetError struct {
	Target ast.Node
}

EntryTransitionTargetError marks a transition out of the entry action whose target is not a state or an allowed junction/choice.

func (*EntryTransitionTargetError) Error

type ExprEntry added in v0.13.0

type ExprEntry struct {
	program.Expr
	// Tree is the syntax the expression was lowered from.
	Tree ast.Node
	// Scope is where its names were resolved: the only scope its symbols answer for.
	Scope *symbols.Scope
	// Operands are the entries behind Args, in order.
	Operands []*ExprEntry
	// Answer is the entry behind Result, nil for none.
	Answer *ExprEntry
}

ExprEntry is one lowered expression with where it came from beside it.

func Declared added in v0.13.0

func Declared(sym *symbols.Symbol) *ExprEntry

Declared is the declaration of sym standing where an expression is read: where a message about it points, and what the dimension its type fixes is read from.

func Valued added in v0.13.0

func Valued(sym *symbols.Symbol) *ExprEntry

Valued is the expression the declaration of sym is valued by, nil for a declaration stating none.

func (*ExprEntry) Classifies added in v0.13.0

func (e *ExprEntry) Classifies(m *semantics.Model, scope *symbols.Scope, elem *symbols.Symbol) (bool, error)

Classifies is the verdict of the classification `@T`/`@@T` the expression writes on elem, its type read in scope: the one a filter condition writing the same test reaches.

func (*ExprEntry) Dimension added in v0.13.0

func (e *ExprEntry) Dimension(m *semantics.Model, scope *symbols.Scope) (semantics.Dimension, bool)

Dimension is the quantity dimension the declarations the expression reads in scope fix for its value, false where they fix none.

func (*ExprEntry) Extent added in v0.13.0

func (e *ExprEntry) Extent() Extent

Extent is where the expression was written, the zero Extent for no expression.

func (*ExprEntry) Folded added in v0.13.0

func (e *ExprEntry) Folded(m *semantics.Model, maxBits int64) (semantics.Value, bool)

Folded is the constant the expression folds to under an Integer budget of maxBits, false for one only evaluation settles: the fold the semantic model makes of its syntax.

func (*ExprEntry) Footprint added in v0.13.0

func (e *ExprEntry) Footprint(resolver *resolve.Resolver, sem *semantics.Model, scope *symbols.Scope) Footprint

Footprint is what evaluating the expression in scope reads and writes.

func (*ExprEntry) Held added in v0.13.0

func (e *ExprEntry) Held(m *semantics.Model, scope *symbols.Scope) (semantics.Range, bool)

Held is how many values the expression holds wherever it is evaluated in scope, as far as the declarations it reads fix that.

func (*ExprEntry) Invoked added in v0.13.0

func (e *ExprEntry) Invoked() ([]string, bool)

Invoked are the names an invocation's function is written with, false for any other expression or one naming nothing; a chain never steps through them.

func (*ExprEntry) Reads added in v0.13.0

func (e *ExprEntry) Reads(visit func(segments []string, chain, ok bool) bool)

Reads visits each name and whole feature chain the expression reads a value through, a quantity's unit aside, with the names it steps through and false for one naming nothing; it stops where visit answers false.

func (*ExprEntry) Reference added in v0.13.0

func (e *ExprEntry) Reference() bool

Reference reports whether the expression is a name read as a feature reference or a chain of them, rather than a bare qualified name standing where an expression does.

func (*ExprEntry) Segments added in v0.13.0

func (e *ExprEntry) Segments() ([]string, bool)

Segments are the names a reference or a feature chain steps through, false for any other expression or one naming nothing.

func (*ExprEntry) Unit added in v0.13.0

func (e *ExprEntry) Unit(m *semantics.Model, scope *symbols.Scope) (semantics.Unit, error)

Unit reads the expression as the unit a quantity carries, its names read in scope.

func (*ExprEntry) UnitTerm added in v0.13.0

func (e *ExprEntry) UnitTerm(m *semantics.Model, scope *symbols.Scope) (semantics.UnitTerm, error)

UnitTerm reads the expression as a unit reduced to the base units it is made of, its names read in scope.

func (*ExprEntry) Written added in v0.13.0

func (e *ExprEntry) Written() string

Written names the syntax the expression was lowered from, for a message refusing a form the expression records carry no kind for.

type ExprTable added in v0.13.0

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

ExprTable is a table of lowered expressions by id, index zero "none".

func LowerExpr added in v0.13.0

func LowerExpr(node ast.Node, scope *symbols.Scope, resolver *resolve.Resolver) (*ExprTable, program.ExprID)

LowerExpr lowers the expression node, written in scope, into a table of its own: every name it reads is resolved here, once, and recorded beside its spelling.

func NewExprTable added in v0.13.0

func NewExprTable(resolver *resolve.Resolver) *ExprTable

NewExprTable is an empty table whose interned expressions resolve with resolver.

func (*ExprTable) At added in v0.13.0

func (t *ExprTable) At(id program.ExprID) *program.Expr

At is the lowered expression behind an id, nil for none.

func (*ExprTable) Entry added in v0.13.0

func (t *ExprTable) Entry(id program.ExprID) *ExprEntry

Entry is the expression behind an id with its tree and scope, nil for none.

func (*ExprTable) Intern added in v0.13.0

func (t *ExprTable) Intern(node ast.Node, scope *symbols.Scope) program.ExprID

Intern lowers node, written in scope, and gives it an id; 0 for no node or no table.

func (*ExprTable) Lower added in v0.13.0

func (t *ExprTable) Lower(node ast.Node, scope *symbols.Scope, resolver *resolve.Resolver) program.ExprID

Lower adds the expression node, written in scope, to the table and returns its id. It never fails: a name resolving to nothing is for the run reading it to report.

func (*ExprTable) Tree added in v0.13.0

func (t *ExprTable) Tree(id program.ExprID) ast.Node

Tree is the syntax the expression behind an id was lowered from, nil for none.

type Extent added in v0.13.0

type Extent struct {
	Span    source.Span
	Written bool
}

Extent is where a declaration or an expression was written, the zero Extent for one lowering supplied or none at all.

func StatementAt added in v0.13.0

func StatementAt(s Statement) Extent

StatementAt is where a statement was written, a send by its message; the zero Extent for one lowering supplied.

type Feature

type Feature struct {
	Name      string
	Direction ast.FeatureDirection
	IsResult  bool // a `return` parameter, what the node stands for read as a value
	// ValueID is Value in the table of the flow or machine the feature was lowered for.
	ValueID program.ExprID
	Value   ast.Node
	Binding bool
	Node    ast.Node // the declaration, for diagnostics
	Scope   *symbols.Scope
	// Shadowed marks an inherited feature a same-named nearer feature hides without
	// redefining it; Name is then its ShadowedKey (see Attribute.Shadowed).
	Shadowed bool
}

Feature is one parameter or attribute an action node declares itself. Value is its declared value (nil when none), resolving in Scope, the node's scope.

func (Feature) At added in v0.13.0

func (f Feature) At() Extent

At is where the feature was declared.

func (Feature) Bound added in v0.13.0

func (f Feature) Bound() bool

Bound reports whether the feature states a value.

func (Feature) Declared added in v0.13.0

func (f Feature) Declared() ast.Node

Declared is the declaration the feature was lowered from.

func (Feature) Output added in v0.9.2

func (f Feature) Output() bool

Output reports whether the feature is written back rather than read: an `out` or `return` parameter.

func (Feature) ValueAt added in v0.13.0

func (f Feature) ValueAt() Extent

ValueAt is where the feature's value was written, the zero Extent for none.

func (Feature) ValueLiteral added in v0.13.0

func (f Feature) ValueLiteral() string

ValueLiteral is the feature's literal value as the notation writes it, "" for a value that is no literal.

func (Feature) ValueName added in v0.13.0

func (f Feature) ValueName() (string, bool)

ValueName is the last segment of the name the feature's value references, false for a value that is no reference.

type FeatureFlow added in v0.13.0

type FeatureFlow struct {
	// Source and Target are the ends' paths from the declaring type, feature by feature.
	Source, Target []string
	// Multiplicity is the flow's own as written (`flow f [0] from …`), nil when none,
	// read in Scope, the body the flow was written in.
	Multiplicity *ast.Multiplicity
	Scope        *symbols.Scope
	Decl         *ast.Usage
}

FeatureFlow is a streaming flow a type or usage declares between two features it reaches by path (`flow pusher.push.output to cart.roll.input`).

func ToFeatureFlows added in v0.13.0

func ToFeatureFlows(decl ast.Node, scope *symbols.Scope) []FeatureFlow

ToFeatureFlows lowers the streaming flows decl directly declares whose two ends are feature paths; a succession flow, which orders its ends, is none.

type Flow added in v0.12.0

type Flow struct {
	Reads  []Place
	Writes []Place
}

Flow is one statement's data flow: its writes stand on its reads.

type FlowKind

type FlowKind int

FlowKind is how a data flow carries its values: streaming, as a `flow` is unless designated otherwise (Flows::Flow), or as a succession flow (Flows::SuccessionFlow).

const (
	// FlowStreaming delivers each value the source pin takes to the target's ongoing
	// performances, or ahead of its next one while none is under way.
	FlowStreaming FlowKind = iota
	// FlowSuccession delivers the value the source pin holds once the source
	// completes, and the target begins no sooner.
	FlowSuccession
)

func (FlowKind) String

func (k FlowKind) String() string

String names the kind as the notation spells it.

type FlowNode added in v0.13.0

type FlowNode struct {
	Graph *ActionGraph
	ID    program.NodeID
}

FlowNode names a node of a flow by its id there; the zero FlowNode names none.

type Footprint

type Footprint struct {
	Reads      []Place
	Writes     []Place
	Sends      []Channel
	Accepts    []Channel
	Control    []ast.Node
	Completion bool
	Dynamic    bool
	Creates    bool
	Routes     bool
	// Flows are the data flows of the move's statements, one each: what the
	// statement writes stands on what it reads. None for a move described whole.
	Flows []Flow
}

Footprint is what one atomic move (one token advancing one node, one transition firing) may touch. Control lists the joins and merges it arrives at; Completion marks a move that may queue a completion event; Dynamic an unresolved target. Creates marks a move that may create an object starting no behavior; Routes one sending through connections, which reads whatever the objects' structure holds.

func ConstraintBodyFootprint added in v0.10.0

func ConstraintBodyFootprint(scope *symbols.Scope, stmts []Statement) Footprint

ConstraintBodyFootprint projects the reads and writes of one constraint performance, marking declarations in its body-local scopes as local.

func ExpressionFootprint added in v0.11.0

func ExpressionFootprint(resolver *resolve.Resolver, sem *semantics.Model, scope *symbols.Scope, expr ast.Node) Footprint

ExpressionFootprint is what evaluating expr in scope reads: the places a guard or condition depends on, dynamic where the declarations do not decide them.

func FlowFootprint added in v0.10.0

func FlowFootprint(graph *ActionGraph) Footprint

FlowFootprint is what running the flow may touch: every node's footprint and those of the flows its nodes own; a node performing an action is dynamic.

func (Footprint) Dependent

func (f Footprint) Dependent(g Footprint) bool

Dependent reports whether the two moves may not commute: a data race, both touching the bus (a send meeting an accept, two accepts competing for one message, two sends ordering it), both queuing a completion, convergence on one join or merge, creation meeting creation or an extent, routing meeting a structural write, or a dynamic target.

func (Footprint) DependentBy added in v0.10.0

func (f Footprint) DependentBy(g Footprint, rel Relation) bool

DependentBy is Dependent under what rel knows of the moves' executors.

func (Footprint) PlacesEqual added in v0.12.1

func (f Footprint) PlacesEqual(g Footprint) bool

PlacesEqual reports whether the two footprints read and write the same places by the same statements, so one Standing serves both.

func (Footprint) Standing added in v0.12.1

func (f Footprint) Standing() *Standing

Standing indexes the footprint's flows by what they read and write.

func (Footprint) String

func (f Footprint) String() string

String renders the footprint one clause per line, names sorted, for tests and the checker's report.

type ForkPlan

type ForkPlan struct {
	Owner    *ast.StateNode
	Branches map[*ast.StateRegion]*Transition
}

ForkPlan is where a fork's branches lead: one per orthogonal region of Owner, each region starting at its branch's target after the branch's effect.

func (*ForkPlan) Targets

func (p *ForkPlan) Targets() map[*ast.StateRegion]*ast.StateNode

Targets is the state each region starts in.

type Hop added in v0.12.1

type Hop struct {
	Feature   string
	Anonymous *ast.Usage
}

Hop is one step from a holder to a connector object it holds: by feature name, or by the declaration of an anonymous connector member.

func (Hop) Reaches added in v0.12.1

func (h Hop) Reaches() bool

Reaches reports a hop that leads somewhere: a named feature or an anonymous declaration.

type If

type If struct {
	Condition ast.Node
	// ConditionID is Condition in the table of the flow or body the statement was lowered for.
	ConditionID program.ExprID
	Then        Block
	Else        *Block
	Node        ast.Node       // the conditional itself, for diagnostics
	Scope       *symbols.Scope // the scope the conditional, and so its condition, was declared in
}

If is a lowered conditional. The condition is evaluated in the enclosing body, outside both branches. Else is nil when the conditional declared none.

func (If) ConditionAt added in v0.13.0

func (i If) ConditionAt() Extent

ConditionAt is where the conditional's condition was written.

type Inherited

type Inherited struct {
	Decl ast.Node
	Body *symbols.Scope
}

Inherited is a declaration a graph took content from besides the one lowered (a definition typing or specializing it or a state of it); Body is its body's scope.

func (Inherited) Declared added in v0.13.0

func (in Inherited) Declared() ast.Node

Declared is the declaration the graph took content from.

func (Inherited) Doc added in v0.13.0

func (in Inherited) Doc() string

Doc is the document the inherited declaration was written in, "" outside any.

type Integrator

type Integrator int

Integrator is a fixed-step integration scheme the runtime provides for Integrate.

const (
	// IntegratorUnstated leaves the scheme to the run's default.
	IntegratorUnstated Integrator = iota
	IntegratorEuler
	IntegratorRK4
)

func (Integrator) String

func (i Integrator) String() string

String names the integrator as the library does.

type JoinPlan

type JoinPlan struct {
	Owner   *ast.StateNode
	Regions map[*Transition]*ast.StateRegion
}

JoinPlan is where a join's incoming segments come from: Regions maps each to the orthogonal region of Owner it leaves, Owner being the innermost state all the sources lie below, nil when only the machine's own regions do.

type LibraryStateTypes

type LibraryStateTypes struct {
	*resolve.Resolver
	// contains filtered or unexported fields
}

LibraryStateTypes lowers a state machine through the name-resolution tier, so a definition in another document contributes, withholding States::StateAction's content.

func (*LibraryStateTypes) StartShot

func (s *LibraryStateTypes) StartShot(decl ast.Node) bool

StartShot reports the library StateAction's own `start`, the shot every state inherits: a declaration elsewhere under that name is no start shot.

func (*LibraryStateTypes) WithholdsStateType

func (s *LibraryStateTypes) WithholdsStateType(decl ast.Node) bool

WithholdsStateType reports the library's StateAction, whose content lowering must not take: TypeDecl still resolves it, so lowering looks no further.

type Loop

type Loop struct {
	Kind      ast.LoopKind
	Condition ast.Node // nil for `for`, and for a `loop` written without `until`
	// ConditionID is Condition in the table of the flow or body the statement was lowered for.
	ConditionID program.ExprID
	// Until is the condition a `while` loop's `until` clause tests after each
	// iteration (`while c { … } until d;`), nil when it carries none.
	Until ast.Node
	// UntilID is Until in the table of the flow or body the statement was lowered for.
	UntilID    program.ExprID
	Variable   string   // `for` only: the name each element is bound to
	Alias      string   // `for` only: the variable's short name, where it declares a name as well
	Bound      bool     // `for` only: a variable is declared, the empty name included
	Collection ast.Node // `for` only: the collection iterated over
	// CollectionID is Collection in the table of the flow or body the statement was lowered for.
	CollectionID program.ExprID
	Body         Block
	// BodyAction is the action usage the loop declares as its body (`loop action
	// body { … }`, `loop action { … }`), nil for a body of statements alone.
	BodyAction *symbols.Symbol
	Node       ast.Node // the loop itself, for diagnostics
	// Scope is the scope the loop was declared in, which its collection resolves
	// in; its condition resolves in Body.Scope, which the body declares into.
	Scope *symbols.Scope
}

Loop is a lowered loop statement. Kind says when the condition is tested: before each iteration (`while`), after each iteration (`loop … until`), or not at all, iteration being driven by a collection (`for`).

Condition and Collection stay expressions because their values are only known at execution time. The iteration count is bounded by the executor's step budget, so a loop that never terminates fails the run rather than hanging it.

func (Loop) CollectionAt added in v0.13.0

func (l Loop) CollectionAt() Extent

CollectionAt is where the collection a `for` loop iterates was written.

func (Loop) ConditionAt added in v0.13.0

func (l Loop) ConditionAt() Extent

ConditionAt is where the loop's condition was written, the zero Extent for none.

func (Loop) For added in v0.13.0

func (l Loop) For() bool

For reports a `for` loop, which iterates over a collection.

func (Loop) PostTested added in v0.13.0

func (l Loop) PostTested() bool

PostTested reports a loop whose condition is tested after each run of its body.

func (Loop) Same added in v0.13.0

func (l Loop) Same(other Loop) bool

Same reports whether l and other are one loop statement.

func (Loop) UntilAt added in v0.13.0

func (l Loop) UntilAt() Extent

UntilAt is where a `while` loop's `until` condition was written, the zero Extent for none.

func (Loop) Word added in v0.13.0

func (l Loop) Word() string

Word is the keyword the loop was written with.

type NodeForm added in v0.13.0

type NodeForm uint8

NodeForm is how a node of an action graph was written, which decides what a consumer checks of it: finer than its NodeKind, which says what it does.

const (
	// FormOther is a node of no form below.
	FormOther NodeForm = iota
	FormInitial
	FormFinal
	FormFork
	FormJoin
	FormMerge
	FormDecision
	// FormAction is an action node written with the `action` keyword in a flow.
	FormAction
	// FormUsage is a usage standing as a node: a nested or performed action, an accept.
	FormUsage
	FormLoop
	FormIf
	FormAssign
	FormSend
	FormTerminate
)

type ObjectFlow

type ObjectFlow struct {
	// Name is the flow's own name, when it was declared with one
	// (`flow generateToAmplify from a.out to b.in;`), and "" for the anonymous
	// form and for a flow the notation writes as an edge.
	Name      string
	SourcePin string
	TargetPin string
	Target    ast.Node
	// SourceID and TargetID are the node the flow leaves and Target, in the graph's identity table.
	SourceID, TargetID program.NodeID
	// Kind is how the flow carries its values, as its declaration designated.
	Kind FlowKind
	// Decl is the declaration the flow was written as, for a consumer that
	// reports where it comes from.
	Decl ast.Node
	// Gate is the succession whose target is this succession flow
	// (`first a if g then f;`): the flow moves its value only when that succession is taken.
	Gate ast.Node
}

ObjectFlow represents a data flow edge between pins.

func (ObjectFlow) Declared added in v0.13.0

func (f ObjectFlow) Declared() ast.Node

Declared is the declaration the object flow was lowered from.

func (ObjectFlow) GateAt added in v0.13.0

func (f ObjectFlow) GateAt() Extent

GateAt is where the succession guarding the flow was declared.

func (ObjectFlow) Gated added in v0.13.0

func (f ObjectFlow) Gated() bool

Gated reports a succession flow a succession leads to, which may guard it.

func (ObjectFlow) Written added in v0.13.0

func (f ObjectFlow) Written() (source.Span, bool)

Written is where the flow was declared and whether it was declared at all.

type PerformedType added in v0.10.0

type PerformedType struct {
	Target *ast.QualifiedName
	// Referrer is the redefined node when it performs by reference subsetting
	// (`perform v.close;`) rather than by typing; Target is then nil.
	Referrer *ast.Usage
	Scope    *symbols.Scope
}

PerformedType is an action invocation inherited through action-node redefinition, resolved where the redefined node was declared.

type PinBinding

type PinBinding struct {
	Node  ast.Node
	Path  []ast.Node
	Pin   string
	Other ast.Node
	// OtherID is Other in the table of the flow the binding was lowered for.
	OtherID   program.ExprID
	OtherNode ast.Node
	OtherPath []ast.Node
	// NodeID and OtherNodeID are Node and OtherNode in the graph's identity table, 0 for none.
	NodeID, OtherNodeID program.NodeID
	OtherPin            string
	// OtherChain is the chain the other end walks to the object whose feature
	// OtherFeature it names (`holder.inner.mark`); nil for a node's pin or a plain name.
	OtherChain   *AssignTarget
	OtherFeature string
	// OtherOwner is the qualifier's symbol when the other end was qualified
	// (`Bench::level`), and OtherFeatureSym the feature it names.
	OtherOwner      *symbols.Symbol
	OtherFeatureSym *symbols.Symbol
	// OtherParameter is the parameter of the action itself the other end names
	// (`toast`, `ToastBread::bread`, one a usage inherits from its type), "" for
	// an end naming none; the action's own frame holds that pin.
	OtherParameter string
	Scope          *symbols.Scope // the scope the binding was written in
	Decl           *ast.Usage
	// FromValue marks the binding a pin's own value states (`inout n = ticks;`): the
	// value is the pin's initial value alone when no feature around the node holds it.
	FromValue bool
}

PinBinding is a binding connector with an end at pin Pin of Node — or, where Path is set, of the node Path reaches under it through the flows each owns (`leg.inner.v`: Node leg, Path [inner], Pin v). Other is the other end as written; OtherNode, OtherPath and OtherPin name the node pin it addresses, if any.

func PerformedPinBindings added in v0.11.0

func PerformedPinBindings(graph *ActionGraph, prefix []string, bindings []Binding, exprs *ExprTable) ([]PinBinding, error)

PerformedPinBindings lowers the bindings an object writes through the feature it performs graph as (`bind run.measure.report = theReport;`, prefix [run]) to pin bindings of graph's nodes, as the same bindings written in the action's body lower. Scope stays the object's, so the other end resolves where it was written.

func (PinBinding) At added in v0.13.0

func (b PinBinding) At() Extent

At is where the binding was declared.

func (PinBinding) AtNode added in v0.13.0

func (b PinBinding) AtNode() bool

AtNode reports whether the binding's own end is at a node rather than at the action itself.

func (PinBinding) Declared added in v0.13.0

func (b PinBinding) Declared() *ast.Usage

Declared is the usage the binding was lowered from.

func (PinBinding) OtherAt added in v0.13.0

func (b PinBinding) OtherAt() Extent

OtherAt is where the binding's other end was written.

func (PinBinding) OtherAtNode added in v0.13.0

func (b PinBinding) OtherAtNode() bool

OtherAtNode reports whether the binding's other end is at a node.

func (PinBinding) OtherPathDecls added in v0.13.0

func (b PinBinding) OtherPathDecls() []ast.Node

OtherPathDecls are the declarations OtherPath steps through into nested flows.

func (PinBinding) OtherPathNames added in v0.13.0

func (b PinBinding) OtherPathNames() []string

OtherPathNames are the names of the nodes the binding's other end steps through.

func (PinBinding) PathDecls added in v0.13.0

func (b PinBinding) PathDecls() []ast.Node

PathDecls are the declarations Path steps through into nested flows, which this graph does not number.

func (PinBinding) PathNames added in v0.13.0

func (b PinBinding) PathNames() []string

PathNames are the names of the nodes the binding's own end steps through.

type Place

type Place struct {
	Sym    *symbols.Symbol
	Name   string
	Local  bool
	State  *ast.StateNode
	Direct bool
	Via    *symbols.Symbol
	// Node is the node whose pin the place is, each performance of a node holding
	// its own; nil for a feature or a declaration's own value.
	Node ast.Node
}

Place is one feature a move reads or writes: the declaration the name resolves to (nil when unresolved) and the name; Local marks a pin, held per performance. State marks the activity of a state, which a transition reads and writes. Direct marks a name written alone, not reached through a chain or qualified. Via is the feature whose value holds the one a chain names (`left` in `left.raw`), nil for a name reached no such way; whether two such places hold one value is the run's to decide (features may alias), so Conflicts ignores it.

func (Place) Conflicts

func (p Place) Conflicts(q Place) bool

Conflicts reports whether the two places may name one value: places resolving to one declaration do under any of its names (a short name, a redefined name), as do same-named places, except two distinct pins, which each performance holds its own of; the activity of a state meets only itself.

func (Place) String

func (p Place) String() string

String renders the place as the name it was written under.

type Probability

type Probability struct {
	Expr ast.Node
	// ExprID is Expr in the table of the flow or machine the weight was lowered for.
	ExprID program.ExprID
	// Node is the annotation, for the span a message about the weight points at.
	Node ast.Node
}

Probability is the weight a succession's `@Probability { p = ...; }` states for its branch: the expression bound to p, read where the succession's guard is.

func (*Probability) Constant

func (p *Probability) Constant() (float64, bool)

Constant is the weight when its expression is a number computed from literals alone (0.7, 1 - 0.3); a weight computed from features is known only when drawn.

func (*Probability) Span

func (p *Probability) Span() source.Span

Span is where the annotation is written.

type ProbabilityError

type ProbabilityError struct {
	Node   ast.Node
	Reason string
}

ProbabilityError reports Probability metadata the lowering cannot give a meaning: at what node, and why.

func (*ProbabilityError) Error

func (e *ProbabilityError) Error() string

func (*ProbabilityError) Is

func (e *ProbabilityError) Is(target error) bool

Is makes every ProbabilityError match ErrProbability.

func (*ProbabilityError) Span

func (e *ProbabilityError) Span() source.Span

Span is where the offending annotation or succession is written.

type Provenance added in v0.13.0

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

Provenance maps a graph's ids back to the declarations its records were lowered from; index zero of every table is "none".

func (*Provenance) Node added in v0.13.0

func (p *Provenance) Node(id program.NodeID) ast.Node

Node is the declaration behind a node id, nil for none.

func (*Provenance) Pseudostate added in v0.13.0

func (p *Provenance) Pseudostate(id program.PseudoID) *ast.PseudostateNode

Pseudostate is the declaration behind a pseudostate id, nil for none.

func (*Provenance) Region added in v0.13.0

func (p *Provenance) Region(id program.RegionID) *ast.StateRegion

Region is the declaration behind a region id, nil for none.

func (*Provenance) State added in v0.13.0

func (p *Provenance) State(id program.StateID) *ast.StateNode

State is the declaration behind a state id, nil for none.

func (*Provenance) Transition added in v0.13.0

func (p *Provenance) Transition(id program.TransID) *Transition

Transition is the record behind a transition id, nil for none.

type Relation added in v0.10.0

type Relation struct {
	Channels ChannelsMeet
	Apart    bool
	Objects  bool
	Held     func(p, q Place) bool
}

Relation is what is known of the executors two moves belong to. Channels decides which message operations meet, nil having every two meet. Apart marks two executors, each converging on control nodes of its own; Objects two run for two objects, each holding its own pins and state activity, and Held, where set, reports whether a direct place of the first move's and one of the second's are slots of different objects.

func (Relation) PlaceMeet added in v0.12.1

func (rel Relation) PlaceMeet(p, q Place) bool

PlaceMeet reports whether p, a place of the first move's, may name the value of q, a place of the second's.

type Return

type Return struct {
	Value ast.Node
	// ValueID is Value in the table of the flow or body the statement was lowered for.
	ValueID program.ExprID
	Node    ast.Node       // the return itself, for diagnostics
	Scope   *symbols.Scope // the scope the returned expression was written in
}

Return is a lowered `return`: the value the enclosing behavior computes, possibly from inside a block. Value is nil when it named no expression.

func (Return) Syntax added in v0.13.0

func (r Return) Syntax() ast.Node

Syntax is the returned expression as written, nil for a return of none; a reader compiling the expression itself (a query plan) starts from it.

func (Return) ValueAt added in v0.13.0

func (r Return) ValueAt() Extent

ValueAt is where the returned value was written, the zero Extent for none.

type RunToCompletion

type RunToCompletion struct {
	// Value is the isRunToCompletion expression, nil for the default true.
	Value ast.Node
	// ValueID is Value in the table of the machine.
	ValueID program.ExprID
	// ValueScope resolves names in Value.
	ValueScope *symbols.Scope
	// ValueOwner owns Value's state data; nil denotes the machine.
	ValueOwner *ast.StateNode
	// Scope is the state named by runToCompletionScope; nil denotes the machine.
	Scope *ast.StateNode
}

RunToCompletion is the effective run-to-completion configuration of a body.

type RunToCompletionRedefinition

type RunToCompletionRedefinition struct {
	// Feature is the redefined run-to-completion feature.
	Feature string
	// Decl is the redefinition declaration.
	Decl *ast.Usage
	// Owner describes the body containing the declaration.
	Owner string
	// Written is the value as written.
	Written string
	// NotAncestor reports a resolved state outside the current state ancestry.
	NotAncestor bool
}

RunToCompletionRedefinition reports a redefinition of runToCompletionScope the graph cannot resolve to this machine or an enclosing state.

func (*RunToCompletionRedefinition) Error

func (*RunToCompletionRedefinition) Unwrap

func (e *RunToCompletionRedefinition) Unwrap() error

Unwrap makes the refusal match ErrUnsupportedStateContent, the error every other state content lowering cannot represent reports.

type Send

type Send struct {
	Message ast.Node
	// MessageID is Message in the table of the flow or body the statement was lowered for.
	MessageID program.ExprID
	Target    string
	TargetSym *symbols.Symbol
	Node      ast.Node
	// TargetPath records that Target is a feature chain (`a.b`) reaching through
	// the sender's features, rather than a name in a namespace (`R`, `P::R`).
	TargetPath bool
	// TargetExpr is the receiver expression of an addressed send as written; the
	// runtime evaluates it to objects where Target carries no name or path.
	TargetExpr ast.Node
	// TargetExprID is TargetExpr in the table of the flow or body the statement was lowered for.
	TargetExprID program.ExprID
	IsVia        bool
	// ViaSelf records a via path written from `this`, whose root is a feature of
	// the sender even where the behavior binds that name to another object.
	ViaSelf bool
	// Receiver is the name addressed by a routed send, empty when omitted.
	Receiver     string
	ReceiverPath bool
	// ReceiverExpr is the `to` expression of a routed send, likewise evaluated to
	// objects where Receiver carries no name the sender resolves.
	ReceiverExpr ast.Node
	// ReceiverExprID is ReceiverExpr in the table of the flow or body the statement was lowered for.
	ReceiverExprID program.ExprID
	Scope          *symbols.Scope // the scope the statement was declared in
}

Send is a lowered send statement. Message stays an expression because its value is only known at execution time.

Target is the name the send addressed, empty for a broadcast. IsVia records that the name is a port of the sender rather than a receiver, in which case it is the whole path the port was written as and the message goes to whatever the graph's Connections join that port to.

TargetSym is the feature a via target resolves to where it was written, so routing matches the feature the name denotes rather than the name alone: a port a behavior declares under a connected port's name shadows that port. It is nil where the scope tree alone does not resolve the path.

func (Send) Constructs added in v0.13.0

func (s Send) Constructs() (string, bool)

Constructs is the last segment of the type the send's message constructs, false for a message that is any other expression.

func (Send) MessageAt added in v0.13.0

func (s Send) MessageAt() Extent

MessageAt is where the send's message was written.

func (Send) ReceiverAt added in v0.13.0

func (s Send) ReceiverAt() Extent

ReceiverAt is where the `to` receiver of a routed send was written, the zero Extent for none.

func (Send) Signal added in v0.13.0

func (s Send) Signal() string

Signal names the signal type the send posts: the type its message names, else the form its message was written in where it is a value.

func (Send) TargetAt added in v0.13.0

func (s Send) TargetAt() Extent

TargetAt is where the send's `via` or `to` addressee was written, the zero Extent for none.

type SequenceEvent added in v0.11.0

type SequenceEvent struct {
	Symbol   *symbols.Symbol
	Lifeline *symbols.Symbol // nil for a nested interaction use
	Use      bool
	Performs []*symbols.Symbol
	Asserts  []Assert
	// Sends and Receives are the transfers leaving and reaching the event, in declaration order.
	Sends, Receives []*Transfer
	// contains filtered or unexported fields
}

SequenceEvent is one node of the interaction: an event occurrence a lifeline holds, with the actions its body performs when the event occurs (`perform action spinCall ::> Motor::spin`) and the constraints it asserts hold there; or, with Use set, an occurrence usage of a nested interaction performed at its place.

func (*SequenceEvent) Text added in v0.11.0

func (ev *SequenceEvent) Text() string

Text names the node: an event as its lifeline's member, a use by its name.

type SequenceGraph added in v0.11.0

type SequenceGraph struct {
	Decl  ast.Node
	Scope *symbols.Scope
	// Bodies are the bodies the occurrence's members are read from: its own, then
	// those of the types it is typed by or specializes, nearest first.
	Bodies    []*symbols.Scope
	Lifelines []*symbols.Symbol
	// Events are the nodes of the interaction in declaration order: the event
	// occurrences of the lifelines and the occurrence usages of nested interactions.
	Events []*SequenceEvent
	Orders []SequenceOrder
	// Order is the nodes in realization order: topological over the stated
	// orders and each message's own send-before-receive, ties broken by
	// declaration order. A transfer is posted at its source event and taken at
	// its target event; a nested interaction is performed at its place.
	Order []*SequenceEvent
	// Transfers are the messages in the order they are taken, which is the order
	// of their target events.
	Transfers []*Transfer
}

SequenceGraph is an occurrence definition or usage lowered as an interaction: the lifelines (the usages of its body holding event occurrences), the events each holds, the nested interactions its body uses, the orders the model states between them, and its messages as transfers in the order the events admit. A message is abstract (SysML v2.1 §7.16.2) and is realized by a transfer between its two ends (§7.16.1). A usage typed by an occurrence def (`occurrence spinup : Spinup { ref part :>> c = ctrl; }`) inherits the def's lifelines, events and messages; a member of its own body hides the inherited member of its name.

func ToSequenceGraph added in v0.11.0

func ToSequenceGraph(sym *symbols.Symbol, resolver *resolve.Resolver) (*SequenceGraph, error)

ToSequenceGraph lowers an occurrence definition or usage read as an interaction. The resolver resolves the ends and the typing; nil lowers a body whose ends are all simple names of the occurrence's own members and reads no inherited body.

type SequenceOrder added in v0.11.0

type SequenceOrder struct {
	From, To *SequenceEvent
	Decl     ast.Node
}

SequenceOrder is one order stated between two nodes: a member-attached `then` or a `succession first a then b;`.

type Site added in v0.13.0

type Site struct {
	// Kind labels what was declared: `start`, `fork`, `action usage`, `pseudostate entry`.
	Kind string
	// Name is the name the declaration answers to, "" for an anonymous one.
	Name string
	Span source.Span
}

Site is what a declaration of a lowered graph is called and where it was written, as an export of the graph names it.

type Standing added in v0.12.1

type Standing struct {
	Reads  []Place
	Writes []Place
	// contains filtered or unexported fields
}

Standing is a footprint indexed by declaration, name and state so that a place is decided only against the places of the move it may conflict with, each once.

func (*Standing) MeetsRead added in v0.13.0

func (s *Standing) MeetsRead(p Place, meet func(p, q Place) bool) bool

MeetsRead reports whether p meets a place among Reads, by meet, which may hold only of places p Conflicts with (a Relation's PlaceMeet does); so may MeetsWrite and WritesReading.

func (*Standing) MeetsWrite added in v0.13.0

func (s *Standing) MeetsWrite(p Place, meet func(p, q Place) bool) bool

MeetsWrite reports whether p meets a place among Writes.

func (*Standing) WritesReading added in v0.12.1

func (s *Standing) WritesReading(p Place, meet func(p, q Place) bool) ([]Place, bool)

WritesReading reports whether p meets a place among Reads, and if so the places the move writes standing on a read of a place met: the writes of the statements reading one, or every write of the move when a read outside its statements (a guard's) or a move described whole does. The places are valid until the next call.

type StartShotResolver

type StartShotResolver interface {
	StartShot(decl ast.Node) bool
}

StartShotResolver identifies the library's inherited `start` shot, the one declaration a `first start then s;` may leave from without naming a vertex.

type StateBehavior

type StateBehavior struct {
	// Node is the behavior's declaration, unwrapped of the membership the parser
	// puts it in, and is what a diagnostic about it names.
	Node ast.Node
	// Name is the name the behavior was declared with, "" for an anonymous one.
	Name string
	// Body are the behavior's statements in declaration order. An inline action
	// body is one block, since it is a namespace of its own; every other form
	// lowers to the one statement it states.
	Body []Statement
	// Nodes are the action nodes the blocks of Body declare, in declaration order,
	// each of which performs as a subperformance of the behavior's.
	Nodes []ast.Node
	// Multiplicities are the declared action-node multiplicities in Body.
	Multiplicities map[ast.Node]*ast.Multiplicity
	// Multiplicity is a declaration on the entry, do or exit behavior itself.
	Multiplicity *ast.Multiplicity
	// Scope is the scope the behavior was declared in, which its own statements
	// and the action name it performs resolve in.
	Scope *symbols.Scope
	// Owner is the state whose attributes the behavior reads and writes: the
	// state it belongs to, or the source of the transition it is an effect of.
	Owner *ast.StateNode
	// OwnerID is Owner by id in the machine the behavior was lowered for.
	OwnerID program.StateID
	// Block is the transition whose body the behavior is one step of, shared by
	// the steps of that body and by no other: a `terminate` in one ends them all.
	// Every other behavior is a performance of its own and has none (nil).
	Block ast.Node
	// Ordered marks a Body whose statements run in the order written where a
	// schedule would otherwise pick it: a terminate node's body, then its terminate.
	Ordered bool
}

StateBehavior is one behavior a state machine performs: an entry, do or exit behavior of a state, or one effect of a transition. Every form it may be written in — an inline action body, an assignment, a send, a performed action — is lowered into the statements the runtime executes.

func LowerBehaviors

func LowerBehaviors(actions []ast.Node, block ast.Node, scope *symbols.Scope, resolver *resolve.Resolver, exprs *ExprTable) []StateBehavior

LowerBehaviors lowers the actions of an entry, do or exit member, or the effects of a transition, in the scope they were declared in; block is the transition whose body they are the steps of, nil for any other. resolver is the name-resolution tier's, by which a body's Probability metadata is read (ToActionGraphWith).

func (StateBehavior) At added in v0.13.0

func (b StateBehavior) At() Extent

At is where the behavior was declared.

func (StateBehavior) Declared added in v0.13.0

func (b StateBehavior) Declared() ast.Node

Declared is the declaration the behavior was lowered from.

func (StateBehavior) NodeNames added in v0.13.0

func (b StateBehavior) NodeNames() []string

NodeNames are the names of the action nodes the behavior's blocks declare.

type StateBehaviors

type StateBehaviors struct {
	Entry []StateBehavior
	Do    []StateBehavior
	Exit  []StateBehavior
}

StateBehaviors are the lowered entry, do and exit behaviors of one state, each in declaration order.

type StateGraph

type StateGraph struct {
	// RunToCompletion contains effective RTC values for each state and the
	// machine under the nil key.
	RunToCompletion map[*ast.StateNode]RunToCompletion

	// Scope is the scope the machine's own body was declared in, in which the
	// expressions written directly among its members resolve their names.
	Scope *symbols.Scope

	// Attributes are the attributes the machine declares, in declaration order.
	Attributes []Attribute

	// StateScopes: state → the scope that state's body was declared in, which is
	// what the names in its entry, do and exit behaviors resolve against.
	StateScopes map[*ast.StateNode]*symbols.Scope

	// Behaviors: state → its lowered entry, do and exit behaviors. The executor
	// runs these rather than the state's AST members, so an inline action body is
	// executable statements by the time it is reached.
	Behaviors map[*ast.StateNode]*StateBehaviors

	// Parallel: state → its substates run in parallel, by its own `parallel` or
	// an inherited definition's; MachineParallel says it of the machine.
	Parallel        map[*ast.StateNode]bool
	MachineParallel bool

	// Features: a state's entry, do or exit action usage → the directed parameters
	// it declares (`in target : Target;`), the pins a view draws on its node.
	Features map[ast.Node][]Feature

	// HiddenStates are graph-only composite owners synthesized for parallel
	// regions. They execute behaviors but are not user-visible state visits.
	HiddenStates map[*ast.StateNode]bool

	// HiddenRegionOf: graph-only owner → the region it stands for, so a walk up
	// the parent chain crosses it without losing which region a state is in.
	HiddenRegionOf map[*ast.StateNode]*ast.StateRegion

	// RegionState: synthesized region → the graph-only owner standing for it,
	// which holds the attributes the region's body declares.
	RegionState map[*ast.StateRegion]*ast.StateNode

	// Machine is the graph-only root state for the machine's own entry, do and
	// exit behaviors. A parallel machine's regions are TopRegions instead.
	Machine *ast.StateNode

	// Exprs is the table the graph's ExprIDs index, shared with the flows of its behaviors.
	Exprs *ExprTable

	// States in the machine (flat list, includes nested)
	States []*ast.StateNode

	// ID is each state's graph-local id, dense from 1 in the order of States.
	ID map[*ast.StateNode]program.StateID

	// Origins is each state's origin by id; Origins[0] is unused.
	Origins []program.Origin

	// RegionID is each region's id, the machine's own regions first, then each
	// state's in state order; RegionOrigins is its origin by id.
	RegionID      map[*ast.StateRegion]program.RegionID
	RegionOrigins []program.Origin

	// PseudoID is each pseudostate's id in the order of Pseudostates;
	// PseudoOrigins is its origin by id.
	PseudoID      map[*ast.PseudostateNode]program.PseudoID
	PseudoOrigins []program.Origin

	// TransID is each transition's id, those leaving each state in state order,
	// then each pseudostate's; TransOrigins is its origin by id.
	TransID      map[*Transition]program.TransID
	TransOrigins []program.Origin

	// Provenance maps the ids back to the records they were lowered from.
	Provenance Provenance

	// Pseudostates of the machine in declaration order. Not keyed by name:
	// sibling regions may declare same-named pseudostates.
	Pseudostates []*ast.PseudostateNode

	// PseudostateOwner: pseudostate -> the composite state that declares it,
	// absent for one declared directly in the machine. A history pseudostate
	// restores the configuration of its owner, so the owner must survive lowering.
	PseudostateOwner map[*ast.PseudostateNode]*ast.StateNode
	// PseudostateRegion is the region its outgoing route segments run within, if any.
	PseudostateRegion map[*ast.PseudostateNode]*ast.StateRegion

	// Terminates are the machine's terminate action usages (`action stop terminate;`)
	// in declaration order: a transition ending at one ends the machine's performance.
	Terminates []*ast.Usage

	// TerminateOwner: terminate action usage -> the composite state that declares
	// it, absent for one declared directly in the machine.
	TerminateOwner map[*ast.Usage]*ast.StateNode

	// TerminateBehaviors: terminate action usage naming an occurrence (`action
	// halt terminate worker;`) -> the behavior a transition ending at the usage
	// performs in place of ending the machine: the usage's body, then the terminate.
	TerminateBehaviors map[*ast.Usage]StateBehavior

	// TerminateCompletion: terminate action usage naming an occurrence -> the
	// completion vertex of the body declaring it, which a transition ending at
	// the usage enters once its behavior has run, as one to `done` does.
	TerminateCompletion map[*ast.Usage]*ast.StateNode

	// Transitions: source node (StateNode or PseudostateNode) → list of transitions
	Transitions map[ast.Node][]*Transition

	// CompositeStates: state → regions
	CompositeStates map[*ast.StateNode][]*ast.StateRegion

	// CompositeStateOrder preserves declaration order for deterministic runtime
	// selection of an active composite owner.
	CompositeStateOrder []*ast.StateNode

	// RegionInitials: region → initial state, nil when default entry leaves it inactive.
	RegionInitials map[*ast.StateRegion]*ast.StateNode

	// ParentState: child → parent
	ParentState map[*ast.StateNode]*ast.StateNode

	// RegionOwner: region → owning composite state
	RegionOwner map[*ast.StateRegion]*ast.StateNode

	// TopRegions are the machine's own orthogonal regions, in declaration order.
	// The order is observable: it is the order regions are entered and exited in.
	TopRegions []*ast.StateRegion

	// RegionOf: state → the region that declares it (fork/join need the region a
	// target belongs to)
	RegionOf map[*ast.StateNode]*ast.StateRegion

	// InitialState (required for simple machines, nil for multi-region)
	Initial *ast.StateNode

	// EntryTransitions: the body a transition out of the entry action is written
	// in (a state, a region, nil for the machine's own body) → those transitions in
	// declaration order; the first whose guard holds names the state it starts in.
	EntryTransitions map[ast.Node][]*EntryTransition

	// ForkPlans: fork → where its branches lead, checked when the graph is built.
	ForkPlans map[*ast.PseudostateNode]*ForkPlan

	// ForkEntered: region → the forks whose branches enter it, in declaration order.
	ForkEntered map[*ast.StateRegion][]*ast.PseudostateNode

	// JoinPlans: join → where its segments come from, checked when the graph is built.
	JoinPlans map[*ast.PseudostateNode]*JoinPlan

	// Connections are the connectors declared in the state machine body, which
	// is how a `send ... via <port>` in an entry/do/exit/effect action finds the
	// ports it reaches.
	Connections []Connection

	// StateAttributes: state → the attributes it owns, its own and those it
	// inherits from the definition typing it. Each state owns its values, so two
	// usages of one definition hold two sets of them.
	StateAttributes map[*ast.StateNode][]Attribute
	// contains filtered or unexported fields
}

StateGraph is the execution IR for state machines.

func ToStateGraph

func ToStateGraph(stateMachineDecl ast.Node, scope *symbols.Scope) (*StateGraph, error)

ToStateGraph converts a state machine AST (Usage or Definition) to a StateGraph. scope is the scope the machine's body was declared in — the scope the machine itself owns — from which the scope of every state and transition it carries is derived. Its endpoints resolve against the machine's own symbols; a caller holding the name-resolution tier's uses ToStateGraphWithEndpoints instead.

func ToStateGraphWithEndpoints

func ToStateGraphWithEndpoints(stateMachineDecl ast.Node, scope *symbols.Scope, endpoints EndpointResolver) (*StateGraph, error)

ToStateGraphWithEndpoints lowers a state machine, building its transitions from the endpoints the name-resolution tier already resolved.

func (*StateGraph) AttributeScope

func (g *StateGraph) AttributeScope(attr Attribute) *symbols.Scope

AttributeScope is the scope an attribute's value resolves in, which is the body declaring it rather than the machine's when the machine inherits it.

func (*StateGraph) AttributesOf added in v0.13.0

func (g *StateGraph) AttributesOf(id program.StateID) []Attribute

AttributesOf are the attributes the state owns, its own and those it inherits.

func (*StateGraph) BehaviorFeatures added in v0.13.0

func (g *StateGraph) BehaviorFeatures(behavior StateBehavior) []Feature

BehaviorFeatures are the directed parameters an entry, do or exit action usage declares.

func (*StateGraph) BehaviorFootprint added in v0.11.0

func (g *StateGraph) BehaviorFootprint(behavior StateBehavior) Footprint

BehaviorFootprint is what running the behavior touches: its table entry for an entry, do or exit behavior, computed on first use for a transition's or an entry transition's effect, which the table does not key.

func (*StateGraph) BehaviorFootprints

func (g *StateGraph) BehaviorFootprints() map[ast.Node]Footprint

BehaviorFootprints is entry, do or exit behavior (its Node) → what running it touches, computed on first use as TransitionFootprints is.

func (*StateGraph) BehaviorsOf added in v0.13.0

func (g *StateGraph) BehaviorsOf(id program.StateID) *StateBehaviors

BehaviorsOf are the state's lowered entry, do and exit behaviors, nil for a state with none.

func (*StateGraph) BranchFootprints added in v0.11.0

func (g *StateGraph) BranchFootprints() map[*Transition]Footprint

BranchFootprints is segment out of a pseudostate → what taking that branch of a junction or choice may touch, computed on first use as TransitionFootprints is; a pseudostate's branches are segments of the transitions into it, so they are not among TransitionFootprints.

func (*StateGraph) BranchFootprintsFrom added in v0.11.0

func (g *StateGraph) BranchFootprintsFrom(origin *ast.StateNode, segs []*Transition) []Footprint

BranchFootprintsFrom is what taking each of segs, the branches out of one pseudostate, does for a transition that left origin: the states left and entered, their exit, entry and do behaviors, and the branch's guard, probability and effects, followed through further pseudostates as the transition's own footprint is. The exits every branch shares — origin up to the nearest of the branches' boundaries — are left out, since they happen whichever branch is drawn; a branch into a further pseudostate leaves its boundary unknown, so then nothing is left out.

func (*StateGraph) Completes

func (g *StateGraph) Completes(state *ast.StateNode) bool

Completes reports whether entering state completes the region it belongs to: it is the `done` end shot of the state or machine whose body names it.

func (*StateGraph) Completing added in v0.13.0

func (g *StateGraph) Completing(id program.StateID) bool

Completing reports whether the state is the `done` vertex of the body naming it.

func (*StateGraph) CompositeIDs added in v0.13.0

func (g *StateGraph) CompositeIDs() []program.StateID

CompositeIDs are the ids of the states owning regions, in declaration order.

func (*StateGraph) DeclOf

func (g *StateGraph) DeclOf(state *ast.StateNode) ast.Node

DeclOf is the declaration state was lowered from: the node the scope tree is keyed by, or the state itself when it was written as one.

func (*StateGraph) DocOf

func (g *StateGraph) DocOf(decl ast.Node) string

DocOf is the document a declaration of the graph was written in: the general's where inherited, else the machine's own; "" outside any document.

func (*StateGraph) EntryDoc added in v0.13.0

func (g *StateGraph) EntryDoc(t *EntryTransition) string

EntryDoc is the document the entry transition was written in, the general's where inherited.

func (*StateGraph) EntryOwner

func (g *StateGraph) EntryOwner(owner ast.Node) ast.Node

EntryOwner is the body owner's entry transitions are written in, as EntryTransitions keys it: the region a state of a parallel state stands for, else owner itself.

func (*StateGraph) EntryTransitionsOf added in v0.13.0

func (g *StateGraph) EntryTransitionsOf(id program.StateID) []*EntryTransition

EntryTransitionsOf are the transitions out of the entry action of the state's body, in declaration order; 0 is the machine's own body.

func (*StateGraph) ForkStarted

func (g *StateGraph) ForkStarted(region *ast.StateRegion) bool

ForkStarted reports whether a fork branch enters region.

func (*StateGraph) Hidden added in v0.13.0

func (g *StateGraph) Hidden(id program.StateID) bool

Hidden reports whether the state is a graph-only owner synthesized for a parallel region.

func (*StateGraph) HiddenRegion added in v0.13.0

func (g *StateGraph) HiddenRegion(id program.StateID) program.RegionID

HiddenRegion is the region a graph-only owner stands for, 0 for a visible state.

func (*StateGraph) Inherited

func (g *StateGraph) Inherited() []Inherited

Inherited lists the declarations the machine's content was materialized from besides its own, each once, in the order lowering first reached them.

func (*StateGraph) InitialID added in v0.13.0

func (g *StateGraph) InitialID() program.StateID

InitialID is the state a machine without top-level regions starts in, 0 for none.

func (*StateGraph) IsInitial

func (g *StateGraph) IsInitial(state *ast.StateNode) bool

IsInitial reports whether the machine may start in state: some entry transition of its body names it. Whether it starts there unconditionally is UnconditionalStart's.

func (*StateGraph) JoinSegmentFootprints added in v0.11.0

func (g *StateGraph) JoinSegmentFootprints(join *ast.PseudostateNode, segs []*Transition) []Footprint

JoinSegmentFootprints is what firing each of segs, transitions pending into one join, does on its own once the join fires: its source's activity, trigger and guard read, its effects run, and the states from its source up to the join's owner exited. The owner's exit and the join's way out follow whichever segment fires first, so they are left out of every segment's footprint, as the exits a junction's branches share are; a join without a plan leaves each footprint dynamic.

func (*StateGraph) MachineID added in v0.13.0

func (g *StateGraph) MachineID() program.StateID

MachineID is the id of the machine state, which the state table leaves out: one past the last numbered state.

func (*StateGraph) ParallelState added in v0.13.0

func (g *StateGraph) ParallelState(id program.StateID) bool

ParallelState reports whether the state's substates run in parallel.

func (*StateGraph) ParentOf added in v0.13.0

func (g *StateGraph) ParentOf(id program.StateID) program.StateID

ParentOf is the state's parent, 0 for a state without one.

func (*StateGraph) PseudoIDs added in v0.13.0

func (g *StateGraph) PseudoIDs() []program.PseudoID

PseudoIDs are the ids of the graph's pseudostates, in declaration order.

func (*StateGraph) PseudostateOwnerOf added in v0.13.0

func (g *StateGraph) PseudostateOwnerOf(id program.PseudoID) program.StateID

PseudostateOwnerOf is the composite state declaring the pseudostate, 0 for one of the machine.

func (*StateGraph) PseudostateRegionOf added in v0.13.0

func (g *StateGraph) PseudostateRegionOf(id program.PseudoID) program.RegionID

PseudostateRegionOf is the region the pseudostate's outgoing segments run within, 0 for none.

func (*StateGraph) RegionDecl added in v0.13.0

func (g *StateGraph) RegionDecl(id program.RegionID) ast.Node

RegionDecl is the declaration the region was built from, nil for no region.

func (*StateGraph) RegionDeclOf added in v0.11.0

func (g *StateGraph) RegionDeclOf(region *ast.StateRegion) ast.Node

RegionDeclOf is the declaration region was built from: the direct substate of a parallel state or machine that supplies its body, else the region itself.

func (*StateGraph) RegionDoc added in v0.13.0

func (g *StateGraph) RegionDoc(id program.RegionID) string

RegionDoc is the document the region was written in, the machine's for no region.

func (*StateGraph) RegionEntryTransitions added in v0.13.0

func (g *StateGraph) RegionEntryTransitions(id program.RegionID) []*EntryTransition

RegionEntryTransitions are the transitions out of the entry action of the region's body.

func (*StateGraph) RegionInitialOf added in v0.13.0

func (g *StateGraph) RegionInitialOf(id program.RegionID) program.StateID

RegionInitialOf is the state the region starts in, 0 when default entry leaves it inactive.

func (*StateGraph) RegionOwnerOf added in v0.13.0

func (g *StateGraph) RegionOwnerOf(id program.RegionID) program.StateID

RegionOwnerOf is the composite state owning the region, 0 for a region of the machine.

func (*StateGraph) RegionSite added in v0.13.0

func (g *StateGraph) RegionSite(id program.RegionID) (Site, bool)

RegionSite is the site of the region behind id, false for none.

func (*StateGraph) RegionStateOf added in v0.13.0

func (g *StateGraph) RegionStateOf(id program.RegionID) program.StateID

RegionStateOf is the graph-only owner standing for a synthesized region, 0 for none.

func (*StateGraph) RegionsOf added in v0.13.0

func (g *StateGraph) RegionsOf(id program.StateID) []program.RegionID

RegionsOf are the composite state's regions, in declaration order.

func (*StateGraph) RunToCompletionOf

func (g *StateGraph) RunToCompletionOf(state *ast.StateNode) RunToCompletion

RunToCompletionOf returns the effective configuration for state, or the machine when state is nil.

func (*StateGraph) Semantics added in v0.12.0

func (g *StateGraph) Semantics() *semantics.Model

Semantics is the semantic model over the graph's resolver, built once and shared by every footprint of the graph; nil without a resolver.

func (*StateGraph) StartOf

func (g *StateGraph) StartOf(owner ast.Node) []*EntryTransition

StartOf returns the transitions out of a body's entry action in declaration order: owner is the state whose body it is, the region, or nil for the machine's own body. A state standing for a region of a parallel state starts where that region's entry transitions say.

func (*StateGraph) StartOfState added in v0.13.0

func (g *StateGraph) StartOfState(id program.StateID) []*EntryTransition

StartOfState are the transitions out of the entry action of the state's body, those of the region it stands for when it does; 0 is the machine's own body.

func (*StateGraph) StartsBody added in v0.13.0

func (g *StateGraph) StartsBody(id program.StateID) bool

StartsBody reports whether the body declaring the state starts in it whatever its guards say.

func (*StateGraph) StateDecl added in v0.13.0

func (g *StateGraph) StateDecl(id program.StateID) ast.Node

StateDecl is the declaration the state was lowered from, nil for no state.

func (*StateGraph) StateIDOf added in v0.13.0

func (g *StateGraph) StateIDOf(state *ast.StateNode) program.StateID

StateIDOf is the id of a state of the graph, the machine state included; 0 for nil.

func (*StateGraph) StateIDs added in v0.13.0

func (g *StateGraph) StateIDs() []program.StateID

StateIDs are the machine's states, nested ones included, in the order of States.

func (*StateGraph) StateNamed added in v0.10.0

func (g *StateGraph) StateNamed(scope *symbols.Scope, target ast.Node) (*ast.StateNode, bool)

StateNamed is the state a name or feature chain written in scope (nil: the machine's own) names, as a transition endpoint would name it.

func (*StateGraph) StateRegion added in v0.13.0

func (g *StateGraph) StateRegion(id program.StateID) program.RegionID

StateRegion is the region that declares the state, 0 for a state in none.

func (*StateGraph) StateScope added in v0.13.0

func (g *StateGraph) StateScope(id program.StateID) *symbols.Scope

StateScope is the namespace the state owns, nil for none.

func (*StateGraph) TerminateOwnerOf added in v0.13.0

func (g *StateGraph) TerminateOwnerOf(ref program.VertexRef) program.StateID

TerminateOwnerOf is the composite state declaring the terminate action ref names, 0 for one of the machine or another kind of vertex.

func (*StateGraph) TopRegionIDs added in v0.13.0

func (g *StateGraph) TopRegionIDs() []program.RegionID

TopRegionIDs are the machine's own orthogonal regions, in declaration order.

func (*StateGraph) TransitionDoc added in v0.13.0

func (g *StateGraph) TransitionDoc(t *Transition) string

TransitionDoc is the document the transition was written in, the general's where inherited.

func (*StateGraph) TransitionFootprints

func (g *StateGraph) TransitionFootprints() map[*Transition]Footprint

TransitionFootprints is transition out of a state → what firing it may touch, its route through pseudostates followed along every branch. It is computed from the lowered graph on first use and shared by every caller.

func (*StateGraph) TransitionSteps added in v0.10.0

func (g *StateGraph) TransitionSteps() map[*Transition]TransitionStep

TransitionSteps is transition out of a state → its TransitionStep, computed on first use as TransitionFootprints is.

func (*StateGraph) TransitionsOf added in v0.13.0

func (g *StateGraph) TransitionsOf(ref program.VertexRef) []*Transition

TransitionsOf are the transitions leaving the vertex, in declaration order.

func (*StateGraph) UnconditionalStart

func (g *StateGraph) UnconditionalStart(owner ast.Node) *ast.StateNode

UnconditionalStart is the state a body starts in whatever its guards say.

func (*StateGraph) VertexDoc added in v0.13.0

func (g *StateGraph) VertexDoc(ref program.VertexRef) string

VertexDoc is the document the vertex was written in, the machine's for no vertex.

func (*StateGraph) VertexOf added in v0.13.0

func (g *StateGraph) VertexOf(node ast.Node) program.VertexRef

VertexOf names a state, pseudostate or terminate action of the graph by id; the zero reference for nil or any other node.

func (*StateGraph) VertexSite added in v0.13.0

func (g *StateGraph) VertexSite(ref program.VertexRef) (Site, bool)

VertexSite is the site of the state, pseudostate or terminate action ref names.

type StateRedefinitionResolver

type StateRedefinitionResolver interface {
	RedefinitionTarget(scope *symbols.Scope, decl, target ast.Node) (*symbols.Symbol, bool)
	LibraryFeature(sym *symbols.Symbol) bool
}

StateRedefinitionResolver resolves the feature a redefinition written in a state body targets, an alias followed to what it names, and tells the library's own declarations from a model's spelled like them.

type StateSpaceDynamics

type StateSpaceDynamics struct {
	Kind StateSpaceKind
	// Action is the action lowered; Scope its body scope, where its features resolve.
	Action *symbols.Symbol
	Scope  *symbols.Scope
	// State, Input and Output are the protocol's stateSpace, input and output
	// features as the action holds them, the nearest declaration of each.
	State, Input, Output *symbols.Symbol
	// TimeStep and StopTime are the features stating the step and the instant the
	// run stops at, nil where the action declares none; Time, when declared,
	// receives the clock's instant at each step.
	TimeStep, StopTime, Time *symbols.Symbol
	// Derivative is the model's getDerivative (continuous), Difference its
	// getDifference (discrete), OutputCalc its getOutput; each concrete.
	Derivative, Difference, OutputCalc *symbols.Symbol
	// NextState is a getNextState the model bodies itself, which the runner calls
	// in place of the library's; nil when the library's runs natively.
	NextState *symbols.Symbol
	// Integrator is the scheme the model binds to the library's integrate, unstated
	// when it leaves the run's default; IntegratorType is that scheme's declaration.
	Integrator     Integrator
	IntegratorType *symbols.Symbol
	// Crossings are the zero-crossing events the dynamics raise, in declaration order.
	Crossings []ZeroCrossing
}

StateSpaceDynamics is the lowering of an action specializing the library's StateSpaceDynamics: the calcs the model provides for the protocol, how the next state is reached, the features a step reads and writes, and the zero crossings it watches.

func ToStateSpaceDynamics

func ToStateSpaceDynamics(action *symbols.Symbol, scope *symbols.Scope, model StateSpaceModel, exprs *ExprTable) (*StateSpaceDynamics, error)

ToStateSpaceDynamics lowers an action specializing one of the library's dynamics into what the runner steps: a member the protocol needs that the model leaves abstract, or an integrator the runtime does not provide, is an ErrUnsupportedStateSpace.

type StateSpaceKind

type StateSpaceKind int

StateSpaceKind tells continuous dynamics, stepped by integrating a derivative, from discrete ones, stepped by adding a difference.

const (
	// NotStateSpace is an action specializing neither dynamics.
	NotStateSpace StateSpaceKind = iota
	ContinuousDynamics
	DiscreteDynamics
)

func StateSpaceKindOf

func StateSpaceKindOf(action *symbols.Symbol, model StateSpaceModel) StateSpaceKind

StateSpaceKindOf classifies an action: the dynamics it specializes, if either.

func (StateSpaceKind) String

func (k StateSpaceKind) String() string

String names the kind as the library does.

type StateSpaceModel

type StateSpaceModel interface {
	// LibrarySymbol is the library declaration of this qualified name, nil when unloaded.
	LibrarySymbol(fqn string) *symbols.Symbol
	// Specializes reports whether sym is general or transitively specializes it.
	Specializes(sym, general *symbols.Symbol) bool
	// MembersOf lists sym's effective members, inherited ones masked by its redefinitions.
	MembersOf(sym *symbols.Symbol) []*symbols.Symbol
	// FeatureTypes lists the types a feature has, declared or along its redefinitions.
	FeatureTypes(sym *symbols.Symbol) []*symbols.Symbol
	// ParameterDefault is the value a feature states along its redefinitions, with its scope.
	ParameterDefault(sym *symbols.Symbol) (ast.Node, *symbols.Scope)
	// LibraryDeclared reports a declaration of a library document, not the model's.
	LibraryDeclared(sym *symbols.Symbol) bool
}

StateSpaceModel answers the semantic questions lowering state-space dynamics asks, so an inherited or redefined protocol member is found where it was declared.

type StateTypeResolver

type StateTypeResolver interface {
	TypeDecl(scope *symbols.Scope, qn *ast.QualifiedName) (ast.Node, *symbols.Scope, bool)
}

StateTypeResolver resolves the declaration a type name reaches and its body scope. Lowering falls back to the scope tree only without one or for a name it cannot resolve.

type StateTypeWithholder

type StateTypeWithholder interface {
	WithholdsStateType(decl ast.Node) bool
}

StateTypeWithholder names resolved declarations whose content lowering must not take. A withheld type is settled: it is never looked up again through the scope tree.

type Statement

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

Statement is one lowered statement in an action node's body. Statements are kept in declaration order so the executor never walks the node's members again to find them.

func CalcBody

func CalcBody(owner ast.Node, members []ast.Node, scope *symbols.Scope) []Statement

CalcBody lowers the computation a calculation or case body states (CalcBodyWithOrder), its flow's `@Probability` annotations unread for want of a resolver.

func CalcBodyWith

func CalcBodyWith(owner ast.Node, members []ast.Node, scope *symbols.Scope, resolver *resolve.Resolver) []Statement

CalcBodyWith is CalcBody reading the metadata the resolver identifies: a weighted succession among a case's steps keeps its weight.

func CalcSteps added in v0.10.0

func CalcSteps(body []Statement) []Statement

CalcSteps returns the statements an invocation performs, excluding bindings of output features that are read when their values are needed.

func ConstraintStep added in v0.10.0

func ConstraintStep(member ast.Node, scope *symbols.Scope, resolver *resolve.Resolver, exprs *ExprTable) (Statement, bool)

ConstraintStep lowers one member of a constraint body to the step it states, as calcStep does for a calculation body: statements run in declaration order except for precedence stated by successions between steps. false for what a constraint body states other ways: the parameters a check binds (`in x`), the conditions the body exists to hold (expressions and nested constraint, require, assume and assert members), the unnamed bindings a parameter redefinition writes, and members declaring nothing a step can run. Successions between steps supply precedence; other successions and control nodes remain unexecutable because a verdict does not run a token flow.

type StatementOrder added in v0.10.0

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

StatementOrder is how the statements of one list may run: in runs separated by the statements that keep their place, each run's in any order, of which only those reordering two dependent statements differ.

func BodyStatementOrder added in v0.10.0

func BodyStatementOrder(graph *ActionGraph, node ast.Node, stmts []Statement) *StatementOrder

BodyStatementOrder is the order of stmts, statements of node's body in graph or of a block within it.

func CalcBodyStatementOrder added in v0.10.0

func CalcBodyStatementOrder(scope *symbols.Scope, members []ast.Node, stmts []Statement) *StatementOrder

CalcBodyStatementOrder is the order of a calculation body's statements, including any `then` successions the lowered body states.

func ConstraintBodyStatementOrder added in v0.10.0

func ConstraintBodyStatementOrder(scope *symbols.Scope, stmts []Statement) *StatementOrder

ConstraintBodyStatementOrder is the order of a constraint body's statements.

func (*StatementOrder) Dependent added in v0.11.0

func (o *StatementOrder) Dependent(i, j int, divided bool) bool

Dependent reports whether statements i and j may not commute: their footprints meet, a succession orders them, or, divided, both touch a shared place.

func (*StatementOrder) Footprint added in v0.11.0

func (o *StatementOrder) Footprint(i int) Footprint

Footprint is what statement i touches.

func (*StatementOrder) HasReversePrecedence added in v0.10.0

func (o *StatementOrder) HasReversePrecedence() bool

HasReversePrecedence reports whether an explicit succession runs against declaration order.

func (*StatementOrder) HasSkipped added in v0.10.0

func (o *StatementOrder) HasSkipped() bool

HasSkipped reports whether this order carries any non-executable successions.

func (*StatementOrder) Len added in v0.10.0

func (o *StatementOrder) Len() int

Len is how many statements the order is over.

func (*StatementOrder) Next added in v0.10.0

func (o *StatementOrder) Next(done, blocked []bool, divided bool) []int

Next lists, ascending, the statements that may run next after those done, so that the statements run in the least order, by position, of every class of orders equal up to swapping independent neighbours: each class is reached once. A statement blocked waits for one dependent on it to run first. Empty once all are done.

func (*StatementOrder) NextFixed added in v0.10.0

func (o *StatementOrder) NextFixed(done, blocked []bool, divided bool) []int

NextFixed lists the declaration-least ready statement, respecting explicit precedence without exposing a choice point under a fixed scheduling policy.

func (*StatementOrder) Ran added in v0.10.0

func (o *StatementOrder) Ran(s int, done, blocked []bool, divided bool)

Ran marks s run after those done, unblocking each statement left that depends on it and blocking each before it that does not.

func (*StatementOrder) Reorders added in v0.10.0

func (o *StatementOrder) Reorders(divided bool) bool

Reorders reports whether two of the statements may run in either order with different results: two dependent ones in one run, or with divided set (another performance interleaving between statements), two that both touch what it does.

func (*StatementOrder) Rivals added in v0.10.0

func (o *StatementOrder) Rivals(s int, done []bool, divided bool) []int

Rivals lists, ascending, the statements not done, besides s, that run with s and may not commute with it: those another may run between two moves of s, s once started.

func (*StatementOrder) Skipped added in v0.10.0

func (o *StatementOrder) Skipped(i int) bool

Skipped reports whether i is a succession represented by this order, not a statement to execute.

type StepMultiplicityError added in v0.10.0

type StepMultiplicityError struct {
	Node          ast.Node
	Step          string
	Multiplicity  string
	Code          string
	Reason        string
	Declaration   ast.Node
	InheritedFrom string
	Err           error
}

StepMultiplicityError describes a step multiplicity the executor cannot honor.

func (*StepMultiplicityError) Error added in v0.10.0

func (e *StepMultiplicityError) Error() string

func (*StepMultiplicityError) Unwrap added in v0.10.0

func (e *StepMultiplicityError) Unwrap() error

type Subflow

type Subflow struct {
	Graph *ActionGraph
	Err   error
	// Deferred is set, Graph nil, for a typed body nested in its own type: its
	// flow is lowered once, by Unfold, when a performance of it first starts.
	Deferred *DeferredSubflow
}

Subflow is the flow a nested action node's own members state. Graph is nil when those members state a flow that could not be built, which Err says; the executor reports it at initialize() rather than treating the node as a leaf.

func (*Subflow) Unfold added in v0.11.0

func (s *Subflow) Unfold() (*ActionGraph, error)

Unfold returns the flow the node's performance runs, lowering a deferred body once (per node, on the outermost flow) so every level of a recursion shares it.

type SubjectDecl added in v0.13.0

type SubjectDecl struct {
	Name  string
	Value ast.Node
	Node  ast.Node
}

SubjectDecl is a case's subject as declared: its name, its binding and the node.

func SubjectDeclaration added in v0.13.0

func SubjectDeclaration(member ast.Node) (SubjectDecl, bool)

SubjectDeclaration reads a subject declaration, written as a subject member (`subject s : T;`, `subject = expr;`) or a subject-kind usage.

type TerminateTarget

type TerminateTarget int

TerminateTarget is what a terminate names, settled where it was written.

const (
	// TerminateContaining is a terminate naming nothing: the containing performance ends.
	TerminateContaining TerminateTarget = iota
	// TerminateEnclosing is a terminate action usage: the performance its node is a step of ends.
	TerminateEnclosing
	// TerminateNode names an action usage (Effect.Target): a node of an enclosing flow,
	// or else the action occurrence the name denotes, evaluated as TerminateOccurrence is.
	TerminateNode
	// TerminateOccurrence names an occurrence by an expression the executor evaluates.
	TerminateOccurrence
)

type Transfer added in v0.11.0

type Transfer struct {
	Message  *symbols.Symbol
	Name     string
	From, To *SequenceEvent
	Payload  *ast.FlowEnds
	// contains filtered or unexported fields
}

Transfer is one message realized as a transfer from the event it leaves to the event it reaches, carrying the payload its `of` clause states.

type Transition

type Transition struct {
	// Name is the transition's own name, when it was written with one
	// (`transition maintain first idle then busy`), and "" when it was not.
	Name string
	// Decl is the declaration the transition was written as, for a consumer that
	// reports where it comes from.
	Decl   ast.Node
	Source ast.Node // *ast.StateNode or *ast.PseudostateNode
	Target ast.Node // *ast.StateNode, *ast.PseudostateNode or a terminate action *ast.Usage
	// SourceRef and TargetRef are Source and Target by id.
	SourceRef, TargetRef program.VertexRef
	// Owner is the state whose body declares the transition, nil for the machine body.
	Owner *ast.StateNode
	// OwnerID is Owner by id, 0 for the machine body.
	OwnerID program.StateID
	Trigger ast.Node // TimeEvent, ChangeEvent, SignalEvent, CallEvent, nil = completion
	// TriggerExprID is the condition of a change trigger or the time of a timer, in
	// the table of the machine; 0 for a trigger stating neither.
	TriggerExprID program.ExprID
	// Accepted names what the trigger binds when the transition fires — an accept's
	// payload, a call's parameters — in declaration order; nil binds nothing.
	Accepted []string
	Guard    ast.Node // guard expression, nil = no guard
	// GuardID is Guard in the table of the machine.
	GuardID program.ExprID
	// Effect are the transition's effect behaviors, lowered the same way a state's
	// entry, do and exit behaviors are.
	Effect []StateBehavior
	// Via is the port the accepted occurrence must arrive at
	// (`accept Ping via commPort`), and "" when the trigger names no port, in
	// which case an occurrence reaching the machine by any route fires it.
	Via string
	// ViaSelf records a via path written from `this`, whose root is a feature of
	// the performer however the machine's data would resolve the name.
	ViaSelf bool

	// Scope is the scope the transition was declared in, in which the expressions
	// its trigger carries — a time event's duration, a change event's condition —
	// resolve their names.
	Scope *symbols.Scope

	// BodyScope is the scope the transition's guard and effect resolve in. It is
	// Scope, except for a call trigger, whose parameters are visible to the guard
	// and effect and nowhere else (`accept setSpeed(v) if v > 0`).
	BodyScope *symbols.Scope

	// Probability is the weight `@Probability { p = ...; }` states for the
	// transition, read where its guard is; nil when the transition is unweighted.
	Probability *Probability

	// GroupKey is the resolved trigger spelling this transition competes under:
	// TriggerKey returns it when set, else computes the un-resolved spelling.
	GroupKey string
}

Transition represents a state transition (lowered from TransitionEdge or TransitionMember).

func (*Transition) At added in v0.13.0

func (t *Transition) At() Extent

At is where the transition was declared.

func (*Transition) Declared added in v0.13.0

func (t *Transition) Declared() ast.Node

Declared is the declaration the transition was lowered from.

func (*Transition) EndNames added in v0.13.0

func (t *Transition) EndNames() (source, target string)

EndNames are the names of the vertices the transition leaves and reaches, "" for an unnamed one.

func (*Transition) GuardAt added in v0.13.0

func (t *Transition) GuardAt() Extent

GuardAt is where the transition's guard was written, the zero Extent for none.

func (*Transition) TriggerWritten added in v0.13.0

func (t *Transition) TriggerWritten() (Trigger, bool)

TriggerWritten describes the transition's trigger, false for a completion transition.

type TransitionSourceError

type TransitionSourceError struct {
	Source ast.Node
	Region bool
}

TransitionSourceError marks a sourceless transition whose preceding member, Source, is not a state of the machine; Region records that it is a region of a parallel state.

func (*TransitionSourceError) Error

func (e *TransitionSourceError) Error() string

type TransitionStep added in v0.10.0

type TransitionStep struct {
	Footprint Footprint
	Enters    []*ast.StateNode
}

TransitionStep is what firing a transition may do short of the do behaviors it starts: its Footprint, and every state it may enter, whose do behaviors start.

type Trigger added in v0.13.0

type Trigger struct {
	// Kind is `accept`, `call`, `change` or `time`, else the label of what was written.
	Kind string
	Span source.Span
	// SignalType, Subsets and Payload are an accept trigger's.
	SignalType, Subsets, Payload string
	// Operation and Parameters are a call trigger's.
	Operation  string
	Parameters []string
	// Expr is where a change trigger's condition or a time trigger's duration was written.
	Expr Extent
	// Absolute reports a time trigger written `at` rather than `after`.
	Absolute bool
	// Signal and Called are the last segments of the signal type and of the
	// operation; Typed and Calls report that one was written.
	Signal, Called string
	Typed, Calls   bool
	// PayloadName is the payload's declared name.
	PayloadName string
	// Subset is what the trigger subsets, spelled as the notation writes it;
	// Subsetting reports that it subsets something.
	Subset     string
	Subsetting bool
}

Trigger is what an accept or a transition waits for, as it was written.

type UnresolvedEndpointError added in v0.13.0

type UnresolvedEndpointError struct {
	Endpoint ast.Node
}

UnresolvedEndpointError marks a transition or succession endpoint that names no element from the namespace it is written in (KerML 8.2.3.5).

func (*UnresolvedEndpointError) Error added in v0.13.0

func (e *UnresolvedEndpointError) Error() string

type Unsupported

type Unsupported struct {
	Description string
	Node        ast.Node
	Scope       *symbols.Scope // the scope the member was declared in
}

Unsupported is a body member the lowering layer recognizes but cannot yet turn into an executable statement. It is lowered rather than dropped so that reaching it fails the execution with a diagnostic instead of silently producing a wrong answer. Description names the construct.

type ZeroCrossing

type ZeroCrossing struct {
	Name string
	// Event is the event occurrence usage; EventType the ZeroCrossingEventDef
	// specialization typing it, which the raised event carries.
	Event     *symbols.Symbol
	EventType *symbols.Symbol
	// Derivative marks an event whose type states no guard: it occurs where a
	// component of the derivative crosses zero, and Guard is nil.
	Derivative bool
	Guard      ast.Node
	// GuardID is Guard in the table of the flow the dynamics were lowered for.
	GuardID program.ExprID
	// GuardScope is where the guard was written, its names resolving there.
	GuardScope *symbols.Scope
	// Terminal is the expression stating whether the crossing ends the run, nil for never.
	Terminal ast.Node
	// TerminalID is Terminal in the table of the flow.
	TerminalID    program.ExprID
	TerminalScope *symbols.Scope
}

ZeroCrossing is one event occurrence among the dynamics' zeroCrossingEvents: what crosses zero to raise the event, and whether that ends the run.

Jump to

Keyboard shortcuts

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