summaryrefslogtreecommitdiff
path: root/dexlayout/dexlayout.cc
diff options
context:
space:
mode:
Diffstat (limited to 'dexlayout/dexlayout.cc')
-rw-r--r--dexlayout/dexlayout.cc43
1 files changed, 10 insertions, 33 deletions
diff --git a/dexlayout/dexlayout.cc b/dexlayout/dexlayout.cc
index d6dd9d1829..bd7a301a56 100644
--- a/dexlayout/dexlayout.cc
+++ b/dexlayout/dexlayout.cc
@@ -71,26 +71,10 @@ static inline uint16_t Get2LE(unsigned char const* src) {
}
/*
- * Converts a type descriptor to human-readable "dotted" form. For
- * example, "Ljava/lang/String;" becomes "java.lang.String", and
- * "[I" becomes "int[]". Also converts '$' to '.', which means this
- * form can't be converted back to a descriptor.
- */
-static std::string DescriptorToDotWrapper(const char* descriptor) {
- std::string result = DescriptorToDot(descriptor);
- size_t found = result.find('$');
- while (found != std::string::npos) {
- result[found] = '.';
- found = result.find('$', found);
- }
- return result;
-}
-
-/*
* Converts the class name portion of a type descriptor to human-readable
* "dotted" form. For example, "Ljava/lang/String;" becomes "String".
*/
-static std::string DescriptorClassToDot(const char* str) {
+static std::string DescriptorClassToName(const char* str) {
std::string descriptor(str);
// Reduce to just the class name prefix.
size_t last_slash = descriptor.rfind('/');
@@ -104,13 +88,6 @@ static std::string DescriptorClassToDot(const char* str) {
size_t size = descriptor.size() - 1 - last_slash;
std::string result(descriptor.substr(last_slash, size));
- // Replace '$' with '.'.
- size_t dollar_sign = result.find('$');
- while (dollar_sign != std::string::npos) {
- result[dollar_sign] = '.';
- dollar_sign = result.find('$', dollar_sign);
- }
-
return result;
}
@@ -786,7 +763,7 @@ void DexLayout::DumpInterface(const dex_ir::TypeId* type_item, int i) {
if (options_.output_format_ == kOutputPlain) {
fprintf(out_file_, " #%d : '%s'\n", i, interface_name);
} else {
- std::string dot(DescriptorToDotWrapper(interface_name));
+ std::string dot(DescriptorToDot(interface_name));
fprintf(out_file_, "<implements name=\"%s\">\n</implements>\n", dot.c_str());
}
}
@@ -1044,7 +1021,7 @@ void DexLayout::DumpBytecodes(uint32_t idx, const dex_ir::CodeItem* code, uint32
const char* back_descriptor = method_id->Class()->GetStringId()->Data();
// Generate header.
- std::string dot(DescriptorToDotWrapper(back_descriptor));
+ std::string dot(DescriptorToDot(back_descriptor));
fprintf(out_file_, "%06x: |[%06x] %s.%s:%s\n",
code_offset, code_offset, dot.c_str(), name, type_descriptor.c_str());
@@ -1212,9 +1189,9 @@ void DexLayout::DumpMethod(uint32_t idx, uint32_t flags, const dex_ir::CodeItem*
// Method name and prototype.
if (constructor) {
- std::string dot(DescriptorClassToDot(back_descriptor));
+ std::string dot(DescriptorClassToName(back_descriptor));
fprintf(out_file_, "<constructor name=\"%s\"\n", dot.c_str());
- dot = DescriptorToDotWrapper(back_descriptor);
+ dot = DescriptorToDot(back_descriptor);
fprintf(out_file_, " type=\"%s\"\n", dot.c_str());
} else {
fprintf(out_file_, "<method name=\"%s\"\n", name);
@@ -1223,7 +1200,7 @@ void DexLayout::DumpMethod(uint32_t idx, uint32_t flags, const dex_ir::CodeItem*
LOG(ERROR) << "bad method type descriptor '" << type_descriptor << "'";
goto bail;
}
- std::string dot(DescriptorToDotWrapper(return_type + 1));
+ std::string dot(DescriptorToDot(return_type + 1));
fprintf(out_file_, " return=\"%s\"\n", dot.c_str());
fprintf(out_file_, " abstract=%s\n", QuotedBool((flags & kAccAbstract) != 0));
fprintf(out_file_, " native=%s\n", QuotedBool((flags & kAccNative) != 0));
@@ -1265,7 +1242,7 @@ void DexLayout::DumpMethod(uint32_t idx, uint32_t flags, const dex_ir::CodeItem*
}
// Null terminate and display.
*cp++ = '\0';
- std::string dot(DescriptorToDotWrapper(tmp_buf));
+ std::string dot(DescriptorToDot(tmp_buf));
fprintf(out_file_, "<parameter name=\"arg%d\" type=\"%s\">\n"
"</parameter>\n", arg_num++, dot.c_str());
} // while
@@ -1309,7 +1286,7 @@ void DexLayout::DumpSField(uint32_t idx, uint32_t flags, int i, dex_ir::EncodedV
}
} else if (options_.output_format_ == kOutputXml) {
fprintf(out_file_, "<field name=\"%s\"\n", name);
- std::string dot(DescriptorToDotWrapper(type_descriptor));
+ std::string dot(DescriptorToDot(type_descriptor));
fprintf(out_file_, " type=\"%s\"\n", dot.c_str());
fprintf(out_file_, " transient=%s\n", QuotedBool((flags & kAccTransient) != 0));
fprintf(out_file_, " volatile=%s\n", QuotedBool((flags & kAccVolatile) != 0));
@@ -1415,10 +1392,10 @@ void DexLayout::DumpClass(int idx, char** last_package) {
}
fprintf(out_file_, " Interfaces -\n");
} else {
- std::string dot(DescriptorClassToDot(class_descriptor));
+ std::string dot(DescriptorClassToName(class_descriptor));
fprintf(out_file_, "<class name=\"%s\"\n", dot.c_str());
if (superclass_descriptor != nullptr) {
- dot = DescriptorToDotWrapper(superclass_descriptor);
+ dot = DescriptorToDot(superclass_descriptor);
fprintf(out_file_, " extends=\"%s\"\n", dot.c_str());
}
fprintf(out_file_, " interface=%s\n",