aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Object/YAML.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2013-06-05 02:32:26 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2013-06-05 02:32:26 +0000
commit5fd5fe0f7bfac0f7973475fcf7a5f8061d983538 (patch)
tree8596242c630f6f9a293d27abcda4f0c7746b806e /lib/Object/YAML.cpp
parent6afb65c2b709cfa078d0f6f6c5feceb2abab8036 (diff)
downloadexternal_llvm-5fd5fe0f7bfac0f7973475fcf7a5f8061d983538.zip
external_llvm-5fd5fe0f7bfac0f7973475fcf7a5f8061d983538.tar.gz
external_llvm-5fd5fe0f7bfac0f7973475fcf7a5f8061d983538.tar.bz2
Move BinaryRef to a new include/llvm/Object/YAML.h file.
It will be used for ELF dumping too. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183287 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Object/YAML.cpp')
-rw-r--r--lib/Object/YAML.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/lib/Object/YAML.cpp b/lib/Object/YAML.cpp
new file mode 100644
index 0000000..36b1997
--- /dev/null
+++ b/lib/Object/YAML.cpp
@@ -0,0 +1,34 @@
+//===- YAML.cpp - YAMLIO 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 utility classes for handling the YAML representation of
+// object files.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/Object/YAML.h"
+
+using namespace llvm;
+
+void yaml::ScalarTraits<object::yaml::BinaryRef>::output(
+ const object::yaml::BinaryRef &Val, void *, llvm::raw_ostream &Out) {
+ ArrayRef<uint8_t> Data = Val.getBinary();
+ for (ArrayRef<uint8_t>::iterator I = Data.begin(), E = Data.end(); I != E;
+ ++I) {
+ uint8_t Byte = *I;
+ Out << hexdigit(Byte >> 4);
+ Out << hexdigit(Byte & 0xf);
+ }
+}
+
+StringRef yaml::ScalarTraits<object::yaml::BinaryRef>::input(
+ StringRef Scalar, void *, object::yaml::BinaryRef &Val) {
+ Val = object::yaml::BinaryRef(Scalar);
+ return StringRef();
+}