mirror of
https://github.com/holub/mame
synced 2025-04-22 16:31:49 +03:00
Keep track were registry elements are created. (nw)
This commit is contained in:
parent
10a4ab4af1
commit
969e6ed6a0
@ -19,8 +19,8 @@ namespace netlist
|
||||
P_PREVENT_COPYING(netlist_factory_truthtable_t)
|
||||
public:
|
||||
netlist_factory_truthtable_t(const pstring &name, const pstring &classname,
|
||||
const pstring &def_param)
|
||||
: netlist_base_factory_truthtable_t(name, classname, def_param)
|
||||
const pstring &def_param, const pstring &sourcefile)
|
||||
: netlist_base_factory_truthtable_t(name, classname, def_param, sourcefile)
|
||||
{ }
|
||||
|
||||
plib::owned_ptr<device_t> Create(netlist_t &anetlist, const pstring &name) override
|
||||
@ -260,8 +260,8 @@ void truthtable_desc_t::setup(const plib::pstring_vector_t &truthtable, uint_lea
|
||||
}
|
||||
|
||||
netlist_base_factory_truthtable_t::netlist_base_factory_truthtable_t(const pstring &name, const pstring &classname,
|
||||
const pstring &def_param)
|
||||
: factory::element_t(name, classname, def_param), m_family(family_TTL())
|
||||
const pstring &def_param, const pstring &sourcefile)
|
||||
: factory::element_t(name, classname, def_param, sourcefile), m_family(family_TTL())
|
||||
{
|
||||
}
|
||||
|
||||
@ -270,28 +270,29 @@ netlist_base_factory_truthtable_t::~netlist_base_factory_truthtable_t()
|
||||
}
|
||||
|
||||
|
||||
#define ENTRYY(n, m) case (n * 100 + m): \
|
||||
#define ENTRYY(n, m, s) case (n * 100 + m): \
|
||||
{ using xtype = netlist_factory_truthtable_t<n, m>; \
|
||||
ret = new xtype(desc.name, desc.classname, desc.def_param); } break
|
||||
ret = new xtype(desc.name, desc.classname, desc.def_param, s); } break
|
||||
|
||||
#define ENTRY(n) ENTRYY(n, 1); ENTRYY(n, 2); ENTRYY(n, 3); ENTRYY(n, 4); ENTRYY(n, 5); ENTRYY(n, 6)
|
||||
#define ENTRY(n, s) ENTRYY(n, 1, s); ENTRYY(n, 2, s); ENTRYY(n, 3, s); \
|
||||
ENTRYY(n, 4, s); ENTRYY(n, 5, s); ENTRYY(n, 6, s)
|
||||
|
||||
void tt_factory_create(setup_t &setup, tt_desc &desc)
|
||||
void tt_factory_create(setup_t &setup, tt_desc &desc, const pstring &sourcefile)
|
||||
{
|
||||
netlist_base_factory_truthtable_t *ret;
|
||||
|
||||
switch (desc.ni * 100 + desc.no)
|
||||
{
|
||||
ENTRY(1);
|
||||
ENTRY(2);
|
||||
ENTRY(3);
|
||||
ENTRY(4);
|
||||
ENTRY(5);
|
||||
ENTRY(6);
|
||||
ENTRY(7);
|
||||
ENTRY(8);
|
||||
ENTRY(9);
|
||||
ENTRY(10);
|
||||
ENTRY(1, sourcefile);
|
||||
ENTRY(2, sourcefile);
|
||||
ENTRY(3, sourcefile);
|
||||
ENTRY(4, sourcefile);
|
||||
ENTRY(5, sourcefile);
|
||||
ENTRY(6, sourcefile);
|
||||
ENTRY(7, sourcefile);
|
||||
ENTRY(8, sourcefile);
|
||||
ENTRY(9, sourcefile);
|
||||
ENTRY(10, sourcefile);
|
||||
default:
|
||||
pstring msg = plib::pfmt("unable to create truthtable<{1},{2}>")(desc.ni)(desc.no);
|
||||
nl_assert_always(false, msg);
|
||||
|
@ -371,7 +371,7 @@ namespace netlist
|
||||
P_PREVENT_COPYING(netlist_base_factory_truthtable_t)
|
||||
public:
|
||||
netlist_base_factory_truthtable_t(const pstring &name, const pstring &classname,
|
||||
const pstring &def_param);
|
||||
const pstring &def_param, const pstring &sourcefile);
|
||||
|
||||
virtual ~netlist_base_factory_truthtable_t();
|
||||
|
||||
@ -379,7 +379,7 @@ namespace netlist
|
||||
const logic_family_desc_t *m_family;
|
||||
};
|
||||
|
||||
void tt_factory_create(setup_t &setup, tt_desc &desc);
|
||||
void tt_factory_create(setup_t &setup, tt_desc &desc, const pstring &sourcefile);
|
||||
|
||||
} //namespace devices
|
||||
} // namespace netlist
|
||||
|
@ -16,9 +16,17 @@
|
||||
namespace netlist { namespace factory
|
||||
{
|
||||
|
||||
element_t::element_t(const pstring &name, const pstring &classname,
|
||||
const pstring &def_param, const pstring &sourcefile)
|
||||
: m_name(name), m_classname(classname), m_def_param(def_param),
|
||||
m_sourcefile(sourcefile)
|
||||
{
|
||||
}
|
||||
|
||||
element_t::element_t(const pstring &name, const pstring &classname,
|
||||
const pstring &def_param)
|
||||
: m_name(name), m_classname(classname), m_def_param(def_param)
|
||||
: m_name(name), m_classname(classname), m_def_param(def_param),
|
||||
m_sourcefile("<unknown>")
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,18 @@
|
||||
#include "plib/putil.h"
|
||||
#include "nl_base.h"
|
||||
|
||||
#if 1
|
||||
#define NETLIB_DEVICE_IMPL(chip) \
|
||||
static std::unique_ptr<factory::element_t> NETLIB_NAME(chip ## _c)( \
|
||||
const pstring &name, const pstring &classname, const pstring &def_param) \
|
||||
{ \
|
||||
return std::unique_ptr<factory::element_t>(new factory::device_element_t<NETLIB_NAME(chip)>(name, classname, def_param, pstring(__FILE__))); \
|
||||
} \
|
||||
factory::constructor_ptr_t decl_ ## chip = NETLIB_NAME(chip ## _c);
|
||||
#else
|
||||
#define NETLIB_DEVICE_IMPL(chip) factory::constructor_ptr_t decl_ ## chip = factory::constructor_t< NETLIB_NAME(chip) >;
|
||||
#endif
|
||||
|
||||
#define NETLIB_DEVICE_IMPL_NS(ns, chip) factory::constructor_ptr_t decl_ ## chip = factory::constructor_t< ns :: NETLIB_NAME(chip) >;
|
||||
|
||||
namespace netlist { namespace factory
|
||||
@ -32,6 +43,8 @@ namespace netlist { namespace factory
|
||||
public:
|
||||
element_t(const pstring &name, const pstring &classname,
|
||||
const pstring &def_param);
|
||||
element_t(const pstring &name, const pstring &classname,
|
||||
const pstring &def_param, const pstring &sourcefile);
|
||||
virtual ~element_t();
|
||||
|
||||
virtual plib::owned_ptr<device_t> Create(netlist_t &anetlist, const pstring &name) = 0;
|
||||
@ -40,11 +53,13 @@ namespace netlist { namespace factory
|
||||
const pstring &name() const { return m_name; }
|
||||
const pstring &classname() const { return m_classname; }
|
||||
const pstring ¶m_desc() const { return m_def_param; }
|
||||
const pstring &sourcefile() const { return m_sourcefile; }
|
||||
|
||||
protected:
|
||||
pstring m_name; /* device name */
|
||||
pstring m_classname; /* device class name */
|
||||
pstring m_def_param; /* default parameter */
|
||||
pstring m_sourcefile; /* source file */
|
||||
};
|
||||
|
||||
template <class C>
|
||||
@ -55,6 +70,9 @@ namespace netlist { namespace factory
|
||||
device_element_t(const pstring &name, const pstring &classname,
|
||||
const pstring &def_param)
|
||||
: element_t(name, classname, def_param) { }
|
||||
device_element_t(const pstring &name, const pstring &classname,
|
||||
const pstring &def_param, const pstring &sourcefile)
|
||||
: element_t(name, classname, def_param, sourcefile) { }
|
||||
|
||||
plib::owned_ptr<device_t> Create(netlist_t &anetlist, const pstring &name) override
|
||||
{
|
||||
@ -125,8 +143,8 @@ namespace netlist { namespace factory
|
||||
public:
|
||||
|
||||
library_element_t(setup_t &setup, const pstring &name, const pstring &classname,
|
||||
const pstring &def_param)
|
||||
: element_t(name, classname, def_param), m_setup(setup) { }
|
||||
const pstring &def_param, const pstring &source)
|
||||
: element_t(name, classname, def_param, source), m_setup(setup) { }
|
||||
|
||||
plib::owned_ptr<device_t> Create(netlist_t &anetlist, const pstring &name) override;
|
||||
|
||||
|
@ -99,7 +99,7 @@ bool parser_t::parse(const pstring nlname)
|
||||
}
|
||||
}
|
||||
|
||||
void parser_t::parse_netlist(ATTR_UNUSED const pstring &nlname)
|
||||
void parser_t::parse_netlist(const pstring &nlname)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
@ -132,10 +132,10 @@ void parser_t::parse_netlist(ATTR_UNUSED const pstring &nlname)
|
||||
else if (token.is(m_tok_LOCAL_SOURCE))
|
||||
net_local_source();
|
||||
else if (token.is(m_tok_TRUTHTABLE_START))
|
||||
net_truthtable_start();
|
||||
net_truthtable_start(nlname);
|
||||
else if (token.is(m_tok_LOCAL_LIB_ENTRY))
|
||||
{
|
||||
m_setup.register_lib_entry(get_identifier());
|
||||
m_setup.register_lib_entry(get_identifier(), "parser: " + nlname);
|
||||
require_token(m_tok_param_right);
|
||||
}
|
||||
else if (token.is(m_tok_NETLIST_END))
|
||||
@ -148,7 +148,7 @@ void parser_t::parse_netlist(ATTR_UNUSED const pstring &nlname)
|
||||
}
|
||||
}
|
||||
|
||||
void parser_t::net_truthtable_start()
|
||||
void parser_t::net_truthtable_start(const pstring &nlname)
|
||||
{
|
||||
pstring name = get_identifier();
|
||||
require_token(m_tok_comma);
|
||||
@ -194,7 +194,7 @@ void parser_t::net_truthtable_start()
|
||||
require_token(token, m_tok_TRUTHTABLE_END);
|
||||
require_token(m_tok_param_left);
|
||||
require_token(m_tok_param_right);
|
||||
netlist::devices::tt_factory_create(m_setup, desc);
|
||||
netlist::devices::tt_factory_create(m_setup, desc, nlname);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ namespace netlist
|
||||
void net_submodel();
|
||||
void net_include();
|
||||
void net_local_source();
|
||||
void net_truthtable_start();
|
||||
void net_truthtable_start(const pstring &nlname);
|
||||
|
||||
/* for debugging messages */
|
||||
netlist_t &netlist() { return m_setup.netlist(); }
|
||||
|
@ -71,9 +71,9 @@ void setup_t::namespace_pop()
|
||||
m_namespace_stack.pop();
|
||||
}
|
||||
|
||||
void setup_t::register_lib_entry(const pstring &name)
|
||||
void setup_t::register_lib_entry(const pstring &name, const pstring &sourcefile)
|
||||
{
|
||||
factory().register_device(plib::make_unique_base<factory::element_t, factory::library_element_t>(*this, name, name, ""));
|
||||
factory().register_device(plib::make_unique_base<factory::element_t, factory::library_element_t>(*this, name, name, "", sourcefile));
|
||||
}
|
||||
|
||||
void setup_t::register_dev(const pstring &classname, const pstring &name)
|
||||
@ -892,9 +892,9 @@ nl_double setup_t::model_value(model_map_t &map, const pstring &entity)
|
||||
return tmp.as_double() * factor;
|
||||
}
|
||||
|
||||
void setup_t::tt_factory_create(tt_desc &desc)
|
||||
void setup_t::tt_factory_create(tt_desc &desc, const pstring &sourcefile)
|
||||
{
|
||||
devices::tt_factory_create(*this, desc);
|
||||
devices::tt_factory_create(*this, desc, sourcefile);
|
||||
}
|
||||
|
||||
|
||||
|
@ -71,7 +71,7 @@ void NETLIST_NAME(name)(netlist::setup_t &setup) \
|
||||
|
||||
#define LOCAL_LIB_ENTRY(name) \
|
||||
LOCAL_SOURCE(name) \
|
||||
setup.register_lib_entry(# name);
|
||||
setup.register_lib_entry(# name, __FILE__);
|
||||
|
||||
#define INCLUDE(name) \
|
||||
setup.include(# name);
|
||||
@ -108,7 +108,7 @@ void NETLIST_NAME(name)(netlist::setup_t &setup) \
|
||||
desc.family = x;
|
||||
|
||||
#define TRUTHTABLE_END() \
|
||||
netlist::devices::tt_factory_create(setup, desc); \
|
||||
netlist::devices::tt_factory_create(setup, desc, __FILE__); \
|
||||
}
|
||||
|
||||
|
||||
@ -205,7 +205,7 @@ namespace netlist
|
||||
|
||||
void register_dev(const pstring &classname, const pstring &name);
|
||||
|
||||
void register_lib_entry(const pstring &name);
|
||||
void register_lib_entry(const pstring &name, const pstring &sourcefile);
|
||||
|
||||
void register_model(const pstring &model_in);
|
||||
void register_alias(const pstring &alias, const pstring &out);
|
||||
@ -268,7 +268,7 @@ namespace netlist
|
||||
|
||||
/* FIXME: truth table trampoline */
|
||||
|
||||
void tt_factory_create(tt_desc &desc);
|
||||
void tt_factory_create(tt_desc &desc, const pstring &sourcefile);
|
||||
|
||||
/* helper - also used by nltool */
|
||||
const pstring resolve_alias(const pstring &name) const;
|
||||
|
@ -365,8 +365,17 @@ static void create_header(tool_options_t &opts)
|
||||
pout(" * ---------------------------------------------------------------------------*/\n");
|
||||
pout("\n");
|
||||
|
||||
pstring last_source("");
|
||||
|
||||
for (auto &e : nt.setup().factory())
|
||||
{
|
||||
if (last_source != e->sourcefile())
|
||||
{
|
||||
last_source = e->sourcefile();
|
||||
pout("{1}\n", pstring("// ").rpad("-", 72));
|
||||
pout("{1}\n", pstring("// Source: ").cat(e->sourcefile().replace("../","")));
|
||||
pout("{1}\n", pstring("// ").rpad("-", 72));
|
||||
}
|
||||
auto v = plib::pstring_vector_t(e->param_desc(), ",");
|
||||
pstring vs;
|
||||
for (auto s : v)
|
||||
|
Loading…
Reference in New Issue
Block a user