aboutsummaryrefslogtreecommitdiffhomepage
path: root/third_party/ijar/classfile.cc
diff options
context:
space:
mode:
authorGravatar Dmitry Lomov <dslomov@google.com>2016-02-17 17:34:23 +0000
committerGravatar Kristina Chodorow <kchodorow@google.com>2016-02-17 19:39:09 +0000
commit92adfd338d798c2fb934a6b5ec7104a868b2bfce (patch)
tree49fccbd916b562d15b8ff9c9acc0f80da2b7b9e0 /third_party/ijar/classfile.cc
parentab049e0e35e7f4dd8b9ea8280e888f20d6cb84a9 (diff)
Use a custom ToString instead of std::to_string that is not available on mingw.
Needed for #276. -- MOS_MIGRATED_REVID=114867808
Diffstat (limited to 'third_party/ijar/classfile.cc')
-rw-r--r--third_party/ijar/classfile.cc17
1 files changed, 15 insertions, 2 deletions
diff --git a/third_party/ijar/classfile.cc b/third_party/ijar/classfile.cc
index 09c03cfeeb..04e54221b9 100644
--- a/third_party/ijar/classfile.cc
+++ b/third_party/ijar/classfile.cc
@@ -33,11 +33,24 @@
#include <string.h>
#include <set>
+#include <sstream>
#include <string>
#include <vector>
#include "third_party/ijar/common.h"
+namespace {
+// Converts a value to string.
+// Workaround for mingw where std::to_string is not implemented.
+// See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52015.
+template <typename T>
+std::string ToString(const T& value) {
+ std::ostringstream oss;
+ oss << value;
+ return oss.str();
+}
+} // namespace
+
namespace devtools_ijar {
// See Table 4.3 in JVM Spec.
@@ -347,7 +360,7 @@ struct Constant_MethodHandle : Constant
}
std::string Display() {
- return "Constant_MethodHandle::" + std::to_string(reference_kind_) + "::"
+ return "Constant_MethodHandle::" + ToString(reference_kind_) + "::"
+ constant(reference_index_)->Display();
}
@@ -390,7 +403,7 @@ struct Constant_InvokeDynamic : Constant
std::string Display() {
return "Constant_InvokeDynamic::"
- + std::to_string(bootstrap_method_attr_index_) + "::"
+ + ToString(bootstrap_method_attr_index_) + "::"
+ constant(name_and_type_index_)->Display();
}