mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 08:14:09 -08:00
wasm gc: implement flags for classes
This commit is contained in:
parent
bfd2c8479c
commit
845523f1a7
|
@ -88,6 +88,7 @@ import org.teavm.model.analysis.ClassInitializerInfo;
|
||||||
import org.teavm.model.analysis.ClassMetadataRequirements;
|
import org.teavm.model.analysis.ClassMetadataRequirements;
|
||||||
import org.teavm.model.classes.TagRegistry;
|
import org.teavm.model.classes.TagRegistry;
|
||||||
import org.teavm.model.util.ReflectionUtil;
|
import org.teavm.model.util.ReflectionUtil;
|
||||||
|
import org.teavm.runtime.RuntimeClass;
|
||||||
|
|
||||||
public class WasmGCClassGenerator implements WasmGCClassInfoProvider, WasmGCInitializerContributor {
|
public class WasmGCClassGenerator implements WasmGCClassInfoProvider, WasmGCInitializerContributor {
|
||||||
private static final MethodDescriptor CLINIT_METHOD_DESC = new MethodDescriptor("<clinit>", ValueType.VOID);
|
private static final MethodDescriptor CLINIT_METHOD_DESC = new MethodDescriptor("<clinit>", ValueType.VOID);
|
||||||
|
@ -504,6 +505,7 @@ public class WasmGCClassGenerator implements WasmGCClassInfoProvider, WasmGCInit
|
||||||
target.add(setClassField(classInfo, classNameOffset, new WasmGetGlobal(namePtr)));
|
target.add(setClassField(classInfo, classNameOffset, new WasmGetGlobal(namePtr)));
|
||||||
}
|
}
|
||||||
if (cls != null) {
|
if (cls != null) {
|
||||||
|
target.add(setClassField(classInfo, classFlagsOffset, new WasmInt32Constant(getFlags(cls))));
|
||||||
if (metadataReq.simpleName() && cls.getSimpleName() != null) {
|
if (metadataReq.simpleName() && cls.getSimpleName() != null) {
|
||||||
var namePtr = strings.getStringConstant(cls.getSimpleName()).global;
|
var namePtr = strings.getStringConstant(cls.getSimpleName()).global;
|
||||||
target.add(setClassField(classInfo, classSimpleNameOffset, new WasmGetGlobal(namePtr)));
|
target.add(setClassField(classInfo, classSimpleNameOffset, new WasmGetGlobal(namePtr)));
|
||||||
|
@ -547,6 +549,29 @@ public class WasmGCClassGenerator implements WasmGCClassInfoProvider, WasmGCInit
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int getFlags(ClassReader cls) {
|
||||||
|
var flags = 0;
|
||||||
|
if (cls.hasModifier(ElementModifier.ABSTRACT)) {
|
||||||
|
flags |= WasmGCClassFlags.ABSTRACT;
|
||||||
|
}
|
||||||
|
if (cls.hasModifier(ElementModifier.INTERFACE)) {
|
||||||
|
flags |= WasmGCClassFlags.INTERFACE;
|
||||||
|
}
|
||||||
|
if (cls.hasModifier(ElementModifier.FINAL)) {
|
||||||
|
flags |= WasmGCClassFlags.FINAL;
|
||||||
|
}
|
||||||
|
if (cls.hasModifier(ElementModifier.ANNOTATION)) {
|
||||||
|
flags |= WasmGCClassFlags.ANNOTATION;
|
||||||
|
}
|
||||||
|
if (cls.hasModifier(ElementModifier.SYNTHETIC)) {
|
||||||
|
flags |= WasmGCClassFlags.SYNTHETIC;
|
||||||
|
}
|
||||||
|
if (cls.hasModifier(ElementModifier.ENUM)) {
|
||||||
|
flags |= WasmGCClassFlags.ENUM;
|
||||||
|
}
|
||||||
|
return flags;
|
||||||
|
}
|
||||||
|
|
||||||
private WasmFunction generateCloneFunction(WasmGCClassInfo classInfo, String className) {
|
private WasmFunction generateCloneFunction(WasmGCClassInfo classInfo, String className) {
|
||||||
var function = new WasmFunction(functionTypes.of(standardClasses.objectClass().getType(),
|
var function = new WasmFunction(functionTypes.of(standardClasses.objectClass().getType(),
|
||||||
standardClasses.objectClass().getType()));
|
standardClasses.objectClass().getType()));
|
||||||
|
|
Loading…
Reference in New Issue
Block a user