Chris Bieneman | 9062ab9 | 2016-05-12 16:04:16 +0000 | [diff] [blame^] | 1 | //===- MachOYAML.cpp - MachO YAMLIO implementation ------------------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file defines classes for handling the YAML representation of MachO. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #include "llvm/ObjectYAML/MachOYAML.h" |
| 15 | #include "llvm/Support/Casting.h" |
| 16 | |
| 17 | namespace llvm { |
| 18 | |
| 19 | namespace yaml { |
| 20 | |
| 21 | void MappingTraits<MachOYAML::FileHeader>::mapping( |
| 22 | IO &IO, MachOYAML::FileHeader &FileHdr) { |
| 23 | IO.mapRequired("cputype", FileHdr.cputype); |
| 24 | IO.mapRequired("cpusubtype", FileHdr.cpusubtype); |
| 25 | IO.mapOptional("filetype", FileHdr.filetype); |
| 26 | IO.mapRequired("ncmds", FileHdr.ncmds); |
| 27 | IO.mapRequired("flags", FileHdr.flags); |
| 28 | } |
| 29 | |
| 30 | void MappingTraits<MachOYAML::Object>::mapping(IO &IO, |
| 31 | MachOYAML::Object &Object) { |
| 32 | // If the context isn't already set, tag the document as !mach-o. |
| 33 | // For Fat files there will be a different tag so they can be differentiated. |
| 34 | if(!IO.getContext()) { |
| 35 | IO.setContext(&Object); |
| 36 | IO.mapTag("!mach-o", true); |
| 37 | } |
| 38 | IO.mapRequired("FileHeader", Object.Header); |
| 39 | IO.setContext(nullptr); |
| 40 | } |
| 41 | |
| 42 | } // namespace llvm::yaml |
| 43 | |
| 44 | } // namespace llvm |