aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/firrtl/annotations/Annotation.scala
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/scala/firrtl/annotations/Annotation.scala')
-rw-r--r--src/main/scala/firrtl/annotations/Annotation.scala15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/main/scala/firrtl/annotations/Annotation.scala b/src/main/scala/firrtl/annotations/Annotation.scala
index 5881001f..2e361833 100644
--- a/src/main/scala/firrtl/annotations/Annotation.scala
+++ b/src/main/scala/firrtl/annotations/Annotation.scala
@@ -3,19 +3,26 @@
package firrtl
package annotations
-import firrtl.ir._
-
case class AnnotationException(message: String) extends Exception(message)
final case class Annotation(target: Named, transform: Class[_ <: Transform], value: String) {
val targetString: String = target.serialize
val transformClass: String = transform.getName
- def serialize: String = this.toString
+
+ /**
+ * This serialize is basically a pretty printer, actual serialization is handled by
+ * AnnotationYamlProtocol
+ * @return a nicer string than the raw case class default
+ */
+ def serialize: String = {
+ s"Annotation(${target.serialize},${transform.getCanonicalName},$value)"
+ }
+
def update(tos: Seq[Named]): Seq[Annotation] = {
check(target, tos, this)
propagate(target, tos, duplicate)
}
def propagate(from: Named, tos: Seq[Named], dup: Named=>Annotation): Seq[Annotation] = tos.map(dup(_))
def check(from: Named, tos: Seq[Named], which: Annotation): Unit = {}
- def duplicate(n: Named) = new Annotation(n, transform, value)
+ def duplicate(n: Named) = Annotation(n, transform, value)
}