blob: 91d9583c98e0547d5a6fb4dd295900740558d154 [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) {
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
30void 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