diff options
| author | Donggyu | 2016-09-25 14:56:46 -0700 |
|---|---|---|
| committer | GitHub | 2016-09-25 14:56:46 -0700 |
| commit | 744ea401553cabfb31c7cc32aecfd8ca2764d1b8 (patch) | |
| tree | 628d4ce1d4bebc228fadd5a74365019f0dc5c62b /src/main/scala/firrtl/Visitor.scala | |
| parent | bd1a3ae2d1130fbfb51ad4ef88349364c931680d (diff) | |
| parent | 2e553ec9859c369938ed035c83040dd80877f893 (diff) | |
Merge pull request #316 from ucb-bar/style-cleanup-take-3
Style cleanup take 3
Diffstat (limited to 'src/main/scala/firrtl/Visitor.scala')
| -rw-r--r-- | src/main/scala/firrtl/Visitor.scala | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/src/main/scala/firrtl/Visitor.scala b/src/main/scala/firrtl/Visitor.scala index 05202555..00ef8f1b 100644 --- a/src/main/scala/firrtl/Visitor.scala +++ b/src/main/scala/firrtl/Visitor.scala @@ -61,15 +61,13 @@ class Visitor(infoMode: InfoMode) extends FIRRTLBaseVisitor[FirrtlNode] { case ZeroPattern(_*) => BigInt(0) case HexPattern(hexdigits) => hexdigits(0) match { - case NegPattern(_) => { + case NegPattern(_) => BigInt("-" + hexdigits, 16) - } case _ => BigInt(hexdigits, 16) } - case DecPattern(sign, num) => { + case DecPattern(sign, num) => if (sign != null) BigInt(sign + num, 10) else BigInt(num, 10) - } case _ => throw new Exception("Invalid String for conversion to BigInt " + s) } } @@ -297,7 +295,7 @@ class Visitor(infoMode: InfoMode) extends FIRRTLBaseVisitor[FirrtlNode] { Reference(ctx.getText, UnknownType) else ctx.getChild(0).getText match { - case "UInt" => { + case "UInt" => // This could be better val (width, value) = if (ctx.getChildCount > 4) @@ -307,8 +305,7 @@ class Visitor(infoMode: InfoMode) extends FIRRTLBaseVisitor[FirrtlNode] { (IntWidth(BigInt(scala.math.max(bigint.bitLength, 1))), bigint) } UIntLiteral(value, width) - } - case "SInt" => { + case "SInt" => val (width, value) = if (ctx.getChildCount > 4) (IntWidth(string2BigInt(ctx.IntLit(0).getText)), string2BigInt(ctx.IntLit(1).getText)) @@ -317,7 +314,6 @@ class Visitor(infoMode: InfoMode) extends FIRRTLBaseVisitor[FirrtlNode] { (IntWidth(BigInt(bigint.bitLength + 1)), bigint) } SIntLiteral(value, width) - } case "validif(" => ValidIf(visitExp(ctx.exp(0)), visitExp(ctx.exp(1)), UnknownType) case "mux(" => Mux(visitExp(ctx.exp(0)), visitExp(ctx.exp(1)), visitExp(ctx.exp(2)), UnknownType) case _ => |
