Don't load source files twice
Some checks failed
Build and Test with Maven / Build-and-test-with-Maven (push) Failing after 2m55s

This commit is contained in:
Vic Nightfall 2024-04-27 22:44:09 +02:00
parent b774281cbb
commit d31eadc277

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<>();