summaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
authorGravatarGravatar Couriersud <couriersud@users.noreply.github.com>2014-01-10 21:19:53 +0000
committerGravatarGravatar Couriersud <couriersud@users.noreply.github.com>2014-01-10 21:19:53 +0000
commitc2d61b01dc2f4060630e9615127fea8cddcf489c (patch)
treef724459beb3fcac0128e827d04e73353df7bd91e /src
parent81cafc3d2931d94e947f260fe2366704e3782a16 (diff)
Removed pointless "...->object()->" usage and fixed some issues in debug build. No wn
Diffstat (limited to 'src')
-rw-r--r--src/emu/machine/netlist.c6
-rw-r--r--src/emu/netlist/analog/nld_solver.c52
-rw-r--r--src/emu/netlist/devices/net_lib.c12
-rw-r--r--src/emu/netlist/nl_base.c14
-rw-r--r--src/emu/netlist/nl_base.h4
-rw-r--r--src/emu/netlist/nl_lists.h52
-rw-r--r--src/emu/netlist/nl_setup.c30
7 files changed, 83 insertions, 87 deletions
diff --git a/src/emu/machine/netlist.c b/src/emu/machine/netlist.c
index 3b606ee0260..cc977fa028d 100644
--- a/src/emu/machine/netlist.c
+++ b/src/emu/machine/netlist.c
@@ -278,9 +278,9 @@ ATTR_HOT ATTR_ALIGN void netlist_mame_device_t::check_mame_abort_slice()
ATTR_COLD void netlist_mame_device_t::save_state()
{
- for (pstate_entry_t::list_t::entry_t *p = netlist().save_list().first(); p != NULL; p = netlist().save_list().next(p))
+ for (pstate_entry_t * const *p = netlist().save_list().first(); p != NULL; p = netlist().save_list().next(p))
{
- pstate_entry_t *s = p->object();
+ pstate_entry_t *s = *p;
NL_VERBOSE_OUT(("saving state for %s\n", s->m_name.cstr()));
switch (s->m_dt)
{
@@ -337,7 +337,7 @@ void netlist_mame_cpu_device_t::device_start()
for (int i=0; i < netlist().m_nets.count(); i++)
{
netlist_net_t *n = netlist().m_nets[i];
- if (n->isRailNet())
+ if (n->isFamily(netlist_object_t::LOGIC))
{
state_add(i*2, n->name(), n->Q_state_ptr());
}
diff --git a/src/emu/netlist/analog/nld_solver.c b/src/emu/netlist/analog/nld_solver.c
index 26551de46c7..56cead68c5c 100644
--- a/src/emu/netlist/analog/nld_solver.c
+++ b/src/emu/netlist/analog/nld_solver.c
@@ -23,15 +23,15 @@ ATTR_COLD void netlist_matrix_solver_t::setup(netlist_net_t::list_t &nets, NETLI
m_resched = true;
m_owner = &aowner;
- for (netlist_net_t::list_t::entry_t *pn = nets.first(); pn != NULL; pn = nets.next(pn))
+ for (netlist_net_t * const * pn = nets.first(); pn != NULL; pn = nets.next(pn))
{
NL_VERBOSE_OUT(("setting up net\n"));
- m_nets.add(pn->object());
+ m_nets.add(*pn);
- pn->object()->m_solver = this;
+ (*pn)->m_solver = this;
- for (netlist_core_terminal_t *p = pn->object()->m_head; p != NULL; p = p->m_update_list_next)
+ for (netlist_core_terminal_t *p = (*pn)->m_head; p != NULL; p = p->m_update_list_next)
{
switch (p->type())
{
@@ -52,7 +52,7 @@ ATTR_COLD void netlist_matrix_solver_t::setup(netlist_net_t::list_t &nets, NETLI
default:
break;
}
- pn->object()->m_terms.add(static_cast<netlist_terminal_t *>(p));
+ (*pn)->m_terms.add(static_cast<netlist_terminal_t *>(p));
NL_VERBOSE_OUT(("Added terminal\n"));
break;
case netlist_terminal_t::INPUT:
@@ -71,22 +71,22 @@ ATTR_COLD void netlist_matrix_solver_t::setup(netlist_net_t::list_t &nets, NETLI
ATTR_HOT inline void netlist_matrix_solver_t::step(const netlist_time delta)
{
const double dd = delta.as_double();
- for (dev_list_t::entry_t *p = m_steps.first(); p != NULL; p = m_steps.next(p))
- p->object()->step_time(dd);
+ for (netlist_core_device_t * const *p = m_steps.first(); p != NULL; p = m_steps.next(p))
+ (*p)->step_time(dd);
}
ATTR_HOT inline void netlist_matrix_solver_t::update_inputs()
{
- for (netlist_core_terminal_t::list_t::entry_t *p = m_inps.first(); p != NULL; p = m_inps.next(p))
+ for (netlist_core_terminal_t * const *p = m_inps.first(); p != NULL; p = m_inps.next(p))
{
- if (p->object()->net().m_last.Analog != p->object()->net().m_cur.Analog)
+ if ((*p)->net().m_last.Analog != (*p)->net().m_cur.Analog)
{
- p->object()->netdev().update_dev();
+ (*p)->netdev().update_dev();
}
}
- for (netlist_core_terminal_t::list_t::entry_t *p = m_inps.first(); p != NULL; p = m_inps.next(p))
+ for (netlist_core_terminal_t * const *p = m_inps.first(); p != NULL; p = m_inps.next(p))
{
- p->object()->net().m_last.Analog = p->object()->net().m_cur.Analog;
+ (*p)->net().m_last.Analog = (*p)->net().m_cur.Analog;
}
}
@@ -106,9 +106,9 @@ ATTR_HOT inline int netlist_matrix_solver_t::solve_non_dynamic()
do {
resched = false;
- for (netlist_net_t::list_t::entry_t *pn = m_nets.first(); pn != NULL; pn = m_nets.next(pn))
+ for (netlist_net_t * const *pn = m_nets.first(); pn != NULL; pn = m_nets.next(pn))
{
- netlist_net_t *net = pn->object();
+ netlist_net_t *net = *pn;
const netlist_net_t::terminal_list_t &terms = net->m_terms;
double gtot = 0;
@@ -159,14 +159,14 @@ ATTR_HOT inline bool netlist_matrix_solver_t::solve()
do
{
/* update all non-linear devices */
- for (dev_list_t::entry_t *p = m_dynamic.first(); p != NULL; p = m_dynamic.next(p))
- switch (p->object()->family())
+ for (netlist_core_device_t * const *p = m_dynamic.first(); p != NULL; p = m_dynamic.next(p))
+ switch ((*p)->family())
{
case netlist_device_t::DIODE:
- static_cast<NETLIB_NAME(D) *>(p->object())->update_terminals();
+ static_cast<NETLIB_NAME(D) *>((*p))->update_terminals();
break;
default:
- p->object()->update_terminals();
+ (*p)->update_terminals();
break;
}
this_resched = solve_non_dynamic();
@@ -261,11 +261,11 @@ NETLIB_UPDATE_PARAM(solver)
NETLIB_NAME(solver)::~NETLIB_NAME(solver)()
{
- netlist_matrix_solver_t::list_t::entry_t *e = m_mat_solvers.first();
+ netlist_matrix_solver_t * const *e = m_mat_solvers.first();
while (e != NULL)
{
- netlist_matrix_solver_t::list_t::entry_t *en = m_mat_solvers.next(e);
- delete e->object();
+ netlist_matrix_solver_t * const *en = m_mat_solvers.next(e);
+ delete *e;
e = en;
}
@@ -281,9 +281,9 @@ NETLIB_UPDATE(solver)
NL_VERBOSE_OUT(("Step!\n"));
/* update all terminals for new time step */
m_last_step = now;
- for (netlist_matrix_solver_t::list_t::entry_t *e = m_mat_solvers.first(); e != NULL; e = m_mat_solvers.next(e))
+ for (netlist_matrix_solver_t * const *e = m_mat_solvers.first(); e != NULL; e = m_mat_solvers.next(e))
{
- e->object()->step(delta);
+ (*e)->step(delta);
}
}
bool global_resched = false;
@@ -335,12 +335,12 @@ ATTR_COLD void NETLIB_NAME(solver)::post_start()
SOLVER_VERBOSE_OUT(("Scanning net groups ...\n"));
// determine net groups
- for (netlist_net_t::list_t::entry_t *pn = netlist().m_nets.first(); pn != NULL; pn = netlist().m_nets.next(pn))
+ for (netlist_net_t * const *pn = netlist().m_nets.first(); pn != NULL; pn = netlist().m_nets.next(pn))
{
- if (!already_processed(groups, cur_group, pn->object()))
+ if (!already_processed(groups, cur_group, *pn))
{
cur_group++;
- process_net(groups, cur_group, pn->object());
+ process_net(groups, cur_group, *pn);
}
}
diff --git a/src/emu/netlist/devices/net_lib.c b/src/emu/netlist/devices/net_lib.c
index 885059d3258..500b99181b9 100644
--- a/src/emu/netlist/devices/net_lib.c
+++ b/src/emu/netlist/devices/net_lib.c
@@ -228,9 +228,9 @@ netlist_factory_t::netlist_factory_t()
netlist_factory_t::~netlist_factory_t()
{
- for (list_t::entry_t *e = m_list.first(); e != NULL; e = m_list.next(e))
+ for (net_device_t_base_factory * const *e = m_list.first(); e != NULL; e = m_list.next(e))
{
- net_device_t_base_factory *p = e->object();
+ net_device_t_base_factory *p = *e;
delete p;
}
m_list.reset();
@@ -281,9 +281,9 @@ void netlist_factory_t::initialize()
netlist_device_t *netlist_factory_t::new_device_by_classname(const pstring &classname, netlist_setup_t &setup) const
{
- for (list_t::entry_t *e = m_list.first(); e != NULL; e = m_list.next(e))
+ for (net_device_t_base_factory * const *e = m_list.first(); e != NULL; e = m_list.next(e))
{
- net_device_t_base_factory *p = e->object();
+ net_device_t_base_factory *p = *e;
if (strcmp(p->classname(), classname) == 0)
{
netlist_device_t *ret = p->Create();
@@ -303,9 +303,9 @@ netlist_device_t *netlist_factory_t::new_device_by_name(const pstring &name, net
net_device_t_base_factory * netlist_factory_t::factory_by_name(const pstring &name, netlist_setup_t &setup) const
{
- for (list_t::entry_t *e = m_list.first(); e != NULL; e = m_list.next(e))
+ for (net_device_t_base_factory * const *e = m_list.first(); e != NULL; e = m_list.next(e))
{
- net_device_t_base_factory *p = e->object();
+ net_device_t_base_factory *p = *e;
if (strcmp(p->name(), name) == 0)
{
return p;
diff --git a/src/emu/netlist/nl_base.c b/src/emu/netlist/nl_base.c
index 9407d4e1c7f..68f63d70317 100644
--- a/src/emu/netlist/nl_base.c
+++ b/src/emu/netlist/nl_base.c
@@ -132,12 +132,12 @@ netlist_base_t::~netlist_base_t()
{
tagmap_free_entries<tagmap_devices_t>(m_devices);
- netlist_net_t::list_t::entry_t *p = m_nets.first();
+ netlist_net_t * const *p = m_nets.first();
while (p != NULL)
{
- netlist_net_t::list_t::entry_t *pn = m_nets.next(p);
- if (!p->object()->isRailNet())
- delete p->object();
+ netlist_net_t * const *pn = m_nets.next(p);
+ if (!(*p)->isRailNet())
+ delete (*p);
p = pn;
}
@@ -147,10 +147,10 @@ netlist_base_t::~netlist_base_t()
ATTR_COLD netlist_net_t *netlist_base_t::find_net(const pstring &name)
{
- for (netlist_net_t::list_t::entry_t *p = m_nets.first(); p != NULL; p = m_nets.next(p))
+ for (netlist_net_t * const *p = m_nets.first(); p != NULL; p = m_nets.next(p))
{
- if (p->object()->name() == name)
- return p->object();
+ if ((*p)->name() == name)
+ return *p;
}
return NULL;
}
diff --git a/src/emu/netlist/nl_base.h b/src/emu/netlist/nl_base.h
index ce993107fb4..0e4cfa9f9d9 100644
--- a/src/emu/netlist/nl_base.h
+++ b/src/emu/netlist/nl_base.h
@@ -597,6 +597,8 @@ public:
return m_cur.Analog;
}
+ ATTR_HOT inline int num_cons() { return m_num_cons; }
+
// m_terms is only used by analog subsystem
typedef netlist_list_t<netlist_terminal_t *> terminal_list_t;
@@ -683,8 +685,6 @@ public:
ATTR_HOT inline void set_Q(const netlist_sig_t newQ, const netlist_time delay)
{
- assert(net().m_num_cons != 1);
-
if (EXPECTED(newQ != net().m_new.Q))
{
net().m_new.Q = newQ;
diff --git a/src/emu/netlist/nl_lists.h b/src/emu/netlist/nl_lists.h
index c49c9c4adc7..70f0569d0f4 100644
--- a/src/emu/netlist/nl_lists.h
+++ b/src/emu/netlist/nl_lists.h
@@ -20,27 +20,17 @@ class netlist_list_t
{
public:
- struct entry_t
- {
- friend class netlist_list_t;
- public:
- // keep compatibility with tagmap
- ATTR_HOT inline _ListClass object() { return m_obj; }
- private:
- _ListClass m_obj;
- };
-
ATTR_COLD netlist_list_t(int numElements = _NumElem)
{
m_num_elements = numElements;
- m_list = new entry_t[m_num_elements];
+ m_list = new _ListClass[m_num_elements];
m_count = 0;
}
ATTR_COLD netlist_list_t(const netlist_list_t &rhs)
{
m_num_elements = rhs.capacity();
- m_list = new entry_t[m_num_elements];
+ m_list = new _ListClass[m_num_elements];
m_count = 0;
for (int i=0; i<rhs.count(); i++)
{
@@ -63,21 +53,21 @@ public:
delete[] m_list;
}
- ATTR_HOT inline void add(const _ListClass elem)
+ ATTR_HOT inline void add(const _ListClass &elem)
{
if (m_count >= m_num_elements)
resize(m_num_elements * 2);
- m_list[m_count++].m_obj = elem;
+ m_list[m_count++] = elem;
}
ATTR_HOT inline void resize(const int new_size)
{
int cnt = count();
- entry_t *m_new = new entry_t[new_size];
- entry_t *pd = m_new;
+ _ListClass *m_new = new _ListClass[new_size];
+ _ListClass *pd = m_new;
- for (entry_t *ps = m_list; ps < m_list + cnt; ps++, pd++)
+ for (_ListClass *ps = m_list; ps < m_list + cnt; ps++, pd++)
*pd = *ps;
delete[] m_list;
m_list = m_new;
@@ -85,11 +75,11 @@ public:
m_num_elements = new_size;
}
- ATTR_HOT inline void remove(const _ListClass elem)
+ ATTR_HOT inline void remove(const _ListClass &elem)
{
- for (int i =0; i < m_count; i++)
+ for (int i = 0; i < m_count; i++)
{
- if (m_list[i].object() == elem)
+ if (m_list[i] == elem)
{
m_count --;
while (i < m_count)
@@ -102,19 +92,19 @@ public:
}
}
- ATTR_HOT inline bool contains(const _ListClass elem) const
+ ATTR_HOT inline bool contains(const _ListClass &elem) const
{
- for (entry_t *i = m_list; i < m_list + m_count; i++)
+ for (_ListClass *i = m_list; i < m_list + m_count; i++)
{
- if (i->object() == elem)
+ if (*i == elem)
return true;
}
return false;
}
- ATTR_HOT inline entry_t *first() const { return ((m_count > 0) ? &m_list[0] : NULL ); }
- ATTR_HOT inline entry_t *next(entry_t *lc) const { return ((lc < last()) ? lc + 1 : NULL ); }
- ATTR_HOT inline entry_t *last() const { return &m_list[m_count -1]; }
+ ATTR_HOT inline const _ListClass *first() const { return ((m_count > 0) ? &m_list[0] : NULL ); }
+ ATTR_HOT inline const _ListClass *next(const _ListClass *lc) const { return ((lc < last()) ? lc + 1 : NULL ); }
+ ATTR_HOT inline const _ListClass *last() const { return &m_list[m_count -1]; }
ATTR_HOT inline int count() const { return m_count; }
ATTR_HOT inline bool empty() const { return (m_count == 0); }
ATTR_HOT inline void reset() { m_count = 0; }
@@ -122,19 +112,19 @@ public:
ATTR_COLD void reset_and_free()
{
- for (entry_t *i = m_list; i < m_list + m_count; i++)
+ for (_ListClass *i = m_list; i < m_list + m_count; i++)
{
- delete i->object();
+ delete *i;
}
reset();
}
- ATTR_HOT inline _ListClass& operator[](const int & index) { return m_list[index].m_obj; }
- ATTR_HOT inline const _ListClass& operator[](const int & index) const { return m_list[index].m_obj; }
+ ATTR_HOT inline _ListClass& operator[](const int & index) { return m_list[index]; }
+ ATTR_HOT inline const _ListClass& operator[](const int & index) const { return m_list[index]; }
private:
int m_count;
- entry_t * m_list;
+ _ListClass * m_list;
int m_num_elements;
//_ListClass m_list[_NumElements];
};
diff --git a/src/emu/netlist/nl_setup.c b/src/emu/netlist/nl_setup.c
index 9b460c48c45..8a9697a7061 100644
--- a/src/emu/netlist/nl_setup.c
+++ b/src/emu/netlist/nl_setup.c
@@ -92,12 +92,12 @@ void netlist_setup_t::remove_dev(const pstring &name)
remove_start_with<tagmap_terminal_t>(m_terminals, temp);
remove_start_with<tagmap_param_t>(m_params, temp);
- tagmap_link_t::entry_t *p = m_links.first();
+ const link_t *p = m_links.first();
while (p != NULL)
{
- tagmap_link_t::entry_t *n = m_links.next(p);
- if (temp.equals(p->object().e1.substr(0,temp.len())) || temp.equals(p->object().e2.substr(0,temp.len())))
- m_links.remove(p->object());
+ const link_t *n = m_links.next(p);
+ if (temp.equals(p->e1.substr(0,temp.len())) || temp.equals(p->e2.substr(0,temp.len())))
+ m_links.remove(*p);
p = n;
}
netlist().m_devices.remove(name);
@@ -527,10 +527,10 @@ void netlist_setup_t::resolve_inputs()
bool has_twoterms = false;
NL_VERBOSE_OUT(("Resolving ...\n"));
- for (tagmap_link_t::entry_t *entry = m_links.first(); entry != NULL; entry = m_links.next(entry))
+ for (const link_t *entry = m_links.first(); entry != NULL; entry = m_links.next(entry))
{
- const pstring t1s = entry->object().e1;
- const pstring t2s = entry->object().e2;
+ const pstring t1s = entry->e1;
+ const pstring t2s = entry->e2;
netlist_core_terminal_t *t1 = find_terminal(t1s);
netlist_core_terminal_t *t2 = find_terminal(t2s);
@@ -548,12 +548,12 @@ void netlist_setup_t::resolve_inputs()
NL_VERBOSE_OUT(("deleting empty nets ...\n"));
// delete empty nets ...
- for (netlist_net_t::list_t::entry_t *pn = netlist().m_nets.first(); pn != NULL; pn = netlist().m_nets.next(pn))
+ for (netlist_net_t *const *pn = netlist().m_nets.first(); pn != NULL; pn = netlist().m_nets.next(pn))
{
- if (pn->object()->m_head == NULL)
+ if ((*pn)->m_head == NULL)
{
NL_VERBOSE_OUT(("Deleting net ...\n"));
- netlist_net_t *to_delete = pn->object();
+ netlist_net_t *to_delete = *pn;
netlist().m_nets.remove(to_delete);
if (!to_delete->isRailNet())
delete to_delete;
@@ -564,8 +564,8 @@ void netlist_setup_t::resolve_inputs()
/* now that nets were deleted ... register all net items */
NL_VERBOSE_OUT(("late state saving for nets ...\n"));
- for (netlist_net_t::list_t::entry_t *pn = netlist().m_nets.first(); pn != NULL; pn = netlist().m_nets.next(pn))
- pn->object()->late_save_register();
+ for (netlist_net_t * const * pn = netlist().m_nets.first(); pn != NULL; pn = netlist().m_nets.next(pn))
+ (*pn)->late_save_register();
NL_VERBOSE_OUT(("looking for terminals not connected ...\n"));
for (tagmap_terminal_t::entry_t *entry = m_terminals.first(); entry != NULL; entry = m_terminals.next(entry))
@@ -573,6 +573,12 @@ void netlist_setup_t::resolve_inputs()
if (!entry->object()->has_net())
netlist().error("Found terminal %s without a net\n",
entry->object()->name().cstr());
+ // FIXME: need a warning callback ....
+#if 0
+ else if (entry->object()->net().num_cons() == 0)
+ netlist().error("Found terminal %s without connections\n",
+ entry->object()->name().cstr());
+#endif
}