mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 08:14:09 -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) {
|
||||
if (statements.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
boolean oldEnd = end;
|
||||
for (int i = 0; i < statements.size() - 1; ++i) {
|
||||
end = false;
|
||||
|
|
|
@ -211,6 +211,10 @@ public final class ProgramEmitter {
|
|||
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) {
|
||||
for (int i = 0; i < method.parameterCount(); ++i) {
|
||||
if (!classSource.isSuperType(method.parameterType(i), arguments[i].getType()).orElse(true)) {
|
||||
|
|
|
@ -34,6 +34,7 @@ public class KOTestRunner implements TestRunner {
|
|||
if (++repeatCount == 10) {
|
||||
throw e;
|
||||
}
|
||||
Thread.sleep(50);
|
||||
} catch (Throwable e) {
|
||||
throw e;
|
||||
}
|
||||
|
|
|
@ -93,13 +93,13 @@ public class JavaScriptBodyConversionTest {
|
|||
@JavaScriptBody(args = { "value" }, body = "return value + 1;")
|
||||
private native int addOne(int value);
|
||||
|
||||
@JavaScriptBody(args = { "value" }, body = "return value;")
|
||||
@JavaScriptBody(args = { "array" }, body = "return 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);
|
||||
|
||||
@JavaScriptBody(args = { "value" }, body = "return value;")
|
||||
@JavaScriptBody(args = { "array" }, body = "return array;")
|
||||
private native Integer[] returnAsIntegerArray(Object array);
|
||||
|
||||
@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); " +
|
||||
"return f.apply(null, args);"
|
||||
)
|
||||
public native Object executeScript(String script, Object[] arguments);
|
||||
public native Object executeScript(String s, Object[] args);
|
||||
|
||||
@JavaScriptBody(args = { }, body =
|
||||
"var h;" +
|
||||
|
|
|
@ -22,6 +22,8 @@ import org.teavm.testing.TestRunner;
|
|||
* @author Alexey Andreev
|
||||
*/
|
||||
final class TestEntryPoint {
|
||||
private static Object testCase;
|
||||
|
||||
private TestEntryPoint() {
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,9 @@ import org.teavm.model.ElementModifier;
|
|||
import org.teavm.model.MethodHolder;
|
||||
import org.teavm.model.MethodReference;
|
||||
import org.teavm.model.Program;
|
||||
import org.teavm.model.ValueType;
|
||||
import org.teavm.model.emit.ProgramEmitter;
|
||||
import org.teavm.model.emit.ValueEmitter;
|
||||
import org.teavm.vm.spi.TeaVMHost;
|
||||
import org.teavm.vm.spi.TeaVMPlugin;
|
||||
|
||||
|
@ -70,7 +72,15 @@ class TestEntryPointTransformer implements ClassHolderTransformer, TeaVMPlugin {
|
|||
|
||||
private Program generateLaunchProgram(MethodHolder method, ClassReaderSource 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();
|
||||
return pe.getProgram();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user