mirror of
https://github.com/Maschell/ghs-demangle-java.git
synced 2024-11-21 23:49:16 +01:00
Formatting, fix some bugs
This commit is contained in:
parent
d1819ad7c1
commit
64d89ee4a5
@ -8,10 +8,6 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
|
||||||
* Hello world!
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class App {
|
public class App {
|
||||||
|
|
||||||
static String[] templatePrefixes = new String[] { "tm", "ps", "pt" /* XXX from libiberty cplus-dem.c */ };
|
static String[] templatePrefixes = new String[] { "tm", "ps", "pt" /* XXX from libiberty cplus-dem.c */ };
|
||||||
@ -23,34 +19,27 @@ public class App {
|
|||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
init();
|
init();
|
||||||
|
|
||||||
|
|
||||||
demangle("__sti___17_RZApplication_cpp_8fdb2739");
|
|
||||||
|
|
||||||
BufferedReader reader;
|
BufferedReader reader;
|
||||||
try {
|
try {
|
||||||
reader = new BufferedReader(new FileReader("functions.txt"));
|
reader = new BufferedReader(new FileReader(args[0]));
|
||||||
String line = reader.readLine();
|
String line = reader.readLine();
|
||||||
while (line != null) {
|
while (line != null) {
|
||||||
String newStr = line;
|
String newStr = line;
|
||||||
try {
|
try {
|
||||||
newStr = demangle(line);
|
newStr = demangle(line);
|
||||||
|
System.out.println(newStr);
|
||||||
// System.out.println(newStr);
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
System.out.println(line);
|
||||||
System.out.println(newStr);
|
}
|
||||||
}
|
|
||||||
// read next line
|
|
||||||
line = reader.readLine();
|
line = reader.readLine();
|
||||||
}
|
}
|
||||||
reader.close();
|
reader.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void init() {
|
private static void init() {
|
||||||
@ -128,7 +117,7 @@ public class App {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static String demangle(String name) {
|
private static String demangle(String name) {
|
||||||
if(name.startsWith("__sti__")) {
|
if (name.startsWith("__sti__")) {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
name = Decompress(name);
|
name = Decompress(name);
|
||||||
@ -201,7 +190,7 @@ public class App {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mangle.getValue().length() > 0)
|
if (mangle.getValue().length() > 0)
|
||||||
throw new IllegalArgumentException("Unknown modifier: \"" + mangle.getValue().charAt(0) + "\".");
|
throw new IllegalArgumentException("Unknown modifier: \"" + mangle.getValue().charAt(0) + "\".");
|
||||||
|
|
||||||
@ -232,9 +221,8 @@ public class App {
|
|||||||
if (end == -1) throw new IllegalArgumentException("Unexpected end of string. Expected \"Z\".");
|
if (end == -1) throw new IllegalArgumentException("Unexpected end of string. Expected \"Z\".");
|
||||||
|
|
||||||
current = remainder.getValue().substring(0, end);
|
current = remainder.getValue().substring(0, end);
|
||||||
remainder.setValue(name.substring(end + 1));
|
remainder.setValue(name.substring(end + 2));
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
current = ReadString(remainder.getValue(), remainder);
|
current = ReadString(remainder.getValue(), remainder);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -333,7 +321,7 @@ public class App {
|
|||||||
if (name.length() < 2) throw new IllegalArgumentException("Unexpected end of string. Expected \"_\".");
|
if (name.length() < 2) throw new IllegalArgumentException("Unexpected end of string. Expected \"_\".");
|
||||||
if (!Character.isDigit(name.charAt(1))) throw new IllegalArgumentException("Unexpected character \"" + name.charAt(1) + "\". Expected a digit.");
|
if (!Character.isDigit(name.charAt(1))) throw new IllegalArgumentException("Unexpected character \"" + name.charAt(1) + "\". Expected a digit.");
|
||||||
|
|
||||||
int arg = Integer.parseInt(name.substring(1, 2));
|
int arg = Integer.parseInt(name.substring(1, 2));
|
||||||
|
|
||||||
remainder.setValue(name.substring(2));
|
remainder.setValue(name.substring(2));
|
||||||
|
|
||||||
@ -415,7 +403,11 @@ public class App {
|
|||||||
name = name.substring(0, mstart);
|
name = name.substring(0, mstart);
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
if (!StartsWithAny(remainder, templatePrefixes)) throw new IllegalArgumentException("Unexpected template argument prefix.");
|
if (!StartsWithAny(remainder, templatePrefixes)) {
|
||||||
|
// throw new IllegalArgumentException("Unexpected template argument prefix. " + remainder);
|
||||||
|
return name;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/* format of remainder should be <type>__<len>_<arg> */
|
/* format of remainder should be <type>__<len>_<arg> */
|
||||||
int lstart = remainder.indexOf("__");
|
int lstart = remainder.indexOf("__");
|
||||||
@ -569,7 +561,7 @@ public class App {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (end > start) valid = false;
|
if (end < start) valid = false;
|
||||||
|
|
||||||
if (valid) {
|
if (valid) {
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user