Skip to content

Commit

Permalink
fix: irgen
Browse files Browse the repository at this point in the history
  • Loading branch information
emil14 committed Sep 20, 2023
1 parent 447583f commit 2b88c77
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions internal/irgen/irgen.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,22 +105,24 @@ func (g Generator) processNode(

// We use network as a source of true about ports usage instead of component's interface definitions.
// We cannot rely on then because there's not enough information about how many slots are used.
// On the other hand, we believe network has everything we need because probram is checked by analyzer and thus correct.
// On the other hand, we believe network has everything we need because probram is correct.
nodesIOUsage, err := g.insertConnectionsAndReturnPortsUsage(pkgs, component.Net, nodeCtx, result)
if err != nil {
return fmt.Errorf("handle network: %w", err)
}

// Insert ports for const nodes if const node used by this network.
if constUsage, ok := nodesIOUsage["const"]; ok {
for portName := range constUsage.out { // const node does not have inports, only outports
// Handle const subnode if current node makes use of it.
if constNodeUsage, ok := nodesIOUsage["const"]; ok {
// Insert ports for const nodes.
for portName := range constNodeUsage.out { // Const node does not have inports, only outports.
result.Ports = append(result.Ports, &ir.PortInfo{
PortAddr: &ir.PortAddr{
Path: nodeCtx.path + "/" + "const",
Port: portName,
},
})
}
// TODO Add func call for const node with meta msg (maybe via recursion?)
}

for name, node := range component.Nodes {
Expand Down Expand Up @@ -178,7 +180,8 @@ func (g Generator) insertConnectionsAndReturnPortsUsage(
receiverSideIR := g.mapReceiverSide(nodeCtx.path, receiverSide)
receiverSidesIR = append(receiverSidesIR, receiverSideIR)

if _, ok := nodesIOUsage[receiverSide.PortAddr.Node]; !ok { // same receiver can be used by multiple senders so we only add it once
// same receiver can be used by multiple senders so we only add it once
if _, ok := nodesIOUsage[receiverSide.PortAddr.Node]; !ok {
nodesIOUsage[receiverSide.PortAddr.Node] = nodeIOUsage{
in: map[repPortAddr]struct{}{},
out: map[string]uint8{},
Expand Down

0 comments on commit 2b88c77

Please sign in to comment.