mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 08:14:09 -08:00
Fix async test building. Fix Window.prompt. Fix non-integer JS number to
Java primitive conversion
This commit is contained in:
parent
1d72ea166b
commit
84be461a69
|
@ -72,18 +72,8 @@ public class AsyncMethodFinder {
|
|||
if (asyncMethods.contains(method.getReference()) || method.getProgram() == null) {
|
||||
continue;
|
||||
}
|
||||
if (method.hasModifier(ElementModifier.SYNCHRONIZED)) {
|
||||
if (hasMonitor(method)) {
|
||||
add(method.getReference());
|
||||
continue;
|
||||
}
|
||||
ProgramReader program = method.getProgram();
|
||||
AsyncInstructionReader insnReader = new AsyncInstructionReader();
|
||||
for (int i = 0; i < program.basicBlockCount(); ++i) {
|
||||
program.basicBlockAt(i).readAllInstructions(insnReader);
|
||||
if (insnReader.async) {
|
||||
add(method.getReference());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -105,21 +95,36 @@ public class AsyncMethodFinder {
|
|||
}
|
||||
|
||||
private boolean hasAsyncMethods() {
|
||||
int count = asyncMethods.size();
|
||||
if (asyncMethods.contains(new MethodReference(Object.class, "monitorEnter", Object.class, void.class))) {
|
||||
--count;
|
||||
}
|
||||
if (asyncMethods.contains(new MethodReference(Object.class, "monitorEnter", Object.class,
|
||||
int.class, void.class))) {
|
||||
--count;
|
||||
}
|
||||
if (asyncMethods.contains(new MethodReference(Object.class, "monitorEnterWait", Object.class,
|
||||
int.class, void.class))) {
|
||||
--count;
|
||||
boolean result = false;
|
||||
loop: for (String clsName : classSource.getClassNames()) {
|
||||
ClassReader cls = classSource.get(clsName);
|
||||
for (MethodReader method : cls.getMethods()) {
|
||||
if (!asyncMethods.contains(method.getReference()) || method.getProgram() == null) {
|
||||
continue;
|
||||
}
|
||||
if (hasMonitor(method)) {
|
||||
break loop;
|
||||
}
|
||||
}
|
||||
}
|
||||
ClassReader cls = classSource.get("java.lang.Thread");
|
||||
MethodReader method = cls != null ? cls.getMethod(new MethodDescriptor("start", void.class)) : null;
|
||||
return count > 0 && method != null;
|
||||
return result && method != null;
|
||||
}
|
||||
|
||||
private boolean hasMonitor(MethodReader method) {
|
||||
if (method.hasModifier(ElementModifier.SYNCHRONIZED)) {
|
||||
return true;
|
||||
}
|
||||
ProgramReader program = method.getProgram();
|
||||
AsyncInstructionReader insnReader = new AsyncInstructionReader();
|
||||
for (int i = 0; i < program.basicBlockCount(); ++i) {
|
||||
program.basicBlockAt(i).readAllInstructions(insnReader);
|
||||
if (insnReader.async) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void add(MethodReference methodRef) {
|
||||
|
|
|
@ -138,7 +138,7 @@ public class JavaScriptConvGenerator implements Generator {
|
|||
writer.outdent().append("} else if (" + type + " === ").appendClass("java.lang.Character")
|
||||
.append(") {").indent().softNewLine();
|
||||
writer.append("return ").appendMethodBody(valueOfCharMethod).append("(typeof " + obj + " === 'number' ? "
|
||||
+ obj + "0xFFFF : " + obj + ".charCodeAt(0));").softNewLine();
|
||||
+ obj + " & 0xFFFF : " + obj + ".charCodeAt(0));").softNewLine();
|
||||
|
||||
writer.outdent().append("} else if (" + type + " === ").appendClass("java.lang.Byte")
|
||||
.append(") {").indent().softNewLine();
|
||||
|
@ -186,7 +186,7 @@ public class JavaScriptConvGenerator implements Generator {
|
|||
writer.append("return $rt_str(" + obj + ");").softNewLine();
|
||||
|
||||
writer.outdent().append("} else if (typeof " + obj + " === 'number') {").indent().softNewLine();
|
||||
writer.append("if (" + obj + "|0 === " + obj + ") {").indent().softNewLine();
|
||||
writer.append("if ((" + obj + "|0) === " + obj + ") {").indent().softNewLine();
|
||||
writer.append("return ").appendMethodBody(valueOfIntMethod).append("(" + obj + ");").softNewLine();
|
||||
writer.outdent().append("} else {").indent().softNewLine();
|
||||
writer.append("return ").appendMethodBody(valueOfDoubleMethod).append("(" + obj + ");").softNewLine();
|
||||
|
|
|
@ -93,7 +93,7 @@ public abstract class Window implements JSObject, WindowEventTarget, StorageProv
|
|||
return prompt(message, "");
|
||||
}
|
||||
|
||||
@JSBody(params = { "message", "default" }, script = "prompt(message, default);")
|
||||
@JSBody(params = { "message", "defaultValue" }, script = "prompt(message, defaultValue);")
|
||||
public static native String prompt(String message, String defaultValue);
|
||||
|
||||
@JSBody(params = { "handler", "delay" }, script = "return setTimeout(handler, delay);")
|
||||
|
|
Loading…
Reference in New Issue
Block a user