blob: 0ef716047c8704cac0917f2146cc052abcc02923 [file] [log] [blame]
Chris Bieneman9062ab92016-05-12 16:04:16 +00001//===- 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
17namespace llvm {
18
19namespace yaml {
20
21void MappingTraits<MachOYAML::FileHeader>::mapping(
22 IO &IO, MachOYAML::FileHeader &FileHdr) {
Chris Bieneman24f07472016-05-12 17:44:43 +000023 IO.mapRequired("magic", FileHdr.magic);
Chris Bieneman9062ab92016-05-12 16:04:16 +000024 IO.mapRequired("cputype", FileHdr.cputype);
25 IO.mapRequired("cpusubtype", FileHdr.cpusubtype);
26 IO.mapOptional("filetype", FileHdr.filetype);
27 IO.mapRequired("ncmds", FileHdr.ncmds);
Chris Bieneman24f07472016-05-12 17:44:43 +000028 IO.mapRequired("sizeofcmds", FileHdr.sizeofcmds);
Chris Bieneman9062ab92016-05-12 16:04:16 +000029 IO.mapRequired("flags", FileHdr.flags);
30}
31
32void MappingTraits<MachOYAML::Object>::mapping(IO &IO,
33 MachOYAML::Object &Object) {
34 // If the context isn't already set, tag the document as !mach-o.
35 // For Fat files there will be a different tag so they can be differentiated.
Chris Bieneman24f07472016-05-12 17:44:43 +000036 if (!IO.getContext()) {
Chris Bieneman9062ab92016-05-12 16:04:16 +000037 IO.setContext(&Object);
38 IO.mapTag("!mach-o", true);
39 }
40 IO.mapRequired("FileHeader", Object.Header);
41 IO.setContext(nullptr);
42}
43
44} // namespace llvm::yaml
45
46} // namespace llvm