mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 08:14:09 -08:00
When name of method parameter is not an identifier, mangle it to contain only Java identifier character
This commit is contained in:
parent
eb3558cb1a
commit
3f58e3b24f
|
@ -1245,12 +1245,21 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext
|
|||
List<String> nameList = new ArrayList<>(names);
|
||||
Collections.sort(nameList);
|
||||
for (String name : nameList) {
|
||||
sb.append('_').append(name);
|
||||
sb.append('_').append(escapeName(name));
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private static String escapeName(String name) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < name.length(); ++i) {
|
||||
char c = name.charAt(i);
|
||||
sb.append(Character.isJavaIdentifierPart(c) ? c : '_');
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private String pointerName() {
|
||||
return minifying ? "$p" : "$ptr";
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user