C: further workaround for msvc bug

This commit is contained in:
Alexey Andreev 2020-05-19 09:56:47 +03:00
parent 8f68c64193
commit eebe16157b

View File

@ -562,7 +562,7 @@ public class ClassGenerator {
if (classLayout != null) { if (classLayout != null) {
codeWriter.println("static int16_t teavm_classLayouts_" + name + "[" + (classLayout.length + 1) + "];"); codeWriter.println("static int16_t teavm_classLayouts_" + name + "[" + (classLayout.length + 1) + "];");
} }
codeWriter.print("alignas(8) ").print(structName).print(" ").print(name).println(" = {").indent(); codeWriter.print("alignas(8) ").print(structName).print(" ").print(name);
if (className != null) { if (className != null) {
if (context.isIncremental()) { if (context.isIncremental()) {
@ -570,25 +570,35 @@ public class ClassGenerator {
} else { } else {
VirtualTable virtualTable = context.getVirtualTableProvider().lookup(className); VirtualTable virtualTable = context.getVirtualTableProvider().lookup(className);
if (cls.hasModifier(ElementModifier.INTERFACE)) { if (cls.hasModifier(ElementModifier.INTERFACE)) {
codeWriter.println(" = {").indent();
generateRuntimeClassInitializer(type, enumConstants, false, 0); generateRuntimeClassInitializer(type, enumConstants, false, 0);
codeWriter.outdent().print("}");
} else if (virtualTable != null) { } else if (virtualTable != null) {
boolean tooDeep = getInheritanceDepth(className) > VT_STRUCTURE_INITIALIZER_DEPTH_THRESHOLD; boolean tooDeep = getInheritanceDepth(className) > VT_STRUCTURE_INITIALIZER_DEPTH_THRESHOLD;
if (tooDeep) { if (tooDeep) {
codeWriter.println("0");
initWriter.print(structName).print("* vt_0 = &").print(name).println(";"); initWriter.print(structName).print("* vt_0 = &").print(name).println(";");
} else {
codeWriter.println(" = {").indent();
} }
generateVirtualTableContent(virtualTable, virtualTable, type, enumConstants, tooDeep, 0); generateVirtualTableContent(virtualTable, virtualTable, type, enumConstants, tooDeep, 0);
if (!tooDeep) {
codeWriter.outdent().print("}");
}
} else { } else {
codeWriter.println(" = {").indent();
codeWriter.println(".parent = {").indent(); codeWriter.println(".parent = {").indent();
generateRuntimeClassInitializer(type, enumConstants, false, 0); generateRuntimeClassInitializer(type, enumConstants, false, 0);
codeWriter.outdent().println("}"); codeWriter.outdent().println("}");
codeWriter.outdent().println("}");
} }
} }
} else { } else {
codeWriter.println(" = {").indent();
generateRuntimeClassInitializer(type, enumConstants, false, 0); generateRuntimeClassInitializer(type, enumConstants, false, 0);
codeWriter.outdent().println("}");
} }
codeWriter.outdent().println("};"); codeWriter.outdent().println(";");
} }
private int getInheritanceDepth(String className) { private int getInheritanceDepth(String className) {