Decrease memory footprint. (nw)

This commit is contained in:
couriersud 2017-01-08 17:10:04 +01:00
parent f425f2b997
commit 233b0b7dbe
2 changed files with 43 additions and 23 deletions

View File

@ -206,13 +206,32 @@ const pstring &detail::object_t::name() const
// device_object_t
// ----------------------------------------------------------------------------------------
detail::device_object_t::device_object_t(core_device_t &dev, const pstring &aname, const type_t atype)
detail::device_object_t::device_object_t(core_device_t &dev, const pstring &aname)
: object_t(aname)
, m_device(dev)
, m_type(atype)
{
}
detail::device_object_t::type_t detail::device_object_t::type() const
{
if (dynamic_cast<const terminal_t *>(this) != nullptr)
return type_t::TERMINAL;
else if (dynamic_cast<const param_t *>(this) != nullptr)
return param_t::PARAM;
else if (dynamic_cast<const logic_input_t *>(this) != nullptr)
return param_t::INPUT;
else if (dynamic_cast<const logic_output_t *>(this) != nullptr)
return param_t::OUTPUT;
else if (dynamic_cast<const analog_input_t *>(this) != nullptr)
return param_t::INPUT;
else if (dynamic_cast<const analog_output_t *>(this) != nullptr)
return param_t::OUTPUT;
else
{
netlist().log().fatal("Unknown type for object {1} ", name());
return type_t::TERMINAL; // please compiler
}
}
// ----------------------------------------------------------------------------------------
// netlist_t
@ -791,9 +810,8 @@ analog_net_t::~analog_net_t()
// core_terminal_t
// ----------------------------------------------------------------------------------------
detail::core_terminal_t::core_terminal_t(core_device_t &dev, const pstring &aname,
const type_t type, const state_e state)
: device_object_t(dev, dev.name() + "." + aname, type)
detail::core_terminal_t::core_terminal_t(core_device_t &dev, const pstring &aname, const state_e state)
: device_object_t(dev, dev.name() + "." + aname)
, plib::linkedlist_t<core_terminal_t>::element_t()
, m_net(nullptr)
, m_state(*this, "m_state", state)
@ -835,7 +853,7 @@ logic_t::~logic_t()
// ----------------------------------------------------------------------------------------
terminal_t::terminal_t(core_device_t &dev, const pstring &aname)
: analog_t(dev, aname, TERMINAL, STATE_BIDIR)
: analog_t(dev, aname, STATE_BIDIR)
, m_otherterm(nullptr)
, m_Idr1(*this, "m_Idr1", nullptr)
, m_go1(*this, "m_go1", nullptr)
@ -875,7 +893,7 @@ void terminal_t::schedule_after(const netlist_time &after)
// ----------------------------------------------------------------------------------------
logic_output_t::logic_output_t(core_device_t &dev, const pstring &aname)
: logic_t(dev, aname, OUTPUT, STATE_OUT)
: logic_t(dev, aname, STATE_OUT)
, m_my_net(dev.netlist(), name() + ".net", this)
{
this->set_net(&m_my_net);
@ -897,7 +915,7 @@ void logic_output_t::initial(const netlist_sig_t val)
// ----------------------------------------------------------------------------------------
analog_input_t::analog_input_t(core_device_t &dev, const pstring &aname)
: analog_t(dev, aname, INPUT, STATE_INP_ACTIVE)
: analog_t(dev, aname, STATE_INP_ACTIVE)
{
netlist().setup().register_term(*this);
}
@ -911,7 +929,7 @@ analog_input_t::~analog_input_t()
// ----------------------------------------------------------------------------------------
analog_output_t::analog_output_t(core_device_t &dev, const pstring &aname)
: analog_t(dev, aname, OUTPUT, STATE_OUT)
: analog_t(dev, aname, STATE_OUT)
, m_my_net(dev.netlist(), name() + ".net", this)
{
this->set_net(&m_my_net);
@ -934,7 +952,7 @@ void analog_output_t::initial(const nl_double val)
// -----------------------------------------------------------------------------
logic_input_t::logic_input_t(core_device_t &dev, const pstring &aname)
: logic_t(dev, aname, INPUT, STATE_INP_ACTIVE)
: logic_t(dev, aname, STATE_INP_ACTIVE)
{
set_logic_family(dev.logic_family());
netlist().setup().register_term(*this);
@ -949,7 +967,7 @@ logic_input_t::~logic_input_t()
// ----------------------------------------------------------------------------------------
param_t::param_t(const param_type_t atype, device_t &device, const pstring &name)
: device_object_t(device, device.name() + "." + name, PARAM)
: device_object_t(device, device.name() + "." + name)
, m_param_type(atype)
{
device.setup().register_param(this->name(), *this);

View File

@ -441,7 +441,7 @@ namespace netlist
* \param name string holding the name of the device
* \param type type of this object.
*/
device_object_t(core_device_t &dev, const pstring &name, const type_t type);
device_object_t(core_device_t &dev, const pstring &name);
/*! returns reference to owning device.
* \returns reference to owning device.
*/
@ -450,21 +450,21 @@ namespace netlist
/*! The object type.
* \returns type of the object
*/
type_t type() const { return m_type; }
type_t type() const;
/*! Checks if object is of specified type.
* \param type type to check object against.
* \returns true if object is of specified type else false.
*/
bool is_type(const type_t type) const { return (m_type == type); }
bool is_type(const type_t atype) const { return (type() == atype); }
/*! The netlist owning the owner of this object.
* \returns reference to netlist object.
*/
netlist_t &netlist();
const netlist_t &netlist() const;
private:
core_device_t & m_device;
const type_t m_type;
};
@ -493,8 +493,7 @@ namespace netlist
STATE_BIDIR = 256
};
core_terminal_t(core_device_t &dev, const pstring &aname,
const type_t type, const state_e state);
core_terminal_t(core_device_t &dev, const pstring &aname, const state_e state);
virtual ~core_terminal_t();
void set_net(net_t *anet);
@ -526,9 +525,8 @@ namespace netlist
{
public:
analog_t(core_device_t &dev, const pstring &aname, const type_t type,
const state_e state)
: core_terminal_t(dev, aname, type, state)
analog_t(core_device_t &dev, const pstring &aname, const state_e state)
: core_terminal_t(dev, aname, state)
{
}
virtual ~analog_t();
@ -607,9 +605,8 @@ namespace netlist
class logic_t : public detail::core_terminal_t, public logic_family_t
{
public:
logic_t(core_device_t &dev, const pstring &aname, const type_t type,
const state_e state)
: core_terminal_t(dev, aname, type, state)
logic_t(core_device_t &dev, const pstring &aname, const state_e state)
: core_terminal_t(dev, aname, state)
, logic_family_t()
, m_proxy(nullptr)
{
@ -1484,6 +1481,11 @@ namespace netlist
return m_device.netlist();
}
inline const netlist_t &detail::device_object_t::netlist() const
{
return m_device.netlist();
}
}