mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2025-01-09 00:14:10 -08:00
C: fix naming when bytecode contains method names with special characters
This commit is contained in:
parent
7313b2bb62
commit
4284bb2a6c
|
@ -160,22 +160,23 @@ public abstract class LowLevelNameProvider implements NameProvider {
|
||||||
|
|
||||||
private String sanitize(String name) {
|
private String sanitize(String name) {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
for (int i = 0; i < name.length(); ++i) {
|
char c = name.charAt(0);
|
||||||
char c = name.charAt(i);
|
sb.append(isIdentifierStart(c) ? c : '_');
|
||||||
switch (c) {
|
for (int i = 1; i < name.length(); ++i) {
|
||||||
case '>':
|
c = name.charAt(i);
|
||||||
case '<':
|
sb.append(isIdentifierPart(c) ? c : '_');
|
||||||
case '$':
|
|
||||||
sb.append('_');
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
sb.append(c);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean isIdentifierStart(char c) {
|
||||||
|
return c >= 'A' && c <= 'Z' || c >= 'a' && c <= 'z' || c == '_';
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean isIdentifierPart(char c) {
|
||||||
|
return isIdentifierStart(c) || c >= '0' && c <= '9';
|
||||||
|
}
|
||||||
|
|
||||||
private String pickUnoccupied(String name) {
|
private String pickUnoccupied(String name) {
|
||||||
return pickUnoccupied(name, occupiedTopLevelNames);
|
return pickUnoccupied(name, occupiedTopLevelNames);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user