Fix type deployment

This commit is contained in:
Daniel Holle 2023-05-16 13:31:05 +02:00
parent a7ccd15286
commit 136bccab93
3 changed files with 46 additions and 6 deletions

View File

@ -54,8 +54,8 @@ http://maven.apache.org/maven-v4_0_0.xsd">
<version>3.8.0</version>
<configuration>
<compilerArgs>--enable-preview</compilerArgs>
<source>20</source>
<target>20</target>
<source>19</source>
<target>19</target>
</configuration>
</plugin>
<plugin>
@ -112,8 +112,8 @@ http://maven.apache.org/maven-v4_0_0.xsd">
</repository>
</repositories>
<properties>
<maven.compiler.source>20</maven.compiler.source>
<maven.compiler.target>20</maven.compiler.target>
<maven.compiler.source>19</maven.compiler.source>
<maven.compiler.target>19</maven.compiler.target>
<mainClass>de.dhbwstuttgart.core.ConsoleInterface</mainClass>
</properties>
<distributionManagement>

View File

@ -55,8 +55,8 @@ class TypeInsertPlacerClass extends AbstractASTWalker{
@Override
public void visit(Method method) {
this.method = method;
//constraints = generatedGenerics.getMethodConstraintsByID(id);
classConstraints = generatedGenerics.get(method);
constraints = generatedGenerics.get(method);
classConstraints = generatedGenerics.get(cl);
if(method.getReturnType() instanceof TypePlaceholder)
inserts.add(TypeInsertFactory.createInsertPoints(
method.getReturnType(), method.getReturnType().getOffset(), cl, method, results, constraints, classConstraints));

View File

@ -0,0 +1,40 @@
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();
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);
}
}
}
}