mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2025-01-03 05:44:10 -08:00
C: fix heap dump generator
This commit is contained in:
parent
1fa48560c6
commit
15466bad93
|
@ -920,48 +920,52 @@ public class ClassGenerator {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void generateHeapDumpMetadata(CodeWriter codeWriter, ClassReader cls, boolean initMethod,
|
private void generateHeapDumpMetadata(CodeWriter writer, ClassReader cls, boolean initMethod,
|
||||||
int depth) {
|
int depth) {
|
||||||
List<HeapDumpField> fields = getHeapDumpFields(cls);
|
List<HeapDumpField> fields = getHeapDumpFields(cls);
|
||||||
List<HeapDumpField> staticFields = getHeapDumpStaticFields(cls);
|
List<HeapDumpField> staticFields = getHeapDumpStaticFields(cls);
|
||||||
if (staticFields.isEmpty() && fields.isEmpty()) {
|
if (staticFields.isEmpty() && fields.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
codeWriter.println().println("#if TEAVM_HEAP_DUMP").indent();
|
writer.println().println("#if TEAVM_HEAP_DUMP").indent();
|
||||||
if (!fields.isEmpty()) {
|
if (!fields.isEmpty()) {
|
||||||
|
String structDecl = "struct { uint32_t count; TeaVM_FieldDescriptor data[" + fields.size() + "]; }";
|
||||||
if (initMethod) {
|
if (initMethod) {
|
||||||
codeWriter.print("vt_" + depth + "->");
|
writer.print("static " + structDecl + " fieldDescriptors = ");
|
||||||
} else {
|
} else {
|
||||||
codeWriter.println(",");
|
writer.println(",");
|
||||||
codeWriter.print(".");
|
writer.println(".fieldDescriptors = (TeaVM_FieldDescriptors*) &(" + structDecl + ") ");
|
||||||
}
|
}
|
||||||
|
writer.println("{").indent();
|
||||||
|
|
||||||
|
generateHeapDumpFields(writer, fields);
|
||||||
|
writer.outdent().print("}");
|
||||||
|
|
||||||
codeWriter.println("fieldDescriptors = (TeaVM_FieldDescriptors*) "
|
|
||||||
+ "&(struct { uint32_t count; TeaVM_FieldDescriptor data["
|
|
||||||
+ fields.size() + "]; }) {").indent();
|
|
||||||
generateHeapDumpFields(codeWriter, fields);
|
|
||||||
codeWriter.outdent().print("}");
|
|
||||||
if (initMethod) {
|
if (initMethod) {
|
||||||
codeWriter.println(";");
|
writer.println(";");
|
||||||
|
writer.println("vt_" + depth + "->fieldDescriptors = (TeaVM_FieldDescriptors*) &fieldDescriptors;");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!staticFields.isEmpty()) {
|
if (!staticFields.isEmpty()) {
|
||||||
|
String structDecl = "struct { uint32_t count; TeaVM_StaticFieldDescriptor data["
|
||||||
|
+ staticFields.size() + "]; }";
|
||||||
if (initMethod) {
|
if (initMethod) {
|
||||||
codeWriter.print("vt_" + depth + "->");
|
writer.print("static " + structDecl + " staticFieldDescriptors = ");
|
||||||
} else {
|
} else {
|
||||||
codeWriter.println(",");
|
writer.println(",");
|
||||||
codeWriter.print(".");
|
writer.println(".staticFieldDescriptors = (TeaVM_StaticFieldDescriptors*) &(" + structDecl + ") ");
|
||||||
}
|
}
|
||||||
codeWriter.println("staticFieldDescriptors = (TeaVM_StaticFieldDescriptors*) "
|
writer.println("{").indent();
|
||||||
+ "&(struct { uint32_t count; TeaVM_StaticFieldDescriptor data["
|
generateHeapDumpFields(writer, staticFields);
|
||||||
+ staticFields.size() + "]; }) {").indent();
|
writer.outdent().print("}");
|
||||||
generateHeapDumpFields(codeWriter, staticFields);
|
|
||||||
codeWriter.outdent().print("}");
|
|
||||||
if (initMethod) {
|
if (initMethod) {
|
||||||
codeWriter.println(";");
|
writer.println(";");
|
||||||
|
writer.print("vt_" + depth + "->staticFieldDescriptors = "
|
||||||
|
+ "(TeaVM_StaticFieldDescriptors*) &staticFieldDescriptors;");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
codeWriter.println().outdent().println("#endif");
|
writer.println().outdent().println("#endif");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void generateHeapDumpFields(CodeWriter codeWriter, List<HeapDumpField> fields) {
|
private void generateHeapDumpFields(CodeWriter codeWriter, List<HeapDumpField> fields) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user