23 unsigned CurDocNum = 0;
25 if (++CurDocNum != DocNum)
30 if (std::error_code EC = YIn.error()) {
31 ErrHandler(
"failed to parse YAML input: " + EC.message());
36 return yaml2elf(*Doc.Elf, Out, ErrHandler);
38 return yaml2coff(*Doc.Coff, Out, ErrHandler);
39 if (Doc.MachO || Doc.FatMachO)
44 return yaml2wasm(*Doc.Wasm, Out, ErrHandler);
46 ErrHandler(
"unknown document type");
49 }
while (YIn.nextDocument());
51 ErrHandler(
"cannot find the " +
Twine(DocNum) +
56 std::unique_ptr<object::ObjectFile>
62 yaml::Input YIn(Yaml);
70 return std::move(*ObjOrErr);
static Expected< OwningBinary< ObjectFile > > createObjectFile(StringRef ObjectPath)
bool yaml2macho(YamlObjectFile &Doc, raw_ostream &Out, ErrorHandler EH)
This class represents lattice values for constants.
bool yaml2coff(COFFYAML::Object &Doc, raw_ostream &Out, ErrorHandler EH)
An efficient, type-erasing, non-owning reference to a callable.
A raw_ostream that writes to an SmallVector or SmallString.
Error takeError()
Take ownership of the stored error.
std::string toString(Error E)
Write all error messages (if any) in E to a string.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Tagged union holding either a T or a Error.
Common declarations for yaml2obj.
StringRef str()
Return a StringRef for the vector contents.
bool yaml2minidump(MinidumpYAML::Object &Doc, raw_ostream &Out, ErrorHandler EH)
bool yaml2elf(ELFYAML::Object &Doc, raw_ostream &Out, ErrorHandler EH)
bool convertYAML(Input &YIn, raw_ostream &Out, ErrorHandler ErrHandler, unsigned DocNum=1)
StringRef getOrdinalSuffix(unsigned Val)
Returns the English suffix for an ordinal integer (-st, -nd, -rd, -th).
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 yaml2wasm(WasmYAML::Object &Doc, raw_ostream &Out, ErrorHandler EH)
std::unique_ptr< object::ObjectFile > yaml2ObjectFile(SmallVectorImpl< char > &Storage, StringRef Yaml, ErrorHandler ErrHandler)
Convenience function for tests.