Skip to content

Commit

Permalink
- when processing splice/prune directives, unique port names now only…
Browse files Browse the repository at this point in the history
… required within the set of replacement edges (generated by splicing)

- only remove ports (when pruning) if the port does not appear in the replacement edges (generated by splicing)
  • Loading branch information
dozy committed Mar 11, 2024
1 parent 81dba99 commit d2e366a
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions bin/vtfp.pl
Original file line number Diff line number Diff line change
Expand Up @@ -1412,9 +1412,9 @@ sub validate_splice_candidates {
}
}

# all edge termini must be unique (over replacement and pruning edges) except for STDIN/STDOUT
# all edge termini must be unique (over replacement edges) except for STDIN/STDOUT
my %endpoints;
for my $edge (@{$splice_candidates->{replacement_edges}}, @{$prune_edges}) {
for my $edge (@{$splice_candidates->{replacement_edges}}) {
my $from_end = $edge->{from};
if($from_end and $from_end !~ /:/) { $from_end .= q[:STDOUT] };

Expand Down Expand Up @@ -1472,15 +1472,33 @@ sub final_splice {
# add new edges
push @{$flat_graph->{edges}}, @{$splice_candidates->{replacement_edges}};

# remove pruned ports - prune edges are not required to be two-ended; just disregard undefined to/from attributes
# remove pruned ports - prune edges are not required to be two-ended; just disregard undefined to/from attributes; only remove ports
# that do not appear in splice edges (aka replacement edges)
for my $prune_edge (@{$splice_candidates->{prune_edges}}) {
if($prune_edge->{from}) { remove_port($prune_edge->{from}, $SRC, $flat_graph); }
if($prune_edge->{to}) { remove_port($prune_edge->{to}, $DST, $flat_graph); }
if($prune_edge->{from} and not _in_replacement_edges($prune_edge->{from}, $splice_candidates, $SRC)) { remove_port($prune_edge->{from}, $SRC, $flat_graph); }
if($prune_edge->{to} and not _in_replacement_edges($prune_edge->{to}, $splice_candidates, $DST)) { remove_port($prune_edge->{to}, $DST, $flat_graph); }
}

return $flat_graph;
}

sub _in_replacement_edges {
my ($port_spec, $splice_candidates, $type) = @_;

my $direction = ($type == $SRC)? q[from]: q[to];
my $std_port = ($type == $SRC)? q[STDIN]: q[STDOUT];

for my $edge (@{$splice_candidates->{replacement_edges}}) {
my $end = $edge->{$direction};
if($end and $end !~ /:/) { $end .= qq[:$std_port] };

if($end eq $port_spec) { return 1; }
}

return 0;

}

################################################################################################
# resolve_ports:
# given a splice_pair specification, fully determine the [set of] source and destination ports
Expand Down

0 comments on commit d2e366a

Please sign in to comment.