mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-23 00:24:11 -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 {
|
private void renderRuntimeString() throws IOException {
|
||||||
MethodReference stringCons = new MethodReference(String.class, "<init>", char[].class, void.class);
|
MethodReference stringCons = new MethodReference(String.class, "<init>", char[].class, void.class);
|
||||||
writer.append("function $rt_str(str) {").indent().softNewLine();
|
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.append("return null;").softNewLine();
|
||||||
writer.outdent().append("}").softNewLine();
|
writer.outdent().append("}").softNewLine();
|
||||||
writer.append("var characters = $rt_createCharArray(str.length);").softNewLine();
|
writer.append("var characters = $rt_createCharArray(str.length);").softNewLine();
|
||||||
|
|
|
@ -458,7 +458,7 @@ public class StatementRenderer implements ExprVisitor, StatementVisitor {
|
||||||
? currentMethod.getVariables().get(index)
|
? currentMethod.getVariables().get(index)
|
||||||
: null;
|
: null;
|
||||||
if (variable != null && variable.getName() != 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)) {
|
if (keywords.contains(result) || !usedVariableNames.add(result)) {
|
||||||
String base = result;
|
String base = result;
|
||||||
int suffix = 0;
|
int suffix = 0;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user