Don't load source files twice
All checks were successful
Build and Test with Maven / Build-and-test-with-Maven (push) Successful in 2m51s

This commit is contained in:
Daniel Holle 2024-04-27 23:08:15 +02:00
parent b774281cbb
commit cba35a4bec

View File

@ -666,6 +666,7 @@ public class JavaTXCompiler {
public final Map<JavaClassName, ClassEntry> loadedClasses = new HashMap<>(); public final Map<JavaClassName, ClassEntry> loadedClasses = new HashMap<>();
private SourceFile parse(File sourceFile) throws IOException, java.lang.ClassNotFoundException { private SourceFile parse(File sourceFile) throws IOException, java.lang.ClassNotFoundException {
if (sourceFiles.containsKey(sourceFile)) return sourceFiles.get(sourceFile);
SourceFileContext tree = JavaTXParser.parse(sourceFile); SourceFileContext tree = JavaTXParser.parse(sourceFile);
environment.addClassesToRegistry(classRegistry, tree, sourceFile, this); environment.addClassesToRegistry(classRegistry, tree, sourceFile, this);
SyntaxTreeGenerator generator = new SyntaxTreeGenerator(this, classRegistry, new GenericsRegistry(null), sourceFile.getName()); SyntaxTreeGenerator generator = new SyntaxTreeGenerator(this, classRegistry, new GenericsRegistry(null), sourceFile.getName());
@ -740,7 +741,9 @@ public class JavaTXCompiler {
var sf = sourceFiles.get(sourceFile); var sf = sourceFiles.get(sourceFile);
if (sf.isGenerated()) return null; if (sf.isGenerated()) return null;
List<ResultSet> typeinferenceResult = this.typeInference(sourceFile); List<ResultSet> typeinferenceResult = this.typeInference(sourceFile);
return generateBytecode(sf, typeinferenceResult); var classes = generateBytecode(sf, typeinferenceResult);
sf.setGenerated();
return classes;
} }
private Map<SourceFile, List<GenericsResult>> generatedGenerics = new HashMap<>(); private Map<SourceFile, List<GenericsResult>> generatedGenerics = new HashMap<>();