mirror of
https://github.com/konsoletyper/teavm.git
synced 2024-11-21 01:00:54 +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.generate.BufferedCodeWriter;
|
||||
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.GenerationContext;
|
||||
import org.teavm.backend.c.generate.NameProvider;
|
||||
@ -416,7 +417,9 @@ public class CTarget implements TeaVMTarget, TeaVMCHost {
|
||||
private void generateVirtualTableHeaders(GenerationContext context, CodeWriter writer,
|
||||
Set<? extends ValueType> types) {
|
||||
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) {
|
||||
if (!ClassGenerator.needsVirtualTable(context.getCharacteristics(), type)) {
|
||||
@ -430,8 +433,9 @@ public class CTarget implements TeaVMTarget, TeaVMCHost {
|
||||
|
||||
private void generateStringPoolHeaders(GenerationContext context, CodeWriter writer) {
|
||||
String stringClassName = context.getNames().forClassInstance(ValueType.object("java.lang.String"));
|
||||
writer.println("int32_t stringHeader = PACK_CLASS(&" + stringClassName + ") | "
|
||||
+ RuntimeObject.GC_MARKED + ";");
|
||||
writer.print("int32_t stringHeader = PACK_CLASS(&" + stringClassName + ") | ");
|
||||
CodeGeneratorUtil.writeValue(writer, context, RuntimeObject.GC_MARKED);
|
||||
writer.println(";");
|
||||
|
||||
int size = context.getStringPool().getStrings().size();
|
||||
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 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 }, \
|
||||
.data = s \
|
||||
}, \
|
||||
@ -89,7 +89,7 @@ static inline void* checkcast(void*, int32_t (*)(JavaClass*));
|
||||
}
|
||||
|
||||
#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 }, \
|
||||
.data = { __VA_ARGS__ } \
|
||||
}, \
|
||||
|
@ -92,14 +92,7 @@ class CRunStrategy implements TestRunStrategy {
|
||||
throws IOException, InterruptedException {
|
||||
String[] parts = compilerCommand.split(" +");
|
||||
for (int i = 0; i < parts.length; ++i) {
|
||||
switch (parts[i]) {
|
||||
case "@IN":
|
||||
parts[i] = inputFile.getPath();
|
||||
break;
|
||||
case "@OUT":
|
||||
parts[i] = outputFile.getPath();
|
||||
break;
|
||||
}
|
||||
parts[i] = parts[i].replace("@IN", inputFile.getPath()).replace("@OUT", outputFile.getPath());
|
||||
}
|
||||
return runProcess(new ProcessBuilder(parts).start(), output);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user