24 struct ScalarDocNode :
DocNode {
46 OS << (Bool ?
"true" :
"false");
52 if (getDocument()->getHexMode())
53 OS <<
format(
"%#llx", (
unsigned long long)
UInt);
71 if (Tag ==
"tag:yaml.org,2002:str")
73 if (Tag ==
"!int" || Tag ==
"") {
75 *
this = getDocument()->getNode(uint64_t(0));
76 StringRef Err = yaml::ScalarTraits<uint64_t>::input(S,
nullptr, getUInt());
78 *
this = getDocument()->getNode(int64_t(0));
79 Err = yaml::ScalarTraits<int64_t>::input(S,
nullptr,
getInt());
81 if (Err ==
"" || Tag !=
"")
85 *
this = getDocument()->getNode();
88 if (Tag ==
"!bool" || Tag ==
"") {
89 *
this = getDocument()->getNode(
false);
90 StringRef Err = yaml::ScalarTraits<bool>::input(S,
nullptr, getBool());
91 if (Err ==
"" || Tag !=
"")
94 if (Tag ==
"!float" || Tag ==
"") {
95 *
this = getDocument()->getNode(0.0);
96 StringRef Err = yaml::ScalarTraits<double>::input(S,
nullptr, getFloat());
97 if (Err ==
"" || Tag !=
"")
100 assert((Tag ==
"!str" || Tag ==
"") &&
"unsupported tag");
102 StringRef Err = yaml::ScalarTraits<std::string>::input(S,
nullptr, V);
104 *
this = getDocument()->getNode(V,
true);
111 StringRef ScalarDocNode::getYAMLTag()
const {
116 ScalarDocNode
N = getDocument()->getNode();
118 if (N.getKind() == getKind())
147 template <>
struct PolymorphicTraits<
DocNode> {
168 return *
static_cast<ScalarDocNode *
>(&
N);
173 template <>
struct TaggedScalarTraits<ScalarDocNode> {
177 TagOS << S.getYAMLTag();
183 return S.fromString(Str, Tag);
187 switch (S.getKind()) {
189 return ScalarTraits<int64_t>::mustQuote(ScalarStr);
191 return ScalarTraits<uint64_t>::mustQuote(ScalarStr);
193 return ScalarTraits<StringRef>::mustQuote(ScalarStr);
195 return ScalarTraits<bool>::mustQuote(ScalarStr);
197 return ScalarTraits<double>::mustQuote(ScalarStr);
200 return ScalarTraits<std::string>::mustQuote(ScalarStr);
212 KeyObj.fromString(Key,
"");
213 IO.mapRequired(Key.
str().c_str(), M.
getMap()[KeyObj]);
218 IO.mapRequired(
I.first.toString().c_str(),
I.second);
238 yaml::Output Yout(OS);
static QuotingType mustQuote(const ScalarDocNode &S, StringRef ScalarStr)
LLVM_NODISCARD std::string str() const
str - Get the contents as an std::string.
static size_t size(IO &IO, ArrayDocNode &A)
This class represents lattice values for constants.
static ArrayDocNode & getAsSequence(DocNode &N)
static MapDocNode & getAsMap(DocNode &N)
static NodeKind getKind(const DocNode &N)
Document * getDocument() const
void toYAML(raw_ostream &OS)
Convert MsgPack Document to YAML text.
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
A DocNode that is an array.
std::string toString(Error E)
Write all error messages (if any) in E to a string.
MapDocNode & getMap(bool Convert=false)
Get a MapDocNode for a map node.
static unsigned getInt(StringRef R)
Get an unsigned integer, including error checks.
bool fromYAML(StringRef S)
Read YAML text into the MsgPack document. Returns false on failure.
DocNode getNode()
Create a nil node associated with this Document.
std::string toString() const
Convert this node to a string, assuming it is scalar.
static void inputOne(IO &IO, StringRef Key, MapDocNode &M)
static ScalarDocNode & getAsScalar(DocNode &N)
ArrayDocNode & getArray(bool Convert=false)
Get an ArrayDocNode for an array node.
static void output(const ScalarDocNode &S, void *Ctxt, raw_ostream &OS, raw_ostream &TagOS)
std::string & str()
Flushes the stream contents to the target string and returns the string's reference.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
static void clear(coro::Shape &Shape)
Sequence
A sequence of states that a pointer may go through in which an objc_retain and objc_release are actua...
StringRef fromString(StringRef S, StringRef Tag="")
Convert the StringRef and use it to set this DocNode (assuming scalar).
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static void output(IO &IO, MapDocNode &M)
A raw_ostream that writes to an std::string.
This class implements an extremely fast bulk output stream that can only output to a stream...
StringRef - Represent a constant reference to a string, i.e.
A node in a MsgPack Document.
static DocNode & element(IO &IO, ArrayDocNode &A, size_t Index)
static StringRef input(StringRef Str, StringRef Tag, void *Ctxt, ScalarDocNode &S)