diff options
| author | Jack | 2015-10-12 16:56:08 -0700 |
|---|---|---|
| committer | Jack | 2015-10-12 16:56:08 -0700 |
| commit | 09ef2e42b00174e99124477b443a472e8664708f (patch) | |
| tree | bd7d6fb6ca05823f09b85d253c4fe186d8903f51 | |
| parent | 0c288c48382f1b31fbfb1c202867fb444e46136c (diff) | |
Renamed Subindex to Index and added type information to Index and DoPrimOp
| -rw-r--r-- | src/main/scala/firrtl/IR.scala | 4 | ||||
| -rw-r--r-- | src/main/scala/firrtl/Utils.scala | 6 | ||||
| -rw-r--r-- | src/main/scala/firrtl/Visitor.scala | 5 |
3 files changed, 8 insertions, 7 deletions
diff --git a/src/main/scala/firrtl/IR.scala b/src/main/scala/firrtl/IR.scala index 876e8641..7905612e 100644 --- a/src/main/scala/firrtl/IR.scala +++ b/src/main/scala/firrtl/IR.scala @@ -54,8 +54,8 @@ case class UIntValue(value: BigInt, width: Width) extends Exp case class SIntValue(value: BigInt, width: Width) extends Exp case class Ref(name: String, tpe: Type) extends Exp case class Subfield(exp: Exp, name: String, tpe: Type) extends Exp -case class Subindex(exp: Exp, value: BigInt) extends Exp -case class DoPrimOp(op: PrimOp, args: Seq[Exp], consts: Seq[BigInt]) extends Exp +case class Index(exp: Exp, value: BigInt, tpe: Type) extends Exp +case class DoPrimOp(op: PrimOp, args: Seq[Exp], consts: Seq[BigInt], tpe: Type) extends Exp trait AccessorDir extends AST case object Infer extends AccessorDir diff --git a/src/main/scala/firrtl/Utils.scala b/src/main/scala/firrtl/Utils.scala index 8a7a5b0d..110da9a5 100644 --- a/src/main/scala/firrtl/Utils.scala +++ b/src/main/scala/firrtl/Utils.scala @@ -66,7 +66,7 @@ object Utils { case v: SIntValue => s"SInt${v.width.serialize}(${v.value.serialize})" case r: Ref => r.name case s: Subfield => s"${s.exp.serialize}.${s.name}" - case s: Subindex => s"${s.exp.serialize}[${s.value}]" + case s: Index => s"${s.exp.serialize}[${s.value}]" case p: DoPrimOp => s"${p.op.serialize}(" + (p.args.map(_.serialize) ++ p.consts.map(_.toString)).mkString(", ") + ")" } @@ -74,8 +74,8 @@ object Utils { def map(f: Exp => Exp): Exp = exp match { case s: Subfield => Subfield(f(s.exp), s.name, s.tpe) - case s: Subindex => Subindex(f(s.exp), s.value) - case p: DoPrimOp => DoPrimOp(p.op, p.args.map(f), p.consts) + case i: Index => Index(f(i.exp), i.value, i.tpe) + case p: DoPrimOp => DoPrimOp(p.op, p.args.map(f), p.consts, p.tpe) case e: Exp => e } } diff --git a/src/main/scala/firrtl/Visitor.scala b/src/main/scala/firrtl/Visitor.scala index 879ce80d..8bbed2e3 100644 --- a/src/main/scala/firrtl/Visitor.scala +++ b/src/main/scala/firrtl/Visitor.scala @@ -147,9 +147,10 @@ class Visitor(val fullFilename: String) extends FIRRTLBaseVisitor[AST] case _ => ctx.getChild(1).getText match { case "." => new Subfield(visitExp(ctx.exp(0)), ctx.id.getText, UnknownType) - case "[" => new Subindex(visitExp(ctx.exp(0)), string2BigInt(ctx.IntLit(0).getText)) + case "[" => new Index(visitExp(ctx.exp(0)), string2BigInt(ctx.IntLit(0).getText), UnknownType) case "(" => - DoPrimOp(visitPrimop(ctx.primop), ctx.exp.map(visitExp), ctx.IntLit.map(x => string2BigInt(x.getText))) + DoPrimOp(visitPrimop(ctx.primop), ctx.exp.map(visitExp), + ctx.IntLit.map(x => string2BigInt(x.getText)), UnknownType) } } |
