-
Notifications
You must be signed in to change notification settings - Fork 636
Add OverrideSerializationClass for custom annotation serialization #4953
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add OverrideSerializationClass for custom annotation serialization #4953
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
val tags = mutable.ListBuffer.empty[Class[_]] | ||
val seenTags = mutable.Set.empty[Class[_]] | ||
def addTag(clazz: Class[_]): Unit = { | ||
if (!seenTags(clazz)) { | ||
tags += clazz | ||
seenTags += clazz | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't realize that ListBuffer
has constant time prepend and append. This looked like a performance issue, but it isn't.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, and .toList
is constant time (copy-on-write to original ListBuffer object). It's how Scala makes List relatively fast all things considered.
res should include(""""class":"firrtl.annotations.UnserializeableAnnotation",""") | ||
res should include(""""error":"Classes defined in method bodies are not supported.",""") | ||
res should include(""""content":"MyAnno(3)"""") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FileCheck would be better. 😉 However, I don't think FileCheck is available in this compilation unit.
Co-authored-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
Contributor Checklist
docs/src
?Type of Improvement
Desired Merge Strategy
Release Notes
Annotations can now mixin
OverrideSerializationClass
to customize the "class" field in annotation serialization. This allows annotation classes to reside in a different package than firtool is expecting for theclass
field. Note that this breaks automatic deserialization which does not matter to firtool but would matter for annotations communicating information between Chisel generator invocations.Reviewer Checklist (only modified by reviewer)
3.6.x
,5.x
, or6.x
depending on impact, API modification or big change:7.0
)?Enable auto-merge (squash)
and clean up the commit message.Create a merge commit
.