mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-31 12:24:10 -08:00
C backend: few fixes for MVSC
This commit is contained in:
parent
76ca3f06cf
commit
4d8f33d994
|
@ -35,6 +35,7 @@ import org.teavm.ast.decompilation.Decompiler;
|
||||||
import org.teavm.backend.c.analyze.CDependencyListener;
|
import org.teavm.backend.c.analyze.CDependencyListener;
|
||||||
import org.teavm.backend.c.generate.BufferedCodeWriter;
|
import org.teavm.backend.c.generate.BufferedCodeWriter;
|
||||||
import org.teavm.backend.c.generate.ClassGenerator;
|
import org.teavm.backend.c.generate.ClassGenerator;
|
||||||
|
import org.teavm.backend.c.generate.CodeGeneratorUtil;
|
||||||
import org.teavm.backend.c.generate.CodeWriter;
|
import org.teavm.backend.c.generate.CodeWriter;
|
||||||
import org.teavm.backend.c.generate.GenerationContext;
|
import org.teavm.backend.c.generate.GenerationContext;
|
||||||
import org.teavm.backend.c.generate.NameProvider;
|
import org.teavm.backend.c.generate.NameProvider;
|
||||||
|
@ -416,7 +417,9 @@ public class CTarget implements TeaVMTarget, TeaVMCHost {
|
||||||
private void generateVirtualTableHeaders(GenerationContext context, CodeWriter writer,
|
private void generateVirtualTableHeaders(GenerationContext context, CodeWriter writer,
|
||||||
Set<? extends ValueType> types) {
|
Set<? extends ValueType> types) {
|
||||||
String classClassName = context.getNames().forClassInstance(ValueType.object("java.lang.Class"));
|
String classClassName = context.getNames().forClassInstance(ValueType.object("java.lang.Class"));
|
||||||
writer.println("int32_t classHeader = PACK_CLASS(&" + classClassName + ") | " + RuntimeObject.GC_MARKED + ";");
|
writer.print("int32_t classHeader = PACK_CLASS(&" + classClassName + ") | ");
|
||||||
|
CodeGeneratorUtil.writeValue(writer, context, RuntimeObject.GC_MARKED);
|
||||||
|
writer.println(";");
|
||||||
|
|
||||||
for (ValueType type : types) {
|
for (ValueType type : types) {
|
||||||
if (!ClassGenerator.needsVirtualTable(context.getCharacteristics(), type)) {
|
if (!ClassGenerator.needsVirtualTable(context.getCharacteristics(), type)) {
|
||||||
|
@ -430,8 +433,9 @@ public class CTarget implements TeaVMTarget, TeaVMCHost {
|
||||||
|
|
||||||
private void generateStringPoolHeaders(GenerationContext context, CodeWriter writer) {
|
private void generateStringPoolHeaders(GenerationContext context, CodeWriter writer) {
|
||||||
String stringClassName = context.getNames().forClassInstance(ValueType.object("java.lang.String"));
|
String stringClassName = context.getNames().forClassInstance(ValueType.object("java.lang.String"));
|
||||||
writer.println("int32_t stringHeader = PACK_CLASS(&" + stringClassName + ") | "
|
writer.print("int32_t stringHeader = PACK_CLASS(&" + stringClassName + ") | ");
|
||||||
+ RuntimeObject.GC_MARKED + ";");
|
CodeGeneratorUtil.writeValue(writer, context, RuntimeObject.GC_MARKED);
|
||||||
|
writer.println(";");
|
||||||
|
|
||||||
int size = context.getStringPool().getStrings().size();
|
int size = context.getStringPool().getStrings().size();
|
||||||
writer.println("for (int i = 0; i < " + size + "; ++i) {").indent();
|
writer.println("for (int i = 0; i < " + size + "; ++i) {").indent();
|
||||||
|
|
|
@ -81,7 +81,7 @@ static inline void* checkcast(void*, int32_t (*)(JavaClass*));
|
||||||
#define STRUCTURE_ADD(structure, address, offset) (((structure*) (address)) + offset)
|
#define STRUCTURE_ADD(structure, address, offset) (((structure*) (address)) + offset)
|
||||||
|
|
||||||
#define TEAVM_STRING(length, hash, s) { \
|
#define TEAVM_STRING(length, hash, s) { \
|
||||||
.characters = (JavaArray*) & (struct { JavaArray hdr; char16_t data[length]; }) { \
|
.characters = (JavaArray*) & (struct { JavaArray hdr; char16_t data[(length) + 1]; }) { \
|
||||||
.hdr = { .size = length }, \
|
.hdr = { .size = length }, \
|
||||||
.data = s \
|
.data = s \
|
||||||
}, \
|
}, \
|
||||||
|
@ -89,7 +89,7 @@ static inline void* checkcast(void*, int32_t (*)(JavaClass*));
|
||||||
}
|
}
|
||||||
|
|
||||||
#define TEAVM_STRING_FROM_CODES(length, hash, ...) { \
|
#define TEAVM_STRING_FROM_CODES(length, hash, ...) { \
|
||||||
.characters = (JavaArray*) & (struct { JavaArray hdr; char16_t data[length]; }) { \
|
.characters = (JavaArray*) & (struct { JavaArray hdr; char16_t data[(length) + 1]; }) { \
|
||||||
.hdr = { .size = length }, \
|
.hdr = { .size = length }, \
|
||||||
.data = { __VA_ARGS__ } \
|
.data = { __VA_ARGS__ } \
|
||||||
}, \
|
}, \
|
||||||
|
|
|
@ -92,14 +92,7 @@ class CRunStrategy implements TestRunStrategy {
|
||||||
throws IOException, InterruptedException {
|
throws IOException, InterruptedException {
|
||||||
String[] parts = compilerCommand.split(" +");
|
String[] parts = compilerCommand.split(" +");
|
||||||
for (int i = 0; i < parts.length; ++i) {
|
for (int i = 0; i < parts.length; ++i) {
|
||||||
switch (parts[i]) {
|
parts[i] = parts[i].replace("@IN", inputFile.getPath()).replace("@OUT", outputFile.getPath());
|
||||||
case "@IN":
|
|
||||||
parts[i] = inputFile.getPath();
|
|
||||||
break;
|
|
||||||
case "@OUT":
|
|
||||||
parts[i] = outputFile.getPath();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return runProcess(new ProcessBuilder(parts).start(), output);
|
return runProcess(new ProcessBuilder(parts).start(), output);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user