From ad23b08a1073115ecd0fdbcc01384fac957bcc8c Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Sat, 19 Feb 2022 12:08:57 +0100 Subject: [PATCH] Constify scope reference in NetEConstParam and NetECRealParam Parameter expressions need to remember the scope they have been declared in so that the code generator backends can insert the right parameter reference, rather than a constant value. Currently the scope is stored as a non-const reference. But that is not needed. Mark the scope reference as const so NetEConstParam and NetECRealParam can be created when only a const scope reference is available. Signed-off-by: Lars-Peter Clausen --- net_expr.cc | 2 +- netlist.cc | 2 +- netlist.h | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/net_expr.cc b/net_expr.cc index 4a0ee3008..5cd29e013 100644 --- a/net_expr.cc +++ b/net_expr.cc @@ -304,7 +304,7 @@ ivl_variable_type_t NetECReal::expr_type() const return IVL_VT_REAL; } -NetECRealParam::NetECRealParam(NetScope*s, perm_string n, const verireal&v) +NetECRealParam::NetECRealParam(const NetScope*s, perm_string n, const verireal&v) : NetECReal(v), scope_(s), name_(n) { } diff --git a/netlist.cc b/netlist.cc index a83b5f5e3..21a44faea 100644 --- a/netlist.cc +++ b/netlist.cc @@ -2391,7 +2391,7 @@ void NetEConst::trim() expr_width(value_.len()); } -NetEConstParam::NetEConstParam(NetScope*s, perm_string n, const verinum&v) +NetEConstParam::NetEConstParam(const NetScope*s, perm_string n, const verinum&v) : NetEConst(v), scope_(s), name_(n) { cast_signed_base_(v.has_sign()); diff --git a/netlist.h b/netlist.h index 68514c3e6..dd6b9dbb7 100644 --- a/netlist.h +++ b/netlist.h @@ -2175,7 +2175,7 @@ class NetEConstEnum : public NetEConst { class NetEConstParam : public NetEConst { public: - explicit NetEConstParam(NetScope*scope, perm_string name, + explicit NetEConstParam(const NetScope*scope, perm_string name, const verinum&val); ~NetEConstParam(); @@ -2188,7 +2188,7 @@ class NetEConstParam : public NetEConst { virtual NetEConstParam* dup_expr() const; private: - NetScope*scope_; + const NetScope*scope_; perm_string name_; }; @@ -2236,7 +2236,7 @@ class NetECString : public NetEConst { class NetECRealParam : public NetECReal { public: - explicit NetECRealParam(NetScope*scope, perm_string name, + explicit NetECRealParam(const NetScope*scope, perm_string name, const verireal&val); ~NetECRealParam(); @@ -2249,7 +2249,7 @@ class NetECRealParam : public NetECReal { virtual NetECRealParam* dup_expr() const; private: - NetScope*scope_; + const NetScope*scope_; perm_string name_; };