Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion internal/exec/runtime/action_body_run.go
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,7 @@ func (e *ActionExecutor) resumeBody(tokenIdx int) error {

// pauseAt pauses the run before a node a breakpoint is set on performs, as the run
// pauses before a token steps such a node; a run not made pausable goes on.
func (e *ActionExecutor) pauseAt(within []ast.Node, node ast.Node) error {
func (e *ActionExecutor) pauseAt(within []NodeRef, node NodeRef) error {
if stop, set := e.stopAt(within, node); set {
return e.ctx.pauseBody(bodyPause{breakpoint: stop})
}
Expand Down
12 changes: 6 additions & 6 deletions internal/exec/runtime/action_choice.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ func (e *ActionExecutor) keeps(t Token) bool {
// this step, so the keeping accept does not yield to it.
func (e *ActionExecutor) yieldsKeeping(k Token, pending []Message, unready map[int64]bool) bool {
accept, _ := e.messageAccept(k)
keeps, _ := e.acceptMatch(k.frame, accept, k.Location.(*ast.Usage))
keeps, _ := e.acceptMatch(k.frame, accept, k.Node().(*ast.Usage))
for _, m := range pending {
if !keeps(m) {
continue
Expand All @@ -263,7 +263,7 @@ func (e *ActionExecutor) yieldsKeeping(k Token, pending []Message, unready map[i
continue
}
if other, ok := e.messageAccept(t); ok {
matches, _ := e.acceptMatch(t.frame, other, t.Location.(*ast.Usage))
matches, _ := e.acceptMatch(t.frame, other, t.Node().(*ast.Usage))
if matches(m) {
return true
}
Expand All @@ -286,14 +286,14 @@ func (e *ActionExecutor) offeredMessage(t Token, pending []Message) bool {
if !ok {
return false
}
matches, _ := e.acceptMatch(t.frame, accept, t.Location.(*ast.Usage))
matches, _ := e.acceptMatch(t.frame, accept, t.Node().(*ast.Usage))
return slices.ContainsFunc(pending, matches)
}

// messageAccept returns the accept the token sits at when it is one a message,
// not a trigger, answers.
func (e *ActionExecutor) messageAccept(t Token) (lower.Accept, bool) {
usage, ok := t.Location.(*ast.Usage)
usage, ok := t.Node().(*ast.Usage)
if !ok || t.body != nil {
return lower.Accept{}, false
}
Expand Down Expand Up @@ -367,7 +367,7 @@ func (e *ActionExecutor) noteTokenOrder(step int, order stepOrder, schedule *tok
alts = make([]string, len(tokens))
fps = make([]lower.Footprint, len(tokens))
for i, t := range tokens {
alts[i] = TokenLabel(t.ID, t.Location)
alts[i] = TokenLabel(t.ID, t.Node())
fps[i] = standing(e, t)
if t.ID == first {
taken = i
Expand Down Expand Up @@ -395,7 +395,7 @@ func (e *ActionExecutor) labeledFootprints(labels []string, able []Token) []lowe
for i, label := range labels {
fps[i] = unknownFootprint()
for _, t := range able {
if TokenLabel(t.ID, t.Location) == label {
if TokenLabel(t.ID, t.Node()) == label {
fps[i] = standing(e, t)
break
}
Expand Down
24 changes: 12 additions & 12 deletions internal/exec/runtime/action_control_objects.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ func (e *performances) carryObjects(frame *actionFrame, node ast.Node, via lower
return err
}
if at >= 0 {
inputs[pin] = frame.takeHeld(node, pin, at)
inputs[pin] = frame.takeHeld(refOf(graph, node), pin, at)
}
} else {
for _, f := range features {
if f.Direction == ast.DirIn && len(frame.held[node][f.Name]) > 0 {
inputs[f.Name] = frame.takeHeld(node, f.Name, 0)
if f.Direction == ast.DirIn && len(frame.held[refOf(graph, node)][f.Name]) > 0 {
inputs[f.Name] = frame.takeHeld(refOf(graph, node), f.Name, 0)
}
}
}
Expand Down Expand Up @@ -84,7 +84,7 @@ func arrivingObject(frame *actionFrame, graph *lower.ActionGraph, node ast.Node,
continue
}
if via.Carries && flow.Kind == lower.FlowSuccession && flow.Decl == via.Decl {
if at := frame.heldFrom(node, flow.TargetPin, flow.Decl); at >= 0 {
if at := frame.heldFrom(refOf(graph, node), flow.TargetPin, flow.Decl); at >= 0 {
return flow.TargetPin, at, nil
}
continue
Expand All @@ -96,7 +96,7 @@ func arrivingObject(frame *actionFrame, graph *lower.ActionGraph, node ast.Node,
var held []string
first := make(map[string]int)
for _, flow := range from {
at := frame.heldFrom(node, flow.TargetPin, flow.Decl)
at := frame.heldFrom(refOf(graph, node), flow.TargetPin, flow.Decl)
if at < 0 {
continue
}
Expand All @@ -116,15 +116,15 @@ func arrivingObject(frame *actionFrame, graph *lower.ActionGraph, node ast.Node,
return "", -1, nil
}
for _, f := range graph.Features[node] {
if f.Direction == ast.DirIn && slices.ContainsFunc(frame.held[node][f.Name], func(h nodeObject) bool { return !h.carried }) {
if f.Direction == ast.DirIn && slices.ContainsFunc(frame.held[refOf(graph, node)][f.Name], func(h nodeObject) bool { return !h.carried }) {
held = append(held, f.Name)
}
}
switch len(held) {
case 0:
return "", -1, nil
case 1:
return held[0], slices.IndexFunc(frame.held[node][held[0]], func(h nodeObject) bool { return !h.carried }), nil
return held[0], slices.IndexFunc(frame.held[refOf(graph, node)][held[0]], func(h nodeObject) bool { return !h.carried }), nil
}
return "", -1, fmt.Errorf("%w: %s holds values at %s", errAmbiguousMergeInput, nodeDescription(node), strings.Join(held, ", "))
}
Expand All @@ -137,17 +137,17 @@ func (e *performances) queueControlObject(frame *actionFrame, graph *lower.Actio
if err := e.ctx.checkNamedWriteAs(graph.Scopes[flow.Target], func() string { return nodeDescription(flow.Target) }, f.Name, &value); err != nil {
return fmt.Errorf("%s: %w", flowDescription(flow), err)
}
frame.hold(flow.Target, f.Name, nodeObject{value: value, flow: flow.Decl, carried: flow.Kind == lower.FlowSuccession})
frame.hold(refOf(graph, flow.Target), f.Name, nodeObject{value: value, flow: flow.Decl, carried: flow.Kind == lower.FlowSuccession})
return nil
}
}
return fmt.Errorf("%s: %w: %s declares no input %s", flowDescription(flow), errNodePin, nodeDescription(flow.Target), flow.TargetPin)
}

// hold appends a value to those node holds at pin.
func (f *actionFrame) hold(node ast.Node, pin string, object nodeObject) {
func (f *actionFrame) hold(node NodeRef, pin string, object nodeObject) {
if f.held == nil {
f.held = make(map[ast.Node]map[string][]nodeObject)
f.held = make(map[NodeRef]map[string][]nodeObject)
}
if f.held[node] == nil {
f.held[node] = make(map[string][]nodeObject)
Expand All @@ -156,12 +156,12 @@ func (f *actionFrame) hold(node ast.Node, pin string, object nodeObject) {
}

// heldFrom is the position of the oldest value flow brought that node holds at pin; -1 if none.
func (f *actionFrame) heldFrom(node ast.Node, pin string, flow ast.Node) int {
func (f *actionFrame) heldFrom(node NodeRef, pin string, flow ast.Node) int {
return slices.IndexFunc(f.held[node][pin], func(h nodeObject) bool { return h.flow == flow })
}

// takeHeld removes and returns the value node holds at pin's position at.
func (f *actionFrame) takeHeld(node ast.Node, pin string, at int) Value {
func (f *actionFrame) takeHeld(node NodeRef, pin string, at int) Value {
objects := f.held[node][pin]
value := objects[at].value
if len(objects) > 1 {
Expand Down
Loading
Loading