svlog: value: Migrate repeats to MIR
@@ -293,7 +293,7 @@ fn const_expr<'gcx>(
_ => Err(()),
}
}
- hir::ExprKind::PositionalPattern(..) | hir::ExprKind::RepeatPattern(..) => {
+ hir::ExprKind::PositionalPattern(..) => {
let mut resolved = resolver::resolve_pattern(cx, expr.id, env)?;
resolved.sort_by(|(a, _), (b, _)| a.cmp(b));
trace!("resolved {:?} to {:#?}", expr.kind, resolved);
@@ -461,6 +461,19 @@ fn const_mir<'gcx>(cx: &impl Context<'gcx>, mir: &'gcx mir::Rvalue<'gcx>) -> Val
cx.intern_value(make_int(mir.ty, result))
}
+ mir::RvalueKind::Repeat(count, value) => {
+ let value_const = const_mir(cx, value);
+ if value_const.is_error() {
+ return cx.intern_value(make_error(mir.ty));
+ }
+ let mut result = BigInt::zero();
+ for _ in 0..count {
+ result <<= value.ty.width();
+ result |= value_const.get_int().expect("repeat non-integer");
+ }
+ cx.intern_value(make_int(mir.ty, result))
+ }
+
mir::RvalueKind::Var(id) | mir::RvalueKind::Port(id) => {
match cx.constant_value_of(id, mir.env) {
Ok(k) => k,
