LLVM: lib/BinaryFormat/MsgPackDocumentYAML.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

15

16using namespace llvm;

18

19namespace {

20

21

22

23struct ScalarDocNode : DocNode {

24 ScalarDocNode(DocNode N) : DocNode(N) {}

25

26

27

28

29 StringRef getYAMLTag() const;

30};

31

32}

33

34

36 std::string S;

40 OS << Raw;

41 break;

43 break;

45 OS << (Bool ? "true" : "false");

46 break;

48 OS << Int;

49 break;

52 OS << format("%#llx", (unsigned long long)UInt);

53 else

55 break;

58 break;

59 default:

61 break;

62 }

63 return OS.str();

64}

65

66

67

68

70 if (Tag == "tag:yaml.org,2002:str")

72 if (Tag == "!int" || Tag == "") {

73

76 if (Err != "") {

79 }

80 if (Err == "" || Tag != "")

81 return Err;

82 }

83 if (Tag == "!nil") {

85 return "";

86 }

87 if (Tag == "!bool" || Tag == "") {

90 if (Err == "" || Tag != "")

91 return Err;

92 }

93 if (Tag == "!float" || Tag == "") {

96 if (Err == "" || Tag != "")

97 return Err;

98 }

99 assert((Tag == "!str" || Tag == "") && "unsupported tag");

100 std::string V;

102 if (Err == "")

104 return Err;

105}

106

107

108

109

110StringRef ScalarDocNode::getYAMLTag() const {

112 return "!nil";

113

114

115 ScalarDocNode N = getDocument()->getNode();

117 if (N.getKind() == getKind())

118 return "";

119

120

122 return "";

124 return "";

125

126 switch (getKind()) {

128 return "!str";

130 return "!int";

132 return "!int";

134 return "!bool";

136 return "!float";

137 default:

139 }

140}

141

142namespace llvm {

143namespace yaml {

144

145

147

149 switch (N.getKind()) {

154 default:

156 }

157 }

158

160

162 N.getArray(true);

164 }

165

167 return *static_cast<ScalarDocNode *>(&N);

168 }

169};

170

171

173

176 TagOS << S.getYAMLTag();

177 OS << S.toString();

178 }

179

181 ScalarDocNode &S) {

182 return S.fromString(Str, Tag);

183 }

184

186 switch (S.getKind()) {

200 default:

202 }

203 }

204};

205

206

208

210 ScalarDocNode KeyObj = M.getDocument()->getNode();

211 KeyObj.fromString(Key, "");

213 }

214

216 for (auto I : M.getMap()) {

218 }

219 }

220};

221

222

224

226

228 return A[Index];

229 }

230};

231

232}

233}

234

235

240

241

246 return !Yin.error();

247}

248

assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")

static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")

static DeltaTreeNode * getRoot(void *Root)

This file declares a class that exposes a simple in-memory representation of a document of MsgPack ob...

StringRef - Represent a constant reference to a string, i.e.

A DocNode that is an array.

A node in a MsgPack Document.

LLVM_ABI StringRef fromString(StringRef S, StringRef Tag="")

Convert the StringRef and use it to set this DocNode (assuming scalar).

Definition MsgPackDocumentYAML.cpp:69

LLVM_ABI std::string toString() const

Convert this node to a string, assuming it is scalar.

Definition MsgPackDocumentYAML.cpp:35

Document * getDocument() const

void clear()

Restore the Document to an empty state.

DocNode getNode()

Create a nil node associated with this Document.

LLVM_ABI void toYAML(raw_ostream &OS)

Convert MsgPack Document to YAML text.

Definition MsgPackDocumentYAML.cpp:236

LLVM_ABI bool fromYAML(StringRef S)

Read YAML text into the MsgPack document. Returns false on failure.

Definition MsgPackDocumentYAML.cpp:242

This class implements an extremely fast bulk output stream that can only output to a stream.

A raw_ostream that writes to an std::string.

std::string & str()

Returns the string's reference.

void mapRequired(StringRef Key, T &Val)

The Input class is used to parse a yaml document into in-memory structs and vectors.

std::error_code error() override

The Output class is used to generate a yaml document from in-memory structs and vectors.

#define llvm_unreachable(msg)

Marks that the current location is not supposed to be reachable.

QuotingType

Describe which type of quotes should be used when quoting is necessary.

This is an optimization pass for GlobalISel generic memory operations.

format_object< Ts... > format(const char *Fmt, const Ts &... Vals)

These are helper functions used to produce formatted output.

LLVM_ATTRIBUTE_VISIBILITY_DEFAULT AnalysisKey InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Key

std::string toString(const APInt &I, unsigned Radix, bool Signed, bool formatAsCLiteral=false, bool UpperCase=true, bool InsertSeparators=false)

static void inputOne(IO &IO, StringRef Key, MapDocNode &M)

Definition MsgPackDocumentYAML.cpp:209

static void output(IO &IO, MapDocNode &M)

Definition MsgPackDocumentYAML.cpp:215

This class should be specialized by any type that needs to be converted to/from a YAML mapping in the...

static NodeKind getKind(const DocNode &N)

Definition MsgPackDocumentYAML.cpp:148

static ArrayDocNode & getAsSequence(DocNode &N)

Definition MsgPackDocumentYAML.cpp:161

static MapDocNode & getAsMap(DocNode &N)

Definition MsgPackDocumentYAML.cpp:159

static ScalarDocNode & getAsScalar(DocNode &N)

Definition MsgPackDocumentYAML.cpp:166

This class should be specialized by any type that can be represented as a scalar, map,...

This class should be specialized by type that requires custom conversion to/from a yaml scalar.

static size_t size(IO &IO, ArrayDocNode &A)

Definition MsgPackDocumentYAML.cpp:225

static DocNode & element(IO &IO, ArrayDocNode &A, size_t Index)

Definition MsgPackDocumentYAML.cpp:227

This class should be specialized by any type that needs to be converted to/from a YAML sequence.

static StringRef input(StringRef Str, StringRef Tag, void *Ctxt, ScalarDocNode &S)

Definition MsgPackDocumentYAML.cpp:180

static void output(const ScalarDocNode &S, void *Ctxt, raw_ostream &OS, raw_ostream &TagOS)

Definition MsgPackDocumentYAML.cpp:174

static QuotingType mustQuote(const ScalarDocNode &S, StringRef ScalarStr)

Definition MsgPackDocumentYAML.cpp:185

This class should be specialized by type that requires custom conversion to/from a YAML scalar with o...