Compare commits

...

10 Commits

Author SHA1 Message Date
pl@gohorb.ba-horb.de
a84d1ffdd7 modified: ../src/main/java/de/dhbwstuttgart/core/JavaTXCompiler.java
Resultmodell aktiviert
	modified:   ../src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java
a < void und void < a => a = void.
2023-11-08 18:28:54 +01:00
pl@gohorb.ba-horb.de
a3d63a0266 modified: ../src/main/java/de/dhbwstuttgart/core/JavaTXCompiler.java
modified:   ../src/test/java/TestComplete.java
2023-11-08 18:10:56 +01:00
pl@gohorb.ba-horb.de
dcc2da85c5 Merge branch 'targetBytecode' of ssh://gohorb.ba-horb.de/bahome/projekt/git/JavaCompilerCore into targetBytecode 2023-11-07 00:13:53 +01:00
pl@gohorb.ba-horb.de
6f193b19ab modified: src/main/java/de/dhbwstuttgart/parser/SyntaxTreeGenerator/SyntaxTreeGenerator.java
modified:   src/test/java/TestComplete.java
2023-11-07 00:13:43 +01:00
1c55954e5c Merge branch 'targetBytecode' of ssh://gohorb.ba-horb.de:/bahome/projekt/git/JavaCompilerCore into targetBytecode 2023-11-06 12:31:27 +01:00
ec04f01a10 Allow relative paths by getting the absolute file (seriously Java) 2023-11-06 12:30:42 +01:00
pl@gohorb.ba-horb.de
78a2fddc21 modified: ../../../../../resources/bytecode/javFiles/Cycle.class 2023-11-03 20:30:22 +01:00
pl@gohorb.ba-horb.de
44f8899157 Merge branch 'targetBytecode' of gohorb.ba-horb.de:/bahome/projekt/git/JavaCompilerCore into targetBytecode 2023-11-03 20:26:41 +01:00
pl@gohorb.ba-horb.de
d1a6dcbbac modified: core/JavaTXCompiler.java
modified:   typeinference/constraints/ConstraintSet.java
	modified:   typeinference/unify/TypeUnifyTask.java
2023-11-03 20:25:17 +01:00
pl@gohorb.ba-horb.de
15150fca9e modified: ../../../src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java 2023-11-03 18:56:31 +01:00
7 changed files with 32 additions and 14 deletions

0
resources/bytecode/javFiles/Cycle.class Executable file → Normal file
View File

View File

