Generic Method inserts.

This commit is contained in:
Michael Uhl 2019-07-26 10:18:50 +02:00
parent 809459f6e9
commit ab664efb6b

View File

@ -24,6 +24,7 @@ import org.eclipse.core.runtime.Status;
import de.dhbwstuttgart.bytecode.BytecodeGen;
import de.dhbwstuttgart.bytecode.Exception.BytecodeGeneratorError;
import de.dhbwstuttgart.bytecode.descriptor.TypeToDescriptor;
import de.dhbwstuttgart.bytecode.utilities.SimplifyResult;
import de.dhbwstuttgart.core.JavaTXCompiler;
import de.dhbwstuttgart.exceptions.TypeinferenceException;
import de.dhbwstuttgart.syntaxtree.SourceFile;
@ -79,6 +80,21 @@ public class Typinferenz {
this.forByteCode.addAll(newResults);
Set<TypeInsert> tips = new HashSet<>();
String outputDirectory = getOutputDirectory();
if (this.forByteCode.size() > 0) {
for (SourceFile sf : compiler.sourceFiles.values()) {
try {
HashMap<String, byte[]> bytecode = getBytecode(sf, this.forByteCode, outputDirectory);
compiler.generateBytecodForFile(outputDirectory, bytecode, sf, new ArrayList<>(forByteCode));
this.writeClassFile(outputDirectory, bytecode);
} catch (BytecodeGeneratorError | IOException ex) {
ErrorMarker toAdd = new ErrorMarker(ex.getMessage(), new CodePoint(sf.getOffset()));
ret.add(toAdd);
}
}
}
for (ResultSet tiResult : newResults) {
tips.addAll(TypeInsertFactory.createTypeInsertPoints(parsedSource, tiResult));
for (TypeInsert p : tips) {
@ -91,19 +107,6 @@ public class Typinferenz {
}
}
String outputDirectory = getOutputDirectory();
if (this.forByteCode.size() > 0) {
for (SourceFile sf : compiler.sourceFiles.values()) {
try {
HashMap<String, byte[]> bytecode = getBytecode(sf, this.forByteCode, outputDirectory);
this.writeClassFile(outputDirectory, bytecode);
} catch (BytecodeGeneratorError ex) {
ErrorMarker toAdd = new ErrorMarker(ex.getMessage(), new CodePoint(sf.getOffset()));
ret.add(toAdd);
}
}
}
return ret;
}
@ -146,6 +149,7 @@ public class Typinferenz {
HashMap<String, byte[]> classFiles = new HashMap<>();
BytecodeGen bytecodeGen = new BytecodeGen(classFiles, resultSets, sf, path);
bytecodeGen.visit(sf);
List<HashMap<String, SimplifyResult>> simplifyResultsList = bytecodeGen.getSimplifyResultsList();
return bytecodeGen.getClassFiles();
}