24 #ifndef LLVM_BINARYFORMAT_MSGPACKTYPES_H 25 #define LLVM_BINARYFORMAT_MSGPACKTYPES_H 48 virtual void anchor() = 0;
60 virtual ~Node() =
default;
85 void anchor()
override;
179 assert(SKind == SK_Boolean);
187 assert(SKind == SK_Float);
195 assert(SKind == SK_String);
203 assert(SKind == SK_Binary);
221 yaml::QuotingType mustQuoteYAML(
StringRef ScalarStr)
const;
236 bool IgnoreTag =
false;
247 void anchor()
override;
255 for (
auto &
N : *
this)
261 void anchor()
override;
269 for (
auto &
N : *
this) {
270 MPWriter.
write(
N.first());
271 N.second->write(MPWriter);
282 if (isa<msgpack::ScalarNode>(*N))
284 if (isa<msgpack::MapNode>(*N))
286 if (isa<msgpack::ArrayNode>(*N))
291 if (!N || !isa<msgpack::ScalarNode>(*N))
293 return *cast<msgpack::ScalarNode>(N.get());
296 if (!N || !isa<msgpack::MapNode>(*N))
298 return *cast<msgpack::MapNode>(N.get());
301 if (!N || !isa<msgpack::ArrayNode>(*N))
303 return *cast<msgpack::ArrayNode>(N.get());
326 Tag ==
"tag:yaml.org,2002:str")
339 return "Unsupported messagepack tag";
349 template <>
struct CustomMappingTraits<
msgpack::MapNode> {
351 IO.mapRequired(Key.
str().c_str(), M[
Key]);
355 IO.mapRequired(
N.getKey().str().c_str(),
N.getValue());
359 template <>
struct SequenceTraits<
msgpack::ArrayNode> {
363 if (Index >= A.size())
372 #endif // LLVM_BINARYFORMAT_MSGPACKTYPES_H static const char * FloatTag
static size_t size(IO &IO, msgpack::ArrayNode &A)
static bool classof(const Node *N)
LLVM_NODISCARD std::string str() const
str - Get the contents as an std::string.
static NodeKind getKind(const msgpack::NodePtr &N)
This class represents lattice values for constants.
StringRef getYAMLTag() const
Get the YAML tag for the current ScalarKind.
ScalarKind getScalarKind()
Get the current kind of ScalarNode.
yaml::QuotingType mustQuoteYAML(StringRef ScalarStr) const
Determine which YAML quoting type the current value would need when output.
StringRef getString()
Get the value of a String scalar.
double getFloat()
Get the value of an Float scalar.
static bool classof(const Node *N)
void writeMapSize(uint32_t Size)
Write the header for a Map of the given size.
Writes MessagePack objects to an output stream, one at a time.
uint64_t getUInt()
Get the value of a UInt scalar.
Tagged union holding either a T or a Error.
static const char * BinaryTag
void outputYAML(raw_ostream &OS) const
Output a YAML scalar of the current ScalarKind into OS.
static msgpack::ArrayNode & getAsSequence(msgpack::NodePtr &N)
static const char * IntTag
static Expected< OptNodePtr > read(Reader &MPReader)
Read from a MessagePack reader MPReader, returning an error if one is encountered, or None if MPReader is at the end of stream, or some Node pointer if some type is read.
static bool classof(const Node *N)
static void inputOne(IO &IO, StringRef Key, msgpack::MapNode &M)
int64_t getInt()
Get the value of an Int scalar.
static const char * BooleanTag
Reads MessagePack objects from memory, one at a time.
virtual void write(Writer &MPWriter)=0
Write to a MessagePack writer MPWriter.
std::shared_ptr< Node > NodePtr
Short-hand for a Node pointer.
bool IgnoreTag
Flag which affects how the type handles YAML tags when reading and writing.
void writeArraySize(uint32_t Size)
Write the header for an Array of the given size.
Node(NodeKind Kind)
Construct a Node. Used by derived classes to track kind information.
void write(Writer &MPWriter) override
Write to a MessagePack writer MPWriter.
Abstract base-class which can be any MessagePack type.
static void output(const msgpack::ScalarNode &S, void *Ctxt, raw_ostream &ScalarOS, raw_ostream &TagOS)
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
A scalar node is an opaque datum that can be presented as a series of zero or more Unicode scalar val...
static QuotingType mustQuote(const msgpack::ScalarNode &S, StringRef Str)
static const char * NilTag
static msgpack::MapNode & getAsMap(msgpack::NodePtr &N)
This is a MessagePack reader.
void write(bool b)
Write a Boolean to the output stream.
auto size(R &&Range, typename std::enable_if< std::is_same< typename std::iterator_traits< decltype(Range.begin())>::iterator_category, std::random_access_iterator_tag >::value, void >::type *=nullptr) -> decltype(std::distance(Range.begin(), Range.end()))
Get the size of a range.
StringMap - This is an unconventional map that is specialized for handling keys that are "strings"...
static msgpack::ScalarNode & getAsScalar(msgpack::NodePtr &N)
static void output(IO &IO, msgpack::MapNode &M)
Sequence
A sequence of states that a pointer may go through in which an objc_retain and objc_release are actua...
void setScalarKind(ScalarKind SKind)
Change the kind of this ScalarNode, zero initializing it to the new type.
static StringRef input(StringRef ScalarStr, StringRef Tag, void *Ctxt, msgpack::ScalarNode &S)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
StringRef getBinary()
Get the value of a Binary scalar.
static msgpack::NodePtr & element(IO &IO, msgpack::ArrayNode &A, size_t Index)
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.
bool getBool()
Get the value of an Boolean scalar.
This file contains a MessagePack writer.
static const char * StringTag
void write(Writer &MPWriter) override
Write to a MessagePack writer MPWriter.
StringRef inputYAML(StringRef ScalarStr)
Parse a YAML scalar of the current ScalarKind from ScalarStr.