44 auto ItAndInserted =
Map->insert(Entry);
45 if (ItAndInserted.second) {
49 return ItAndInserted.first->second;
54 if (
size() <= Index) {
81 Root = getArrayNode();
88 if (!MPReader.
read(Obj)) {
89 if (Multi && Stack.
size() == 1) {
102 Node = getNode(Obj.
Int);
105 Node = getNode(Obj.
UInt);
108 Node = getNode(Obj.
Bool);
111 Node = getNode(Obj.
Float);
114 Node = getNode(Obj.
Raw);
120 Node = getArrayNode();
131 auto &
Array = Stack.
back().Node.getArray();
132 Array.push_back(Node);
134 auto &
Map = Stack.
back().Node.getMap();
135 if (!Stack.
back().MapEntry) {
137 Stack.
back().MapEntry = &
Map[Node];
140 *Stack.
back().MapEntry = Node;
141 Stack.
back().MapEntry =
nullptr;
156 while (!Stack.
empty()) {
158 if (Stack.
back().Node.getArray().size() != Stack.
back().Length)
161 if (Stack.
back().MapEntry ||
162 Stack.
back().Node.getMap().size() != Stack.
back().Length)
167 }
while (!Stack.
empty());
190 {Node, DocNode::MapTy::iterator(), Node.
getArray().
begin(),
false});
195 {Node, Node.
getMap().
begin(), DocNode::ArrayTy::iterator(),
true});
216 while (!Stack.
empty()) {
218 if (Stack.
back().MapIt != Stack.
back().Node.getMap().end())
221 if (Stack.
back().ArrayIt != Stack.
back().Node.getArray().end())
230 if (Stack.
back().OnKey) {
232 Node = Stack.
back().MapIt->first;
233 Stack.
back().OnKey =
false;
235 Node = Stack.
back().MapIt->second;
236 ++Stack.
back().MapIt;
237 Stack.
back().OnKey =
true;
240 Node = *Stack.
back().ArrayIt;
241 ++Stack.
back().ArrayIt;
Expected< bool > read(Object &Obj)
Read one object from the input buffer, advancing past it.
DocNode & operator[](size_t Index)
Element access. This extends the array if necessary.
This class represents lattice values for constants.
Document * getDocument() const
void push_back(const T &Elt)
DocNode & operator[](StringRef S)
Member access.
MapDocNode & getMap(bool Convert=false)
Get a MapDocNode for a map node.
void writeMapSize(uint32_t Size)
Write the header for a Map of the given size.
DocNode::MapTy::iterator MapIt
Writes MessagePack objects to an output stream, one at a time.
ArrayTy::iterator begin()
DocNode getNode()
Create a nil node associated with this Document.
StringRef getString() const
MessagePack object, represented as a tagged union of C++ types.
ArrayDocNode getArrayNode()
Create an empty Array node associated with this Document.
MapTy::iterator find(DocNode Key)
void writeNil()
Write a Nil to the output stream.
Reads MessagePack objects from memory, one at a time.
ArrayDocNode & getArray(bool Convert=false)
Get an ArrayDocNode for an array node.
void writeArraySize(uint32_t Size)
Write the header for an Array of the given size.
auto find(R &&Range, const T &Val) -> decltype(adl_begin(Range))
Provide wrappers to std::find which take ranges instead of having to pass begin/end explicitly...
MapDocNode getMapNode()
Create an empty Map node associated with this Document.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
double Float
Value for Type::Float.
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.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
void writeToBlob(std::string &Blob)
Write a MsgPack document to a binary MsgPack blob.
StringRef Raw
Value for Type::String and Type::Binary.
DocNode::ArrayTy::iterator ArrayIt
LLVM_NODISCARD bool empty() const
int64_t Int
Value for Type::Int.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
A raw_ostream that writes to an std::string.
bool Bool
Value for Type::Boolean.
StringRef - Represent a constant reference to a string, i.e.
uint64_t UInt
Value for Type::Uint.
size_t Length
Value for Type::Array and Type::Map.
bool readFromBlob(StringRef Blob, bool Multi)
Read a MsgPack document from a binary MsgPack blob.
A node in a MsgPack Document.
This file contains a MessagePack writer.