mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2026-04-25 21:18:19 +00:00
Tighten up the yamilizer so it stops eliding empty sequences if the embedded empty sequence is the first key/value in a map which is itself in a sequence.
Patch with help from Nick Kledzik. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188508 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -334,6 +334,10 @@ void Input::setError(const Twine &Message) {
|
||||
this->setError(CurrentNode, Message);
|
||||
}
|
||||
|
||||
bool Input::canElideEmptySequence() {
|
||||
return false;
|
||||
}
|
||||
|
||||
Input::MapHNode::~MapHNode() {
|
||||
for (MapHNode::NameToNode::iterator i = Mapping.begin(), End = Mapping.end();
|
||||
i != End; ++i) {
|
||||
@@ -532,6 +536,19 @@ void Output::scalarString(StringRef &S) {
|
||||
void Output::setError(const Twine &message) {
|
||||
}
|
||||
|
||||
bool Output::canElideEmptySequence() {
|
||||
// Normally, with an optional key/value where the value is an empty sequence,
|
||||
// the whole key/value can be not written. But, that produces wrong yaml
|
||||
// if the key/value is the only thing in the map and the map is used in
|
||||
// a sequence. This detects if the this sequence is the first key/value
|
||||
// in map that itself is embedded in a sequnce.
|
||||
if (StateStack.size() < 2)
|
||||
return true;
|
||||
if (StateStack.back() != inMapFirstKey)
|
||||
return true;
|
||||
return (StateStack[StateStack.size()-2] != inSeq);
|
||||
}
|
||||
|
||||
void Output::output(StringRef s) {
|
||||
Column += s.size();
|
||||
Out << s;
|
||||
|
||||
Reference in New Issue
Block a user