diff options
Diffstat (limited to 'src/main/scala/firrtl/Utils.scala')
| -rw-r--r-- | src/main/scala/firrtl/Utils.scala | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/main/scala/firrtl/Utils.scala b/src/main/scala/firrtl/Utils.scala index 383d4df7..be70ac77 100644 --- a/src/main/scala/firrtl/Utils.scala +++ b/src/main/scala/firrtl/Utils.scala @@ -62,6 +62,20 @@ object Utils extends LazyLogging { result } + /** Removes all [[firrtl.ir.Empty]] statements and condenses + * [[firrtl.ir.Block]] statements. + */ + def squashEmpty(s: Statement): Statement = s map squashEmpty match { + case Block(stmts) => + val newStmts = stmts filter (_ != EmptyStmt) + newStmts.size match { + case 0 => EmptyStmt + case 1 => newStmts.head + case _ => Block(newStmts) + } + case s => s + } + /** Indent the results of [[ir.FirrtlNode.serialize]] */ def indent(str: String) = str replaceAllLiterally ("\n", "\n ") def serialize(bi: BigInt): String = |
