aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/firrtl/passes/CheckInitialization.scala
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/scala/firrtl/passes/CheckInitialization.scala')
-rw-r--r--src/main/scala/firrtl/passes/CheckInitialization.scala38
1 files changed, 16 insertions, 22 deletions
diff --git a/src/main/scala/firrtl/passes/CheckInitialization.scala b/src/main/scala/firrtl/passes/CheckInitialization.scala
index 6d69b792..69629bf0 100644
--- a/src/main/scala/firrtl/passes/CheckInitialization.scala
+++ b/src/main/scala/firrtl/passes/CheckInitialization.scala
@@ -60,8 +60,7 @@ object CheckInitialization extends Pass {
}
def run(c: Circuit): Circuit = {
- val errors = collection.mutable.ArrayBuffer[PassException]()
-
+ val errors = new Errors()
def checkInitM(m: Module): Unit = {
val voidExprs = collection.mutable.HashMap[WrappedExpression, VoidExpr]()
@@ -69,19 +68,17 @@ object CheckInitialization extends Pass {
def hasVoidExpr(e: Expression): (Boolean, Seq[Expression]) = {
var void = false
val voidDeps = collection.mutable.ArrayBuffer[Expression]()
- def hasVoid(e: Expression): Expression = {
- e match {
- case e: WVoid =>
+ def hasVoid(e: Expression): Expression = e match {
+ case e: WVoid =>
+ void = true
+ e
+ case (_: WRef | _: WSubField) =>
+ if (voidExprs.contains(e)) {
void = true
- e
- case (_: WRef | _: WSubField) =>
- if (voidExprs.contains(e)) {
- void = true
- voidDeps += e
- }
- e
- case e => e map hasVoid
- }
+ voidDeps += e
+ }
+ e
+ case e => e map hasVoid
}
hasVoid(e)
(void, voidDeps)
@@ -110,19 +107,16 @@ object CheckInitialization extends Pass {
case node: DefNode => // Ignore nodes
case decl: IsDeclaration =>
val trace = getTrace(expr, voidExprs.toMap)
- errors += new RefNotInitializedException(decl.info, m.name, decl.name, trace)
+ errors append new RefNotInitializedException(decl.info, m.name, decl.name, trace)
}
}
}
- c.modules foreach { m =>
- m match {
- case m: Module => checkInitM(m)
- case m => // Do nothing
- }
+ c.modules foreach {
+ case m: Module => checkInitM(m)
+ case m => // Do nothing
}
-
- if (errors.nonEmpty) throw new PassExceptions(errors)
+ errors.trigger
c
}
}