mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 08:14:09 -08:00
Fix generation of JS aliases for Java objects
This commit is contained in:
parent
3f7b142d6e
commit
fb3412b4c0
|
@ -57,8 +57,12 @@ class JSAliasRenderer implements RendererListener {
|
|||
}
|
||||
writer.append("c").ws().append("=").ws().appendClass(entry.getKey()).append(".prototype;").softNewLine();
|
||||
for (Map.Entry<MethodDescriptor, String> aliasEntry : cls.methods.entrySet()) {
|
||||
writer.append("c.").append(aliasEntry.getValue()).ws().append("=").ws().append("c.")
|
||||
.appendMethod(aliasEntry.getKey()).append(";").softNewLine();
|
||||
if (isKeyword(aliasEntry.getValue())) {
|
||||
writer.append("c[\"").append(aliasEntry.getValue()).append("\"]");
|
||||
} else {
|
||||
writer.append("c.").append(aliasEntry.getValue());
|
||||
}
|
||||
writer.ws().append("=").ws().append("c.").appendMethod(aliasEntry.getKey()).append(";").softNewLine();
|
||||
}
|
||||
|
||||
if (cls.functorField != null) {
|
||||
|
@ -68,6 +72,25 @@ class JSAliasRenderer implements RendererListener {
|
|||
writer.outdent().append("})();").newLine();
|
||||
}
|
||||
|
||||
private boolean isKeyword(String id) {
|
||||
switch (id) {
|
||||
case "with":
|
||||
case "delete":
|
||||
case "in":
|
||||
case "undefined":
|
||||
case "debugger":
|
||||
case "export":
|
||||
case "function":
|
||||
case "let":
|
||||
case "var":
|
||||
case "typeof":
|
||||
case "yield":
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void writeFunctor(ExposedClass cls) throws IOException {
|
||||
String alias = cls.methods.get(cls.functorMethod);
|
||||
if (alias == null) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user