From 05d5c9b35f986b2c3cdad223d3c5bff766d6cc26 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Sat, 26 Mar 2022 11:45:51 +0100 Subject: [PATCH] Provide default implementation of NetExpr::enumeration() The current NetExpr::enumeration() always returns a nullptr. The NetExpr class has a ivl_type_t member that represents the type of the expression. Provide a default implementation of NetExpr::enumeration() that casts this type to the netenum_t type. This will allow to share this implementation between subclasses and remove a bit of duplicated code. Signed-off-by: Lars-Peter Clausen --- net_expr.cc | 12 +++--------- netlist.h | 2 -- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/net_expr.cc b/net_expr.cc index 25f10dcb5..08524f807 100644 --- a/net_expr.cc +++ b/net_expr.cc @@ -72,7 +72,7 @@ ivl_variable_type_t NetExpr::expr_type() const const netenum_t*NetExpr::enumeration() const { - return 0; + return dynamic_cast(net_type_); } NetEArrayPattern::NetEArrayPattern(ivl_type_t lv_type, vector&items) @@ -464,15 +464,14 @@ const netenum_t* NetESelect::enumeration() const NetESFunc::NetESFunc(const char*n, ivl_variable_type_t t, unsigned width, unsigned np, bool is_overridden) -: name_(0), type_(t), enum_type_(0), parms_(np), is_overridden_(is_overridden) +: name_(0), type_(t), parms_(np), is_overridden_(is_overridden) { name_ = lex_strings.add(n); expr_width(width); } NetESFunc::NetESFunc(const char*n, ivl_type_t rtype, unsigned np) -: NetExpr(rtype), name_(0), type_(rtype->base_type()), - enum_type_(dynamic_cast(rtype)), parms_(np), +: NetExpr(rtype), name_(0), type_(rtype->base_type()), parms_(np), is_overridden_(false) { name_ = lex_strings.add(n); @@ -523,11 +522,6 @@ ivl_variable_type_t NetESFunc::expr_type() const return type_; } -const netenum_t* NetESFunc::enumeration() const -{ - return enum_type_; -} - NetEShallowCopy::NetEShallowCopy(NetExpr*arg1, NetExpr*arg2) : arg1_(arg1), arg2_(arg2) { diff --git a/netlist.h b/netlist.h index 37fd61f48..ffc0630b2 100644 --- a/netlist.h +++ b/netlist.h @@ -4663,7 +4663,6 @@ class NetESFunc : public NetExpr { virtual ivl_variable_type_t expr_type() const; virtual NexusSet* nex_input(bool rem_out = true, bool always_sens = false, bool nested_func = false) const; - virtual const netenum_t* enumeration() const; virtual void dump(std::ostream&) const; virtual void expr_scan(struct expr_scan_t*) const; @@ -4739,7 +4738,6 @@ class NetESFunc : public NetExpr { const char* name_; ivl_variable_type_t type_; - const netenum_t*enum_type_; std::vectorparms_; bool is_overridden_;