forked from JavaTX/JavaCompilerCore
expression NewClass kann nach bigRefactoring wieder verarbeitet werden
This commit is contained in:
parent
7dbc2bbd4c
commit
13330e4fd6
1823
.idea/workspace.xml
generated
1823
.idea/workspace.xml
generated
File diff suppressed because it is too large
Load Diff
@ -2,6 +2,7 @@ package de.dhbwstuttgart.parser.SyntaxTreeGenerator;
|
|||||||
|
|
||||||
import de.dhbwstuttgart.exceptions.NotImplementedException;
|
import de.dhbwstuttgart.exceptions.NotImplementedException;
|
||||||
import de.dhbwstuttgart.parser.ClassNotFoundException;
|
import de.dhbwstuttgart.parser.ClassNotFoundException;
|
||||||
|
import de.dhbwstuttgart.parser.NullToken;
|
||||||
import de.dhbwstuttgart.parser.PackageCrawler;
|
import de.dhbwstuttgart.parser.PackageCrawler;
|
||||||
import de.dhbwstuttgart.parser.antlr.Java8Parser;
|
import de.dhbwstuttgart.parser.antlr.Java8Parser;
|
||||||
import de.dhbwstuttgart.syntaxtree.*;
|
import de.dhbwstuttgart.syntaxtree.*;
|
||||||
|
@ -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<String> nameArguments = new ArrayList<>();
|
||||||
|
nameArguments.add("x");
|
||||||
|
nameArguments.add("y");
|
||||||
|
Method m = makeMethodForInterface("mt" , nameArguments);
|
||||||
|
makeMethodForInterface("add" , nameArguments );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public static ClassOrInterface makeInterface(String nameInterface, List<String> 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<GenericTypeVar> genericTypeVars = new ArrayList<>();
|
||||||
|
GenericDeclarationList genericClassParameters = new GenericDeclarationList(genericTypeVars, new NullToken());
|
||||||
|
RefTypeOrTPHOrWildcardOrGeneric superClass = null;
|
||||||
|
Boolean isInterface = true;
|
||||||
|
List<? extends RefTypeOrTPHOrWildcardOrGeneric> 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<String> 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<String> namesArgruments ) {
|
||||||
|
|
||||||
|
String methodName = name;
|
||||||
|
RefTypeOrTPHOrWildcardOrGeneric returnType = null;
|
||||||
|
int modifiers = 0;
|
||||||
|
|
||||||
|
List<FormalParameter> 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<GenericTypeVar> genericDeclarations = new ArrayList<>();
|
||||||
|
GenericDeclarationList gtvDeclarations = new GenericDeclarationList(genericDeclarations ,new NullToken());
|
||||||
|
Token offset = new NullToken();
|
||||||
|
|
||||||
|
return new Method(methodName ,returnType , 0 , parameterList ,block , gtvDeclarations, offset);
|
||||||
|
}
|
||||||
|
}
|
@ -155,7 +155,6 @@ public class Construct {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//Konstruktor:
|
//Konstruktor:
|
||||||
// public ClassOrInterface(int modifiers, JavaClassName name, List<Field> fielddecl, List<Method> methods, GenericDeclarationList genericClassParameters,
|
// public ClassOrInterface(int modifiers, JavaClassName name, List<Field> fielddecl, List<Method> methods, GenericDeclarationList genericClassParameters,
|
||||||
// RefTypeOrTPHOrWildcardOrGeneric superClass, Boolean isInterface, List<? extends RefTypeOrTPHOrWildca
|
// RefTypeOrTPHOrWildcardOrGeneric superClass, Boolean isInterface, List<? extends RefTypeOrTPHOrWildca
|
||||||
@ -167,8 +166,10 @@ public class Construct {
|
|||||||
Boolean isInterface = true;
|
Boolean isInterface = true;
|
||||||
List<RefTypeOrTPHOrWildcardOrGeneric> implementetInterfaces = new ArrayList<>();
|
List<RefTypeOrTPHOrWildcardOrGeneric> 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -54,8 +54,16 @@ public class TI {
|
|||||||
ConstructInterfaceTemplates constructInterfaceTemplates = new ConstructInterfaceTemplates(cl, tp.getTypeVarStore(), type.constraintList , tp.getMappingAltNeu());
|
ConstructInterfaceTemplates constructInterfaceTemplates = new ConstructInterfaceTemplates(cl, tp.getTypeVarStore(), type.constraintList , tp.getMappingAltNeu());
|
||||||
System.out.println("Generierte Interfaces");
|
System.out.println("Generierte Interfaces");
|
||||||
System.out.println(constructInterfaceTemplates.interfaceList);
|
System.out.println(constructInterfaceTemplates.interfaceList);
|
||||||
|
//ToDo -> Interfaces umwandeln
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
System.out.println("Generierte Constraints");
|
System.out.println("Generierte Constraints");
|
||||||
System.out.println(constructInterfaceTemplates.remainingConstraints);
|
System.out.println(constructInterfaceTemplates.remainingConstraints);
|
||||||
|
// ToDo -> constraints umwandeln
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Generiere Generics für die Klasse
|
// 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 ------------------------
|
// -------- Das Ergebnis aus Solve wird in die Assumptions gespeichert zu weiteren Verwendung ------------------------
|
||||||
|
|
||||||
|
|
||||||
@ -121,9 +127,6 @@ public class TI {
|
|||||||
System.out.println(newResultConstraints);
|
System.out.println(newResultConstraints);
|
||||||
this.resultConstraints = newResultConstraints;
|
this.resultConstraints = newResultConstraints;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -144,6 +147,8 @@ public class TI {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public List<ConstraintAbstract> bearbeiteConstraints(List<ConstraintAbstract> constraints , TypeVarStore typeVarStore) {
|
public List<ConstraintAbstract> bearbeiteConstraints(List<ConstraintAbstract> constraints , TypeVarStore typeVarStore) {
|
||||||
|
|
||||||
List<ConstraintAbstract> newResultConstraints = new ArrayList<>();
|
List<ConstraintAbstract> newResultConstraints = new ArrayList<>();
|
||||||
|
@ -16,7 +16,7 @@ import de.dhbwstuttgart.syntaxtree.type.RefType;
|
|||||||
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
|
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
|
||||||
|
|
||||||
|
|
||||||
|
import javax.swing.plaf.nimbus.State;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -69,6 +69,8 @@ public class TypeExpr {
|
|||||||
LocalVar localVar = (LocalVar) expression;
|
LocalVar localVar = (LocalVar) expression;
|
||||||
// Erstellung keines Constriants
|
// Erstellung keines Constriants
|
||||||
// Lediglich eintrag in TypeVarStore
|
// Lediglich eintrag in TypeVarStore
|
||||||
|
// Todo Problem TypeVar Expression != TypeVar Methode.
|
||||||
|
|
||||||
|
|
||||||
RefTypeOrTPHOrWildcardOrGeneric typeVar = assumptionMap.getVarAssumption(localVar.get_expression());
|
RefTypeOrTPHOrWildcardOrGeneric typeVar = assumptionMap.getVarAssumption(localVar.get_expression());
|
||||||
typeVarStore.addTuple(typeVar,localVar.getType());
|
typeVarStore.addTuple(typeVar,localVar.getType());
|
||||||
@ -85,6 +87,12 @@ public class TypeExpr {
|
|||||||
else if (expression instanceof MethodCall) {
|
else if (expression instanceof MethodCall) {
|
||||||
MethodCall methodCall = (MethodCall) expression;
|
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
|
// Call of non-Abstract Field do not add constraints
|
||||||
if (methodCall.get_Receiver().getType() instanceof RefType) {
|
if (methodCall.get_Receiver().getType() instanceof RefType) {
|
||||||
List<ConstraintAbstract> result = typeExpression(methodCall.get_Receiver());
|
List<ConstraintAbstract> result = typeExpression(methodCall.get_Receiver());
|
||||||
@ -131,8 +139,26 @@ public class TypeExpr {
|
|||||||
List<ConstraintAbstract> result = typeExpression(receiver.get_Expression());
|
List<ConstraintAbstract> result = typeExpression(receiver.get_Expression());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (expression instanceof NewClass) {
|
else if (expression instanceof NewClass) {
|
||||||
NewClass newClass = (NewClass) expression;
|
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;
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
System.err.println("Fehler unbekannt");
|
||||||
|
System.out.println(expression);
|
||||||
|
List<ConstraintAbstract> noResult = new ArrayList<>();
|
||||||
|
return noResult;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public List<ConstraintAbstract> walkNewClass(NewClass newClass) {
|
||||||
|
|
||||||
// Argumente
|
// Argumente
|
||||||
List<ConstraintAbstract> result = new ArrayList<>();
|
List<ConstraintAbstract> result = new ArrayList<>();
|
||||||
@ -141,9 +167,6 @@ public class TypeExpr {
|
|||||||
for (Expression arg : newClass.getArgumentList().getArguments()) {
|
for (Expression arg : newClass.getArgumentList().getArguments()) {
|
||||||
result.addAll(typeExpression(arg));
|
result.addAll(typeExpression(arg));
|
||||||
}
|
}
|
||||||
;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Information:
|
Information:
|
||||||
@ -152,7 +175,6 @@ public class TypeExpr {
|
|||||||
Diese können dann verwendet werden.
|
Diese können dann verwendet werden.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
//Versuche Informationen zu laden
|
//Versuche Informationen zu laden
|
||||||
AssumptionClass assumptionClass = assumptionMap.getClassAssumption(newClass.getType().toString());
|
AssumptionClass assumptionClass = assumptionMap.getClassAssumption(newClass.getType().toString());
|
||||||
if (assumptionClass != null) {
|
if (assumptionClass != null) {
|
||||||
@ -178,10 +200,6 @@ public class TypeExpr {
|
|||||||
//assumptionMap.putClass(assumptionClass1);
|
//assumptionMap.putClass(assumptionClass1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
//Versuche Informationen zu laden
|
//Versuche Informationen zu laden
|
||||||
AssumptionClass assumptionClass = assumptionMap.getClassAssumption(newClass.getType().toString());
|
AssumptionClass assumptionClass = assumptionMap.getClassAssumption(newClass.getType().toString());
|
||||||
@ -202,17 +220,11 @@ public class TypeExpr {
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
typeVarStore.addTuple(TypeVarFactory.makeTypeVar() , newClass.getType());
|
typeVarStore.addTuple(TypeVarFactory.makeTypeVar() , newClass.getType());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
System.err.println("Fehler unbekannt");
|
|
||||||
System.out.println(expression);
|
|
||||||
List<ConstraintAbstract> noResult = new ArrayList<>();
|
|
||||||
return noResult;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public List<ConstraintAbstract> getResultConstraints() {
|
public List<ConstraintAbstract> getResultConstraints() {
|
||||||
|
@ -133,6 +133,13 @@ public class Class2String {
|
|||||||
}
|
}
|
||||||
else if (expression instanceof MethodCall) {
|
else if (expression instanceof MethodCall) {
|
||||||
MethodCall methodCall = (MethodCall) expression;
|
MethodCall methodCall = (MethodCall) expression;
|
||||||
|
|
||||||
|
if (methodCall instanceof NewClass) {
|
||||||
|
return generateExpressionNewClass((NewClass) methodCall);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
String receiverString = generateExpressionString(methodCall.get_Receiver());
|
String receiverString = generateExpressionString(methodCall.get_Receiver());
|
||||||
|
|
||||||
String arguments = "";
|
String arguments = "";
|
||||||
@ -147,14 +154,8 @@ public class Class2String {
|
|||||||
return generateExpressionString(receiver.get_Expression());
|
return generateExpressionString(receiver.get_Expression());
|
||||||
}
|
}
|
||||||
else if (expression instanceof NewClass) {
|
else if (expression instanceof NewClass) {
|
||||||
NewClass newClass = (NewClass) expression;
|
|
||||||
|
|
||||||
String arguments = "";
|
return "XXX";
|
||||||
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() );
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return "Expression nicht bekannt";
|
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() );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,40 +0,0 @@
|
|||||||
package de.dhbwstuttgart.strucTypes5.constraints;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by sebastian on 20.04.17.
|
|
||||||
*/
|
|
||||||
public class ConstraintSubTypeGeneric<T1, T2> 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -34,7 +34,6 @@ public class InterfaceForConstraint {
|
|||||||
genericsneu.add(tv);
|
genericsneu.add(tv);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
generics = genericsneu;
|
generics = genericsneu;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -33,12 +33,4 @@ public class FactoryForElementes {
|
|||||||
GenericRefType genericRefType = new GenericRefType( genericTypeName , new NullToken());
|
GenericRefType genericRefType = new GenericRefType( genericTypeName , new NullToken());
|
||||||
return genericRefType;
|
return genericRefType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -155,7 +155,7 @@ public class Rules {
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
// Todo wer sagt dass man nicht irgendwo in der mitte anfängt
|
//
|
||||||
public void reflect(List<ConstraintAbstract> constriants) {
|
public void reflect(List<ConstraintAbstract> constriants) {
|
||||||
for (ConstraintAbstract cs : constriants) {
|
for (ConstraintAbstract cs : constriants) {
|
||||||
if (cs instanceof ConstraintSubType) {
|
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)) {
|
if (nameStart.equals(nameVglStart) && nameStartIF.equals(nameVglIf)) {
|
||||||
return cs;
|
return cs;
|
||||||
}
|
}
|
||||||
@ -477,10 +477,7 @@ public class Rules {
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
constraintsToRemove.add(css);
|
constraintsToRemove.add(css);
|
||||||
return constraintsToRemove;
|
return constraintsToRemove;
|
||||||
}
|
}
|
||||||
|
@ -60,9 +60,9 @@ public class Construct {
|
|||||||
List<Method> methods = new ArrayList<Method>();
|
List<Method> methods = new ArrayList<Method>();
|
||||||
|
|
||||||
|
|
||||||
ClassOrInterface face = new ClassOrInterface(0, name, fielddecl, methods, genericDeclaraitonList, null, true, null , null);
|
// return new ClassOrInterface(0, name, fielddecl, methods, genericDeclaraitonList, null, true, null , null);
|
||||||
|
|
||||||
return face;
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
60
test/strucTypes5/InterfaceTest.java
Normal file
60
test/strucTypes5/InterfaceTest.java
Normal file
@ -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<String> filenames = new ArrayList<String>();
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
@ -2,12 +2,12 @@
|
|||||||
|
|
||||||
|
|
||||||
class Main {
|
class Main {
|
||||||
main () { return new A().mt( new MyInteger() ); }
|
main () { return new A().mt( new A.mt( new MyInteger() ) ); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class A{
|
class A{
|
||||||
mt(x) { return x; }
|
mt(x) { return new A().mt(new MyInteger()); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -67,9 +67,9 @@ public class SolveTest_Rek {
|
|||||||
TypeVarRefType myInteger = (TypeVarRefType) getTypeVar(ti1.resultConstraints , "TVar_MyInteger");
|
TypeVarRefType myInteger = (TypeVarRefType) getTypeVar(ti1.resultConstraints , "TVar_MyInteger");
|
||||||
RefTypeOrTPHOrWildcardOrGeneric v2 = getTypeVar(ti1.resultConstraints , "TVar_2");
|
RefTypeOrTPHOrWildcardOrGeneric v2 = getTypeVar(ti1.resultConstraints , "TVar_2");
|
||||||
RefTypeOrTPHOrWildcardOrGeneric v5 = getTypeVar(ti1.resultConstraints , "TVar_5");
|
RefTypeOrTPHOrWildcardOrGeneric v5 = getTypeVar(ti1.resultConstraints , "TVar_5");
|
||||||
System.out.println(myInteger.toString());
|
System.out.println(myInteger);
|
||||||
System.out.println(v2.toString());
|
// System.out.println(v2.toString());
|
||||||
System.out.println(v5.toString());
|
// System.out.println(v5.toString());
|
||||||
|
|
||||||
// Generiere Interface 1
|
// Generiere Interface 1
|
||||||
List<RefTypeOrTPHOrWildcardOrGeneric> generics = new ArrayList<>();
|
List<RefTypeOrTPHOrWildcardOrGeneric> generics = new ArrayList<>();
|
||||||
|
9
test/strucTypes5/TestInterfaces.jav
Normal file
9
test/strucTypes5/TestInterfaces.jav
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
|
||||||
|
|
||||||
|
interface s1<R,A> {
|
||||||
|
|
||||||
|
R add(A x);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -42,7 +42,6 @@ public class TypeExprTest {
|
|||||||
|
|
||||||
SourceFile sf = parser.parse(new File(rootDirectory + filename));
|
SourceFile sf = parser.parse(new File(rootDirectory + filename));
|
||||||
|
|
||||||
|
|
||||||
// Test of the Global Assumption Maker who make mass und fass;
|
// Test of the Global Assumption Maker who make mass und fass;
|
||||||
TypeVarStore typeVarStore = new TypeVarStore();
|
TypeVarStore typeVarStore = new TypeVarStore();
|
||||||
AssumptionMakerGlobal makerGlobal = new AssumptionMakerGlobal(sf.getClasses().get(0), 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 );
|
TypeExpr typeExpr = new TypeExpr(assumptionMap , sf.getClasses().get(0).getMethods().get(0) , typeVarStore );
|
||||||
System.out.println(typeExpr.getResultConstraints());
|
System.out.println(typeExpr.getResultConstraints());
|
||||||
System.out.println(typeExpr.getTypeVarStore());
|
System.out.println(typeExpr.getTypeVarStore());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception exc) {
|
} catch (Exception exc) {
|
||||||
|
Loading…
Reference in New Issue
Block a user