//===- ObjectYAML.cpp - YAML utilities for object files -------------------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // This file defines a wrapper class for handling tagged YAML input // //===----------------------------------------------------------------------===// #include "llvm/ObjectYAML/YAML.h" #include "llvm/ObjectYAML/ObjectYAML.h" using namespace llvm; using namespace yaml; void MappingTraits::mapping(IO &IO, YamlObjectFile &ObjectFile) { if (IO.outputting()) { if (ObjectFile.Elf) MappingTraits::mapping(IO, *ObjectFile.Elf); if (ObjectFile.Coff) MappingTraits::mapping(IO, *ObjectFile.Coff); if (ObjectFile.MachO) MappingTraits::mapping(IO, *ObjectFile.MachO); if (ObjectFile.FatMachO) MappingTraits::mapping(IO, *ObjectFile.FatMachO); } else { if (IO.mapTag("!ELF")) { ObjectFile.Elf.reset(new ELFYAML::Object()); MappingTraits::mapping(IO, *ObjectFile.Elf); } else if (IO.mapTag("!COFF")) { ObjectFile.Coff.reset(new COFFYAML::Object()); MappingTraits::mapping(IO, *ObjectFile.Coff); } else if (IO.mapTag("!mach-o")) { ObjectFile.MachO.reset(new MachOYAML::Object()); MappingTraits::mapping(IO, *ObjectFile.MachO); } else if (IO.mapTag("!fat-mach-o")) { ObjectFile.FatMachO.reset(new MachOYAML::UniversalBinary()); MappingTraits::mapping(IO, *ObjectFile.FatMachO); } else { Input &In = (Input &)IO; std::string Tag = In.getCurrentNode()->getRawTag(); if (Tag.empty()) IO.setError("YAML Object File missing document type tag!"); else IO.setError( llvm::Twine("YAML Object File unsupported document type tag '") + llvm::Twine(Tag.c_str()) + llvm::Twine("'!")); } } }