From 64b2345cf25c51a1d4f044f5b12f9edd76080b14 Mon Sep 17 00:00:00 2001 From: Stephen Williams Date: Sat, 31 Aug 2013 18:48:32 -0700 Subject: [PATCH] eval_as_long takes in const NetExpr arguments. It is not the same as eval_tree, in particular it doesn't rewrite the expression tree. So the NetExpr argument can be constant. --- netmisc.cc | 6 +++--- netmisc.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/netmisc.cc b/netmisc.cc index 6eec50421..782f637f5 100644 --- a/netmisc.cc +++ b/netmisc.cc @@ -873,14 +873,14 @@ void eval_expr(NetExpr*&expr, int context_width) } } -bool eval_as_long(long&value, NetExpr*expr) +bool eval_as_long(long&value, const NetExpr*expr) { - if (NetEConst*tmp = dynamic_cast(expr) ) { + if (const NetEConst*tmp = dynamic_cast(expr) ) { value = tmp->value().as_long(); return true; } - if (NetECReal*rtmp = dynamic_cast(expr)) { + if (const NetECReal*rtmp = dynamic_cast(expr)) { value = rtmp->value().as_long(); return true; } diff --git a/netmisc.h b/netmisc.h index 384bd4137..2335952ae 100644 --- a/netmisc.h +++ b/netmisc.h @@ -273,7 +273,7 @@ void eval_expr(NetExpr*&expr, int context_width =-1); * possible. If it is not possible (the expression is not evaluated * down to a constant) then return false and leave value unchanged. */ -bool eval_as_long(long&value, NetExpr*expr); +bool eval_as_long(long&value, const NetExpr*expr); bool eval_as_double(double&value, NetExpr*expr); /*