mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 08:14:09 -08:00
Small improvements
This commit is contained in:
parent
68f9376242
commit
7782f1edb7
|
@ -30,6 +30,7 @@ public class JCLPlugin implements JavascriptBuilderPlugin {
|
|||
public void install(JavascriptBuilderHost host) {
|
||||
host.add(new EnumDependencySupport());
|
||||
host.add(new EnumTransformer());
|
||||
host.add(new ClassLookupDependencySupport());
|
||||
host.add(new NewInstanceDependencySupport());
|
||||
ServiceLoaderSupport serviceLoaderSupp = new ServiceLoaderSupport(host.getClassLoader());
|
||||
host.add(serviceLoaderSupp);
|
||||
|
|
|
@ -53,10 +53,14 @@ public class TDouble extends TNumber {
|
|||
return new TDouble(d);
|
||||
}
|
||||
|
||||
public static TString toString(double d) {
|
||||
return TString.wrap(new TStringBuilder().append(d).toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Rename("toString")
|
||||
public TString toString0() {
|
||||
return TString.wrap(new TStringBuilder().append(value).toString());
|
||||
return toString(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -16,12 +16,61 @@
|
|||
package org.teavm.classlib.java.lang;
|
||||
|
||||
import org.teavm.javascript.ni.GeneratedBy;
|
||||
import org.teavm.javascript.ni.Rename;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Alexey Andreev
|
||||
*/
|
||||
public class TFloat {
|
||||
public class TFloat extends TNumber {
|
||||
private float value;
|
||||
|
||||
public TFloat(float value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int intValue() {
|
||||
return (int)value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long longValue() {
|
||||
return (long)value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float floatValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double doubleValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public static TFloat valueOf(float d) {
|
||||
return new TFloat(d);
|
||||
}
|
||||
|
||||
public static TString toString(float d) {
|
||||
return TString.wrap(new TStringBuilder().append(d).toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Rename("toString")
|
||||
public TString toString0() {
|
||||
return toString(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(TObject other) {
|
||||
if (this == other) {
|
||||
return true;
|
||||
}
|
||||
return other instanceof TFloat && ((TFloat)other).value == value;
|
||||
}
|
||||
|
||||
@GeneratedBy(FloatNativeGenerator.class)
|
||||
public static native boolean isNaN(float v);
|
||||
|
||||
|
|
|
@ -52,10 +52,14 @@ public class TLong extends TNumber {
|
|||
return value;
|
||||
}
|
||||
|
||||
public TString toString(long value) {
|
||||
return TString.wrap(new TStringBuilder().append(value).toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Rename("toString")
|
||||
public TString toString0() {
|
||||
return TString.wrap(new TStringBuilder().append(value).toString());
|
||||
return toString(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -168,7 +168,7 @@ public class DependencyChecker implements DependencyInfo {
|
|||
return methodCache.map(methodRef);
|
||||
}
|
||||
|
||||
public void initClass(String className, DependencyStack stack) {
|
||||
public void initClass(String className, final DependencyStack stack) {
|
||||
classStacks.putIfAbsent(className, stack);
|
||||
MethodDescriptor clinitDesc = new MethodDescriptor("<clinit>", ValueType.VOID);
|
||||
while (className != null) {
|
||||
|
@ -183,8 +183,12 @@ public class DependencyChecker implements DependencyInfo {
|
|||
return;
|
||||
}
|
||||
if (cls.getMethod(clinitDesc) != null) {
|
||||
MethodReference methodRef = new MethodReference(className, clinitDesc);
|
||||
linkMethod(methodRef, new DependencyStack(methodRef, stack)).use();
|
||||
final MethodReference methodRef = new MethodReference(className, clinitDesc);
|
||||
executor.executeFast(new Runnable() {
|
||||
@Override public void run() {
|
||||
linkMethod(methodRef, new DependencyStack(methodRef, stack)).use();
|
||||
}
|
||||
});
|
||||
}
|
||||
className = cls.getParent();
|
||||
}
|
||||
|
|
|
@ -307,6 +307,7 @@ class DependencyGraphBuilder {
|
|||
FieldDependency fieldDep = dependencyChecker.linkField(field, callerStack);
|
||||
DependencyNode receiverNode = nodes[receiver.getIndex()];
|
||||
fieldDep.getValue().connect(receiverNode);
|
||||
initClass(field.getClassName());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -314,6 +315,7 @@ class DependencyGraphBuilder {
|
|||
FieldDependency fieldDep = dependencyChecker.linkField(field, callerStack);
|
||||
DependencyNode valueNode = nodes[value.getIndex()];
|
||||
valueNode.connect(fieldDep.getValue());
|
||||
initClass(field.getClassName());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -387,6 +389,7 @@ class DependencyGraphBuilder {
|
|||
if (methodDep.getResult() != null && receiver != null) {
|
||||
methodDep.getResult().connect(nodes[receiver.getIndex()]);
|
||||
}
|
||||
initClass(method.getClassName());
|
||||
}
|
||||
|
||||
private void invokeVirtual(VariableReader receiver, VariableReader instance, MethodReference method,
|
||||
|
@ -412,8 +415,12 @@ class DependencyGraphBuilder {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void initClass(String className) {
|
||||
dependencyChecker.initClass(className, callerStack);
|
||||
public void initClass(final String className) {
|
||||
useRunners.add(new Runnable() {
|
||||
@Override public void run() {
|
||||
dependencyChecker.initClass(className, callerStack);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -101,6 +101,7 @@ public class JavascriptBuilder implements JavascriptBuilderHost {
|
|||
}
|
||||
JavascriptEntryPoint entryPoint = new JavascriptEntryPoint(name, ref,
|
||||
dependencyChecker.linkMethod(ref, DependencyStack.ROOT));
|
||||
dependencyChecker.initClass(ref.getClassName(), DependencyStack.ROOT);
|
||||
entryPoints.put(name, entryPoint);
|
||||
return entryPoint;
|
||||
}
|
||||
|
@ -110,6 +111,7 @@ public class JavascriptBuilder implements JavascriptBuilderHost {
|
|||
throw new IllegalArgumentException("Class with public name `" + name + "' already defined for class " +
|
||||
className);
|
||||
}
|
||||
dependencyChecker.initClass(className, DependencyStack.ROOT);
|
||||
exportedClasses.put(name, className);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user