A couple of big refactorings: 1) Move most attributes of Atom down to DefinedAtom, so only atoms representing definitions need to implement them. 2) Remove definitionTentative, definitionWeak, mergeDuplicates, and autoHide. Replace with merge and interposable attributes. 3) Make all methods on Atom be virtual so that future object file readers can lazily generated attributes
llvm-svn: 147903
diff --git a/lld/lib/Core/YamlWriter.cpp b/lld/lib/Core/YamlWriter.cpp
index 5b01582..3e30c0a 100644
--- a/lld/lib/Core/YamlWriter.cpp
+++ b/lld/lib/Core/YamlWriter.cpp
@@ -32,7 +32,7 @@
virtual void doFile(const class File &) { _firstAtom = true; }
- virtual void doAtom(const class Atom &atom) {
+ virtual void doDefinedAtom(const class DefinedAtom &atom) {
// add blank line between atoms for readability
if ( !_firstAtom )
_out << "\n";
@@ -72,6 +72,24 @@
<< "\n";
}
+ if ( atom.interposable() != KeyValues::interposableDefault ) {
+ _out << " "
+ << KeyValues::interposableKeyword
+ << ":"
+ << spacePadding(KeyValues::interposableKeyword)
+ << KeyValues::interposable(atom.interposable())
+ << "\n";
+ }
+
+ if ( atom.merge() != KeyValues::mergeDefault ) {
+ _out << " "
+ << KeyValues::mergeKeyword
+ << ":"
+ << spacePadding(KeyValues::mergeKeyword)
+ << KeyValues::merge(atom.merge())
+ << "\n";
+ }
+
if ( atom.contentType() != KeyValues::contentTypeDefault ) {
_out << " "
<< KeyValues::contentTypeKeyword
@@ -106,25 +124,7 @@
<< "\n";
}
- if ( atom.mergeDuplicates() != KeyValues::mergeDuplicatesDefault ) {
- _out << " "
- << KeyValues::mergeDuplicatesKeyword
- << ":"
- << spacePadding(KeyValues::mergeDuplicatesKeyword)
- << KeyValues::mergeDuplicates(atom.mergeDuplicates())
- << "\n";
- }
-
- if ( atom.autoHide() != KeyValues::autoHideDefault ) {
- _out << " "
- << KeyValues::autoHideKeyword
- << ":"
- << spacePadding(KeyValues::autoHideKeyword)
- << KeyValues::autoHide(atom.autoHide())
- << "\n";
- }
-
- if ( atom.isThumb() != KeyValues::isThumbDefault ) {
+ if ( atom.isThumb() != KeyValues::isThumbDefault ) {
_out << " "
<< KeyValues::isThumbKeyword
<< ":"
@@ -142,8 +142,7 @@
<< "\n";
}
-
- if ( atom.contentType() != Atom::typeZeroFill ) {
+ if ( atom.contentType() != DefinedAtom::typeZeroFill ) {
_out << " "
<< KeyValues::contentKeyword
<< ":"
@@ -172,6 +171,11 @@
}
+ virtual void doUndefinedAtom(const class UndefinedAtom &atom) {
+
+ }
+
+
private:
// return a string of the correct number of spaces to align value
const char* spacePadding(const char* key) {