mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 16:14:10 -08:00
When native method returns undefined
and Java expects string, produce null
. Add $
prefix to local variables to avoid name clashing with global declarations
This commit is contained in:
parent
f96aa54461
commit
b7d760188e
|
@ -182,7 +182,7 @@ public class Renderer implements RenderingManager {
|
|||
private void renderRuntimeString() throws IOException {
|
||||
MethodReference stringCons = new MethodReference(String.class, "<init>", char[].class, void.class);
|
||||
writer.append("function $rt_str(str) {").indent().softNewLine();
|
||||
writer.append("if (str===null){").indent().softNewLine();
|
||||
writer.append("if (str == null) {").indent().softNewLine();
|
||||
writer.append("return null;").softNewLine();
|
||||
writer.outdent().append("}").softNewLine();
|
||||
writer.append("var characters = $rt_createCharArray(str.length);").softNewLine();
|
||||
|
|
|
@ -458,7 +458,7 @@ public class StatementRenderer implements ExprVisitor, StatementVisitor {
|
|||
? currentMethod.getVariables().get(index)
|
||||
: null;
|
||||
if (variable != null && variable.getName() != null) {
|
||||
String result = RenderingUtil.escapeName(variable.getName());
|
||||
String result = "$" + RenderingUtil.escapeName(variable.getName());
|
||||
if (keywords.contains(result) || !usedVariableNames.add(result)) {
|
||||
String base = result;
|
||||
int suffix = 0;
|
||||
|
|
Loading…
Reference in New Issue
Block a user