Bytecode-Generierung generiert jetzt wieder Bytecode für alle möglichen Typen.

This commit is contained in:
Michael Uhl 2019-04-27 16:28:29 +02:00
parent 0d32704d32
commit 9acf2c0ed5

View File

@ -52,6 +52,7 @@ public class Typinferenz {
private JavaTXCompiler compiler; private JavaTXCompiler compiler;
private List<ResultSet> tiResults; private List<ResultSet> tiResults;
private Set<ResultSet> forByteCode = new HashSet<>();
public Typinferenz(JavEditor forEditor) { public Typinferenz(JavEditor forEditor) {
this.editor = forEditor; this.editor = forEditor;
@ -99,6 +100,8 @@ public class Typinferenz {
public Vector<TypeReplaceMarker> updateWithResult(Vector<TypeReplaceMarker> ret, List<ResultSet> newResults) { public Vector<TypeReplaceMarker> updateWithResult(Vector<TypeReplaceMarker> ret, List<ResultSet> newResults) {
this.tiResults.addAll(newResults); this.tiResults.addAll(newResults);
this.forByteCode.addAll(newResults);
Set<TypeInsert> tips = new HashSet<>(); Set<TypeInsert> tips = new HashSet<>();
for (ResultSet tiResult : newResults) { for (ResultSet tiResult : newResults) {
tips.addAll(TypeInsertFactory.createTypeInsertPoints(parsedSource, tiResult)); tips.addAll(TypeInsertFactory.createTypeInsertPoints(parsedSource, tiResult));
@ -115,9 +118,10 @@ public class Typinferenz {
String outputDirectory = editor.getFilePath().toString(); String outputDirectory = editor.getFilePath().toString();
outputDirectory = outputDirectory.substring(0, outputDirectory = outputDirectory.substring(0,
outputDirectory.length() - editor.getFilePath().lastSegment().length());// ".jav" hat Länge 4 outputDirectory.length() - editor.getFilePath().lastSegment().length());// ".jav" hat Länge 4
if (newResults.size() > 0) {
if (this.forByteCode.size() > 0) {
for (SourceFile sf : compiler.sourceFiles.values()) { for (SourceFile sf : compiler.sourceFiles.values()) {
HashMap<String, byte[]> bytecode = getBytecode(sf, this.tiResults, outputDirectory); HashMap<String, byte[]> bytecode = getBytecode(sf, this.forByteCode, outputDirectory);
this.writeClassFile(outputDirectory, bytecode); this.writeClassFile(outputDirectory, bytecode);
} }
} }
@ -152,9 +156,9 @@ public class Typinferenz {
return ret; return ret;
} }
public HashMap<String, byte[]> getBytecode(SourceFile sf, Collection<ResultSet> resultSets, String path) { public synchronized HashMap<String, byte[]> getBytecode(SourceFile sf, Collection<ResultSet> resultSets, String path) {
HashMap<String, byte[]> classFiles = new HashMap<>(); HashMap<String, byte[]> classFiles = new HashMap<>();
BytecodeGen bytecodeGen = new BytecodeGen(classFiles, new ArrayList<>(this.tiResults), sf, path); BytecodeGen bytecodeGen = new BytecodeGen(classFiles, resultSets, sf, path);
bytecodeGen.visit(sf); bytecodeGen.visit(sf);
return bytecodeGen.getClassFiles(); return bytecodeGen.getClassFiles();
} }