LLVM  6.0.0svn
ObjectYAML.cpp
Go to the documentation of this file.
1 //===- ObjectYAML.cpp - YAML utilities for object files -------------------===//
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 a wrapper class for handling tagged YAML input
11 //
12 //===----------------------------------------------------------------------===//
13 
15 #include "llvm/ADT/Twine.h"
18 #include <string>
19 
20 using namespace llvm;
21 using namespace yaml;
22 
24  YamlObjectFile &ObjectFile) {
25  if (IO.outputting()) {
26  if (ObjectFile.Elf)
28  if (ObjectFile.Coff)
30  if (ObjectFile.MachO)
32  if (ObjectFile.FatMachO)
34  *ObjectFile.FatMachO);
35  } else {
36  if (IO.mapTag("!ELF")) {
37  ObjectFile.Elf.reset(new ELFYAML::Object());
39  } else if (IO.mapTag("!COFF")) {
40  ObjectFile.Coff.reset(new COFFYAML::Object());
42  } else if (IO.mapTag("!mach-o")) {
43  ObjectFile.MachO.reset(new MachOYAML::Object());
45  } else if (IO.mapTag("!fat-mach-o")) {
46  ObjectFile.FatMachO.reset(new MachOYAML::UniversalBinary());
48  *ObjectFile.FatMachO);
49  } else if (IO.mapTag("!WASM")) {
50  ObjectFile.Wasm.reset(new WasmYAML::Object());
52  } else {
53  Input &In = (Input &)IO;
54  std::string Tag = In.getCurrentNode()->getRawTag();
55  if (Tag.empty())
56  IO.setError("YAML Object File missing document type tag!");
57  else
58  IO.setError(
59  Twine("YAML Object File unsupported document type tag '") +
60  Twine(Tag) + Twine("'!"));
61  }
62  }
63 }
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
StringRef getRawTag() const
Get the tag as it was written in the document.
Definition: YAMLParser.h:146
virtual void setError(const Twine &)=0
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:81
The Input class is used to parse a yaml document into in-memory structs and vectors.
Definition: YAMLTraits.h:1108
This class should be specialized by any type that needs to be converted to/from a YAML mapping...
std::unique_ptr< COFFYAML::Object > Coff
Definition: ObjectYAML.h:27
virtual bool mapTag(StringRef Tag, bool Default=false)=0
std::unique_ptr< MachOYAML::Object > MachO
Definition: ObjectYAML.h:28
std::unique_ptr< MachOYAML::UniversalBinary > FatMachO
Definition: ObjectYAML.h:29
std::unique_ptr< WasmYAML::Object > Wasm
Definition: ObjectYAML.h:30
virtual bool outputting()=0
std::unique_ptr< ELFYAML::Object > Elf
Definition: ObjectYAML.h:26
const Node * getCurrentNode() const
Returns the current node that&#39;s being parsed by the YAML Parser.
Definition: YAMLTraits.cpp:111