mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 08:14:09 -08:00
Fix bugs in WASM target
This commit is contained in:
parent
06a96911a1
commit
3dd76c9355
|
@ -17,14 +17,10 @@ package org.teavm.classlib.java.lang;
|
||||||
|
|
||||||
import org.teavm.classlib.java.io.TSerializable;
|
import org.teavm.classlib.java.io.TSerializable;
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Alexey Andreev
|
|
||||||
*/
|
|
||||||
public class TBoolean extends TObject implements TSerializable, TComparable<TBoolean> {
|
public class TBoolean extends TObject implements TSerializable, TComparable<TBoolean> {
|
||||||
public static final TBoolean TRUE = new TBoolean(true);
|
public static final TBoolean TRUE = new TBoolean(true);
|
||||||
public static final TBoolean FALSE = new TBoolean(false);
|
public static final TBoolean FALSE = new TBoolean(false);
|
||||||
public static final TClass<TBoolean> TYPE = TClass.booleanClass();
|
public static final Class<Boolean> TYPE = boolean.class;
|
||||||
private boolean value;
|
private boolean value;
|
||||||
|
|
||||||
public TBoolean(boolean value) {
|
public TBoolean(boolean value) {
|
||||||
|
|
|
@ -15,14 +15,10 @@
|
||||||
*/
|
*/
|
||||||
package org.teavm.classlib.java.lang;
|
package org.teavm.classlib.java.lang;
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Alexey Andreev
|
|
||||||
*/
|
|
||||||
public class TByte extends TNumber implements TComparable<TByte> {
|
public class TByte extends TNumber implements TComparable<TByte> {
|
||||||
public static final byte MIN_VALUE = -128;
|
public static final byte MIN_VALUE = -128;
|
||||||
public static final byte MAX_VALUE = 127;
|
public static final byte MAX_VALUE = 127;
|
||||||
public static final TClass<TByte> TYPE = TClass.byteClass();
|
public static final Class<Byte> TYPE = byte.class;
|
||||||
public static final int SIZE = 8;
|
public static final int SIZE = 8;
|
||||||
private byte value;
|
private byte value;
|
||||||
|
|
||||||
|
|
|
@ -108,36 +108,6 @@ public class TClass<T> extends TObject implements TAnnotatedElement {
|
||||||
return getClass(platformClass.getMetadata().getArrayItem());
|
return getClass(platformClass.getMetadata().getArrayItem());
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
static TClass<TBoolean> booleanClass() {
|
|
||||||
return (TClass<TBoolean>) getClass(Platform.getPrimitives().getBooleanClass());
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
static TClass<TByte> byteClass() {
|
|
||||||
return (TClass<TByte>) getClass(Platform.getPrimitives().getByteClass());
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
static TClass<TShort> shortClass() {
|
|
||||||
return (TClass<TShort>) getClass(Platform.getPrimitives().getShortClass());
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
static TClass<TLong> longClass() {
|
|
||||||
return (TClass<TLong>) getClass(Platform.getPrimitives().getLongClass());
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
static TClass<TFloat> floatClass() {
|
|
||||||
return (TClass<TFloat>) getClass(Platform.getPrimitives().getFloatClass());
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
static TClass<TDouble> doubleClass() {
|
|
||||||
return (TClass<TDouble>) getClass(Platform.getPrimitives().getDoubleClass());
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean desiredAssertionStatus() {
|
public boolean desiredAssertionStatus() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,10 +17,6 @@ package org.teavm.classlib.java.lang;
|
||||||
|
|
||||||
import org.teavm.jso.JSBody;
|
import org.teavm.jso.JSBody;
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Alexey Andreev
|
|
||||||
*/
|
|
||||||
public class TDouble extends TNumber implements TComparable<TDouble> {
|
public class TDouble extends TNumber implements TComparable<TDouble> {
|
||||||
public static final double POSITIVE_INFINITY = 1 / 0.0;
|
public static final double POSITIVE_INFINITY = 1 / 0.0;
|
||||||
public static final double NEGATIVE_INFINITY = -POSITIVE_INFINITY;
|
public static final double NEGATIVE_INFINITY = -POSITIVE_INFINITY;
|
||||||
|
@ -31,7 +27,7 @@ public class TDouble extends TNumber implements TComparable<TDouble> {
|
||||||
public static final int MAX_EXPONENT = 1023;
|
public static final int MAX_EXPONENT = 1023;
|
||||||
public static final int MIN_EXPONENT = -1022;
|
public static final int MIN_EXPONENT = -1022;
|
||||||
public static final int SIZE = 64;
|
public static final int SIZE = 64;
|
||||||
public static final TClass<TDouble> TYPE = TClass.doubleClass();
|
public static final Class<Double> TYPE = double.class;
|
||||||
private double value;
|
private double value;
|
||||||
|
|
||||||
public TDouble(double value) {
|
public TDouble(double value) {
|
||||||
|
|
|
@ -17,10 +17,6 @@ package org.teavm.classlib.java.lang;
|
||||||
|
|
||||||
import org.teavm.jso.JSBody;
|
import org.teavm.jso.JSBody;
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Alexey Andreev
|
|
||||||
*/
|
|
||||||
public class TFloat extends TNumber implements TComparable<TFloat> {
|
public class TFloat extends TNumber implements TComparable<TFloat> {
|
||||||
public static final float POSITIVE_INFINITY = 1 / 0.0f;
|
public static final float POSITIVE_INFINITY = 1 / 0.0f;
|
||||||
public static final float NEGATIVE_INFINITY = -POSITIVE_INFINITY;
|
public static final float NEGATIVE_INFINITY = -POSITIVE_INFINITY;
|
||||||
|
@ -31,7 +27,7 @@ public class TFloat extends TNumber implements TComparable<TFloat> {
|
||||||
public static final int MAX_EXPONENT = 127;
|
public static final int MAX_EXPONENT = 127;
|
||||||
public static final int MIN_EXPONENT = -126;
|
public static final int MIN_EXPONENT = -126;
|
||||||
public static final int SIZE = 32;
|
public static final int SIZE = 32;
|
||||||
public static final TClass<TFloat> TYPE = TClass.floatClass();
|
public static final Class<Float> TYPE = float.class;
|
||||||
private float value;
|
private float value;
|
||||||
|
|
||||||
public TFloat(float value) {
|
public TFloat(float value) {
|
||||||
|
|
|
@ -17,14 +17,10 @@ package org.teavm.classlib.java.lang;
|
||||||
|
|
||||||
import org.teavm.javascript.spi.GeneratedBy;
|
import org.teavm.javascript.spi.GeneratedBy;
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Alexey Andreev
|
|
||||||
*/
|
|
||||||
public class TLong extends TNumber implements TComparable<TLong> {
|
public class TLong extends TNumber implements TComparable<TLong> {
|
||||||
public static final long MIN_VALUE = -0x8000000000000000L;
|
public static final long MIN_VALUE = -0x8000000000000000L;
|
||||||
public static final long MAX_VALUE = 0x7FFFFFFFFFFFFFFFL;
|
public static final long MAX_VALUE = 0x7FFFFFFFFFFFFFFFL;
|
||||||
public static final TClass<TLong> TYPE = TClass.longClass();
|
public static final Class<Long> TYPE = long.class;
|
||||||
public static final int SIZE = 64;
|
public static final int SIZE = 64;
|
||||||
private long value;
|
private long value;
|
||||||
|
|
||||||
|
|
|
@ -15,14 +15,10 @@
|
||||||
*/
|
*/
|
||||||
package org.teavm.classlib.java.lang;
|
package org.teavm.classlib.java.lang;
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Alexey Andreev
|
|
||||||
*/
|
|
||||||
public class TShort extends TNumber implements TComparable<TShort> {
|
public class TShort extends TNumber implements TComparable<TShort> {
|
||||||
public static final short MIN_VALUE = -32768;
|
public static final short MIN_VALUE = -32768;
|
||||||
public static final short MAX_VALUE = 32767;
|
public static final short MAX_VALUE = 32767;
|
||||||
public static final TClass<TShort> TYPE = TClass.shortClass();
|
public static final Class<Short> TYPE = short.class;
|
||||||
public static final int SIZE = 16;
|
public static final int SIZE = 16;
|
||||||
private short value;
|
private short value;
|
||||||
|
|
||||||
|
|
|
@ -17,13 +17,18 @@ package org.teavm.classlib.java.util;
|
||||||
|
|
||||||
import java.lang.reflect.Array;
|
import java.lang.reflect.Array;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import org.teavm.classlib.java.lang.*;
|
import org.teavm.classlib.java.lang.TClass;
|
||||||
|
import org.teavm.classlib.java.lang.TComparable;
|
||||||
|
import org.teavm.classlib.java.lang.TDouble;
|
||||||
|
import org.teavm.classlib.java.lang.TFloat;
|
||||||
|
import org.teavm.classlib.java.lang.TIllegalArgumentException;
|
||||||
|
import org.teavm.classlib.java.lang.TInteger;
|
||||||
|
import org.teavm.classlib.java.lang.TMath;
|
||||||
|
import org.teavm.classlib.java.lang.TObject;
|
||||||
|
import org.teavm.classlib.java.lang.TString;
|
||||||
|
import org.teavm.classlib.java.lang.TStringBuilder;
|
||||||
import org.teavm.classlib.java.lang.reflect.TArray;
|
import org.teavm.classlib.java.lang.reflect.TArray;
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Alexey Andreev
|
|
||||||
*/
|
|
||||||
public class TArrays extends TObject {
|
public class TArrays extends TObject {
|
||||||
public static char[] copyOf(char[] array, int length) {
|
public static char[] copyOf(char[] array, int length) {
|
||||||
char[] result = new char[length];
|
char[] result = new char[length];
|
||||||
|
|
|
@ -36,7 +36,7 @@ public final class Allocator {
|
||||||
|
|
||||||
public static Address allocateArray(RuntimeClass tag, int size) {
|
public static Address allocateArray(RuntimeClass tag, int size) {
|
||||||
Address result = address;
|
Address result = address;
|
||||||
int sizeInBytes = tag.size * 4 + Structure.sizeOf(RuntimeArray.class);
|
int sizeInBytes = tag.itemType.size * size + Structure.sizeOf(RuntimeArray.class);
|
||||||
address = result.add(sizeInBytes);
|
address = result.add(sizeInBytes);
|
||||||
fillZero(result, sizeInBytes);
|
fillZero(result, sizeInBytes);
|
||||||
|
|
||||||
|
|
|
@ -362,7 +362,7 @@ public class TeaVM implements TeaVMHost, ServiceRepository {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline(classSet);
|
//inline(classSet);
|
||||||
if (wasCancelled()) {
|
if (wasCancelled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ public final class Example {
|
||||||
println(String.valueOf(a));
|
println(String.valueOf(a));
|
||||||
}
|
}
|
||||||
|
|
||||||
println("A(2) + A(3) = " + new A(2).getValue() + new A(3).getValue());
|
println("A(2) + A(3) = " + (new A(2).getValue() + new A(3).getValue()));
|
||||||
|
|
||||||
for (int i = 0; i < 4; ++i) {
|
for (int i = 0; i < 4; ++i) {
|
||||||
println("instance(" + i + ") = " + instance(i).foo());
|
println("instance(" + i + ") = " + instance(i).foo());
|
||||||
|
@ -43,7 +43,7 @@ public final class Example {
|
||||||
Base[] array = { new Derived1(), new Derived2() };
|
Base[] array = { new Derived1(), new Derived2() };
|
||||||
println("array.length = " + array.length);
|
println("array.length = " + array.length);
|
||||||
for (Base elem : array) {
|
for (Base elem : array) {
|
||||||
println("array[i]" + elem.foo());
|
println("array[i] = " + elem.foo());
|
||||||
}
|
}
|
||||||
|
|
||||||
println("Derived2 instanceof Base = " + (new Derived2() instanceof Base));
|
println("Derived2 instanceof Base = " + (new Derived2() instanceof Base));
|
||||||
|
|
|
@ -147,22 +147,22 @@ public final class WasmRuntime {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int getInt(Address data) {
|
private static int getInt(Address data) {
|
||||||
byte a = data.getByte();
|
int a = data.getByte() & 0xFF;
|
||||||
byte b = data.add(1).getByte();
|
int b = data.add(1).getByte() & 0xFF;
|
||||||
byte c = data.add(2).getByte();
|
int c = data.add(2).getByte() & 0xFF;
|
||||||
byte d = data.add(3).getByte();
|
int d = data.add(3).getByte() & 0xFF;
|
||||||
return (a << 24) | (b << 16) | (c << 8) | d;
|
return (a << 24) | (b << 16) | (c << 8) | d;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static long getLong(Address data) {
|
private static long getLong(Address data) {
|
||||||
long a = data.getByte();
|
long a = data.getByte() & 0xFF;
|
||||||
long b = data.add(1).getByte();
|
long b = data.add(1).getByte() & 0xFF;
|
||||||
long c = data.add(2).getByte();
|
long c = data.add(2).getByte() & 0xFF;
|
||||||
long d = data.add(3).getByte();
|
long d = data.add(3).getByte() & 0xFF;
|
||||||
long e = data.add(4).getByte();
|
long e = data.add(4).getByte() & 0xFF;
|
||||||
long f = data.add(5).getByte();
|
long f = data.add(5).getByte() & 0xFF;
|
||||||
long g = data.add(6).getByte();
|
long g = data.add(6).getByte() & 0xFF;
|
||||||
long h = data.add(7).getByte();
|
long h = data.add(7).getByte() & 0xFF;
|
||||||
return (a << 56) | (b << 48) | (c << 40) | (d << 32) | (e << 24) | (f << 16) | (g << 8) | h;
|
return (a << 56) | (b << 48) | (c << 40) | (d << 32) | (e << 24) | (f << 16) | (g << 8) | h;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -184,6 +184,7 @@ public final class WasmRuntime {
|
||||||
value = index.getByte();
|
value = index.getByte();
|
||||||
index = index.add(1);
|
index = index.add(1);
|
||||||
result |= (value & 0x7F) << shift;
|
result |= (value & 0x7F) << shift;
|
||||||
|
shift += 7;
|
||||||
} while ((value & 0x80) != 0);
|
} while ((value & 0x80) != 0);
|
||||||
offset = index;
|
offset = index;
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -66,10 +66,6 @@ public final class Platform {
|
||||||
@PluggableDependency(PlatformGenerator.class)
|
@PluggableDependency(PlatformGenerator.class)
|
||||||
public static native Class<?> asJavaClass(PlatformObject obj);
|
public static native Class<?> asJavaClass(PlatformObject obj);
|
||||||
|
|
||||||
public static PlatformPrimitives getPrimitives() {
|
|
||||||
return (PlatformPrimitives) Window.current();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static PlatformConsole getConsole() {
|
public static PlatformConsole getConsole() {
|
||||||
return (PlatformConsole) Window.current();
|
return (PlatformConsole) Window.current();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,39 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2015 Alexey Andreev.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.teavm.platform;
|
|
||||||
|
|
||||||
import org.teavm.jso.JSMethod;
|
|
||||||
import org.teavm.jso.JSObject;
|
|
||||||
|
|
||||||
public interface PlatformPrimitives extends JSObject {
|
|
||||||
@JSMethod("$rt_booleancls")
|
|
||||||
PlatformClass getBooleanClass();
|
|
||||||
|
|
||||||
@JSMethod("$rt_bytecls")
|
|
||||||
PlatformClass getByteClass();
|
|
||||||
|
|
||||||
@JSMethod("$rt_shortcls")
|
|
||||||
PlatformClass getShortClass();
|
|
||||||
|
|
||||||
@JSMethod("$rt_longcls")
|
|
||||||
PlatformClass getLongClass();
|
|
||||||
|
|
||||||
@JSMethod("$rt_floatcls")
|
|
||||||
PlatformClass getFloatClass();
|
|
||||||
|
|
||||||
@JSMethod("$rt_doublecls")
|
|
||||||
PlatformClass getDoubleClass();
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user