aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/scala/firrtl/options/Phase.scala23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/main/scala/firrtl/options/Phase.scala b/src/main/scala/firrtl/options/Phase.scala
index ffe3788f..847a4cf2 100644
--- a/src/main/scala/firrtl/options/Phase.scala
+++ b/src/main/scala/firrtl/options/Phase.scala
@@ -79,6 +79,29 @@ trait TransformLike[A] extends LazyLogging {
}
+/** Mix-in that makes a [[firrtl.options.TransformLike TransformLike]] guaranteed to be an identity function on some
+ * type.
+ * @tparam A the transformed type
+ */
+trait IdentityLike[A] { this: TransformLike[A] =>
+
+ /** The internal operation of this transform which, in order for this to be an identity function, must return nothing.
+ * @param a an input object
+ * @return nothing
+ */
+ protected def internalTransform(a: A): Unit = Unit
+
+ /** This method will execute `internalTransform` and then return the original input object
+ * @param a an input object
+ * @return the input object
+ */
+ final override def transform(a: A): A = {
+ internalTransform(a)
+ a
+ }
+
+}
+
/** Mixin that defines dependencies between [[firrtl.options.TransformLike TransformLike]]s (hereafter referred to as
* "transforms")
*