41 lines
1.5 KiB
Java
41 lines
1.5 KiB
Java
import de.dhbwstuttgart.core.JavaTXCompiler;
|
|
import de.dhbwstuttgart.parser.scope.JavaClassName;
|
|
import de.dhbwstuttgart.syntaxtree.SourceFile;
|
|
import de.dhbwstuttgart.typedeployment.TypeInsert;
|
|
import de.dhbwstuttgart.typedeployment.TypeInsertFactory;
|
|
import de.dhbwstuttgart.typeinference.result.ResultSet;
|
|
import org.junit.Test;
|
|
|
|
import java.io.File;
|
|
import java.nio.file.Path;
|
|
import java.util.HashSet;
|
|
import java.util.Map;
|
|
import java.util.Set;
|
|
|
|
public class TestTypeDeployment {
|
|
|
|
@Test
|
|
public void testTypeDeployment() throws Exception {
|
|
var path = Path.of(System.getProperty("user.dir"), "/resources/bytecode/javFiles/Cycle.jav");
|
|
var file = path.toFile();
|
|
var compiler = new JavaTXCompiler(file, false);
|
|
var parsedSource = compiler.sourceFiles.get(file);
|
|
var tiResults = compiler.typeInference(file);
|
|
Set<TypeInsert> tips = new HashSet<>();
|
|
|
|
for (var sf : compiler.sourceFiles.values()) {
|
|
Map<JavaClassName, byte[]> bytecode = compiler.generateBytecode(sf, tiResults);
|
|
}
|
|
|
|
System.out.println(compiler.getGeneratedGenerics());
|
|
|
|
for (int i = 0; i < tiResults.size(); i++) {
|
|
ResultSet tiResult = tiResults.get(i);
|
|
tips.addAll(TypeInsertFactory.createTypeInsertPoints(parsedSource, tiResult, compiler.getGeneratedGenerics().get(compiler.sourceFiles.get(file)).get(i)));
|
|
for (TypeInsert p : tips) {
|
|
System.out.println(p);
|
|
}
|
|
}
|
|
}
|
|
}
|