mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2025-01-08 07:54:11 -08:00
Fix bugs
This commit is contained in:
parent
cf92616a6a
commit
732957cd84
|
@ -2165,6 +2165,9 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext
|
||||||
}
|
}
|
||||||
|
|
||||||
private void visitStatements(List<Statement> statements) {
|
private void visitStatements(List<Statement> statements) {
|
||||||
|
if (statements.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
boolean oldEnd = end;
|
boolean oldEnd = end;
|
||||||
for (int i = 0; i < statements.size() - 1; ++i) {
|
for (int i = 0; i < statements.size() - 1; ++i) {
|
||||||
end = false;
|
end = false;
|
||||||
|
|
|
@ -211,6 +211,10 @@ public final class ProgramEmitter {
|
||||||
return setField(new FieldReference(className, fieldName), value);
|
return setField(new FieldReference(className, fieldName), value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ProgramEmitter setField(Class<?> cls, String fieldName, ValueEmitter value) {
|
||||||
|
return setField(new FieldReference(cls.getName(), fieldName), value);
|
||||||
|
}
|
||||||
|
|
||||||
public ValueEmitter invoke(MethodReference method, ValueEmitter... arguments) {
|
public ValueEmitter invoke(MethodReference method, ValueEmitter... arguments) {
|
||||||
for (int i = 0; i < method.parameterCount(); ++i) {
|
for (int i = 0; i < method.parameterCount(); ++i) {
|
||||||
if (!classSource.isSuperType(method.parameterType(i), arguments[i].getType()).orElse(true)) {
|
if (!classSource.isSuperType(method.parameterType(i), arguments[i].getType()).orElse(true)) {
|
||||||
|
|
|
@ -34,6 +34,7 @@ public class KOTestRunner implements TestRunner {
|
||||||
if (++repeatCount == 10) {
|
if (++repeatCount == 10) {
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
Thread.sleep(50);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,13 +93,13 @@ public class JavaScriptBodyConversionTest {
|
||||||
@JavaScriptBody(args = { "value" }, body = "return value + 1;")
|
@JavaScriptBody(args = { "value" }, body = "return value + 1;")
|
||||||
private native int addOne(int value);
|
private native int addOne(int value);
|
||||||
|
|
||||||
@JavaScriptBody(args = { "value" }, body = "return value;")
|
@JavaScriptBody(args = { "array" }, body = "return array;")
|
||||||
private native Object returnAsObject(Object array);
|
private native Object returnAsObject(Object array);
|
||||||
|
|
||||||
@JavaScriptBody(args = { "value" }, body = "return value;")
|
@JavaScriptBody(args = { "array" }, body = "return array;")
|
||||||
private native int[] returnAsIntArray(Object array);
|
private native int[] returnAsIntArray(Object array);
|
||||||
|
|
||||||
@JavaScriptBody(args = { "value" }, body = "return value;")
|
@JavaScriptBody(args = { "array" }, body = "return array;")
|
||||||
private native Integer[] returnAsIntegerArray(Object array);
|
private native Integer[] returnAsIntegerArray(Object array);
|
||||||
|
|
||||||
@JavaScriptBody(args = { "value" }, body = "value[0] = 1; return value;")
|
@JavaScriptBody(args = { "value" }, body = "value[0] = 1; return value;")
|
||||||
|
|
|
@ -97,7 +97,7 @@ public final class KnockoutFXTest extends KnockoutTCK implements Transfer {
|
||||||
"var f = new Function(s); " +
|
"var f = new Function(s); " +
|
||||||
"return f.apply(null, args);"
|
"return f.apply(null, args);"
|
||||||
)
|
)
|
||||||
public native Object executeScript(String script, Object[] arguments);
|
public native Object executeScript(String s, Object[] args);
|
||||||
|
|
||||||
@JavaScriptBody(args = { }, body =
|
@JavaScriptBody(args = { }, body =
|
||||||
"var h;" +
|
"var h;" +
|
||||||
|
|
|
@ -22,6 +22,8 @@ import org.teavm.testing.TestRunner;
|
||||||
* @author Alexey Andreev
|
* @author Alexey Andreev
|
||||||
*/
|
*/
|
||||||
final class TestEntryPoint {
|
final class TestEntryPoint {
|
||||||
|
private static Object testCase;
|
||||||
|
|
||||||
private TestEntryPoint() {
|
private TestEntryPoint() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,9 @@ import org.teavm.model.ElementModifier;
|
||||||
import org.teavm.model.MethodHolder;
|
import org.teavm.model.MethodHolder;
|
||||||
import org.teavm.model.MethodReference;
|
import org.teavm.model.MethodReference;
|
||||||
import org.teavm.model.Program;
|
import org.teavm.model.Program;
|
||||||
|
import org.teavm.model.ValueType;
|
||||||
import org.teavm.model.emit.ProgramEmitter;
|
import org.teavm.model.emit.ProgramEmitter;
|
||||||
|
import org.teavm.model.emit.ValueEmitter;
|
||||||
import org.teavm.vm.spi.TeaVMHost;
|
import org.teavm.vm.spi.TeaVMHost;
|
||||||
import org.teavm.vm.spi.TeaVMPlugin;
|
import org.teavm.vm.spi.TeaVMPlugin;
|
||||||
|
|
||||||
|
@ -70,7 +72,15 @@ class TestEntryPointTransformer implements ClassHolderTransformer, TeaVMPlugin {
|
||||||
|
|
||||||
private Program generateLaunchProgram(MethodHolder method, ClassReaderSource innerSource) {
|
private Program generateLaunchProgram(MethodHolder method, ClassReaderSource innerSource) {
|
||||||
ProgramEmitter pe = ProgramEmitter.create(method, innerSource);
|
ProgramEmitter pe = ProgramEmitter.create(method, innerSource);
|
||||||
pe.construct(testMethod.getClassName()).invokeSpecial(testMethod);
|
ValueEmitter testCaseVar = pe.getField(TestEntryPoint.class, "testCase", Object.class);
|
||||||
|
pe.when(testCaseVar.isNull())
|
||||||
|
.thenDo(() -> {
|
||||||
|
pe.setField(TestEntryPoint.class, "testCase",
|
||||||
|
pe.construct(testMethod.getClassName()).cast(Object.class));
|
||||||
|
});
|
||||||
|
pe.getField(TestEntryPoint.class, "testCase", Object.class)
|
||||||
|
.cast(ValueType.object(testMethod.getClassName()))
|
||||||
|
.invokeSpecial(testMethod);
|
||||||
pe.exit();
|
pe.exit();
|
||||||
return pe.getProgram();
|
return pe.getProgram();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user