Fix formatting of link routine
This commit is contained in:
parent
2d41a43ae1
commit
77f7609b67
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2004-2021 Stephen Williams (steve@icarus.com)
|
* Copyright (c) 2004-2023 Stephen Williams (steve@icarus.com)
|
||||||
*
|
*
|
||||||
* This source code is free software; you can redistribute it
|
* This source code is free software; you can redistribute it
|
||||||
* and/or modify it in source code form under the terms of the GNU
|
* and/or modify it in source code form under the terms of the GNU
|
||||||
|
|
@ -200,42 +200,37 @@ void vvp_net_t::link(vvp_net_ptr_t port_to_link)
|
||||||
{
|
{
|
||||||
vvp_net_t*net = port_to_link.ptr();
|
vvp_net_t*net = port_to_link.ptr();
|
||||||
|
|
||||||
// Connect nodes with vvp_fun_modpath_src to the head of the
|
// Connect nodes with vvp_fun_modpath_src to the head of the
|
||||||
// linked list, so that vvp_fun_modpath_src are always evaluated
|
// linked list, so that vvp_fun_modpath_src are always evaluated
|
||||||
// before their respective vvp_fun_modpath
|
// before their respective vvp_fun_modpath
|
||||||
if (dynamic_cast<vvp_fun_modpath_src*>(net->fun))
|
if (dynamic_cast<vvp_fun_modpath_src*>(net->fun)) {
|
||||||
{
|
net->port[port_to_link.port()] = out_;
|
||||||
net->port[port_to_link.port()] = out_;
|
out_ = port_to_link;
|
||||||
out_ = port_to_link;
|
// All other nodes connect after the last vvp_fun_modpath_src
|
||||||
}
|
} else {
|
||||||
// All other nodes connect after the last vvp_fun_modpath_src
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// List is empty or first node has no vvp_fun_modpath_src
|
// List is empty or first node has no vvp_fun_modpath_src
|
||||||
// then just insert the node into the head of linked list
|
// then just insert the node into the head of linked list
|
||||||
if (out_.ptr() == nullptr || ! dynamic_cast<vvp_fun_modpath_src*>(out_.ptr()->fun))
|
if (out_.ptr() == nullptr || ! dynamic_cast<vvp_fun_modpath_src*>(out_.ptr()->fun)) {
|
||||||
{
|
net->port[port_to_link.port()] = out_;
|
||||||
net->port[port_to_link.port()] = out_;
|
out_ = port_to_link;
|
||||||
out_ = port_to_link;
|
return;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
vvp_net_ptr_t cur = out_;
|
vvp_net_ptr_t cur = out_;
|
||||||
vvp_net_ptr_t prev = vvp_net_ptr_t(nullptr,0);
|
vvp_net_ptr_t prev = vvp_net_ptr_t(nullptr,0);
|
||||||
|
|
||||||
// Traverse through linked list
|
// Traverse through linked list
|
||||||
while (dynamic_cast<vvp_fun_modpath_src*>(cur.ptr()->fun))
|
while (dynamic_cast<vvp_fun_modpath_src*>(cur.ptr()->fun)) {
|
||||||
{
|
prev = cur;
|
||||||
prev = cur;
|
cur = cur.ptr()->port[cur.port()];
|
||||||
cur = cur.ptr()->port[cur.port()];
|
if (! cur.ptr()) break; // End of list
|
||||||
if (!cur.ptr()) break; // End of list
|
}
|
||||||
}
|
|
||||||
|
|
||||||
assert(prev.ptr());
|
assert(prev.ptr());
|
||||||
|
|
||||||
// Insert after last vvp_fun_modpath_src (or end of list)
|
// Insert after last vvp_fun_modpath_src (or end of list)
|
||||||
net->port[port_to_link.port()] = cur;
|
net->port[port_to_link.port()] = cur;
|
||||||
prev.ptr()->port[prev.port()] = port_to_link;
|
prev.ptr()->port[prev.port()] = port_to_link;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue