forked from JavaTX/JavaCompilerCore
Merge branch 'bytecode2' of ssh://gohorb.ba-horb.de/bahome/projekt/git/JavaCompilerCore into bigRefactoring
This commit is contained in:
commit
01a548215a
14
pom.xml
14
pom.xml
@ -55,6 +55,14 @@ http://maven.apache.org/maven-v4_0_0.xsd">
|
|||||||
<finalName>${project.artifactId}-${project.version}</finalName>
|
<finalName>${project.artifactId}-${project.version}</finalName>
|
||||||
<testOutputDirectory>target/test-classes</testOutputDirectory>
|
<testOutputDirectory>target/test-classes</testOutputDirectory>
|
||||||
<plugins>
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
<version>3.0.0-M3</version>
|
||||||
|
<configuration>
|
||||||
|
<skipTests>true</skipTests>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.antlr</groupId>
|
<groupId>org.antlr</groupId>
|
||||||
<artifactId>antlr4-maven-plugin</artifactId>
|
<artifactId>antlr4-maven-plugin</artifactId>
|
||||||
@ -138,10 +146,6 @@ http://maven.apache.org/maven-v4_0_0.xsd">
|
|||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
<!-- plugin> <groupId>org.eclipse.tycho</groupId> <artifactId>tycho-p2-repository-plugin</artifactId>
|
|
||||||
<version>${tycho.version}</version> <executions> <execution> <phase>package</phase>
|
|
||||||
<goals> <goal>archive-repository</goal> </goals> </execution> </executions>
|
|
||||||
</plugin -->
|
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
<pluginRepositories>
|
<pluginRepositories>
|
||||||
@ -169,5 +173,3 @@ http://maven.apache.org/maven-v4_0_0.xsd">
|
|||||||
</repository>
|
</repository>
|
||||||
</distributionManagement>
|
</distributionManagement>
|
||||||
</project>
|
</project>
|
||||||
|
|
||||||
|
|
||||||
|
@ -147,23 +147,7 @@ public class BytecodeGen implements ASTVisitor {
|
|||||||
if(!tphExtractor.allTPHS.get(t))
|
if(!tphExtractor.allTPHS.get(t))
|
||||||
tphsClass.add(t);
|
tphsClass.add(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayList<TPHConstraint> consClass = new ArrayList<>();
|
|
||||||
for(TPHConstraint cons : tphExtractor.allCons) {
|
|
||||||
TypePlaceholder right = null;
|
|
||||||
for(TypePlaceholder tph : tphsClass) {
|
|
||||||
if(cons.getLeft().equals(tph.getName())) {
|
|
||||||
|
|
||||||
consClass.add(cons);
|
|
||||||
right = getTPH(cons.getRight());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(right != null) {
|
|
||||||
tphsClass.add(right);
|
|
||||||
removeFromMethod(right.getName());
|
|
||||||
right = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
String sig = null;
|
String sig = null;
|
||||||
/* if class has generics then creates signature
|
/* if class has generics then creates signature
|
||||||
* Signature looks like:
|
* Signature looks like:
|
||||||
@ -172,6 +156,23 @@ public class BytecodeGen implements ASTVisitor {
|
|||||||
if(classOrInterface.getGenerics().iterator().hasNext() || !commonPairs.isEmpty() ||
|
if(classOrInterface.getGenerics().iterator().hasNext() || !commonPairs.isEmpty() ||
|
||||||
classOrInterface.getSuperClass().acceptTV(new TypeToSignature()).contains("<")
|
classOrInterface.getSuperClass().acceptTV(new TypeToSignature()).contains("<")
|
||||||
|| !tphsClass.isEmpty()) {
|
|| !tphsClass.isEmpty()) {
|
||||||
|
HashMap<TPHConstraint, HashSet<String>> constraints = Simplify.simplifyConstraintsClass(tphExtractor,tphsClass);
|
||||||
|
ArrayList<TPHConstraint> consClass = new ArrayList<>();
|
||||||
|
for(TPHConstraint cons : constraints.keySet()) {
|
||||||
|
TypePlaceholder right = null;
|
||||||
|
for(TypePlaceholder tph : tphsClass) {
|
||||||
|
if(cons.getLeft().equals(tph.getName())) {
|
||||||
|
|
||||||
|
consClass.add(cons);
|
||||||
|
right = getTPH(cons.getRight());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(right != null) {
|
||||||
|
tphsClass.add(right);
|
||||||
|
removeFromMethod(right.getName());
|
||||||
|
right = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
Signature signature = new Signature(classOrInterface, genericsAndBounds,commonPairs,tphsClass, consClass);
|
Signature signature = new Signature(classOrInterface, genericsAndBounds,commonPairs,tphsClass, consClass);
|
||||||
sig = signature.toString();
|
sig = signature.toString();
|
||||||
System.out.println("Signature: => " + sig);
|
System.out.println("Signature: => " + sig);
|
||||||
|
@ -140,7 +140,8 @@ public class BytecodeGenMethod implements StatementVisitor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public BytecodeGenMethod(LambdaExpression lambdaExpression, ArrayList<String> usedVars, ResultSet resultSet, MethodVisitor mv,
|
public BytecodeGenMethod(LambdaExpression lambdaExpression, ArrayList<String> usedVars, ResultSet resultSet, MethodVisitor mv,
|
||||||
int indexOfFirstParamLam, boolean isInterface, HashMap<String, byte[]> classFiles, String path, int lamCounter, SourceFile sf) {
|
int indexOfFirstParamLam, boolean isInterface, HashMap<String, byte[]> classFiles, String path, int lamCounter, SourceFile sf,HashMap<String, String> genericsAndBoundsMethod,
|
||||||
|
HashMap<String, String> genericsAndBounds) {
|
||||||
|
|
||||||
this.resultSet = resultSet;
|
this.resultSet = resultSet;
|
||||||
this.mv = mv;
|
this.mv = mv;
|
||||||
@ -149,6 +150,9 @@ public class BytecodeGenMethod implements StatementVisitor {
|
|||||||
this.path = path;
|
this.path = path;
|
||||||
this.lamCounter = lamCounter;
|
this.lamCounter = lamCounter;
|
||||||
this.sf = sf;
|
this.sf = sf;
|
||||||
|
this.genericsAndBoundsMethod = genericsAndBoundsMethod;
|
||||||
|
this.genericsAndBounds = genericsAndBounds;
|
||||||
|
|
||||||
Iterator<FormalParameter> itr = lambdaExpression.params.iterator();
|
Iterator<FormalParameter> itr = lambdaExpression.params.iterator();
|
||||||
int i = indexOfFirstParamLam;
|
int i = indexOfFirstParamLam;
|
||||||
|
|
||||||
@ -644,7 +648,8 @@ public class BytecodeGenMethod implements StatementVisitor {
|
|||||||
ArrayList<String> usedVars = kindOfLambda.getUsedVars();
|
ArrayList<String> usedVars = kindOfLambda.getUsedVars();
|
||||||
|
|
||||||
new BytecodeGenMethod(lambdaExpression, usedVars,this.resultSet, mvLambdaBody, indexOfFirstParamLam, isInterface,
|
new BytecodeGenMethod(lambdaExpression, usedVars,this.resultSet, mvLambdaBody, indexOfFirstParamLam, isInterface,
|
||||||
classFiles,this.path, lamCounter, sf);
|
classFiles,this.path, lamCounter, sf, genericsAndBoundsMethod,
|
||||||
|
genericsAndBounds);
|
||||||
|
|
||||||
mvLambdaBody.visitMaxs(0, 0);
|
mvLambdaBody.visitMaxs(0, 0);
|
||||||
mvLambdaBody.visitEnd();
|
mvLambdaBody.visitEnd();
|
||||||
@ -744,6 +749,13 @@ public class BytecodeGenMethod implements StatementVisitor {
|
|||||||
statement = new IfStatement(ifStmt.expr, ifStmt.then_block, ifStmt.else_block);
|
statement = new IfStatement(ifStmt.expr, ifStmt.then_block, ifStmt.else_block);
|
||||||
isBinaryExp = statement.isExprBinary();
|
isBinaryExp = statement.isExprBinary();
|
||||||
ifStmt.expr.accept(this);
|
ifStmt.expr.accept(this);
|
||||||
|
if(!(ifStmt.expr instanceof BinaryExpr)) {
|
||||||
|
doUnboxing(getResolvedType(ifStmt.expr.getType()));
|
||||||
|
Label branchLabel = new Label();
|
||||||
|
Label endLabel = new Label();
|
||||||
|
mv.visitJumpInsn(Opcodes.IFEQ, branchLabel);
|
||||||
|
statement.genBCForRelOp(mv, branchLabel, endLabel, this);
|
||||||
|
}
|
||||||
statement = null;
|
statement = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -758,86 +770,90 @@ public class BytecodeGenMethod implements StatementVisitor {
|
|||||||
System.out.println("In MethodCall = " + methodCall.name);
|
System.out.println("In MethodCall = " + methodCall.name);
|
||||||
String receiverName = getResolvedType(methodCall.receiver.getType());
|
String receiverName = getResolvedType(methodCall.receiver.getType());
|
||||||
System.out.println("Methods of " + receiverName + " ");
|
System.out.println("Methods of " + receiverName + " ");
|
||||||
ClassLoader cLoader = ClassLoader.getSystemClassLoader();
|
|
||||||
// This will be used if the class is not standard class (not in API)
|
|
||||||
ClassLoader cLoader2;
|
|
||||||
java.lang.reflect.Method methodRefl = null;
|
java.lang.reflect.Method methodRefl = null;
|
||||||
String clazz = receiverName.replace("/", ".");
|
String clazz = receiverName.replace("/", ".");
|
||||||
String methCallType = resultSet.resolveType(methodCall.getType()).resolvedType.acceptTV(new TypeToDescriptor());
|
// if(!receiverName.equals(className)) {
|
||||||
String[] typesOfParams = getTypes(methodCall.arglist.getArguments());
|
ClassLoader cLoader = ClassLoader.getSystemClassLoader();
|
||||||
try {
|
// This will be used if the class is not standard class (not in API)
|
||||||
if(receiverName.contains("<")) {
|
ClassLoader cLoader2;
|
||||||
clazz = clazz.substring(0, receiverName.indexOf("<"));
|
|
||||||
}
|
|
||||||
|
|
||||||
java.lang.reflect.Method[] methods = cLoader.loadClass(clazz).getMethods();
|
String methCallType = resultSet.resolveType(methodCall.getType()).resolvedType.acceptTV(new TypeToDescriptor());
|
||||||
System.out.println("Methods of " + receiverName + " ");
|
String[] typesOfParams = getTypes(methodCall.arglist.getArguments());
|
||||||
methodRefl = getMethod(methodCall.name,methodCall.arglist.getArguments().size(),methods);
|
try {
|
||||||
|
if(receiverName.contains("<")) {
|
||||||
} catch (Exception e) {
|
clazz = clazz.substring(0, receiverName.indexOf("<"));
|
||||||
// try {
|
}
|
||||||
// cLoader2 = new URLClassLoader(new URL[] {new URL("file://"+path)});
|
|
||||||
// java.lang.reflect.Method[] methods = cLoader2.loadClass(clazz).getMethods();
|
java.lang.reflect.Method[] methods = cLoader.loadClass(clazz).getMethods();
|
||||||
// System.out.println("Methods of " + receiverName + " ");
|
System.out.println("Methods of " + receiverName + " ");
|
||||||
// for(int i = 0; i<methods.length; i++) {
|
methodRefl = getMethod(methodCall.name,methodCall.arglist.getArguments().size(),methods);
|
||||||
// System.out.println(methods[i]);
|
|
||||||
// }
|
} catch (Exception e) {
|
||||||
// methodRefl = getMethod(methodCall.name,methodCall.arglist.getArguments().size(),methCallType, typesOfParams,methods);
|
// try {
|
||||||
// }catch (Exception e2) {
|
// cLoader2 = new URLClassLoader(new URL[] {new URL("file://"+path)});
|
||||||
String superClass = "";
|
// java.lang.reflect.Method[] methods = cLoader2.loadClass(clazz).getMethods();
|
||||||
// TODO: Test SubMatrix.jav
|
// System.out.println("Methods of " + receiverName + " ");
|
||||||
while(true) {
|
// for(int i = 0; i<methods.length; i++) {
|
||||||
for(ClassOrInterface cl : sf.getClasses()) {
|
// System.out.println(methods[i]);
|
||||||
if(receiverName.equals(cl.getClassName().toString())) {
|
// }
|
||||||
superClass = cl.getSuperClass().getName().toString();
|
// methodRefl = getMethod(methodCall.name,methodCall.arglist.getArguments().size(),methCallType, typesOfParams,methods);
|
||||||
break;
|
// }catch (Exception e2) {
|
||||||
}
|
String superClass = "";
|
||||||
}
|
// TODO: Test SubMatrix.jav
|
||||||
System.out.println(superClass);
|
while(true) {
|
||||||
|
for(ClassOrInterface cl : sf.getClasses()) {
|
||||||
if(superClass.equals(""))
|
if(receiverName.equals(cl.getClassName().toString())) {
|
||||||
break;
|
superClass = cl.getSuperClass().getName().toString();
|
||||||
|
|
||||||
try {
|
|
||||||
String superClazz = superClass.replace("/", ".");
|
|
||||||
if(superClass.contains("<")) {
|
|
||||||
superClazz = superClazz.substring(0, superClass.indexOf("<"));
|
|
||||||
}
|
|
||||||
java.lang.reflect.Method[] methods = cLoader.loadClass(superClazz).getMethods();
|
|
||||||
System.out.println("Methods of " + superClass + " ");
|
|
||||||
|
|
||||||
for(java.lang.reflect.Method m : methods) {
|
|
||||||
if(methodCall.name.equals(m.getName())) {
|
|
||||||
methodRefl = m;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
System.out.println(superClass);
|
||||||
|
|
||||||
break;
|
if(superClass.equals(""))
|
||||||
} catch (Exception e3) {
|
break;
|
||||||
receiverName = superClass;
|
|
||||||
continue;
|
try {
|
||||||
|
String superClazz = superClass.replace("/", ".");
|
||||||
|
if(superClass.contains("<")) {
|
||||||
|
superClazz = superClazz.substring(0, superClass.indexOf("<"));
|
||||||
|
}
|
||||||
|
java.lang.reflect.Method[] methods = cLoader.loadClass(superClazz).getMethods();
|
||||||
|
System.out.println("Methods of " + superClass + " ");
|
||||||
|
|
||||||
|
for(java.lang.reflect.Method m : methods) {
|
||||||
|
if(methodCall.name.equals(m.getName())) {
|
||||||
|
methodRefl = m;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
} catch (Exception e3) {
|
||||||
|
receiverName = superClass;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
// }
|
||||||
// }
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
if(methodRefl == null) {
|
||||||
|
try {
|
||||||
if(methodRefl == null) {
|
cLoader2 = new URLClassLoader(new URL[] {new URL("file://"+path)});
|
||||||
try {
|
java.lang.reflect.Method[] methods = cLoader2.loadClass(clazz).getMethods();
|
||||||
cLoader2 = new URLClassLoader(new URL[] {new URL("file://"+path)});
|
System.out.println("Methods of " + receiverName + " ");
|
||||||
java.lang.reflect.Method[] methods = cLoader2.loadClass(clazz).getMethods();
|
for(int i = 0; i<methods.length; i++) {
|
||||||
System.out.println("Methods of " + receiverName + " ");
|
System.out.println(methods[i]);
|
||||||
for(int i = 0; i<methods.length; i++) {
|
}
|
||||||
System.out.println(methods[i]);
|
methodRefl = getMethod(methodCall.name,methodCall.arglist.getArguments().size(),methCallType, typesOfParams,methods);
|
||||||
|
}
|
||||||
|
catch (Exception e2) {
|
||||||
|
System.out.println("");
|
||||||
|
//do nothing
|
||||||
}
|
}
|
||||||
methodRefl = getMethod(methodCall.name,methodCall.arglist.getArguments().size(),methCallType, typesOfParams,methods);
|
|
||||||
}
|
}
|
||||||
catch (Exception e2) {
|
// }
|
||||||
System.out.println("");
|
|
||||||
//do nothing
|
|
||||||
}
|
|
||||||
}
|
|
||||||
methodCall.receiver.accept(this);
|
methodCall.receiver.accept(this);
|
||||||
|
|
||||||
System.out.println("Methodcall type : " + resultSet.resolveType(methodCall.getType()).resolvedType.acceptTV(new TypeToDescriptor()));
|
System.out.println("Methodcall type : " + resultSet.resolveType(methodCall.getType()).resolvedType.acceptTV(new TypeToDescriptor()));
|
||||||
@ -850,6 +866,7 @@ public class BytecodeGenMethod implements StatementVisitor {
|
|||||||
mDesc = method.accept(new DescriptorToString(resultSet));
|
mDesc = method.accept(new DescriptorToString(resultSet));
|
||||||
methodCall.arglist.accept(this);
|
methodCall.arglist.accept(this);
|
||||||
} else {
|
} else {
|
||||||
|
System.out.println(methodCall.name + " -> Refl != null");
|
||||||
receiverRefl = methodRefl.getAnnotatedReceiverType().getType().toString();
|
receiverRefl = methodRefl.getAnnotatedReceiverType().getType().toString();
|
||||||
for(Parameter p:methodRefl.getParameters()) {
|
for(Parameter p:methodRefl.getParameters()) {
|
||||||
System.out.println(p.getName() + " und is Primitive = " + p.getType().isPrimitive());
|
System.out.println(p.getName() + " und is Primitive = " + p.getType().isPrimitive());
|
||||||
@ -865,7 +882,7 @@ public class BytecodeGenMethod implements StatementVisitor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println("Methodcall Desc : " + mDesc);
|
System.out.println("Methodcall ("+ methodCall.name +") Desc : " + mDesc);
|
||||||
|
|
||||||
|
|
||||||
// methodCall.arglist.accept(this);
|
// methodCall.arglist.accept(this);
|
||||||
@ -1197,6 +1214,7 @@ public class BytecodeGenMethod implements StatementVisitor {
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
case "java/lang/Boolean":
|
case "java/lang/Boolean":
|
||||||
|
mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/lang/Boolean", "booleanValue", "()Z", false);
|
||||||
break;
|
break;
|
||||||
case "java/lang/Byte":
|
case "java/lang/Byte":
|
||||||
mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/lang/Byte", "byteValue", "()B", false);
|
mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/lang/Byte", "byteValue", "()B", false);
|
||||||
|
@ -5,13 +5,19 @@ package de.dhbwstuttgart.bytecode;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
import de.dhbwstuttgart.bytecode.constraint.ExtendsConstraint;
|
import de.dhbwstuttgart.bytecode.constraint.ExtendsConstraint;
|
||||||
import de.dhbwstuttgart.bytecode.constraint.TPHConstraint;
|
import de.dhbwstuttgart.bytecode.constraint.TPHConstraint;
|
||||||
import de.dhbwstuttgart.bytecode.constraint.TPHConstraint.Relation;
|
import de.dhbwstuttgart.bytecode.constraint.TPHConstraint.Relation;
|
||||||
import de.dhbwstuttgart.bytecode.utilities.MethodAndTPH;
|
import de.dhbwstuttgart.bytecode.utilities.MethodAndTPH;
|
||||||
import de.dhbwstuttgart.syntaxtree.AbstractASTWalker;
|
import de.dhbwstuttgart.syntaxtree.AbstractASTWalker;
|
||||||
|
import de.dhbwstuttgart.syntaxtree.Constructor;
|
||||||
|
import de.dhbwstuttgart.syntaxtree.FormalParameter;
|
||||||
import de.dhbwstuttgart.syntaxtree.Method;
|
import de.dhbwstuttgart.syntaxtree.Method;
|
||||||
|
import de.dhbwstuttgart.syntaxtree.ParameterList;
|
||||||
|
import de.dhbwstuttgart.syntaxtree.statement.LocalVar;
|
||||||
|
import de.dhbwstuttgart.syntaxtree.statement.LocalVarDecl;
|
||||||
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
||||||
import de.dhbwstuttgart.typeinference.result.GenericInsertPair;
|
import de.dhbwstuttgart.typeinference.result.GenericInsertPair;
|
||||||
import de.dhbwstuttgart.typeinference.result.ResultSet;
|
import de.dhbwstuttgart.typeinference.result.ResultSet;
|
||||||
@ -20,36 +26,42 @@ import de.dhbwstuttgart.typeinference.result.ResultSet;
|
|||||||
* @author Fayez Abu Alia
|
* @author Fayez Abu Alia
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class TPHExtractor extends AbstractASTWalker{
|
public class TPHExtractor extends AbstractASTWalker {
|
||||||
// Alle TPHs der Felder werden iKopf der Klasse definiert
|
// Alle TPHs der Felder werden iKopf der Klasse definiert
|
||||||
// alle TPHs der Klasse: (TPH, is in Method?)
|
// alle TPHs der Klasse: (TPH, is in Method?)
|
||||||
final HashMap<TypePlaceholder,Boolean> allTPHS = new HashMap<>();
|
final HashMap<TypePlaceholder, Boolean> allTPHS = new HashMap<>();
|
||||||
MethodAndTPH methodAndTph;
|
MethodAndTPH methodAndTph;
|
||||||
|
|
||||||
Boolean inMethod = false;
|
Boolean inMethod = false;
|
||||||
|
boolean inLocalOrParam = false;
|
||||||
|
|
||||||
public final ArrayList<MethodAndTPH> ListOfMethodsAndTph = new ArrayList<>();
|
public final ArrayList<MethodAndTPH> ListOfMethodsAndTph = new ArrayList<>();
|
||||||
final ArrayList<GenericInsertPair> allPairs = new ArrayList<>();
|
final ArrayList<GenericInsertPair> allPairs = new ArrayList<>();
|
||||||
public final ArrayList<TPHConstraint> allCons = new ArrayList<>();
|
public final ArrayList<TPHConstraint> allCons = new ArrayList<>();
|
||||||
private ResultSet resultSet;
|
private ResultSet resultSet;
|
||||||
|
|
||||||
public TPHExtractor() {
|
public TPHExtractor() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setResultSet(ResultSet resultSet) {
|
public void setResultSet(ResultSet resultSet) {
|
||||||
this.resultSet = resultSet;
|
this.resultSet = resultSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visit(TypePlaceholder tph) {
|
public void visit(TypePlaceholder tph) {
|
||||||
if(resultSet.resolveType(tph).resolvedType instanceof TypePlaceholder) {
|
if (resultSet.resolveType(tph).resolvedType instanceof TypePlaceholder) {
|
||||||
TypePlaceholder resolvedTPH = (TypePlaceholder) resultSet.resolveType(tph).resolvedType;
|
TypePlaceholder resolvedTPH = (TypePlaceholder) resultSet.resolveType(tph).resolvedType;
|
||||||
if(inMethod)
|
if (inMethod) {
|
||||||
methodAndTph.getTphs().add(resolvedTPH.getName());
|
methodAndTph.getTphs().add(resolvedTPH.getName());
|
||||||
|
if (inLocalOrParam)
|
||||||
allTPHS.put(resolvedTPH,inMethod);
|
methodAndTph.getLocalTphs().add(resolvedTPH.getName());
|
||||||
resultSet.resolveType(tph).additionalGenerics.forEach(ag ->{
|
}
|
||||||
if(ag.contains(resolvedTPH)&&ag.TA1.equals(resolvedTPH)&&!contains(allPairs,ag)) {
|
|
||||||
if(inMethod)
|
allTPHS.put(resolvedTPH, inMethod);
|
||||||
|
resultSet.resolveType(tph).additionalGenerics.forEach(ag -> {
|
||||||
|
if (ag.contains(resolvedTPH) && ag.TA1.equals(resolvedTPH) && !contains(allPairs, ag)) {
|
||||||
|
if (inMethod)
|
||||||
methodAndTph.getPairs().add(ag);
|
methodAndTph.getPairs().add(ag);
|
||||||
allPairs.add(ag);
|
allPairs.add(ag);
|
||||||
TPHConstraint con = new ExtendsConstraint(ag.TA1.getName(), ag.TA2.getName(), Relation.EXTENDS);
|
TPHConstraint con = new ExtendsConstraint(ag.TA1.getName(), ag.TA2.getName(), Relation.EXTENDS);
|
||||||
@ -58,14 +70,16 @@ public class TPHExtractor extends AbstractASTWalker{
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean contains(ArrayList<GenericInsertPair> pairs, GenericInsertPair genPair) {
|
private boolean contains(ArrayList<GenericInsertPair> pairs, GenericInsertPair genPair) {
|
||||||
for(int i=0; i<pairs.size();++i) {
|
for (int i = 0; i < pairs.size(); ++i) {
|
||||||
GenericInsertPair p = pairs.get(i);
|
GenericInsertPair p = pairs.get(i);
|
||||||
if(p.TA1.equals(genPair.TA1) && p.TA2.equals(genPair.TA2))
|
if (p.TA1.equals(genPair.TA1) && p.TA2.equals(genPair.TA2))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visit(Method method) {
|
public void visit(Method method) {
|
||||||
inMethod = true;
|
inMethod = true;
|
||||||
@ -74,5 +88,33 @@ public class TPHExtractor extends AbstractASTWalker{
|
|||||||
inMethod = false;
|
inMethod = false;
|
||||||
ListOfMethodsAndTph.add(methodAndTph);
|
ListOfMethodsAndTph.add(methodAndTph);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void visit(Constructor cons) {
|
||||||
|
inMethod = false;
|
||||||
|
super.visit(cons);
|
||||||
|
inMethod = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void visit(LocalVarDecl localVarDecl) {
|
||||||
|
inLocalOrParam = true;
|
||||||
|
super.visit(localVarDecl);
|
||||||
|
inLocalOrParam = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void visit(LocalVar localVar) {
|
||||||
|
inLocalOrParam = true;
|
||||||
|
super.visit(localVar);
|
||||||
|
inLocalOrParam = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void visit(ParameterList formalParameters) {
|
||||||
|
inLocalOrParam = true;
|
||||||
|
super.visit(formalParameters);
|
||||||
|
inLocalOrParam = false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -391,7 +391,7 @@ public class Signature {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for(TPHConstraint cons : consClass) {
|
for(TPHConstraint cons : consClass) {
|
||||||
if(!types.contains(cons.getRight())) {
|
if(!types.contains(cons.getRight()) && !genericsAndBounds.keySet().contains(cons.getRight()+"$")) {
|
||||||
String t = cons.getRight()+"$";
|
String t = cons.getRight()+"$";
|
||||||
String bound = Type.getInternalName(Object.class);
|
String bound = Type.getInternalName(Object.class);
|
||||||
sw.visitFormalTypeParameter(t);
|
sw.visitFormalTypeParameter(t);
|
||||||
|
@ -0,0 +1,51 @@
|
|||||||
|
package de.dhbwstuttgart.bytecode.utilities;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import de.dhbwstuttgart.bytecode.constraint.TPHConstraint;
|
||||||
|
import de.dhbwstuttgart.bytecode.constraint.TPHConstraint.Relation;
|
||||||
|
|
||||||
|
public class ConstraintsFinder {
|
||||||
|
private List<TPHConstraint> allConstaints;
|
||||||
|
|
||||||
|
public ConstraintsFinder(List<TPHConstraint> allConstaints) {
|
||||||
|
super();
|
||||||
|
this.allConstaints = allConstaints;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<List<TPHConstraint>> findConstraints() {
|
||||||
|
List<List<TPHConstraint>> result = new ArrayList<>();
|
||||||
|
|
||||||
|
List<TPHConstraint> visitedCons = new ArrayList<>();
|
||||||
|
for(TPHConstraint c : allConstaints) {
|
||||||
|
if(c.getRel() == Relation.EXTENDS) {
|
||||||
|
// get constraints with the same left side
|
||||||
|
List<TPHConstraint> cons = getConstraints(c,visitedCons);
|
||||||
|
if(cons.size()>1)
|
||||||
|
result.add(cons);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<TPHConstraint> getConstraints(TPHConstraint c, List<TPHConstraint> visitedCons) {
|
||||||
|
List<TPHConstraint> res = new ArrayList<>();
|
||||||
|
for(TPHConstraint cons : allConstaints) {
|
||||||
|
if(!isVisited(cons,visitedCons) && cons.getLeft().equals(c.getLeft())) {
|
||||||
|
res.add(cons);
|
||||||
|
visitedCons.add(cons);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isVisited(TPHConstraint cons, List<TPHConstraint> visitedCons) {
|
||||||
|
for(TPHConstraint c : visitedCons) {
|
||||||
|
if(c.getLeft().equals(cons.getLeft()) && c.getRight().equals(cons.getRight()))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
@ -10,6 +10,8 @@ public class MethodAndTPH {
|
|||||||
private String name;
|
private String name;
|
||||||
private final ArrayList<String> tphs = new ArrayList<>();
|
private final ArrayList<String> tphs = new ArrayList<>();
|
||||||
private final ArrayList<GenericInsertPair> pairs = new ArrayList<>();
|
private final ArrayList<GenericInsertPair> pairs = new ArrayList<>();
|
||||||
|
// tphs of local variables and parameters
|
||||||
|
private final ArrayList<String> localTphs = new ArrayList<>();
|
||||||
|
|
||||||
public MethodAndTPH(String name) {
|
public MethodAndTPH(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
@ -26,4 +28,9 @@ public class MethodAndTPH {
|
|||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ArrayList<String> getLocalTphs() {
|
||||||
|
return localTphs;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,49 @@
|
|||||||
|
package de.dhbwstuttgart.bytecode.utilities;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import de.dhbwstuttgart.bytecode.constraint.TPHConstraint;
|
||||||
|
import de.dhbwstuttgart.syntaxtree.factory.NameGenerator;
|
||||||
|
|
||||||
|
public class NameReplacer {
|
||||||
|
private List<TPHConstraint> constraints;
|
||||||
|
private List<TPHConstraint> allConstraints;
|
||||||
|
private List<String> tphs;
|
||||||
|
private List<String> localTphs;
|
||||||
|
|
||||||
|
public NameReplacer(List<TPHConstraint> constraints, List<TPHConstraint> allConstraints,List<String> tphs, ArrayList<String> localTphs) {
|
||||||
|
super();
|
||||||
|
this.constraints = constraints;
|
||||||
|
this.allConstraints = allConstraints;
|
||||||
|
this.tphs = tphs;
|
||||||
|
this.localTphs = localTphs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, List<String>> replaceNames() {
|
||||||
|
String newName = NameGenerator.makeNewName();
|
||||||
|
ArrayList<String> names = new ArrayList<>();
|
||||||
|
for(TPHConstraint cons : constraints) {
|
||||||
|
names.add(cons.getRight());
|
||||||
|
cons.setRight(newName);
|
||||||
|
}
|
||||||
|
|
||||||
|
for(TPHConstraint cons : allConstraints) {
|
||||||
|
if(names.contains(cons.getLeft()))
|
||||||
|
cons.setLeft(newName);
|
||||||
|
if(names.contains(cons.getRight()))
|
||||||
|
cons.setRight(newName);
|
||||||
|
}
|
||||||
|
|
||||||
|
tphs.removeAll(names);
|
||||||
|
tphs.add(newName);
|
||||||
|
localTphs.removeAll(names);
|
||||||
|
localTphs.add(newName);
|
||||||
|
|
||||||
|
HashMap<String, List<String>> res = new HashMap<>();
|
||||||
|
res.put(newName, names);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
@ -34,6 +34,7 @@ import de.dhbwstuttgart.typeinference.unify.model.PlaceholderType;
|
|||||||
import de.dhbwstuttgart.typeinference.unify.model.UnifyPair;
|
import de.dhbwstuttgart.typeinference.unify.model.UnifyPair;
|
||||||
import de.dhbwstuttgart.typeinference.unify.model.UnifyType;
|
import de.dhbwstuttgart.typeinference.unify.model.UnifyType;
|
||||||
import de.dhbwstuttgart.typeinference.unify.TypeUnifyTask;
|
import de.dhbwstuttgart.typeinference.unify.TypeUnifyTask;
|
||||||
|
import de.dhbwstuttgart.typeinference.unify.UnifyResultListener;
|
||||||
import de.dhbwstuttgart.typeinference.unify.UnifyResultListenerImpl;
|
import de.dhbwstuttgart.typeinference.unify.UnifyResultListenerImpl;
|
||||||
import de.dhbwstuttgart.typeinference.unify.UnifyResultModel;
|
import de.dhbwstuttgart.typeinference.unify.UnifyResultModel;
|
||||||
|
|
||||||
@ -41,6 +42,10 @@ import java.io.File;
|
|||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.FileWriter;
|
import java.io.FileWriter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
<<<<<<< HEAD
|
||||||
|
=======
|
||||||
|
import java.io.OutputStreamWriter;
|
||||||
|
>>>>>>> 7cb2eed36edfe2d9f3ec4ce5c0ca40702dcff7f2
|
||||||
import java.io.Writer;
|
import java.io.Writer;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
@ -48,6 +53,7 @@ import java.util.stream.Collectors;
|
|||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import org.antlr.v4.parse.ANTLRParser.throwsSpec_return;
|
import org.antlr.v4.parse.ANTLRParser.throwsSpec_return;
|
||||||
|
import org.apache.commons.io.output.NullOutputStream;
|
||||||
|
|
||||||
public class JavaTXCompiler {
|
public class JavaTXCompiler {
|
||||||
|
|
||||||
@ -275,7 +281,7 @@ public class JavaTXCompiler {
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public UnifyResultModel typeInferenceAsync() throws ClassNotFoundException {
|
public UnifyResultModel typeInferenceAsync(UnifyResultListener resultListener, Writer logFile) throws ClassNotFoundException {
|
||||||
List<ClassOrInterface> allClasses = new ArrayList<>();//environment.getAllAvailableClasses();
|
List<ClassOrInterface> allClasses = new ArrayList<>();//environment.getAllAvailableClasses();
|
||||||
//Alle Importierten Klassen in allen geparsten Sourcefiles kommen ins FC
|
//Alle Importierten Klassen in allen geparsten Sourcefiles kommen ins FC
|
||||||
for(SourceFile sf : this.sourceFiles.values()) {
|
for(SourceFile sf : this.sourceFiles.values()) {
|
||||||
@ -285,10 +291,18 @@ public class JavaTXCompiler {
|
|||||||
|
|
||||||
final ConstraintSet<Pair> cons = getConstraints();
|
final ConstraintSet<Pair> cons = getConstraints();
|
||||||
Set<Set<UnifyPair>> results = new HashSet<>();
|
Set<Set<UnifyPair>> results = new HashSet<>();
|
||||||
|
<<<<<<< HEAD
|
||||||
UnifyResultModel urm = null;
|
UnifyResultModel urm = null;
|
||||||
try {
|
try {
|
||||||
Writer logFile = new FileWriter(new File(System.getProperty("user.dir")+"/src/test/java/logFiles/"+"log_"+sourceFiles.keySet().iterator().next().getName()));
|
Writer logFile = new FileWriter(new File(System.getProperty("user.dir")+"/src/test/java/logFiles/"+"log_"+sourceFiles.keySet().iterator().next().getName()));
|
||||||
|
|
||||||
|
=======
|
||||||
|
UnifyResultModel urm = new UnifyResultModel();
|
||||||
|
urm.addUnifyResultListener(resultListener);
|
||||||
|
try {
|
||||||
|
logFile = logFile == null ? new FileWriter(new File("log_"+sourceFiles.keySet().iterator().next().getName())) : logFile;
|
||||||
|
|
||||||
|
>>>>>>> 7cb2eed36edfe2d9f3ec4ce5c0ca40702dcff7f2
|
||||||
IFiniteClosure finiteClosure = UnifyTypeFactory.generateFC(allClasses,logFile);
|
IFiniteClosure finiteClosure = UnifyTypeFactory.generateFC(allClasses,logFile);
|
||||||
System.out.println(finiteClosure);
|
System.out.println(finiteClosure);
|
||||||
urm = new UnifyResultModel(cons, finiteClosure);
|
urm = new UnifyResultModel(cons, finiteClosure);
|
||||||
@ -423,7 +437,12 @@ public class JavaTXCompiler {
|
|||||||
final ConstraintSet<Pair> cons = getConstraints();
|
final ConstraintSet<Pair> cons = getConstraints();
|
||||||
Set<Set<UnifyPair>> results = new HashSet<>();
|
Set<Set<UnifyPair>> results = new HashSet<>();
|
||||||
try {
|
try {
|
||||||
|
<<<<<<< HEAD
|
||||||
Writer logFile = new FileWriter(new File(System.getProperty("user.dir")+"/src/test/java/logFiles/"+"log_"+sourceFiles.keySet().iterator().next().getName()));
|
Writer logFile = new FileWriter(new File(System.getProperty("user.dir")+"/src/test/java/logFiles/"+"log_"+sourceFiles.keySet().iterator().next().getName()));
|
||||||
|
=======
|
||||||
|
Writer logFile = new OutputStreamWriter(new NullOutputStream());
|
||||||
|
//new FileWriter(new File("log_"+sourceFiles.keySet().iterator().next().getName()));
|
||||||
|
>>>>>>> 7cb2eed36edfe2d9f3ec4ce5c0ca40702dcff7f2
|
||||||
|
|
||||||
IFiniteClosure finiteClosure = UnifyTypeFactory.generateFC(allClasses,logFile);
|
IFiniteClosure finiteClosure = UnifyTypeFactory.generateFC(allClasses,logFile);
|
||||||
System.out.println(finiteClosure);
|
System.out.println(finiteClosure);
|
||||||
|
@ -80,6 +80,9 @@ public abstract class AbstractASTWalker implements ASTVisitor{
|
|||||||
for(Field f : classOrInterface.getFieldDecl()){
|
for(Field f : classOrInterface.getFieldDecl()){
|
||||||
f.accept(this);
|
f.accept(this);
|
||||||
}
|
}
|
||||||
|
for(Constructor c : classOrInterface.getConstructors()){
|
||||||
|
c.accept(this);
|
||||||
|
}
|
||||||
for(Method m : classOrInterface.getMethods()){
|
for(Method m : classOrInterface.getMethods()){
|
||||||
m.accept(this);
|
m.accept(this);
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@ import de.dhbwstuttgart.typeinference.unify.model.FiniteClosure;
|
|||||||
import de.dhbwstuttgart.typeinference.unify.model.UnifyPair;
|
import de.dhbwstuttgart.typeinference.unify.model.UnifyPair;
|
||||||
|
|
||||||
public class TypeUnify {
|
public class TypeUnify {
|
||||||
|
<<<<<<< HEAD
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* unify parallel ohne result modell
|
* unify parallel ohne result modell
|
||||||
@ -27,12 +28,17 @@ public class TypeUnify {
|
|||||||
*/
|
*/
|
||||||
public Set<Set<UnifyPair>> unify(Set<UnifyPair> undConstrains, List<Set<Set<UnifyPair>>> oderConstraints, IFiniteClosure fc, Writer logFile, Boolean log, UnifyResultModel ret) {
|
public Set<Set<UnifyPair>> unify(Set<UnifyPair> undConstrains, List<Set<Set<UnifyPair>>> oderConstraints, IFiniteClosure fc, Writer logFile, Boolean log, UnifyResultModel ret) {
|
||||||
TypeUnifyTask unifyTask = new TypeUnifyTask(undConstrains, oderConstraints, fc, true, logFile, log, 0, ret);
|
TypeUnifyTask unifyTask = new TypeUnifyTask(undConstrains, oderConstraints, fc, true, logFile, log, 0, ret);
|
||||||
|
=======
|
||||||
|
public Set<Set<UnifyPair>> unify(Set<UnifyPair> undConstrains, List<Set<Set<UnifyPair>>> oderConstraints, IFiniteClosure fc, Writer logFile, Boolean log, ConstraintSet<Pair> cons) {
|
||||||
|
TypeUnifyTask unifyTask = new TypeUnifyTask(undConstrains, oderConstraints, fc, true, logFile, log, 0, new UnifyResultModel(), cons);
|
||||||
|
>>>>>>> 7cb2eed36edfe2d9f3ec4ce5c0ca40702dcff7f2
|
||||||
ForkJoinPool pool = new ForkJoinPool();
|
ForkJoinPool pool = new ForkJoinPool();
|
||||||
pool.invoke(unifyTask);
|
pool.invoke(unifyTask);
|
||||||
Set<Set<UnifyPair>> res = unifyTask.join();
|
Set<Set<UnifyPair>> res = unifyTask.join();
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
/**
|
/**
|
||||||
* unify asynchron mit Rückgabe UnifyResultModel ohne dass alle results gesammelt sind
|
* unify asynchron mit Rückgabe UnifyResultModel ohne dass alle results gesammelt sind
|
||||||
* @param undConstrains
|
* @param undConstrains
|
||||||
@ -46,11 +52,16 @@ public class TypeUnify {
|
|||||||
*/
|
*/
|
||||||
public UnifyResultModel unifyAsync(Set<UnifyPair> undConstrains, List<Set<Set<UnifyPair>>> oderConstraints, IFiniteClosure fc, Writer logFile, Boolean log, UnifyResultModel ret) {
|
public UnifyResultModel unifyAsync(Set<UnifyPair> undConstrains, List<Set<Set<UnifyPair>>> oderConstraints, IFiniteClosure fc, Writer logFile, Boolean log, UnifyResultModel ret) {
|
||||||
TypeUnifyTask unifyTask = new TypeUnifyTask(undConstrains, oderConstraints, fc, true, logFile, log, 0, ret);
|
TypeUnifyTask unifyTask = new TypeUnifyTask(undConstrains, oderConstraints, fc, true, logFile, log, 0, ret);
|
||||||
|
=======
|
||||||
|
public UnifyResultModel unifyAsync(Set<UnifyPair> undConstrains, List<Set<Set<UnifyPair>>> oderConstraints, IFiniteClosure fc, Writer logFile, Boolean log, ConstraintSet<Pair> cons, UnifyResultModel ret) {
|
||||||
|
TypeUnifyTask unifyTask = new TypeUnifyTask(undConstrains, oderConstraints, fc, true, logFile, log, 0, ret, cons);
|
||||||
|
>>>>>>> 7cb2eed36edfe2d9f3ec4ce5c0ca40702dcff7f2
|
||||||
ForkJoinPool pool = new ForkJoinPool();
|
ForkJoinPool pool = new ForkJoinPool();
|
||||||
pool.invoke(unifyTask);
|
pool.invoke(unifyTask);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
/**
|
/**
|
||||||
* unify parallel mit Rückgabe UnifyResultModel nachdem alle results gesammelt sind
|
* unify parallel mit Rückgabe UnifyResultModel nachdem alle results gesammelt sind
|
||||||
* @param undConstrains
|
* @param undConstrains
|
||||||
@ -64,6 +75,10 @@ public class TypeUnify {
|
|||||||
*/
|
*/
|
||||||
public UnifyResultModel unifyParallel(Set<UnifyPair> undConstrains, List<Set<Set<UnifyPair>>> oderConstraints, IFiniteClosure fc, Writer logFile, Boolean log, UnifyResultModel ret) {
|
public UnifyResultModel unifyParallel(Set<UnifyPair> undConstrains, List<Set<Set<UnifyPair>>> oderConstraints, IFiniteClosure fc, Writer logFile, Boolean log, UnifyResultModel ret) {
|
||||||
TypeUnifyTask unifyTask = new TypeUnifyTask(undConstrains, oderConstraints, fc, true, logFile, log, 0, ret);
|
TypeUnifyTask unifyTask = new TypeUnifyTask(undConstrains, oderConstraints, fc, true, logFile, log, 0, ret);
|
||||||
|
=======
|
||||||
|
public UnifyResultModel unifyParallel(Set<UnifyPair> undConstrains, List<Set<Set<UnifyPair>>> oderConstraints, IFiniteClosure fc, Writer logFile, Boolean log, ConstraintSet<Pair> cons, UnifyResultModel ret) {
|
||||||
|
TypeUnifyTask unifyTask = new TypeUnifyTask(undConstrains, oderConstraints, fc, true, logFile, log, 0, ret, cons);
|
||||||
|
>>>>>>> 7cb2eed36edfe2d9f3ec4ce5c0ca40702dcff7f2
|
||||||
ForkJoinPool pool = new ForkJoinPool();
|
ForkJoinPool pool = new ForkJoinPool();
|
||||||
pool.invoke(unifyTask);
|
pool.invoke(unifyTask);
|
||||||
Set<Set<UnifyPair>> res = unifyTask.join();
|
Set<Set<UnifyPair>> res = unifyTask.join();
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
package de.dhbwstuttgart.typeinference.unify;
|
package de.dhbwstuttgart.typeinference.unify;
|
||||||
|
|
||||||
import java.io.FileWriter;
|
import java.io.FileWriter;
|
||||||
|
<<<<<<< HEAD
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
=======
|
||||||
|
>>>>>>> 7cb2eed36edfe2d9f3ec4ce5c0ca40702dcff7f2
|
||||||
import java.io.Writer;
|
import java.io.Writer;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -17,8 +20,13 @@ public class TypeUnify2Task extends TypeUnifyTask {
|
|||||||
|
|
||||||
Set<Set<UnifyPair>> setToFlatten;
|
Set<Set<UnifyPair>> setToFlatten;
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
public TypeUnify2Task(Set<Set<UnifyPair>> setToFlatten, Set<UnifyPair> eq, List<Set<Set<UnifyPair>>> oderConstraints, Set<UnifyPair> nextSetElement, IFiniteClosure fc, boolean parallel, Writer logFile, Boolean log, int rekTiefe, UnifyResultModel urm) {
|
public TypeUnify2Task(Set<Set<UnifyPair>> setToFlatten, Set<UnifyPair> eq, List<Set<Set<UnifyPair>>> oderConstraints, Set<UnifyPair> nextSetElement, IFiniteClosure fc, boolean parallel, Writer logFile, Boolean log, int rekTiefe, UnifyResultModel urm) {
|
||||||
super(eq, oderConstraints, fc, parallel, logFile, log, rekTiefe, urm);
|
super(eq, oderConstraints, fc, parallel, logFile, log, rekTiefe, urm);
|
||||||
|
=======
|
||||||
|
public TypeUnify2Task(Set<Set<UnifyPair>> setToFlatten, Set<UnifyPair> eq, List<Set<Set<UnifyPair>>> oderConstraints, IFiniteClosure fc, boolean parallel, Writer logFile, Boolean log, int rekTiefe, UnifyResultModel urm, ConstraintSet<Pair> cons) {
|
||||||
|
super(eq, oderConstraints, fc, parallel, logFile, log, rekTiefe, urm, cons);
|
||||||
|
>>>>>>> 7cb2eed36edfe2d9f3ec4ce5c0ca40702dcff7f2
|
||||||
this.setToFlatten = setToFlatten;
|
this.setToFlatten = setToFlatten;
|
||||||
this.nextSetElement = nextSetElement;
|
this.nextSetElement = nextSetElement;
|
||||||
}
|
}
|
||||||
|
@ -133,7 +133,11 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
public TypeUnifyTask(Set<UnifyPair> eq, List<Set<Set<UnifyPair>>> oderConstraints, IFiniteClosure fc, boolean parallel, Writer logFile, Boolean log, int rekTiefe, UnifyResultModel urm) {
|
public TypeUnifyTask(Set<UnifyPair> eq, List<Set<Set<UnifyPair>>> oderConstraints, IFiniteClosure fc, boolean parallel, Writer logFile, Boolean log, int rekTiefe, UnifyResultModel urm) {
|
||||||
|
=======
|
||||||
|
public TypeUnifyTask(Set<UnifyPair> eq, List<Set<Set<UnifyPair>>> oderConstraints, IFiniteClosure fc, boolean parallel, Writer logFile, Boolean log, int rekTiefe, UnifyResultModel urm, ConstraintSet<de.dhbwstuttgart.typeinference.constraints.Pair> cons2) {
|
||||||
|
>>>>>>> 7cb2eed36edfe2d9f3ec4ce5c0ca40702dcff7f2
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
this.eq = eq;
|
this.eq = eq;
|
||||||
//this.oderConstraints = oderConstraints.stream().map(x -> x.stream().map(y -> new HashSet<>(y)).collect(Collectors.toSet(HashSet::new))).collect(Collectors.toList(ArrayList::new));
|
//this.oderConstraints = oderConstraints.stream().map(x -> x.stream().map(y -> new HashSet<>(y)).collect(Collectors.toSet(HashSet::new))).collect(Collectors.toList(ArrayList::new));
|
||||||
|
@ -32,11 +32,11 @@ public class FieldTphConsMethTest {
|
|||||||
pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/";
|
pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/";
|
||||||
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
||||||
classToTest = loader.loadClass("FieldTphConsMeth");
|
classToTest = loader.loadClass("FieldTphConsMeth");
|
||||||
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test() throws Exception {
|
public void test() throws Exception {
|
||||||
|
instanceOfClass = classToTest.getConstructor(Object.class).newInstance("C");
|
||||||
Field a = classToTest.getDeclaredField("a");
|
Field a = classToTest.getDeclaredField("a");
|
||||||
a.setAccessible(true);
|
a.setAccessible(true);
|
||||||
|
|
||||||
@ -44,6 +44,7 @@ public class FieldTphConsMethTest {
|
|||||||
Object result = m.invoke(instanceOfClass, 42);
|
Object result = m.invoke(instanceOfClass, 42);
|
||||||
|
|
||||||
assertEquals(42,result);
|
assertEquals(42,result);
|
||||||
|
assertEquals("C", a.get(instanceOfClass));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
66
src/test/java/bytecode/FieldTphMMethTest.java
Normal file
66
src/test/java/bytecode/FieldTphMMethTest.java
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
package bytecode;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.net.URLClassLoader;
|
||||||
|
|
||||||
|
import org.junit.BeforeClass;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import de.dhbwstuttgart.core.JavaTXCompiler;
|
||||||
|
|
||||||
|
public class FieldTphMMethTest {
|
||||||
|
|
||||||
|
private static String path;
|
||||||
|
private static File fileToTest;
|
||||||
|
private static JavaTXCompiler compiler;
|
||||||
|
private static ClassLoader loader;
|
||||||
|
private static Class<?> classToTest;
|
||||||
|
private static String pathToClassFile;
|
||||||
|
private static Object instanceOfClass;
|
||||||
|
private static Object instanceOfClass2;
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
public static void setUpBeforeClass() throws Exception {
|
||||||
|
path = System.getProperty("user.dir")+"/src/test/resources/bytecode/javFiles/FieldTphMMeth.jav";
|
||||||
|
fileToTest = new File(path);
|
||||||
|
compiler = new JavaTXCompiler(fileToTest);
|
||||||
|
compiler.generateBytecode(System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/");
|
||||||
|
pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/";
|
||||||
|
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
||||||
|
classToTest = loader.loadClass("FieldTphMMeth");
|
||||||
|
instanceOfClass = classToTest.getConstructor(Object.class,Object.class,Boolean.class).newInstance("C",42,true);
|
||||||
|
instanceOfClass2 = classToTest.getConstructor(Object.class,Object.class,Boolean.class).newInstance("C",42,false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testM() throws Exception {
|
||||||
|
|
||||||
|
Method m = classToTest.getDeclaredMethod("m", Object.class,Object.class,Boolean.class);
|
||||||
|
Object result = m.invoke(instanceOfClass, "C",42,false);
|
||||||
|
|
||||||
|
assertEquals(42,result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testWithTrue() throws Exception {
|
||||||
|
Field a = classToTest.getDeclaredField("a");
|
||||||
|
a.setAccessible(true);
|
||||||
|
|
||||||
|
assertEquals("C", a.get(instanceOfClass));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testWithFalse() throws Exception {
|
||||||
|
Field a = classToTest.getDeclaredField("a");
|
||||||
|
a.setAccessible(true);
|
||||||
|
|
||||||
|
assertEquals(42, a.get(instanceOfClass2));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -3,7 +3,7 @@ package bytecode;
|
|||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Method;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLClassLoader;
|
import java.net.URLClassLoader;
|
||||||
|
|
||||||
@ -12,8 +12,8 @@ import org.junit.Test;
|
|||||||
|
|
||||||
import de.dhbwstuttgart.core.JavaTXCompiler;
|
import de.dhbwstuttgart.core.JavaTXCompiler;
|
||||||
|
|
||||||
public class FieldTph {
|
public class InfTest {
|
||||||
|
|
||||||
private static String path;
|
private static String path;
|
||||||
private static File fileToTest;
|
private static File fileToTest;
|
||||||
private static JavaTXCompiler compiler;
|
private static JavaTXCompiler compiler;
|
||||||
@ -22,22 +22,16 @@ public class FieldTph {
|
|||||||
private static String pathToClassFile;
|
private static String pathToClassFile;
|
||||||
private static Object instanceOfClass;
|
private static Object instanceOfClass;
|
||||||
|
|
||||||
@BeforeClass
|
@Test
|
||||||
public static void setUpBeforeClass() throws Exception {
|
public void generateBC() throws Exception {
|
||||||
path = System.getProperty("user.dir")+"/src/test/resources/bytecode/javFiles/FieldTph.jav";
|
path = System.getProperty("user.dir")+"/src/test/resources/bytecode/javFiles/Inf.jav";
|
||||||
fileToTest = new File(path);
|
fileToTest = new File(path);
|
||||||
compiler = new JavaTXCompiler(fileToTest);
|
compiler = new JavaTXCompiler(fileToTest);
|
||||||
compiler.generateBytecode(System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/");
|
|
||||||
pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/";
|
pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/";
|
||||||
|
compiler.generateBytecode(pathToClassFile);
|
||||||
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
||||||
classToTest = loader.loadClass("FieldTph");
|
classToTest = loader.loadClass("Inf");
|
||||||
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void test() {
|
|
||||||
Field[] fields = classToTest.getFields();
|
|
||||||
assertEquals(1, fields.length);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
37
src/test/java/bytecode/KompTphTest.java
Normal file
37
src/test/java/bytecode/KompTphTest.java
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
package bytecode;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.net.URLClassLoader;
|
||||||
|
|
||||||
|
import org.junit.BeforeClass;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import de.dhbwstuttgart.core.JavaTXCompiler;
|
||||||
|
|
||||||
|
public class KompTphTest {
|
||||||
|
|
||||||
|
private static String path;
|
||||||
|
private static File fileToTest;
|
||||||
|
private static JavaTXCompiler compiler;
|
||||||
|
private static ClassLoader loader;
|
||||||
|
private static Class<?> classToTest;
|
||||||
|
private static String pathToClassFile;
|
||||||
|
private static Object instanceOfClass;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void generateBC() throws Exception {
|
||||||
|
path = System.getProperty("user.dir")+"/src/test/resources/bytecode/javFiles/KompTph.jav";
|
||||||
|
fileToTest = new File(path);
|
||||||
|
compiler = new JavaTXCompiler(fileToTest);
|
||||||
|
pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/";
|
||||||
|
compiler.generateBytecode(pathToClassFile);
|
||||||
|
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
||||||
|
classToTest = loader.loadClass("KompTph");
|
||||||
|
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -4,6 +4,7 @@ import static org.junit.Assert.*;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
@ -27,7 +28,7 @@ public class MatrixOpTest {
|
|||||||
private static Object instanceOfClass_m3;
|
private static Object instanceOfClass_m3;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, ClassNotFoundException, IOException, InstantiationException {
|
public void test() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, ClassNotFoundException, IOException, InstantiationException, NoSuchFieldException {
|
||||||
path = System.getProperty("user.dir")+"/src/test/resources/bytecode/javFiles/MatrixOP.jav";
|
path = System.getProperty("user.dir")+"/src/test/resources/bytecode/javFiles/MatrixOP.jav";
|
||||||
fileToTest = new File(path);
|
fileToTest = new File(path);
|
||||||
compiler = new JavaTXCompiler(fileToTest);
|
compiler = new JavaTXCompiler(fileToTest);
|
||||||
@ -35,7 +36,7 @@ public class MatrixOpTest {
|
|||||||
compiler.generateBytecode(pathToClassFile);
|
compiler.generateBytecode(pathToClassFile);
|
||||||
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
||||||
classToTest = loader.loadClass("MatrixOP");
|
classToTest = loader.loadClass("MatrixOP");
|
||||||
/*
|
|
||||||
Vector<Vector<Integer>> vv = new Vector<Vector<Integer>>();
|
Vector<Vector<Integer>> vv = new Vector<Vector<Integer>>();
|
||||||
Vector<Integer> v1 = new Vector<Integer> ();
|
Vector<Integer> v1 = new Vector<Integer> ();
|
||||||
v1.addElement(2);
|
v1.addElement(2);
|
||||||
@ -48,6 +49,7 @@ public class MatrixOpTest {
|
|||||||
//m1.addElement(v2);
|
//m1.addElement(v2);
|
||||||
vv.addElement(v1);
|
vv.addElement(v1);
|
||||||
vv.addElement(v2);
|
vv.addElement(v2);
|
||||||
|
|
||||||
instanceOfClass_m1 = classToTest.getDeclaredConstructor(Vector.class).newInstance(vv); //Matrix m1 = new Matrix(vv);
|
instanceOfClass_m1 = classToTest.getDeclaredConstructor(Vector.class).newInstance(vv); //Matrix m1 = new Matrix(vv);
|
||||||
|
|
||||||
Vector<Vector<Integer>> vv1 = new Vector<Vector<Integer>>();
|
Vector<Vector<Integer>> vv1 = new Vector<Vector<Integer>>();
|
||||||
@ -62,13 +64,23 @@ public class MatrixOpTest {
|
|||||||
//m2.addElement(v4);
|
//m2.addElement(v4);
|
||||||
vv1.addElement(v3);
|
vv1.addElement(v3);
|
||||||
vv1.addElement(v4);
|
vv1.addElement(v4);
|
||||||
|
|
||||||
instanceOfClass_m2 = classToTest.getDeclaredConstructor(Vector.class).newInstance(vv1);//Matrix m2 = new Matrix(vv1);
|
instanceOfClass_m2 = classToTest.getDeclaredConstructor(Vector.class).newInstance(vv1);//Matrix m2 = new Matrix(vv1);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//Matrix m3 = m1.mul(vv1);
|
//Matrix m3 = m1.mul(vv1);
|
||||||
Method mul = classToTest.getDeclaredMethod("mul", Vector.class);
|
// Method mul = classToTest.getDeclaredMethod("mul", Vector.class);
|
||||||
Object result = mul.invoke(instanceOfClass_m1, instanceOfClass_m2);
|
// Object result = mul.invoke(instanceOfClass_m1, instanceOfClass_m2);
|
||||||
|
Field mul = classToTest.getField("mul");
|
||||||
|
mul.setAccessible(true);
|
||||||
|
|
||||||
|
Class<?> lambda = mul.get(instanceOfClass_m1).getClass();
|
||||||
|
Method apply = lambda.getMethod("apply", Object.class,Object.class);
|
||||||
|
// Damit man auf die Methode zugreifen kann
|
||||||
|
apply.setAccessible(true);
|
||||||
|
|
||||||
|
Object result = apply.invoke(mul.get(instanceOfClass_m1),instanceOfClass_m1, instanceOfClass_m2);
|
||||||
System.out.println(instanceOfClass_m1.toString() + " * " + instanceOfClass_m2.toString() + " = " + result.toString());
|
System.out.println(instanceOfClass_m1.toString() + " * " + instanceOfClass_m2.toString() + " = " + result.toString());
|
||||||
|
|
||||||
Vector<Vector<Integer>> res = new Vector<Vector<Integer>>();
|
Vector<Vector<Integer>> res = new Vector<Vector<Integer>>();
|
||||||
@ -85,7 +97,7 @@ public class MatrixOpTest {
|
|||||||
res.addElement(v6);
|
res.addElement(v6);
|
||||||
instanceOfClass_m3 = classToTest.getDeclaredConstructor(Vector.class).newInstance(res);
|
instanceOfClass_m3 = classToTest.getDeclaredConstructor(Vector.class).newInstance(res);
|
||||||
assertEquals(result, instanceOfClass_m3);
|
assertEquals(result, instanceOfClass_m3);
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
64
src/test/java/bytecode/simplifyalgo/FinderTest.java
Normal file
64
src/test/java/bytecode/simplifyalgo/FinderTest.java
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
package bytecode.simplifyalgo;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.junit.BeforeClass;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.objectweb.asm.Type;
|
||||||
|
|
||||||
|
import de.dhbwstuttgart.bytecode.TPHExtractor;
|
||||||
|
import de.dhbwstuttgart.bytecode.constraint.ExtendsConstraint;
|
||||||
|
import de.dhbwstuttgart.bytecode.constraint.TPHConstraint;
|
||||||
|
import de.dhbwstuttgart.bytecode.constraint.TPHConstraint.Relation;
|
||||||
|
import de.dhbwstuttgart.bytecode.utilities.ConstraintsFinder;
|
||||||
|
import de.dhbwstuttgart.bytecode.utilities.MethodAndTPH;
|
||||||
|
import de.dhbwstuttgart.bytecode.utilities.Simplify;
|
||||||
|
import de.dhbwstuttgart.typedeployment.TypeInsertPlacer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Fayez Abu Alia
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class FinderTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testM1() {
|
||||||
|
List<TPHConstraint> allCons = new ArrayList<>();
|
||||||
|
// L < M
|
||||||
|
TPHConstraint c1 = new ExtendsConstraint("L", "M", Relation.EXTENDS);
|
||||||
|
// L < N
|
||||||
|
TPHConstraint c2 = new ExtendsConstraint("L", "N", Relation.EXTENDS);
|
||||||
|
// M < O
|
||||||
|
TPHConstraint c3 = new ExtendsConstraint("M", "O", Relation.EXTENDS);
|
||||||
|
// M < P
|
||||||
|
TPHConstraint c4 = new ExtendsConstraint("M", "P", Relation.EXTENDS);
|
||||||
|
|
||||||
|
allCons.add(c1);
|
||||||
|
allCons.add(c2);
|
||||||
|
allCons.add(c3);
|
||||||
|
allCons.add(c4);
|
||||||
|
List<List<TPHConstraint>> res = new ArrayList<>();
|
||||||
|
List<TPHConstraint> l1 = new ArrayList<>();
|
||||||
|
List<TPHConstraint> l2 = new ArrayList<>();
|
||||||
|
|
||||||
|
l1.add(c1);
|
||||||
|
l1.add(c2);
|
||||||
|
|
||||||
|
l2.add(c3);
|
||||||
|
l2.add(c4);
|
||||||
|
|
||||||
|
res.add(l1);
|
||||||
|
res.add(l2);
|
||||||
|
|
||||||
|
ConstraintsFinder finder = new ConstraintsFinder(allCons);
|
||||||
|
|
||||||
|
assertEquals(finder.findConstraints(), res);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
27
src/test/resources/bytecode/javFiles/FieldTphMMeth.jav
Normal file
27
src/test/resources/bytecode/javFiles/FieldTphMMeth.jav
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
import java.lang.Boolean;
|
||||||
|
|
||||||
|
public class FieldTphMMeth {
|
||||||
|
a;
|
||||||
|
|
||||||
|
public FieldTphMMeth(c,d,e) {
|
||||||
|
a = m(c,d,e);
|
||||||
|
}
|
||||||
|
|
||||||
|
m(b,d,e) {
|
||||||
|
if(e) {
|
||||||
|
return m3(b);
|
||||||
|
} else{
|
||||||
|
return m3(d);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
m2(b) {
|
||||||
|
a = m3(b);
|
||||||
|
}
|
||||||
|
|
||||||
|
m3(b){
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
19
src/test/resources/bytecode/javFiles/Inf.jav
Normal file
19
src/test/resources/bytecode/javFiles/Inf.jav
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
public class Inf {
|
||||||
|
m(x,y,a){
|
||||||
|
var z;
|
||||||
|
var v;
|
||||||
|
var w;
|
||||||
|
var b;
|
||||||
|
y=x;
|
||||||
|
z=x;
|
||||||
|
v=y;
|
||||||
|
w=y;
|
||||||
|
y=a;
|
||||||
|
b=a;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// v w
|
||||||
|
// \ /
|
||||||
|
// z y b
|
||||||
|
// \ / \ /
|
||||||
|
// x a
|
13
src/test/resources/bytecode/javFiles/KompTph.jav
Normal file
13
src/test/resources/bytecode/javFiles/KompTph.jav
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
public class KompTph {
|
||||||
|
public m(a, b, c) {
|
||||||
|
var d = a;
|
||||||
|
var e = a;
|
||||||
|
a = b;
|
||||||
|
c = b;
|
||||||
|
m2(a,c);
|
||||||
|
}
|
||||||
|
|
||||||
|
public m2(a,b){
|
||||||
|
m(a,a,b);
|
||||||
|
}
|
||||||
|
}
|
@ -18,7 +18,7 @@ public class MatrixOP extends Vector<Vector<Integer>> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mul = (m1, m2) -> {
|
public mul = (m1, m2) -> {
|
||||||
var ret = new MatrixOP();
|
var ret = new MatrixOP();
|
||||||
var i = 0;
|
var i = 0;
|
||||||
while(i < m1.size()) {
|
while(i < m1.size()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user