@@ -68,10 +68,10 @@ public class JavaTXCompiler {
// public static JavaTXCompiler INSTANCE;
final CompilationEnvironment environment;
Boolean resultmodel = false;
Boolean resultmodel = true;
public final Map<File, SourceFile> sourceFiles = new HashMap<>();
Boolean log = true; //gibt an ob ein Log-File nach System.getProperty("user.dir")+""/logFiles/"" geschrieben werden soll?
Boolean log = false; //gibt an ob ein Log-File nach System.getProperty("user.dir")+""/logFiles/"" geschrieben werden soll?
public volatile UnifyTaskModel usedTasks = new UnifyTaskModel();
private final DirectoryClassLoader classLoader;

View File

@@ -75,7 +75,7 @@ public class CompilationEnvironment {
ClassLoader classLoader = compiler.getClassLoader();
List<Class> ret = new ArrayList<>();
// Set classLoader to include default package for this specific source file
File dir = sourceFile.getParentFile();
File dir = sourceFile.getAbsoluteFile().getParentFile();
String dirPath = dir.toString() + "/";
if (packageName.length() > 0)
dirPath = dirPath.substring(0, dirPath.length() - packageName.length() - 1);

View File

@@ -445,6 +445,9 @@ public class SyntaxTreeGenerator {
MethodblockContext methodblock = (MethodblockContext) body;
block = stmtgen.convert(methodblock.block(), true);
}
else {
modifiers += Modifier.ABSTRACT;
}
return new Method(modifiers, name, retType, paramlist, block, gtvDeclarations, bodydeclaration.getStart());
}

View File

@@ -75,11 +75,12 @@ public class ConstraintSet<A> {
Constraint<B> newConst = as.stream()
.map(o)
.collect(Collectors.toCollection((as.getExtendConstraint() != null)
? () -> new Constraint<B> (as.isInherited(),
as.getExtendConstraint().stream().map(o).collect(Collectors.toCollection(Constraint::new)),
as.getmethodSignatureConstraint().stream().map(o).collect(Collectors.toCollection(HashSet::new)))
: () -> new Constraint<B> (as.isInherited())
.collect(Collectors.toCollection((
() -> new Constraint<B> (as.isInherited(),
(as.getExtendConstraint() != null)
? as.getExtendConstraint().stream().map(o).collect(Collectors.toCollection(Constraint::new))
: null,
as.getmethodSignatureConstraint().stream().map(o).collect(Collectors.toCollection(HashSet::new))))
));
//CSA2CSB.put(as, newConst);

View File

@@ -668,7 +668,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
.filter(x -> x.size()==1)
.map(y -> y.stream().findFirst().get())
.collect(Collectors.toCollection(HashSet::new)));
oneElems.forEach(x -> { if (x instanceof Constraint) methodSignatureConstraint.addAll(((Constraint<UnifyPair>)x).getmethodSignatureConstraint());});
//optNextSet: Eine mehrelementige Menge, wenn vorhanden
Optional<Set<? extends Set<UnifyPair>>> optNextSet = topLevelSets.stream().filter(x -> x.size()>1).findAny();
@@ -2024,10 +2024,15 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
if (((pairOp == PairOperator.SMALLERDOT) || (pairOp == PairOperator.SMALLERNEQDOT)) && lhsType instanceof PlaceholderType) {
//System.out.println(pair);
if (first) { //writeLog(pair.toString()+"\n");
if (((PlaceholderType)(pair.getLhsType())).getName().equals("AR")) {
System.out.println("AR");
Set<Set<UnifyPair>> x1 = new HashSet<>();
if (pair.getRhsType().getName().equals("void")) {
Set<UnifyPair> resultOne = new HashSet<>();
resultOne.add(new UnifyPair (pair.getLhsType(), pair.getRhsType(), PairOperator.EQUALSDOT, pair.getSubstitution(), pair));
x1.add(resultOne);
}
else {
x1 = unifyCase1(pair, fc);
}
Set<Set<UnifyPair>> x1 = unifyCase1(pair, fc);
if (pairOp == PairOperator.SMALLERNEQDOT) {
Set<UnifyPair> remElem = new HashSet<>();
remElem.add(new UnifyPair(pair.getLhsType(), pair.getRhsType(), PairOperator.EQUALSDOT));
@@ -2159,7 +2164,15 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
// Case 5: (Theta <. a)
else if ((pairOp == PairOperator.SMALLERDOT) && rhsType instanceof PlaceholderType)
if (first) { //writeLog(pair.toString()+"\n");
Set<Set<UnifyPair>> x1 = unifyCase5(pair, fc);
Set<Set<UnifyPair>> x1 = new HashSet<>();
if (pair.getLhsType().getName().equals("void")) {
Set<UnifyPair> resultOne = new HashSet<>();
resultOne.add(new UnifyPair (pair.getRhsType(), pair.getLhsType(), PairOperator.EQUALSDOT, pair.getSubstitution(), pair));
x1.add(resultOne);
}
else {
x1 = unifyCase5(pair, fc);
}
result.get(4).add(x1);
if (x1.isEmpty()) {
undefined.add(pair); //Theta ist nicht im FC

View File

@@ -234,6 +234,7 @@ public class TestComplete {
}
@Test
//@Ignore("This is to complex")
public void matrixTest() throws Exception {
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Matrix.jav");
var matrix = classFiles.get("Matrix");
@@ -740,7 +741,7 @@ public class TestComplete {
@Test
public void testLambdaRunnable() throws Exception {
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "LambdaRunnable.jav");
var clazz = classFiles.get("LamRunnable");
var clazz = classFiles.get("LambdaRunnable");
var instance = clazz.getDeclaredConstructor().newInstance();
//var m = clazz.getDeclaredMethod("m", Integer.class);
//assertEquals(m.invoke(instance, 10), 60);