Previous 199869 Revisions Next

r30607 Thursday 22nd May, 2014 at 20:49:38 UTC by Couriersud
Renamed auxiliary types to move them into the "p" namespace (plinearlist_t, pstack_t, ...).
[src/emu/machine]netlist.c
[src/emu/netlist]nl_base.c nl_base.h nl_lists.h nl_parser.h nl_setup.h nl_util.h plists.h* pstate.h
[src/emu/netlist/analog]nld_solver.h

trunk/src/emu/machine/netlist.c
r30606r30607
588588
589589   // Configure outputs
590590
591   netlist_list_t<nld_sound_out *> outdevs = netlist().get_device_list<nld_sound_out>();
591   plinearlist_t<nld_sound_out *> outdevs = netlist().get_device_list<nld_sound_out>();
592592   if (outdevs.count() == 0)
593593      fatalerror("No output devices");
594594
r30606r30607
614614   m_num_inputs = 0;
615615   m_in = NULL;
616616
617   netlist_list_t<nld_sound_in *> indevs = netlist().get_device_list<nld_sound_in>();
617   plinearlist_t<nld_sound_in *> indevs = netlist().get_device_list<nld_sound_in>();
618618   if (indevs.count() > 1)
619619      fatalerror("A maximum of one input device is allowed!");
620620   if (indevs.count() == 1)
trunk/src/emu/netlist/pstate.h
r30606r30607
88
99#include "nl_config.h"
1010#include "nl_time.h"
11#include "nl_lists.h"
11#include "plists.h"
1212#include "pstring.h"
1313
1414// ----------------------------------------------------------------------------------------
r30606r30607
5858class pstate_callback_t
5959{
6060public:
61   typedef netlist_list_t<pstate_callback_t *> list_t;
61   typedef plinearlist_t<pstate_callback_t *> list_t;
6262
6363   virtual ~pstate_callback_t() { };
6464
r30606r30607
7070
7171struct pstate_entry_t
7272{
73   typedef netlist_list_t<pstate_entry_t *> list_t;
73   typedef plinearlist_t<pstate_entry_t *> list_t;
7474
7575   pstate_entry_t(const pstring &stname, const pstate_data_type_e dt, const void *owner,
7676         const int size, const int count, void *ptr)
trunk/src/emu/netlist/nl_base.h
r30606r30607
369369// netlist_core_terminal_t
370370// ----------------------------------------------------------------------------------------
371371
372class netlist_core_terminal_t : public netlist_owned_object_t, public plinked_list_element<netlist_core_terminal_t>
372class netlist_core_terminal_t : public netlist_owned_object_t, public plinkedlist_element_t<netlist_core_terminal_t>
373373{
374374   NETLIST_PREVENT_COPYING(netlist_core_terminal_t)
375375public:
376376
377   typedef netlist_list_t<netlist_core_terminal_t *> list_t;
377   typedef plinearlist_t<netlist_core_terminal_t *> list_t;
378378
379379   /* needed here ... */
380380
r30606r30607
429429   NETLIST_PREVENT_COPYING(netlist_terminal_t)
430430public:
431431
432    typedef netlist_list_t<netlist_terminal_t *> list_t;
432    typedef plinearlist_t<netlist_terminal_t *> list_t;
433433
434434   ATTR_COLD netlist_terminal_t();
435435
r30606r30607
554554   NETLIST_PREVENT_COPYING(netlist_net_t)
555555public:
556556
557   typedef netlist_list_t<netlist_net_t *> list_t;
557   typedef plinearlist_t<netlist_net_t *> list_t;
558558
559559   ATTR_COLD netlist_net_t(const family_t afamily);
560560   ATTR_COLD virtual ~netlist_net_t();
r30606r30607
592592
593593    ATTR_COLD void move_connections(netlist_net_t *new_net);
594594
595    netlist_list_t<netlist_core_terminal_t *> m_core_terms; // save post-start m_list ...
595    plinearlist_t<netlist_core_terminal_t *> m_core_terms; // save post-start m_list ...
596596
597597protected:  //FIXME: needed by current solver code
598598
r30606r30607
606606private:
607607
608608    netlist_core_terminal_t * RESTRICT m_railterminal;
609    plinked_list<netlist_core_terminal_t> m_list_active;
609    plinkedlist_t<netlist_core_terminal_t> m_list_active;
610610
611611    netlist_time m_time;
612612    INT32        m_active;
r30606r30607
627627    NETLIST_PREVENT_COPYING(netlist_logic_net_t)
628628public:
629629
630    typedef netlist_list_t<netlist_logic_net_t *> list_t;
630    typedef plinearlist_t<netlist_logic_net_t *> list_t;
631631
632632    ATTR_COLD netlist_logic_net_t();
633633    ATTR_COLD virtual ~netlist_logic_net_t() { };
r30606r30607
694694    NETLIST_PREVENT_COPYING(netlist_analog_net_t)
695695public:
696696
697    typedef netlist_list_t<netlist_analog_net_t *> list_t;
697    typedef plinearlist_t<netlist_analog_net_t *> list_t;
698698
699699    ATTR_COLD netlist_analog_net_t();
700700    ATTR_COLD virtual ~netlist_analog_net_t() { };
r30606r30607
927927   NETLIST_PREVENT_COPYING(netlist_core_device_t)
928928public:
929929
930   typedef netlist_list_t<netlist_core_device_t *> list_t;
930   typedef plinearlist_t<netlist_core_device_t *> list_t;
931931
932932   ATTR_COLD netlist_core_device_t(const family_t afamily, const netlist_logic_family_desc_t *family_desc);
933933
r30606r30607
10331033
10341034   ATTR_COLD void connect(netlist_core_terminal_t &t1, netlist_core_terminal_t &t2);
10351035
1036   netlist_list_t<pstring, 20> m_terminals;
1036   plinearlist_t<pstring, 20> m_terminals;
10371037
10381038protected:
10391039
r30606r30607
10771077// netlist_base_t
10781078// ----------------------------------------------------------------------------------------
10791079
1080template <class _C>
1081class netlist_tagmap_t : public netlist_list_t<_C>
1082{
1083public:
1084    _C find(const pstring name) const
1085    {
1086        for (int i=0; i < this->count(); i++)
1087            if (get_name((*this)[i]) == name)
1088                return (*this)[i];
1089        return _C(NULL);
1090    }
10911080
1092    void remove_by_name(const pstring name)
1093    {
1094        netlist_list_t<_C>::remove(find(name));
1095    }
1096
1097    bool add(_C dev, bool allow_duplicate)
1098    {
1099        if (allow_duplicate)
1100            netlist_list_t<_C>::add(dev);
1101        else
1102        {
1103            if (!(this->find(get_name(dev)) == _C(NULL)))
1104                return false;
1105            netlist_list_t<_C>::add(dev);
1106        }
1107        return true;
1108    }
1109
1110private:
1111    template <typename T> static const pstring get_name(T &elem) { return elem.name(); }
1112    template <typename T> static const pstring get_name(T *elem) { return elem->name(); }
1113
1114};
1115
11161081class netlist_base_t : public netlist_object_t, public pstate_manager_t
11171082{
11181083   NETLIST_PREVENT_COPYING(netlist_base_t)
r30606r30607
11551120   ATTR_COLD void log(const char *format, ...) const ATTR_PRINTF(2,3);
11561121
11571122   template<class _C>
1158   netlist_list_t<_C *> get_device_list()
1123   plinearlist_t<_C *> get_device_list()
11591124   {
1160      netlist_list_t<_C *> tmp;
1125      plinearlist_t<_C *> tmp;
11611126      for (netlist_device_t * const *entry = m_devices.first(); entry != NULL; entry = m_devices.next(entry))
11621127      {
11631128         _C *dev = dynamic_cast<_C *>(*entry);
r30606r30607
11981163      return ret;
11991164   }
12001165
1201   netlist_tagmap_t<netlist_device_t *> m_devices;
1166   pnamedlist_t<netlist_device_t *> m_devices;
12021167   netlist_net_t::list_t m_nets;
12031168
12041169protected:
r30606r30607
14331398class netlist_factory_t
14341399{
14351400public:
1436   typedef netlist_list_t<net_device_t_base_factory *> list_t;
1401   typedef plinearlist_t<net_device_t_base_factory *> list_t;
14371402
14381403   ATTR_COLD netlist_factory_t();
14391404   ATTR_COLD ~netlist_factory_t();
trunk/src/emu/netlist/nl_util.h
r30606r30607
77#define NL_UTIL_H_
88
99#include "pstring.h"
10#include "nl_lists.h"
10#include "plists.h"
1111
1212class nl_util
1313{
r30606r30607
1616   nl_util() {};
1717
1818public:
19   typedef netlist_list_t<pstring, 10> pstring_list;
19   typedef plinearlist_t<pstring, 10> pstring_list;
2020
2121   static pstring_list split(const pstring &str, const pstring &onstr)
2222   {
trunk/src/emu/netlist/analog/nld_solver.h
r30606r30607
4141class netlist_matrix_solver_t : public netlist_device_t
4242{
4343public:
44   typedef netlist_list_t<netlist_matrix_solver_t *> list_t;
44   typedef plinearlist_t<netlist_matrix_solver_t *> list_t;
4545   typedef netlist_core_device_t::list_t dev_list_t;
4646
4747   ATTR_COLD netlist_matrix_solver_t();
r30606r30607
8686    netlist_time m_last_step;
8787    dev_list_t m_steps;
8888    dev_list_t m_dynamic;
89    netlist_list_t<netlist_analog_output_t *> m_inps;
89    plinearlist_t<netlist_analog_output_t *> m_inps;
9090
9191    netlist_ttl_input_t m_fb_sync;
9292    netlist_ttl_output_t m_Q_sync;
trunk/src/emu/netlist/plists.h
r0r30607
1// license:GPL-2.0+
2// copyright-holders:Couriersud
3/*
4 * plists.h
5 *
6 */
7
8#pragma once
9
10#ifndef PLISTS_H_
11#define PLISTS_H_
12
13#include "nl_config.h"
14#include "pstring.h"
15
16// ----------------------------------------------------------------------------------------
17// plinearlist_t: a simple list
18// ----------------------------------------------------------------------------------------
19
20template <class _ListClass, int _NumElem = 0>
21class plinearlist_t
22{
23public:
24
25   ATTR_COLD plinearlist_t(int numElements = _NumElem)
26   {
27      m_num_elements = numElements;
28      if (m_num_elements == 0)
29          m_list = NULL;
30      else
31          m_list = new _ListClass[m_num_elements];
32      m_count = 0;
33   }
34
35   ATTR_COLD plinearlist_t(const plinearlist_t &rhs)
36   {
37      m_num_elements = rhs.capacity();
38        if (m_num_elements == 0)
39            m_list = NULL;
40        else
41            m_list = new _ListClass[m_num_elements];
42      m_count = 0;
43      for (int i=0; i<rhs.count(); i++)
44      {
45         this->add(rhs[i]);
46      }
47   }
48
49   ATTR_COLD plinearlist_t &operator=(const plinearlist_t &rhs)
50   {
51      this->clear();
52      for (int i=0; i<rhs.count(); i++)
53      {
54         this->add(rhs[i]);
55      }
56      return *this;
57   }
58
59
60   ATTR_COLD ~plinearlist_t()
61   {
62       if (m_list != NULL)
63           delete[] m_list;
64   }
65
66   ATTR_HOT inline void add(const _ListClass &elem)
67   {
68      if (m_count >= m_num_elements){
69          int new_size = m_num_elements * 2;
70          if (new_size < 32)
71              new_size = 32;
72            resize(new_size);
73      }
74
75      m_list[m_count++] = elem;
76   }
77
78   ATTR_HOT inline void resize(const int new_size)
79   {
80      int cnt = count();
81      if (new_size > 0)
82      {
83           _ListClass *m_new = new _ListClass[new_size];
84           _ListClass *pd = m_new;
85
86           if (cnt > new_size)
87               cnt = new_size;
88           for (_ListClass *ps = m_list; ps < m_list + cnt; ps++, pd++)
89               *pd = *ps;
90            if (m_list != NULL)
91                delete[] m_list;
92           m_list = m_new;
93           m_count = cnt;
94      }
95      else
96      {
97          if (m_list != NULL)
98               delete[] m_list;
99          m_list = NULL;
100          m_count = 0;
101      }
102      m_num_elements = new_size;
103   }
104
105   ATTR_HOT inline void remove(const _ListClass &elem)
106   {
107      for (int i = 0; i < m_count; i++)
108      {
109         if (m_list[i] == elem)
110         {
111            m_count --;
112            while (i < m_count)
113            {
114               m_list[i] = m_list[i+1];
115               i++;
116            }
117            return;
118         }
119      }
120   }
121
122   ATTR_HOT inline void remove_at(const int pos)
123   {
124      assert((pos>=0) && (pos<m_count));
125      m_count--;
126      for (int i = pos; i < m_count; i++)
127      {
128         m_list[i] = m_list[i+1];
129      }
130   }
131
132   ATTR_HOT inline bool contains(const _ListClass &elem) const
133   {
134      for (_ListClass *i = m_list; i < m_list + m_count; i++)
135      {
136         if (*i == elem)
137            return true;
138      }
139      return false;
140   }
141
142   ATTR_HOT inline int indexof(const _ListClass &elem) const
143   {
144      for (int i = 0; i < m_count; i++)
145      {
146         if (m_list[i] == elem)
147            return i;
148      }
149      return -1;
150   }
151
152   ATTR_HOT inline const _ListClass *first() const { return ((m_count > 0) ? &m_list[0] : NULL ); }
153   ATTR_HOT inline const _ListClass *next(const _ListClass *lc) const { return ((lc < last()) ? lc + 1 : NULL ); }
154   ATTR_HOT inline const _ListClass *last() const { return &m_list[m_count -1]; }
155   ATTR_HOT inline int count() const { return m_count; }
156   ATTR_HOT inline bool is_empty() const { return (m_count == 0); }
157   ATTR_HOT inline void clear() { m_count = 0; }
158   ATTR_HOT inline int capacity() const { return m_num_elements; }
159
160   ATTR_COLD void clear_and_free()
161   {
162      for (_ListClass *i = m_list; i < m_list + m_count; i++)
163      {
164         delete *i;
165      }
166      clear();
167   }
168
169   ATTR_HOT inline _ListClass& operator[](const int & index) { return m_list[index]; }
170   ATTR_HOT inline const _ListClass& operator[](const int & index) const { return m_list[index]; }
171
172private:
173   int m_count;
174   _ListClass * m_list;
175   int m_num_elements;
176};
177
178// ----------------------------------------------------------------------------------------
179// pnamedlist_t: a simple list
180// ----------------------------------------------------------------------------------------
181
182template <class _C>
183class pnamedlist_t : public plinearlist_t<_C>
184{
185public:
186    _C find(const pstring name) const
187    {
188        for (int i=0; i < this->count(); i++)
189            if (get_name((*this)[i]) == name)
190                return (*this)[i];
191        return _C(NULL);
192    }
193
194    void remove_by_name(const pstring name)
195    {
196        plinearlist_t<_C>::remove(find(name));
197    }
198
199    bool add(_C dev, bool allow_duplicate)
200    {
201        if (allow_duplicate)
202            plinearlist_t<_C>::add(dev);
203        else
204        {
205            if (!(this->find(get_name(dev)) == _C(NULL)))
206                return false;
207            plinearlist_t<_C>::add(dev);
208        }
209        return true;
210    }
211
212private:
213    template <typename T> static const pstring get_name(T &elem) { return elem.name(); }
214    template <typename T> static const pstring get_name(T *elem) { return elem->name(); }
215
216};
217
218
219// ----------------------------------------------------------------------------------------
220// pstack_t: a simple stack
221// ----------------------------------------------------------------------------------------
222
223template <class _StackClass, int _NumElem = 128>
224class pstack_t
225{
226public:
227
228   ATTR_COLD pstack_t(int numElements = _NumElem)
229   : m_list(numElements)
230   {
231   }
232
233   ATTR_COLD pstack_t(const pstack_t &rhs)
234   : m_list(rhs.m_list)
235   {
236   }
237
238   ATTR_COLD pstack_t &operator=(const pstack_t &rhs)
239   {
240      m_list = rhs.m_list;
241      return *this;
242   }
243
244
245   ATTR_COLD ~pstack_t()
246   {
247   }
248
249   ATTR_HOT inline void push(const _StackClass &elem)
250   {
251      m_list.add(elem);
252   }
253
254   ATTR_HOT inline _StackClass peek() const
255   {
256      return m_list[m_list.count() - 1];
257   }
258
259   ATTR_HOT inline _StackClass pop()
260   {
261      _StackClass ret = peek();
262      m_list.remove_at(m_list.count() - 1);
263      return ret;
264   }
265
266   ATTR_HOT inline int count() const { return m_list.count(); }
267   ATTR_HOT inline bool empty() const { return (m_list.count() == 0); }
268   ATTR_HOT inline void reset() { m_list.reset(); }
269   ATTR_HOT inline int capacity() const { return m_list.capacity(); }
270
271private:
272   plinearlist_t<_StackClass, _NumElem> m_list;
273};
274
275template <class _ListClass>
276struct plinkedlist_element_t
277{
278   plinkedlist_element_t() : m_next(NULL) {}
279   _ListClass * m_next;
280
281};
282
283// ----------------------------------------------------------------------------------------
284// plinkedlist_t: a simple linked list
285// ----------------------------------------------------------------------------------------
286
287template <class _ListClass>
288class plinkedlist_t
289{
290public:
291
292   plinkedlist_t() : m_head(NULL) {}
293
294   ATTR_HOT inline void insert(const _ListClass &before, _ListClass &elem)
295   {
296      if (m_head == &before)
297      {
298         elem.m_next = m_head;
299         m_head = elem;
300      }
301      else
302      {
303         _ListClass *p = m_head;
304         while (p != NULL)
305         {
306            if (p->m_next == &before)
307            {
308               elem->m_next = &before;
309               p->m_next = &elem;
310               return;
311            }
312            p = p->m_next;
313         }
314         assert_always(false, "element not found");
315      }
316   }
317
318   ATTR_HOT inline void insert(_ListClass &elem)
319   {
320      elem.m_next = m_head;
321      m_head = &elem;
322   }
323
324   ATTR_HOT inline void add(_ListClass &elem)
325   {
326      _ListClass **p = &m_head;
327      while (*p != NULL)
328      {
329         p = &((*p)->m_next);
330      }
331      *p = &elem;
332      elem.m_next = NULL;
333   }
334
335   ATTR_HOT inline void remove(const _ListClass &elem)
336   {
337      _ListClass **p = &m_head;
338      while (*p != &elem)
339      {
340         assert(*p != NULL);
341         p = &((*p)->m_next);
342      }
343      (*p) = elem.m_next;
344   }
345
346
347   ATTR_HOT static inline _ListClass *next(const _ListClass &elem) { return elem.m_next; }
348   ATTR_HOT static inline _ListClass *next(const _ListClass *elem) { return elem->m_next; }
349   ATTR_HOT inline _ListClass *first() const { return m_head; }
350   ATTR_HOT inline void clear() { m_head = NULL; }
351   ATTR_HOT inline bool is_empty() const { return (m_head == NULL); }
352
353private:
354   _ListClass *m_head;
355};
356
357#endif /* PLISTS_H_ */
Property changes on: trunk/src/emu/netlist/plists.h
Added: svn:eol-style
   + native
Added: svn:mime-type
   + text/plain
trunk/src/emu/netlist/nl_parser.h
r30606r30607
127127
128128   pstring m_identifier_chars;
129129   pstring m_number_chars;
130   netlist_list_t<pstring> m_tokens;
130   plinearlist_t<pstring> m_tokens;
131131   pstring m_whitespace;
132132   char  m_string;
133133
r30606r30607
182182class netlist_source_t
183183{
184184public:
185   typedef netlist_list_t<netlist_source_t> list_t;
185   typedef plinearlist_t<netlist_source_t> list_t;
186186
187187   enum source_e
188188   {
trunk/src/emu/netlist/nl_lists.h
r30606r30607
1212
1313#include "nl_config.h"
1414
15// ----------------------------------------------------------------------------------------
16// netlist_list_t: a simple list
17// ----------------------------------------------------------------------------------------
1815
19
20template <class _ListClass, int _NumElem = 128>
21class netlist_list_t
22{
23public:
24
25   ATTR_COLD netlist_list_t(int numElements = _NumElem)
26   {
27      m_num_elements = numElements;
28      m_list = new _ListClass[m_num_elements];
29      m_count = 0;
30   }
31
32   ATTR_COLD netlist_list_t(const netlist_list_t &rhs)
33   {
34      m_num_elements = rhs.capacity();
35      m_list = new _ListClass[m_num_elements];
36      m_count = 0;
37      for (int i=0; i<rhs.count(); i++)
38      {
39         this->add(rhs[i]);
40      }
41   }
42
43   ATTR_COLD netlist_list_t &operator=(const netlist_list_t &rhs)
44   {
45      this->clear();
46      for (int i=0; i<rhs.count(); i++)
47      {
48         this->add(rhs[i]);
49      }
50      return *this;
51   }
52
53
54   ATTR_COLD ~netlist_list_t()
55   {
56      delete[] m_list;
57   }
58
59   ATTR_HOT inline void add(const _ListClass &elem)
60   {
61      if (m_count >= m_num_elements)
62         resize(m_num_elements * 2);
63
64      m_list[m_count++] = elem;
65   }
66
67   ATTR_HOT inline void resize(const int new_size)
68   {
69      int cnt = count();
70      _ListClass *m_new = new _ListClass[new_size];
71      _ListClass *pd = m_new;
72
73      for (_ListClass *ps = m_list; ps < m_list + cnt; ps++, pd++)
74         *pd = *ps;
75      delete[] m_list;
76      m_list = m_new;
77      m_count = cnt;
78      m_num_elements = new_size;
79   }
80
81   ATTR_HOT inline void remove(const _ListClass &elem)
82   {
83      for (int i = 0; i < m_count; i++)
84      {
85         if (m_list[i] == elem)
86         {
87            m_count --;
88            while (i < m_count)
89            {
90               m_list[i] = m_list[i+1];
91               i++;
92            }
93            return;
94         }
95      }
96   }
97
98   ATTR_HOT inline void remove_at(const int pos)
99   {
100      assert((pos>=0) && (pos<m_count));
101      m_count--;
102      for (int i = pos; i < m_count; i++)
103      {
104         m_list[i] = m_list[i+1];
105      }
106   }
107
108   ATTR_HOT inline bool contains(const _ListClass &elem) const
109   {
110      for (_ListClass *i = m_list; i < m_list + m_count; i++)
111      {
112         if (*i == elem)
113            return true;
114      }
115      return false;
116   }
117
118   ATTR_HOT inline int indexof(const _ListClass &elem) const
119   {
120      for (int i = 0; i < m_count; i++)
121      {
122         if (m_list[i] == elem)
123            return i;
124      }
125      return -1;
126   }
127
128   ATTR_HOT inline const _ListClass *first() const { return ((m_count > 0) ? &m_list[0] : NULL ); }
129   ATTR_HOT inline const _ListClass *next(const _ListClass *lc) const { return ((lc < last()) ? lc + 1 : NULL ); }
130   ATTR_HOT inline const _ListClass *last() const { return &m_list[m_count -1]; }
131   ATTR_HOT inline int count() const { return m_count; }
132   ATTR_HOT inline bool is_empty() const { return (m_count == 0); }
133   ATTR_HOT inline void clear() { m_count = 0; }
134   ATTR_HOT inline int capacity() const { return m_num_elements; }
135
136   ATTR_COLD void clear_and_free()
137   {
138      for (_ListClass *i = m_list; i < m_list + m_count; i++)
139      {
140         delete *i;
141      }
142      clear();
143   }
144
145   ATTR_HOT inline _ListClass& operator[](const int & index) { return m_list[index]; }
146   ATTR_HOT inline const _ListClass& operator[](const int & index) const { return m_list[index]; }
147
148private:
149   int m_count;
150   _ListClass * m_list;
151   int m_num_elements;
152};
153
15416// ----------------------------------------------------------------------------------------
15517// timed queue
15618// ----------------------------------------------------------------------------------------
r30606r30607
255117
256118};
257119
258// ----------------------------------------------------------------------------------------
259// netlist_stack_t: a simple stack
260// ----------------------------------------------------------------------------------------
261
262
263template <class _StackClass, int _NumElem = 128>
264class netlist_stack_t
265{
266public:
267
268   ATTR_COLD netlist_stack_t(int numElements = _NumElem)
269   : m_list(numElements)
270   {
271   }
272
273   ATTR_COLD netlist_stack_t(const netlist_stack_t &rhs)
274   : m_list(rhs.m_list)
275   {
276   }
277
278   ATTR_COLD netlist_stack_t &operator=(const netlist_stack_t &rhs)
279   {
280      m_list = rhs.m_list;
281      return *this;
282   }
283
284
285   ATTR_COLD ~netlist_stack_t()
286   {
287   }
288
289   ATTR_HOT inline void push(const _StackClass &elem)
290   {
291      m_list.add(elem);
292   }
293
294   ATTR_HOT inline _StackClass peek() const
295   {
296      return m_list[m_list.count() - 1];
297   }
298
299   ATTR_HOT inline _StackClass pop()
300   {
301      _StackClass ret = peek();
302      m_list.remove_at(m_list.count() - 1);
303      return ret;
304   }
305
306   ATTR_HOT inline int count() const { return m_list.count(); }
307   ATTR_HOT inline bool empty() const { return (m_list.count() == 0); }
308   ATTR_HOT inline void reset() { m_list.reset(); }
309   ATTR_HOT inline int capacity() const { return m_list.capacity(); }
310
311private:
312   netlist_list_t<_StackClass, _NumElem> m_list;
313};
314
315template <class _ListClass>
316struct plinked_list_element
317{
318   plinked_list_element() : m_next(NULL) {}
319   _ListClass * m_next;
320
321};
322
323template <class _ListClass>
324class plinked_list
325{
326public:
327
328   plinked_list() : m_head(NULL) {}
329
330   ATTR_HOT inline void insert(const _ListClass &before, _ListClass &elem)
331   {
332      if (m_head == &before)
333      {
334         elem.m_next = m_head;
335         m_head = elem;
336      }
337      else
338      {
339         _ListClass *p = m_head;
340         while (p != NULL)
341         {
342            if (p->m_next == &before)
343            {
344               elem->m_next = &before;
345               p->m_next = &elem;
346               return;
347            }
348            p = p->m_next;
349         }
350         assert_always(false, "element not found");
351      }
352   }
353
354   ATTR_HOT inline void insert(_ListClass &elem)
355   {
356      elem.m_next = m_head;
357      m_head = &elem;
358   }
359
360   ATTR_HOT inline void add(_ListClass &elem)
361   {
362      _ListClass **p = &m_head;
363      while (*p != NULL)
364      {
365         p = &((*p)->m_next);
366      }
367      *p = &elem;
368      elem.m_next = NULL;
369   }
370
371   ATTR_HOT inline void remove(const _ListClass &elem)
372   {
373      _ListClass **p = &m_head;
374      while (*p != &elem)
375      {
376         assert(*p != NULL);
377         p = &((*p)->m_next);
378      }
379      (*p) = elem.m_next;
380   }
381
382
383   ATTR_HOT static inline _ListClass *next(const _ListClass &elem) { return elem.m_next; }
384   ATTR_HOT static inline _ListClass *next(const _ListClass *elem) { return elem->m_next; }
385   ATTR_HOT inline _ListClass *first() const { return m_head; }
386   ATTR_HOT inline void clear() { m_head = NULL; }
387   ATTR_HOT inline bool is_empty() const { return (m_head == NULL); }
388
389private:
390   _ListClass *m_head;
391};
392
393120#endif /* NLLISTS_H_ */
trunk/src/emu/netlist/nl_setup.h
r30606r30607
105105      const pstring &name() const { return e1; }
106106   };
107107
108   typedef netlist_tagmap_t<link_t> tagmap_nstring_t;
109   typedef netlist_tagmap_t<netlist_param_t *> tagmap_param_t;
110   typedef netlist_tagmap_t<netlist_core_terminal_t *> tagmap_terminal_t;
111   typedef netlist_list_t<link_t> tagmap_link_t;
108   typedef pnamedlist_t<link_t> tagmap_nstring_t;
109   typedef pnamedlist_t<netlist_param_t *> tagmap_param_t;
110   typedef pnamedlist_t<netlist_core_terminal_t *> tagmap_terminal_t;
111   typedef plinearlist_t<link_t> tagmap_link_t;
112112
113113   netlist_setup_t(netlist_base_t &netlist);
114114   ~netlist_setup_t();
r30606r30607
169169
170170   netlist_factory_t m_factory;
171171
172   netlist_list_t<pstring> m_models;
172   plinearlist_t<pstring> m_models;
173173
174174   int m_proxy_cnt;
175175
176   netlist_stack_t<pstring> m_stack;
176   pstack_t<pstring> m_stack;
177177
178178
179179   void connect_terminals(netlist_core_terminal_t &in, netlist_core_terminal_t &out);
trunk/src/emu/netlist/nl_base.c
r30606r30607
758758
759759ATTR_COLD netlist_core_terminal_t::netlist_core_terminal_t(const type_t atype, const family_t afamily)
760760: netlist_owned_object_t(atype, afamily)
761, plinked_list_element<netlist_core_terminal_t>()
761, plinkedlist_element_t<netlist_core_terminal_t>()
762762, m_family_desc(NULL)
763763, m_net(NULL)
764764, m_state(STATE_NONEX)
r30606r30607
771771, m_go(NETLIST_GMIN_DEFAULT)
772772, m_gt(NETLIST_GMIN_DEFAULT)
773773, m_otherterm(NULL)
774, m_otherterm_ptr(NULL)
774775{
775776}
776777

Previous 199869 Revisions Next


© 1997-2024 The MAME Team