From c7eb1570dfb1c7701ea32d1209982a053f3cec1d Mon Sep 17 00:00:00 2001 From: Jack Koenig Date: Tue, 27 Feb 2018 18:07:11 -0800 Subject: Refactor Annotations (#721) - Old Annotation renamed to deprecated LegacyAnnotation - Annotation is now a trait that can be extended - New JsonProtocol for Annotation [de]serialization - Replace AnnotationMap with AnnotationSeq - Deprecate Transform.getMyAnnotations - Update Transforms - Turn on deprecation warnings - Remove deprecated Driver.compile - Make AnnotationTests abstract with Legacy and Json subclasses - Add functionality to convert LegacyAnnotations of built-in annos This will give a noisy warning and is more of a best effort than a robust solution. Fixes #475 Closes #609--- .../scala/firrtl/annotations/AnnotationYamlProtocol.scala | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/main/scala/firrtl/annotations/AnnotationYamlProtocol.scala') diff --git a/src/main/scala/firrtl/annotations/AnnotationYamlProtocol.scala b/src/main/scala/firrtl/annotations/AnnotationYamlProtocol.scala index 9018d494..e0337d6e 100644 --- a/src/main/scala/firrtl/annotations/AnnotationYamlProtocol.scala +++ b/src/main/scala/firrtl/annotations/AnnotationYamlProtocol.scala @@ -7,23 +7,24 @@ import net.jcazevedo.moultingyaml._ object AnnotationYamlProtocol extends DefaultYamlProtocol { // bottom depends on top - implicit object AnnotationYamlFormat extends YamlFormat[Annotation] { - def write(a: Annotation) = YamlObject( + implicit object AnnotationYamlFormat extends YamlFormat[LegacyAnnotation] { + def write(a: LegacyAnnotation) = YamlObject( YamlString("targetString") -> YamlString(a.targetString), YamlString("transformClass") -> YamlString(a.transformClass), YamlString("value") -> YamlString(a.value) ) - def read(yamlValue: YamlValue): Annotation = { + def read(yamlValue: YamlValue): LegacyAnnotation = { try { yamlValue.asYamlObject.getFields( YamlString("targetString"), YamlString("transformClass"), YamlString("value")) match { case Seq(YamlString(targetString), YamlString(transformClass), YamlString(value)) => - Annotation( - toTarget(targetString), Class.forName(transformClass).asInstanceOf[Class[_ <: Transform]], value) - case _ => deserializationError("Annotation expected") + LegacyAnnotation(toTarget(targetString), + Class.forName(transformClass).asInstanceOf[Class[_ <: Transform]], + value) + case _ => deserializationError("LegacyAnnotation expected") } } catch { -- cgit v1.2.3