From 13330e4fd6c76cb3163ad16a04f166d22748534c Mon Sep 17 00:00:00 2001 From: sebastian Date: Sun, 7 May 2017 02:41:22 +0200 Subject: [PATCH] expression NewClass kann nach bigRefactoring wieder verarbeitet werden --- .idea/workspace.xml | 1823 ----------------- .../SyntaxTreeGenerator.java | 1 + .../NeueKlassen/ConstructInterfaces.java | 101 + .../strucTypes5/algo/Construct.java | 7 +- src/de/dhbwstuttgart/strucTypes5/algo/TI.java | 15 +- .../strucTypes5/algo/TypeExpr.java | 98 +- .../strucTypes5/ausgabe/Class2String.java | 25 +- .../constraints/ConstraintSubTypeGeneric.java | 40 - .../constraints/InterfaceForConstraint.java | 1 - .../FactoryForElementes.java | 8 - .../strucTypes5/solve/Rules.java | 7 +- test/strucTypes3/Construct.java | 11 +- test/strucTypes5/InterfaceTest.java | 60 + test/strucTypes5/SolveTestRek.jav | 4 +- test/strucTypes5/SolveTest_Rek.java | 8 +- test/strucTypes5/TestInterfaces.jav | 9 + test/strucTypes5/TypeExprTest.java | 2 - 17 files changed, 272 insertions(+), 1948 deletions(-) delete mode 100644 .idea/workspace.xml create mode 100644 src/de/dhbwstuttgart/strucTypes5/NeueKlassen/ConstructInterfaces.java delete mode 100644 src/de/dhbwstuttgart/strucTypes5/constraints/ConstraintSubTypeGeneric.java create mode 100644 test/strucTypes5/InterfaceTest.java create mode 100644 test/strucTypes5/TestInterfaces.jav diff --git a/.idea/workspace.xml b/.idea/workspace.xml deleted file mode 100644 index 17ca699a..00000000 --- a/.idea/workspace.xml +++ /dev/null @@ -1,1823 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - substi - substitu - reflect - Regel Re - Replac - SWAP - TVar_28 - TVar_25 - Reflec - Refle - remove - Remove - reflec - X - adapt - XXX - Re - adapt2 - erase - MyList - List - MyInteger - Gener - Generierte - equa - Interfaces - Interface - equals - sucheInter - Loca - - - - - - - - - - - - - - true - DEFINITION_ORDER - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - project - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1492600650522 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - file://$PROJECT_DIR$/test/strucTypes3/GeneralParserTestNew.java - 70 - - - - file://$PROJECT_DIR$/test/strucTypes3/GeneralParserTestNeuX.java - 58 - - - - file://$PROJECT_DIR$/test/strucTypes5/NewOperatorTest.java - 46 - - - - file://$PROJECT_DIR$/src/de/dhbwstuttgart/strucTypes5/solve/Rules.java - 392 - - - - file://$PROJECT_DIR$/src/de/dhbwstuttgart/strucTypes5/solve/Rules.java - 368 - - - - file://$PROJECT_DIR$/src/de/dhbwstuttgart/strucTypes5/algo/TypeExpr.java - 68 - - - - file://$PROJECT_DIR$/src/de/dhbwstuttgart/strucTypes5/solve/Rules.java - 157 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - No facets are configured - - - - - - - - - - - - - - - 1.8 - - - - - - - - JavaCompilerCore - - - - - - - - annotations-2.0.1 - - - - - - - - \ No newline at end of file diff --git a/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator/SyntaxTreeGenerator.java b/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator/SyntaxTreeGenerator.java index 8d4a6934..8b136ac7 100644 --- a/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator/SyntaxTreeGenerator.java +++ b/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator/SyntaxTreeGenerator.java @@ -2,6 +2,7 @@ package de.dhbwstuttgart.parser.SyntaxTreeGenerator; import de.dhbwstuttgart.exceptions.NotImplementedException; import de.dhbwstuttgart.parser.ClassNotFoundException; +import de.dhbwstuttgart.parser.NullToken; import de.dhbwstuttgart.parser.PackageCrawler; import de.dhbwstuttgart.parser.antlr.Java8Parser; import de.dhbwstuttgart.syntaxtree.*; diff --git a/src/de/dhbwstuttgart/strucTypes5/NeueKlassen/ConstructInterfaces.java b/src/de/dhbwstuttgart/strucTypes5/NeueKlassen/ConstructInterfaces.java new file mode 100644 index 00000000..23020760 --- /dev/null +++ b/src/de/dhbwstuttgart/strucTypes5/NeueKlassen/ConstructInterfaces.java @@ -0,0 +1,101 @@ +package de.dhbwstuttgart.strucTypes5.NeueKlassen; + +import de.dhbwstuttgart.parser.NullToken; +import de.dhbwstuttgart.parser.SyntaxTreeGenerator.GenericContext; +import de.dhbwstuttgart.syntaxtree.*; +import de.dhbwstuttgart.syntaxtree.statement.Block; +import de.dhbwstuttgart.syntaxtree.type.GenericRefType; +import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric; +import de.dhbwstuttgart.typecheck.GenericTypeName; +import de.dhbwstuttgart.typecheck.JavaClassName; +import org.antlr.v4.runtime.Token; + + + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by sebastian on 06.05.17. + */ +public class ConstructInterfaces { + + + public static void main(String[] args) { + + //ClassOrInterface cl = makeInterface( ); + //System.out.println(cl); + List nameArguments = new ArrayList<>(); + nameArguments.add("x"); + nameArguments.add("y"); + Method m = makeMethodForInterface("mt" , nameArguments); + makeMethodForInterface("add" , nameArguments ); + } + + + + + + public static ClassOrInterface makeInterface(String nameInterface, List arguments) { + + + // Initialisierie alles + int modifiers = 0; + JavaClassName name = new JavaClassName(nameInterface); + List< Field > fielddecl = new ArrayList<>(); + List< Method > methods = new ArrayList<>(); + List< Constructor > constructors = new ArrayList<>(); + + List genericTypeVars = new ArrayList<>(); + GenericDeclarationList genericClassParameters = new GenericDeclarationList(genericTypeVars, new NullToken()); + RefTypeOrTPHOrWildcardOrGeneric superClass = null; + Boolean isInterface = true; + List implementedInterfaces = new ArrayList<>(); + + ClassOrInterface newInterface = new ClassOrInterface(modifiers, name, fielddecl,methods,constructors, + genericClassParameters, superClass , isInterface , implementedInterfaces, new NullToken()); + + // Füge noch die benötigten Infos ein + List nameArguments = new ArrayList<>(); + nameArguments.add("x"); + nameArguments.add("y"); + Method m = makeMethodForInterface("mt" , nameArguments); + + makeMethodForInterface("add" , nameArguments ); + + methods.add( makeMethodForInterface("add" , nameArguments)); + + return newInterface; + } + + + + public static Method makeMethodForInterface(String name , List namesArgruments ) { + + String methodName = name; + RefTypeOrTPHOrWildcardOrGeneric returnType = null; + int modifiers = 0; + + List formalParameters = new ArrayList<>(); + // Generate Formalparameter + for (String nameArgument : namesArgruments ) { + // bounds + // Todo parent Class + GenericContext context = new GenericContext(new JavaClassName("xx") , "xx"); + + GenericTypeName typeName = new GenericTypeName( context,name); + GenericRefType typeVar = new GenericRefType(typeName, new NullToken()); + + formalParameters.add(new FormalParameter(name,typeVar , new NullToken() )); + } + + + ParameterList parameterList = new ParameterList(formalParameters,new NullToken()); + Block block = null; + List genericDeclarations = new ArrayList<>(); + GenericDeclarationList gtvDeclarations = new GenericDeclarationList(genericDeclarations ,new NullToken()); + Token offset = new NullToken(); + + return new Method(methodName ,returnType , 0 , parameterList ,block , gtvDeclarations, offset); + } +} diff --git a/src/de/dhbwstuttgart/strucTypes5/algo/Construct.java b/src/de/dhbwstuttgart/strucTypes5/algo/Construct.java index 75ca6d1d..24cc3a37 100644 --- a/src/de/dhbwstuttgart/strucTypes5/algo/Construct.java +++ b/src/de/dhbwstuttgart/strucTypes5/algo/Construct.java @@ -155,7 +155,6 @@ public class Construct { } } - //Konstruktor: // public ClassOrInterface(int modifiers, JavaClassName name, List fielddecl, List methods, GenericDeclarationList genericClassParameters, // RefTypeOrTPHOrWildcardOrGeneric superClass, Boolean isInterface, List implementetInterfaces = new ArrayList<>(); - ClassOrInterface newInterface = new ClassOrInterface(modifers, name, fields,methods, genericClassParameters, superClass , isInterface, implementetInterfaces ,new NullToken()); - return newInterface; + + + // return newInterface = new ClassOrInterface(modifers, name, fields,methods, genericClassParameters, superClass , isInterface, implementetInterfaces ,new NullToken()); +return null; } diff --git a/src/de/dhbwstuttgart/strucTypes5/algo/TI.java b/src/de/dhbwstuttgart/strucTypes5/algo/TI.java index 67110356..3f853c8c 100644 --- a/src/de/dhbwstuttgart/strucTypes5/algo/TI.java +++ b/src/de/dhbwstuttgart/strucTypes5/algo/TI.java @@ -54,8 +54,16 @@ public class TI { ConstructInterfaceTemplates constructInterfaceTemplates = new ConstructInterfaceTemplates(cl, tp.getTypeVarStore(), type.constraintList , tp.getMappingAltNeu()); System.out.println("Generierte Interfaces"); System.out.println(constructInterfaceTemplates.interfaceList); + //ToDo -> Interfaces umwandeln + + + + + System.out.println("Generierte Constraints"); System.out.println(constructInterfaceTemplates.remainingConstraints); + // ToDo -> constraints umwandeln + // Generiere Generics für die Klasse @@ -97,8 +105,6 @@ public class TI { - - // -------- Das Ergebnis aus Solve wird in die Assumptions gespeichert zu weiteren Verwendung ------------------------ @@ -121,9 +127,6 @@ public class TI { System.out.println(newResultConstraints); this.resultConstraints = newResultConstraints; - - - } @@ -144,6 +147,8 @@ public class TI { + + public List bearbeiteConstraints(List constraints , TypeVarStore typeVarStore) { List newResultConstraints = new ArrayList<>(); diff --git a/src/de/dhbwstuttgart/strucTypes5/algo/TypeExpr.java b/src/de/dhbwstuttgart/strucTypes5/algo/TypeExpr.java index 4af96f6b..6ee12a6c 100644 --- a/src/de/dhbwstuttgart/strucTypes5/algo/TypeExpr.java +++ b/src/de/dhbwstuttgart/strucTypes5/algo/TypeExpr.java @@ -16,7 +16,7 @@ import de.dhbwstuttgart.syntaxtree.type.RefType; import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric; - +import javax.swing.plaf.nimbus.State; import java.util.ArrayList; import java.util.List; @@ -69,6 +69,8 @@ public class TypeExpr { LocalVar localVar = (LocalVar) expression; // Erstellung keines Constriants // Lediglich eintrag in TypeVarStore + // Todo Problem TypeVar Expression != TypeVar Methode. + RefTypeOrTPHOrWildcardOrGeneric typeVar = assumptionMap.getVarAssumption(localVar.get_expression()); typeVarStore.addTuple(typeVar,localVar.getType()); @@ -85,6 +87,12 @@ public class TypeExpr { else if (expression instanceof MethodCall) { MethodCall methodCall = (MethodCall) expression; + // Return aufgrund von Refactoring + if (expression instanceof NewClass) { + return walkNewClass((NewClass) expression); + } + + // Call of non-Abstract Field do not add constraints if (methodCall.get_Receiver().getType() instanceof RefType) { List result = typeExpression(methodCall.get_Receiver()); @@ -131,19 +139,34 @@ public class TypeExpr { List result = typeExpression(receiver.get_Expression()); return result; } + else if (expression instanceof NewClass) { NewClass newClass = (NewClass) expression; + /* + @ veraltet -> kann seit big refactoring so nicht mehr geparst werden + Stattdessen wird dies jetzt in Method Call verarbeitet, weil dort die new Methode aufläuft + */ + return null; - // Argumente - List result = new ArrayList<>(); - - // TypeExpr für die Argumente - for (Expression arg : newClass.getArgumentList().getArguments()) { - result.addAll(typeExpression(arg)); - } -; + } + else { + System.err.println("Fehler unbekannt"); + System.out.println(expression); + List noResult = new ArrayList<>(); + return noResult; + } + } + public List walkNewClass(NewClass newClass) { + + // Argumente + List result = new ArrayList<>(); + + // TypeExpr für die Argumente + for (Expression arg : newClass.getArgumentList().getArguments()) { + result.addAll(typeExpression(arg)); + } /* Information: @@ -152,35 +175,30 @@ public class TypeExpr { Diese können dann verwendet werden. */ + //Versuche Informationen zu laden + AssumptionClass assumptionClass = assumptionMap.getClassAssumption(newClass.getType().toString()); + if (assumptionClass != null) { - //Versuche Informationen zu laden - AssumptionClass assumptionClass = assumptionMap.getClassAssumption(newClass.getType().toString()); - if (assumptionClass != null) { - - ChangeTypeVars changeTypeVars = new ChangeTypeVars(); - assumptionClass = changeTypeVars.change(assumptionClass); - assumptionMap.putClass(assumptionClass); - - OldConstraints oldConstraints= new OldConstraints(assumptionClass.getConstraints()); - result.add(oldConstraints); - - System.out.println("-----------------KlassenAssumption ------"); - System.out.println(assumptionClass.getTypeVarStore().toString()); - Class2String class2String = new Class2String(); - System.out.println(class2String.generateStringTypeVars(assumptionClass.getCl(), assumptionClass.getTypeVarStore())); - System.out.println("-----------------------"); - - //ChangeTypeVars changeTypeVars = new ChangeTypeVars(); - //AssumptionClass assumptionClass1 = changeTypeVars.change(assumptionClass); - - // ToDO Problem mit den neuen Typvariablen da die infos nochmals geladen werden beim Method call !!! - // (Das einige logische wäre bereits davor die TypVariablen zu tauschen -> So steht es ja eigentlich auf im Skript - //assumptionMap.putClass(assumptionClass1); - } + ChangeTypeVars changeTypeVars = new ChangeTypeVars(); + assumptionClass = changeTypeVars.change(assumptionClass); + assumptionMap.putClass(assumptionClass); + OldConstraints oldConstraints= new OldConstraints(assumptionClass.getConstraints()); + result.add(oldConstraints); + System.out.println("-----------------KlassenAssumption ------"); + System.out.println(assumptionClass.getTypeVarStore().toString()); + Class2String class2String = new Class2String(); + System.out.println(class2String.generateStringTypeVars(assumptionClass.getCl(), assumptionClass.getTypeVarStore())); + System.out.println("-----------------------"); + //ChangeTypeVars changeTypeVars = new ChangeTypeVars(); + //AssumptionClass assumptionClass1 = changeTypeVars.change(assumptionClass); + // ToDO Problem mit den neuen Typvariablen da die infos nochmals geladen werden beim Method call !!! + // (Das einige logische wäre bereits davor die TypVariablen zu tauschen -> So steht es ja eigentlich auf im Skript + //assumptionMap.putClass(assumptionClass1); + } /* //Versuche Informationen zu laden @@ -202,19 +220,13 @@ public class TypeExpr { } */ - - typeVarStore.addTuple(TypeVarFactory.makeTypeVar() , newClass.getType()); - return result; - } - else { - System.err.println("Fehler unbekannt"); - System.out.println(expression); - List noResult = new ArrayList<>(); - return noResult; - } + typeVarStore.addTuple(TypeVarFactory.makeTypeVar() , newClass.getType()); + return result; } + + public List getResultConstraints() { return resultConstraints; } diff --git a/src/de/dhbwstuttgart/strucTypes5/ausgabe/Class2String.java b/src/de/dhbwstuttgart/strucTypes5/ausgabe/Class2String.java index 089fecd1..f8ea671f 100644 --- a/src/de/dhbwstuttgart/strucTypes5/ausgabe/Class2String.java +++ b/src/de/dhbwstuttgart/strucTypes5/ausgabe/Class2String.java @@ -133,6 +133,13 @@ public class Class2String { } else if (expression instanceof MethodCall) { MethodCall methodCall = (MethodCall) expression; + + if (methodCall instanceof NewClass) { + return generateExpressionNewClass((NewClass) methodCall); + } + + + String receiverString = generateExpressionString(methodCall.get_Receiver()); String arguments = ""; @@ -147,14 +154,8 @@ public class Class2String { return generateExpressionString(receiver.get_Expression()); } else if (expression instanceof NewClass) { - NewClass newClass = (NewClass) expression; - String arguments = ""; - for (Expression arg : newClass.getArgumentList().getArguments()) { - String expArg = generateExpressionString(arg); - arguments = arguments.concat(expArg + ","); - } - return String.format("[new %s( %s ): %s ]" , newClass.getType() , arguments , newClass.getType() ); + return "XXX"; } else { return "Expression nicht bekannt"; @@ -196,6 +197,16 @@ public class Class2String { } + private String generateExpressionNewClass( NewClass newClass ) { + String arguments = ""; + for (Expression arg : newClass.getArgumentList().getArguments()) { + String expArg = generateExpressionString(arg); + arguments = arguments.concat(expArg + ","); + } + return String.format("[new %s( %s ): %s ]" , newClass.getType() , arguments , newClass.getType() ); + } + + diff --git a/src/de/dhbwstuttgart/strucTypes5/constraints/ConstraintSubTypeGeneric.java b/src/de/dhbwstuttgart/strucTypes5/constraints/ConstraintSubTypeGeneric.java deleted file mode 100644 index 2520e100..00000000 --- a/src/de/dhbwstuttgart/strucTypes5/constraints/ConstraintSubTypeGeneric.java +++ /dev/null @@ -1,40 +0,0 @@ -package de.dhbwstuttgart.strucTypes5.constraints; - -/** - * Created by sebastian on 20.04.17. - */ -public class ConstraintSubTypeGeneric extends ConstraintAbstract { - - private T1 subType; - private T2 superType; - - - public ConstraintSubTypeGeneric(T1 subType, T2 superType) { - this.subType = subType; - this.superType = superType; - } - - - public T1 getSubType() { - return subType; - } - - public void setSubType(T1 subType) { - this.subType = subType; - } - - public T2 getSuperType() { - return superType; - } - - public void setSuperType(T2 superType) { - this.superType = superType; - } - - @Override - public String toString() { - return String.format("ConstraintSubTypeG( %s <* %s )" , subType , superType); - } - - -} diff --git a/src/de/dhbwstuttgart/strucTypes5/constraints/InterfaceForConstraint.java b/src/de/dhbwstuttgart/strucTypes5/constraints/InterfaceForConstraint.java index 56e6385b..c9e0b70d 100644 --- a/src/de/dhbwstuttgart/strucTypes5/constraints/InterfaceForConstraint.java +++ b/src/de/dhbwstuttgart/strucTypes5/constraints/InterfaceForConstraint.java @@ -34,7 +34,6 @@ public class InterfaceForConstraint { genericsneu.add(tv); } } - generics = genericsneu; return true; } diff --git a/src/de/dhbwstuttgart/strucTypes5/factoryForSyntaxtree/FactoryForElementes.java b/src/de/dhbwstuttgart/strucTypes5/factoryForSyntaxtree/FactoryForElementes.java index 502ff9b6..4e74c34a 100644 --- a/src/de/dhbwstuttgart/strucTypes5/factoryForSyntaxtree/FactoryForElementes.java +++ b/src/de/dhbwstuttgart/strucTypes5/factoryForSyntaxtree/FactoryForElementes.java @@ -33,12 +33,4 @@ public class FactoryForElementes { GenericRefType genericRefType = new GenericRefType( genericTypeName , new NullToken()); return genericRefType; } - - - - - - - - } diff --git a/src/de/dhbwstuttgart/strucTypes5/solve/Rules.java b/src/de/dhbwstuttgart/strucTypes5/solve/Rules.java index c9300000..6ec6d40b 100644 --- a/src/de/dhbwstuttgart/strucTypes5/solve/Rules.java +++ b/src/de/dhbwstuttgart/strucTypes5/solve/Rules.java @@ -155,7 +155,7 @@ public class Rules { /* - // Todo wer sagt dass man nicht irgendwo in der mitte anfängt + // public void reflect(List constriants) { for (ConstraintAbstract cs : constriants) { if (cs instanceof ConstraintSubType) { @@ -389,7 +389,7 @@ public class Rules { } - if (nameStart != null && nameStartIF != null && nameVglStart != null && nameVglStart != null ) { + if (nameStart != null && nameStartIF != null && nameVglStart != null && nameVglIf != null ) { if (nameStart.equals(nameVglStart) && nameStartIF.equals(nameVglIf)) { return cs; } @@ -477,10 +477,7 @@ public class Rules { } } - } - - constraintsToRemove.add(css); return constraintsToRemove; } diff --git a/test/strucTypes3/Construct.java b/test/strucTypes3/Construct.java index 8d86dffa..71b8debc 100644 --- a/test/strucTypes3/Construct.java +++ b/test/strucTypes3/Construct.java @@ -60,9 +60,9 @@ public class Construct { List methods = new ArrayList(); - ClassOrInterface face = new ClassOrInterface(0, name, fielddecl, methods, genericDeclaraitonList, null, true, null , null); - - return face; + // return new ClassOrInterface(0, name, fielddecl, methods, genericDeclaraitonList, null, true, null , null); + + return null; } @@ -95,8 +95,9 @@ public class Construct { } - ClassOrInterface face = new ClassOrInterface(0, name, null, methodlist, genericDeclaraitonList, null, true, null, null); - return face; + + // return ClassOrInterface(0, name, null, methodlist, genericDeclaraitonList, null, true, null, null); + return null; } diff --git a/test/strucTypes5/InterfaceTest.java b/test/strucTypes5/InterfaceTest.java new file mode 100644 index 00000000..42683b0c --- /dev/null +++ b/test/strucTypes5/InterfaceTest.java @@ -0,0 +1,60 @@ +package strucTypes5; + +import de.dhbwstuttgart.parser.JavaTXParser; +import de.dhbwstuttgart.strucTypes5.algo.TI; +import de.dhbwstuttgart.strucTypes5.assumptions.AssumptionMap; +import de.dhbwstuttgart.syntaxtree.ClassOrInterface; +import de.dhbwstuttgart.syntaxtree.SourceFile; +import org.junit.Test; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +/** + * + * Test soll prüfen ob bei einem Aufruf von zwei mal der gleichen Klasse unterschiedlich neue Typvariablen vergeben werden + * + * + */ +public class InterfaceTest { + private static final String rootDirectory = System.getProperty("user.dir") + "/test/strucTypes5/"; + + @Test + public void run() { + + + List filenames = new ArrayList(); + filenames.add("TestInterfaces.jav"); + + JavaTXParser parser = new JavaTXParser(); + try { + for (String filename : filenames) { + + System.out.println("Teste: " + filename); + + SourceFile sf = parser.parse(new File(rootDirectory + filename)); + + SourceFile sfdebug = sf; + + ClassOrInterface mainClass = sf.getClasses().get(0); + ClassOrInterface aClass = sf.getClasses().get(1); + + AssumptionMap assumptionMap = new AssumptionMap(); + + TI ti = new TI(assumptionMap, aClass); + + TI ti1 = new TI(ti.assresult, mainClass); + + } + + } catch (Exception exc) { + exc.printStackTrace(); + fail(); + } + assertTrue("Tests durchlaufen", filenames.size() > 0); + } +} diff --git a/test/strucTypes5/SolveTestRek.jav b/test/strucTypes5/SolveTestRek.jav index b02a47e0..d7e25403 100644 --- a/test/strucTypes5/SolveTestRek.jav +++ b/test/strucTypes5/SolveTestRek.jav @@ -2,12 +2,12 @@ class Main { -main () { return new A().mt( new MyInteger() ); } +main () { return new A().mt( new A.mt( new MyInteger() ) ); } } class A{ -mt(x) { return x; } +mt(x) { return new A().mt(new MyInteger()); } } diff --git a/test/strucTypes5/SolveTest_Rek.java b/test/strucTypes5/SolveTest_Rek.java index a79bf8dc..ed0a25cb 100644 --- a/test/strucTypes5/SolveTest_Rek.java +++ b/test/strucTypes5/SolveTest_Rek.java @@ -67,9 +67,9 @@ public class SolveTest_Rek { TypeVarRefType myInteger = (TypeVarRefType) getTypeVar(ti1.resultConstraints , "TVar_MyInteger"); RefTypeOrTPHOrWildcardOrGeneric v2 = getTypeVar(ti1.resultConstraints , "TVar_2"); RefTypeOrTPHOrWildcardOrGeneric v5 = getTypeVar(ti1.resultConstraints , "TVar_5"); - System.out.println(myInteger.toString()); - System.out.println(v2.toString()); - System.out.println(v5.toString()); + System.out.println(myInteger); + // System.out.println(v2.toString()); + // System.out.println(v5.toString()); // Generiere Interface 1 List generics = new ArrayList<>(); @@ -110,7 +110,7 @@ public class SolveTest_Rek { } catch (Exception exc) { exc.printStackTrace(); - fail(); + fail(); } assertTrue("Tests durchlaufen", filenames.size() > 0); } diff --git a/test/strucTypes5/TestInterfaces.jav b/test/strucTypes5/TestInterfaces.jav new file mode 100644 index 00000000..af1bbf64 --- /dev/null +++ b/test/strucTypes5/TestInterfaces.jav @@ -0,0 +1,9 @@ + + +interface s1 { + + R add(A x); + +} + + diff --git a/test/strucTypes5/TypeExprTest.java b/test/strucTypes5/TypeExprTest.java index b3461c19..e765b5bc 100644 --- a/test/strucTypes5/TypeExprTest.java +++ b/test/strucTypes5/TypeExprTest.java @@ -42,7 +42,6 @@ public class TypeExprTest { SourceFile sf = parser.parse(new File(rootDirectory + filename)); - // Test of the Global Assumption Maker who make mass und fass; TypeVarStore typeVarStore = new TypeVarStore(); AssumptionMakerGlobal makerGlobal = new AssumptionMakerGlobal(sf.getClasses().get(0), typeVarStore ); @@ -66,7 +65,6 @@ public class TypeExprTest { TypeExpr typeExpr = new TypeExpr(assumptionMap , sf.getClasses().get(0).getMethods().get(0) , typeVarStore ); System.out.println(typeExpr.getResultConstraints()); System.out.println(typeExpr.getTypeVarStore()); - } } catch (Exception exc) {