diff --git a/doc/LambdaJavadoc/de/dhbwstuttgart/syntaxtree/type/class-use/BoundedGenericTypeVar.html b/doc/LambdaJavadoc/de/dhbwstuttgart/syntaxtree/type/class-use/BoundedGenericTypeVar.html
index 1327735c5..90acaab1b 100644
--- a/doc/LambdaJavadoc/de/dhbwstuttgart/syntaxtree/type/class-use/BoundedGenericTypeVar.html
+++ b/doc/LambdaJavadoc/de/dhbwstuttgart/syntaxtree/type/class-use/BoundedGenericTypeVar.html
@@ -70,7 +70,7 @@
diff --git a/src/de/dhbwstuttgart/bytecode/BytecodeTypeFactory.java b/src/de/dhbwstuttgart/bytecode/BytecodeTypeFactory.java
index d55f9daf6..424ef9096 100644
--- a/src/de/dhbwstuttgart/bytecode/BytecodeTypeFactory.java
+++ b/src/de/dhbwstuttgart/bytecode/BytecodeTypeFactory.java
@@ -1,6 +1,5 @@
package de.dhbwstuttgart.bytecode;
-import de.dhbwstuttgart.syntaxtree.type.BoundedGenericTypeVar;
import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar;
import de.dhbwstuttgart.syntaxtree.type.ObjectType;
import de.dhbwstuttgart.syntaxtree.type.RefType;
diff --git a/src/de/dhbwstuttgart/syntaxtree/factory/ASTFactory.java b/src/de/dhbwstuttgart/syntaxtree/factory/ASTFactory.java
index f733caf8c..83d1cbdd7 100644
--- a/src/de/dhbwstuttgart/syntaxtree/factory/ASTFactory.java
+++ b/src/de/dhbwstuttgart/syntaxtree/factory/ASTFactory.java
@@ -16,7 +16,6 @@ import de.dhbwstuttgart.syntaxtree.statement.Statement;
import de.dhbwstuttgart.syntaxtree.statement.SuperCall;
import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar;
import de.dhbwstuttgart.syntaxtree.type.RefType;
-import de.dhbwstuttgart.syntaxtree.type.Type;
import de.dhbwstuttgart.typeinference.Menge;
public class ASTFactory {
@@ -111,7 +110,7 @@ public class ASTFactory {
*/
public Method createMethod(java.lang.reflect.Method jreMethod, java.lang.Class inClass){
String name = jreMethod.getName();
- Type returnType = createType(jreMethod.getReturnType());
+ RefType returnType = createType(jreMethod.getReturnType());
Parameter[] jreParams = jreMethod.getParameters();
List params = new ArrayList<>();
for(Parameter jreParam : jreParams){
@@ -160,7 +159,7 @@ public class ASTFactory {
public GenericTypeVar createGeneric(TypeVariable jreTypeVar, java.lang.Class inClass){
//TODO: Bei den Namen der Parameter des Generishen Typs nachschauen, ob er in der Klasse als Generic deklariert wurde
String name = jreTypeVar.getTypeName();
- List genericBounds = new ArrayList<>();
+ List genericBounds = new ArrayList<>();
java.lang.reflect.Type[] bounds = jreTypeVar.getBounds();
if(bounds.length > 0){
for(java.lang.reflect.Type bound : bounds){
diff --git a/src/de/dhbwstuttgart/syntaxtree/modifier/Abstract.java b/src/de/dhbwstuttgart/syntaxtree/modifier/Abstract.java
index 0fbc63fd4..11661bcd8 100755
--- a/src/de/dhbwstuttgart/syntaxtree/modifier/Abstract.java
+++ b/src/de/dhbwstuttgart/syntaxtree/modifier/Abstract.java
@@ -1,30 +1,19 @@
-// ino.module.Abstract.8585.package
package de.dhbwstuttgart.syntaxtree.modifier;
import de.dhbwstuttgart.typeinference.JavaCodeResult;
import de.dhbwstuttgart.typeinference.ResultSet;
-
-// ino.class.Abstract.24015.description type=javadoc
/**
* Stellt den Modifier Abstract dar.
*
*/
-// ino.end
-// ino.class.Abstract.24015.declaration
public class Abstract extends Modifier
-// ino.end
-// ino.class.Abstract.24015.body
{
- // ino.method.getBitmask.24019.definition
public short getBitmask()
- // ino.end
- // ino.method.getBitmask.24019.body
{
return 0x0400;
}
- // ino.end
@Override
public JavaCodeResult printJavaCode(ResultSet resultSet) {
@@ -32,4 +21,3 @@ public class Abstract extends Modifier
}
}
-// ino.end
diff --git a/src/de/dhbwstuttgart/syntaxtree/type/BoundedGenericTypeVar.java b/src/de/dhbwstuttgart/syntaxtree/type/BoundedGenericTypeVar.java
index 3481ae89f..bb2c207fc 100755
--- a/src/de/dhbwstuttgart/syntaxtree/type/BoundedGenericTypeVar.java
+++ b/src/de/dhbwstuttgart/syntaxtree/type/BoundedGenericTypeVar.java
@@ -1,13 +1,15 @@
package de.dhbwstuttgart.syntaxtree.type;
+import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
import de.dhbwstuttgart.typeinference.Menge;
-import de.dhbwstuttgart.syntaxtree.Class;
-import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
import de.dhbwstuttgart.typeinference.ConstraintsSet;
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
import de.dhbwstuttgart.typeinference.exceptions.TypeinferenceException;
+import java.util.ArrayList;
+import java.util.List;
+
/**
* Entspricht einem GenericTypeVar, jedoch mit Bounds
* (d.h. vorgaben, von welchem Typ die Typevar sein darf
@@ -17,19 +19,19 @@ import de.dhbwstuttgart.typeinference.exceptions.TypeinferenceException;
* @author hoti 4.5.06
*
*/
-public class BoundedGenericTypeVar extends GenericTypeVar
+public class BoundedGenericTypeVar extends SyntaxTreeNode
{
/**
* Hier sind die Bounds in Form von Type-Objekten abgespeichert
*/
- Menge bounds=new Menge();
+ List bounds=new ArrayList();
private int endOffset;
- public BoundedGenericTypeVar(String s, Menge bounds, int offset, int endOffset)
+ public BoundedGenericTypeVar(String s, List bounds, int offset, int endOffset)
{
super(s, offset);
- if(bounds != null)for(Type t : bounds){
+ if(bounds != null)for(RefType t : bounds){
//if(t!=null)this.extendVars.add(t);
}
//this.genericTypeVar = new RefType(s,offset);
@@ -42,33 +44,11 @@ public class BoundedGenericTypeVar extends GenericTypeVar
return this.endOffset;
}
- public Menge getBounds()
+ public List getBounds()
{
return bounds;
}
-
- @Override
- //TODO: Die Constraints sollte nicht der TYPE Algorithmus generieren, sonder sollte der FC bekannt sein.
- public ConstraintsSet TYPE(TypeAssumptions ass) {
- ConstraintsSet ret = super.TYPE(ass);
- //ass.addGenericVarAssumption(this);
- //Die Type methode der BoundedGenericTypeVar schreibt zusätzlich noch die Constraints für die bounds
- Menge tempBounds = new Menge<>();
- if(this.bounds != null){
- for(ObjectType ev : this.bounds){
- Type extendsType = ev.TYPE(ass, this);
- if(extendsType == null)throw new TypeinferenceException("Der Typ "+ev.getName()+" ist nicht korrekt", this);
-
- //TODO: ??? stimmt der Cast???
- tempBounds.add((ObjectType)extendsType);
- //ret.add(new SingleConstraint(ass.getTypeFor(this, this), extendsType ));
- }
- }
- this.bounds = tempBounds;
- return ret;
- }
-
public BoundedGenericTypeVar clone()
{
return new BoundedGenericTypeVar(this.getName().toString(), this.getBounds(), getOffset(), this.getEndOffset());
diff --git a/src/de/dhbwstuttgart/syntaxtree/type/ExtendsWildcardType.java b/src/de/dhbwstuttgart/syntaxtree/type/ExtendsWildcardType.java
index ed95b2e7e..defb58c8f 100755
--- a/src/de/dhbwstuttgart/syntaxtree/type/ExtendsWildcardType.java
+++ b/src/de/dhbwstuttgart/syntaxtree/type/ExtendsWildcardType.java
@@ -23,7 +23,7 @@ public class ExtendsWildcardType extends WildcardType implements ITypeContainer,
* Author: Arne Lüdtke
* Standard Konstruktor für eine ExtendsWildcard
*/
- public ExtendsWildcardType (int offset, ObjectType extendsType)
+ public ExtendsWildcardType (int offset, RefType extendsType)
{
super(extendsType, offset);
this.name = new JavaClassName(this.toString());
diff --git a/src/de/dhbwstuttgart/syntaxtree/type/FunN.java b/src/de/dhbwstuttgart/syntaxtree/type/FunN.java
index f73aa7c3d..9d42a8e5b 100755
--- a/src/de/dhbwstuttgart/syntaxtree/type/FunN.java
+++ b/src/de/dhbwstuttgart/syntaxtree/type/FunN.java
@@ -30,8 +30,8 @@ import de.dhbwstuttgart.typeinference.exceptions.TypeinferenceException;
*/
public class FunN extends RefType {
- private Type R;
- private List extends Type> T;
+ private RefType R;
+ private List extends RefType> T;
/**
* @author Andreas Stadelmeier, a10023
@@ -41,7 +41,7 @@ public class FunN extends RefType {
* @param T
* @return
*/
- public FunN(Type R, List extends Type> T) {
+ public FunN(RefType R, List extends RefType> T) {
super("",0);
if(T==null || R == null)throw new NullPointerException();
setT(T);
@@ -69,7 +69,7 @@ public class FunN extends RefType {
public FunN(int parameterCount) {
super("",0);
if(parameterCount<0)throw new RuntimeException("Anzahl der Parameter muss >0 sein");
- Menge t = new Menge();
+ List t = new ArrayList<>();
for(int i=0;i t = new Menge();
+ List t = new ArrayList<>();
if(R!=null)t.add(R);
if(T!=null)t.addAll(T);
- for(Type type : t){
+ for(RefType type : t){
if(type instanceof WildcardType){
throw new DebugException("Der FunN-Typ darf keine Wildcards in den Parameter enthalten");
}
}
- this.set_ParaList(t);
+ this.parameter = t;
}
- protected void setT(List extends Type> list){
+ protected void setT(List extends RefType> list){
this.T = list;
calculateNewParalist();
}
- protected void setR(Type R){
+
+ protected void setR(RefType R){
this.R = R;
calculateNewParalist();
}
-
- /*
- @Override
- public String getName(){
- String ret = "FunN<"+R.toString();
- for(Type t : T){
- ret += ", " + t.toString();
- }
- ret += ">";
- return ret;
- }
-*/
-
-
- public int getTypeLineNumber() {
- // TODO Auto-generated method stub
- return 0;
- }
public String getBytecodeInvokeDynamicSignature(ClassGenerator cg, TypeinferenceResultSet rs) {
String ret = "(";
- for(Type t : T){
+ for(RefType t : T){
ret+=t.getBytecodeType(cg, rs).getSignature();
}
ret +=")";
@@ -135,62 +118,11 @@ public class FunN extends RefType {
public String getBytecodeInvokeDynamicSignatureUpperBound(ClassGenerator cg) {
String ret = "(";
- for(Type t : T){
+ for(RefType t : T){
ret+=cg.getInstructionFactory().createObjectType().getSignature();
}
ret +=")";
ret += cg.getInstructionFactory().createObjectType().getSignature();
return ret;
}
-
- @Override
- public Type TYPE(TypeAssumptions ass, SyntaxTreeNode parent){
- //FunN Typen müssen nicht geprüft werden. Sie werden schließlich nur von unserem Typinferenzalgorithmus erstellt:
- List paraList = new ArrayList<>();
- for(Type t : this.T){
- Type toAdd = t.TYPE(ass, parent);
- //if(toAdd == null)throw new TypeinferenceException("Typ "+toAdd+" ist in den Assumptions nicht vorhanden",this);
- paraList.add(toAdd);
- }
- FunN ret = new FunN(this.R.TYPE(ass, parent),paraList);
- return ret;
- }
-
- public FunNInterface getCorrespondingInterface(){
- return null;
- }
-
- /*
- @Override
- public JavaCodeResult printJavaCode(ResultSet resultSet){
- //String ret = super.printJavaCode(resultSet) + (T!=null ? this.T.size() : 0) +"<";
- JavaCodeResult ret = new JavaCodeResult("Fun" + (T!=null ? this.T.size() : 0) +"<");
- ret .attach( this.R.printJavaCode(resultSet)).attach(", ");
- Iterator it = T.iterator();
- while(it.hasNext()){
- Type t = it.next();
- ret.attach( t.printJavaCode(resultSet));
- if(it.hasNext())ret.attach(", ");
- }
- //ret = ret.substring(0, ret.length()-2);
- return ret.attach(">");
- }
- */
- /**
- * Die Clone-Methode von RefType darf von FunN NICHT überschrieben werden.
- @Override
- public FunN clone()
- {
- FunN ret = null;
- Menge clonepara = new Menge();
- for(int i = 0; i< this.T.size(); i++)
- {
- clonepara.addElement(((Type)this.T.elementAt(i)).clone());
- }
-
- ret = new FunN(this.R.clone(),clonepara);
- ret.setPrimitiveFlag(this.getPrimitiveFlag());
- return ret;
- }
- */
}
diff --git a/src/de/dhbwstuttgart/syntaxtree/type/FunVoidN.java b/src/de/dhbwstuttgart/syntaxtree/type/FunVoidN.java
index 81eca895a..62497db1f 100644
--- a/src/de/dhbwstuttgart/syntaxtree/type/FunVoidN.java
+++ b/src/de/dhbwstuttgart/syntaxtree/type/FunVoidN.java
@@ -1,7 +1,10 @@
package de.dhbwstuttgart.syntaxtree.type;
+import java.util.ArrayList;
import java.util.Iterator;
+import java.util.List;
+
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.parser.JavaClassName;
@@ -19,8 +22,8 @@ import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
*/
public class FunVoidN extends FunN {
- private Type R;
- private Menge T;
+ private RefType R;
+ private List T;
/**
* @author Andreas Stadelmeier, a10023
@@ -29,7 +32,7 @@ public class FunVoidN extends FunN {
* @param T
* @return
*/
- public FunVoidN(Menge T) {
+ public FunVoidN(List T) {
super(null,T);
this.setR(new Void(this, -1));
this.name = new JavaClassName("FunVoid"+T.size());
@@ -51,9 +54,9 @@ public class FunVoidN extends FunN {
* Dabei werden bestimmte, von RefType geerbte, Parameter angepasst. Dies ist wichtig für den Typinferenzalgorithmus.
*/
private void calculateNewParalist(){
- Menge t = new Menge();
+ List t = new ArrayList<>();
if(T!=null)t.addAll(T);
- this.set_ParaList(t);
+ this.parameter = t;
}
}
diff --git a/src/de/dhbwstuttgart/syntaxtree/type/GenericClassType.java b/src/de/dhbwstuttgart/syntaxtree/type/GenericClassType.java
deleted file mode 100644
index 9985f48fd..000000000
--- a/src/de/dhbwstuttgart/syntaxtree/type/GenericClassType.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package de.dhbwstuttgart.syntaxtree.type;
-
-import java.util.List;
-
-import de.dhbwstuttgart.bytecode.ClassGenerator;
-import de.dhbwstuttgart.parser.JavaClassName;
-import de.dhbwstuttgart.syntaxtree.Class;
-import de.dhbwstuttgart.syntaxtree.SourceFile;
-import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
-import de.dhbwstuttgart.syntaxtree.factory.ASTFactory;
-import de.dhbwstuttgart.typeinference.Menge;
-import de.dhbwstuttgart.typeinference.ResultSet;
-import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
-
-public class GenericClassType extends RefType{
-
- public GenericClassType(String fullyQualifiedName, List parameter, SyntaxTreeNode parent, int offset) {
- super(fullyQualifiedName, parameter, parent, offset);
- }
-
- @Override
- public String getBytecodeSignature(ClassGenerator cg, TypeinferenceResultSet rs) {
- return "L"+getTypeName()+";";
- }
-}
diff --git a/src/de/dhbwstuttgart/syntaxtree/type/GenericTypeVar.java b/src/de/dhbwstuttgart/syntaxtree/type/GenericTypeVar.java
deleted file mode 100755
index f4ed7c9bd..000000000
--- a/src/de/dhbwstuttgart/syntaxtree/type/GenericTypeVar.java
+++ /dev/null
@@ -1,215 +0,0 @@
-// ino.module.GenericTypeVar.8671.package
-package de.dhbwstuttgart.syntaxtree.type;
-// ino.end
-
-import java.util.ArrayList;
-// ino.module.GenericTypeVar.8671.import
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-
-import de.dhbwstuttgart.typeinference.Menge;
-
-import de.dhbwstuttgart.typeinference.ConstraintsSet;
-import de.dhbwstuttgart.typeinference.JavaCodeResult;
-import de.dhbwstuttgart.typeinference.Pair;
-import de.dhbwstuttgart.typeinference.ResultSet;
-import de.dhbwstuttgart.typeinference.TypeInsertable;
-import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
-import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
-import de.dhbwstuttgart.typeinference.exceptions.DebugException;
-import de.dhbwstuttgart.typeinference.exceptions.TypeinferenceException;
-import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertPoint;
-import de.dhbwstuttgart.bytecode.ClassGenerator;
-import de.dhbwstuttgart.parser.JavaClassName;
-import de.dhbwstuttgart.syntaxtree.Class;
-import de.dhbwstuttgart.syntaxtree.GTVDeclarationContext;
-import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
-import de.dhbwstuttgart.syntaxtree.factory.ASTFactory;
-
-/**
- * TODO: Diese Klasse überarbeiten. Pair genericTypeVar ist nicht implementiert.
- * @author J�rg B�uerle
- * @version $Date: 2013/09/22 20:12:53 $
- */
-public class GenericTypeVar extends ObjectType
-{
- //Type genericTypeVar;
- //Menge extendVars = new Menge();
- protected Pair genericConstraint;
- /**
- * Eine Registry f�r alle Generic-Instanzen, die vor der Bytecode-Generierung durch
- * Ihre Superklasse ersetzt werden m�ssen. Siehe "Type Erasure" in Sun Spezifikation.
- *
Autor: J�rg B�uerle
- */
- // private Hashtable> m_TypeErasureList;
- private static HashMap tph = new HashMap<>();
-
- /**
- *
- * @param genericTypeVarExtendsVar
-
- public GenericTypeVar(Pair genericTypeVarExtendsVar, int offset){
- super(offset);
- genericTypeVar = genericTypeVarExtendsVar.TA1;
- if(genericTypeVarExtendsVar.TA2!=null)this.extendVars.add(genericTypeVarExtendsVar.TA2);
- else{
- this.genericConstraint = genericTypeVarExtendsVar;
- }
- this.name = genericTypeVar.toString();
- }
- */
-
- public GenericTypeVar(String s, int offset)
- {
- super(s,offset);
- this.name = new JavaClassName(s);
- }
-
- /*
- public GenericTypeVar(Type tA1, int offset) {
- this(new Pair(tA1,null),offset);
- }
- */
- /**
- *
Author: J�rg B�uerle
- * @return
- */
- public GenericTypeVar clone()
- {
- return new GenericTypeVar(this.getName().toString(), getOffset());
- }
-
- /**
- *
Author: J�rg B�uerle
- * @param obj
- * @return
- */
- public boolean equals(Object obj)
- {
- return super.equals(obj) && (obj instanceof GenericTypeVar);
- }
-
- public String toString()
- {
- return "GTV " + this.getName();
- }
-
- @Override
- public int hashCode() {
- return this.name.hashCode();
- }
-
- /**
- * hoti 4.5.06
- * Generische Typen werden im Bytecode
- * aus Abwaertskompatiblitaet wie Object dargestellt
- */
- public String get_codegen_Type(Menge paralist)
- {
- return("Ljava/lang/Object;");
- }
-
- public String getSignatureType(Menge paralist)
- {
- return "T" + name + ";";
- }
-
- @Override
- public JavaCodeResult printJavaCode(ResultSet resultSet) {
- /*
- if(this.genericTypeVar!=null){
- JavaCodeResult ret = new JavaCodeResult();
- ret.attach(this.genericTypeVar.printJavaCode(resultSet));
-
- if(this.extendVars.size()>0){
- ret.attach(" extends ");
- Iterator it = this.extendVars.iterator();
- while(it.hasNext()){
- Type extend = it.next();
- ret.attach(extend.printJavaCode(resultSet));
- if(it.hasNext())ret.attach(", ");
- }
- }
-
- return ret;
- }
- */
- return new JavaCodeResult(this.name.toString());
- }
-
- public TypePlaceholder getTypePlaceHolder(SyntaxTreeNode environment) {
- String hashValue = this.getName().toString()+environment.hashCode();
- if(!GenericTypeVar.tph.containsKey(hashValue)){
- GenericTypeVar.tph.put(hashValue, TypePlaceholder.fresh(hashValue,this));
- }
- return GenericTypeVar.tph.get(hashValue);
- //return TypePlaceholder.fresh(this.getParent());
- //if(this.tph == null)this.tph = TypePlaceholder.fresh();
- //return this.tph;
- }
-
- @Override
- public String get_Name() {
- return this.getName().toString();
- }
-
- @Override
- public JavaClassName getName() {
- return this.name;
- }
-
- public TypeAssumptions createAssumptions(){
- TypeAssumptions ret = new TypeAssumptions();
- ret.addGenericVarAssumption(this);
- return ret;
- }
-
- /**
- * Die Type Methode auf generische Variablen angewandt sorgt für deren Eintragung in die TypeAssumptions.
- * @param ass
- * @return
- */
- public ConstraintsSet TYPE(TypeAssumptions ass){
- ConstraintsSet ret = new ConstraintsSet();
- ass.addGenericVarAssumption(this);
- return ret;
- }
-
- @Override
- public Type TYPE(TypeAssumptions ass, SyntaxTreeNode parent) {
- ass.addGenericVarAssumption(this); //Eine GenericTypeVar kann nur an Stellen vorkommen, an denen sie auch gültig ist. Daher kann sie den Assumptions hinzugefügt werden.
- return super.TYPE(ass, parent);
- }
-
- public int getEndOffset() {
- return this.getOffset() + this.name.toString().length();
- }
-
- @Override
- public void parserPostProcessing(SyntaxTreeNode parent) {
- //SyntaxTreeNode parentTemp = this.parent;
- super.parserPostProcessing(parent);
- //if(parentTemp != null)this.parent = parentTemp; //Der Parenttype einer GenericVar soll sich nicht ändern können, falls einmal gesetzt.
- }
-
- public GTVDeclarationContext getDeclarationContext() {
- return this.getGTVDeclarationContext();
- }
-
- @Override
- public org.apache.bcel.generic.Type getBytecodeType(ClassGenerator cg, TypeinferenceResultSet rs) {
- // TODO Bytecode
- return org.apache.bcel.generic.Type.getType(getSignatureType(null));// new org.apache.bcel.generic.ObjectType("Object");
- }
-
- public List getBounds()
- {
- //Gibt eine Liste mit "java.lang.Object" zurück, da jede Generic von Object erbt
- ArrayList ret = new ArrayList<>();
- ret.add(ASTFactory.createObjectType());
- return ret;
- }
-
-}
-
diff --git a/src/de/dhbwstuttgart/syntaxtree/type/IMatchable.java b/src/de/dhbwstuttgart/syntaxtree/type/IMatchable.java
deleted file mode 100755
index 8950040ac..000000000
--- a/src/de/dhbwstuttgart/syntaxtree/type/IMatchable.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package de.dhbwstuttgart.syntaxtree.type;
-
-/**
- * Dieses Interface wird von allen Klassen implementiert, die weitere Klassen
- * enthalten, die im match des Unify beachtet werden müssen.
- *
- * @author Arne Lüdtke
- *
- */
-public interface IMatchable
-{
- /**
- * Author: Arne Lüdtke
- * Gibt den Typen zurück, der bei einem match im Unify verwendet werden soll.
- * Wird über IMatchable implementiert.
- */
- Type getMatchType();
-}
diff --git a/src/de/dhbwstuttgart/syntaxtree/type/ITypeContainer.java b/src/de/dhbwstuttgart/syntaxtree/type/ITypeContainer.java
deleted file mode 100755
index 8ce030cc7..000000000
--- a/src/de/dhbwstuttgart/syntaxtree/type/ITypeContainer.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package de.dhbwstuttgart.syntaxtree.type;
-
-/**
- * Dieses Interface wird von allen Klassen implementiert, die weitere Klassen enthalten.
- * Wird für diverse Hilfsmethoden verwendet.
- *
- * @author Arne Lüdtke
- *
- */
-
-public interface ITypeContainer
-{
- /**
- * Author: Arne Lüdtke
- * Das gleiche wie get_ExtendsType().
- * Implementiert ITypeContainer
- */
- Type getContainedType();
-}
diff --git a/src/de/dhbwstuttgart/syntaxtree/type/ObjectType.java b/src/de/dhbwstuttgart/syntaxtree/type/ObjectType.java
deleted file mode 100644
index 4f1a0f8e1..000000000
--- a/src/de/dhbwstuttgart/syntaxtree/type/ObjectType.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package de.dhbwstuttgart.syntaxtree.type;
-
-import de.dhbwstuttgart.parser.JavaClassName;
-import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
-
-/**
- * Der ObjectType repräsentiert einen Typ ohne Wildcards.
- * Eine Trennung zwischen Wildcard-Typen und anderen Typen ist notwendig.
- * Ein WildcardTyp kann nur ObjectTypes aufnehmen: ? extends ObjectType
- */
-public abstract class ObjectType extends Type {
-
- public ObjectType(JavaClassName s, int offset) {
- super(s, offset);
- }
- public abstract ObjectType clone();
-}
diff --git a/src/de/dhbwstuttgart/syntaxtree/type/ParaList.java b/src/de/dhbwstuttgart/syntaxtree/type/ParaList.java
deleted file mode 100755
index 2e1a9f7ac..000000000
--- a/src/de/dhbwstuttgart/syntaxtree/type/ParaList.java
+++ /dev/null
@@ -1,86 +0,0 @@
-// ino.module.ParaList.8674.package
-package de.dhbwstuttgart.syntaxtree.type;
-// ino.end
-// ino.module.ParaList.8674.import
-import de.dhbwstuttgart.typeinference.Menge;
-
-import de.dhbwstuttgart.logger.Logger;
-// ino.end
-import de.dhbwstuttgart.logger.Section;
-
-
-
-
-
-// ino.class.ParaList.26591.declaration
-public class ParaList extends Menge
-// ino.end
-// ino.class.ParaList.26591.body
-{
- // ino.attribute.paralist.26594.declaration
- //protected Menge paralist = new Menge();
- // ino.end
- // ino.attribute.parserlog.26597.declaration
- protected static Logger parserlog = Logger.getLogger("parser");
- // ino.end
- // ino.method.ParaList.26600.definition
- public ParaList()
- // ino.end
- // ino.method.ParaList.26600.body
- {}
- // ino.end
- // ino.method.ParaList.26603.definition
- ParaList(Type t)
- // ino.end
- // ino.method.ParaList.26603.body
- {
- parserlog.debug( "ParaList: " + t, Section.PARSER );
- this.addElement(t);
- }
- // ino.end
-
- // ino.method.get_ParaList.26606.definition
- public Menge get_ParaList()
- // ino.end
- // ino.method.get_ParaList.26606.body
- {
- return this;
- }
- // ino.end
-
- // ino.method.add_ParaList.26609.definition
- public void add_ParaList(Type obj)
- // ino.end
- // ino.method.add_ParaList.26609.body
- {
- this.addElement(obj);
- }
- // ino.end
-
- // ino.method.get_firstElement.26612.definition
- public Object get_firstElement()
- // ino.end
- // ino.method.get_firstElement.26612.body
- {
- return firstElement();
- }
- // ino.end
- // ino.method.getParalist.26615.definition
- public Menge getParalist()
- // ino.end
- // ino.method.getParalist.26615.body
- {
- return this;
- }
- // ino.end
- // ino.method.setParalist.26618.definition
- public void setParalist(Menge paralist)
- // ino.end
- // ino.method.setParalist.26618.body
- {
- this.removeAllElements();
- this.addAll(paralist);
- }
- // ino.end
-}
-// ino.end
diff --git a/src/de/dhbwstuttgart/syntaxtree/type/RefType.java b/src/de/dhbwstuttgart/syntaxtree/type/RefType.java
index 943e02002..8a175fb47 100755
--- a/src/de/dhbwstuttgart/syntaxtree/type/RefType.java
+++ b/src/de/dhbwstuttgart/syntaxtree/type/RefType.java
@@ -1,7 +1,4 @@
-// ino.module.RefType.8675.package
package de.dhbwstuttgart.syntaxtree.type;
-// ino.end
-// ino.module.RefType.8675.import
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.Hashtable;
@@ -30,12 +27,7 @@ import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
import de.dhbwstuttgart.typeinference.exceptions.TypeinferenceException;
-
-
-// ino.class.RefType.26621.declaration
-public class RefType extends ObjectType implements IMatchable
-// ino.end
-// ino.class.RefType.26621.body
+public class RefType extends SyntaxTreeNode
{
/**
* Ist IsArray auf true, muss beim Codegen ein Zeichen [ gesetzt werden
@@ -44,8 +36,8 @@ public class RefType extends ObjectType implements IMatchable
* Bsp.: 9| tag = CONSTANT_Utf8, length = 21, (Ljava/lang/String;)V
*/
private boolean IsArray = false;
-
- private List parameter = null;
+ protected JavaClassName name;
+ protected List parameter = null;
/**
* Ist primitiveFlag auf true, muss beim Codegen dieser Reftype durch
* den primitiven Datentyp ersetzt werden
@@ -54,10 +46,10 @@ public class RefType extends ObjectType implements IMatchable
*/
private boolean primitiveFlag=false;
- public RefType(String fullyQualifiedName, int offset)
+ public RefType(JavaClassName fullyQualifiedName, int offset)
{
- super(fullyQualifiedName,offset);
- this.setName(fullyQualifiedName);
+ super(offset);
+ this.name = (fullyQualifiedName);
}
@Override
@@ -68,199 +60,28 @@ public class RefType extends ObjectType implements IMatchable
return hash;
}
- // ino.method.RefType.26640.definition
- public RefType(String fullyQualifiedName, List parameter, int offset)
- // ino.end
- // ino.method.RefType.26640.body
+ public RefType(JavaClassName fullyQualifiedName, List parameter, int offset)
{
- super(fullyQualifiedName,offset);
- this.setName(fullyQualifiedName);
- if(parameter != null && parameter.size()>0)this.set_ParaList(parameter);
+ this(fullyQualifiedName, offset);
+ if(parameter != null && parameter.size()>0)this.parameter = parameter;
}
- public RefType( RefType R, SyntaxTreeNode parent,int offset )
- {
- super(R.name.toString(),offset);
- // otth: Copy-Konstruktor
- this.setName(R.getTypeName());
- this.set_ParaList(R.getParaList());
- }
- // ino.end
-
- public RefType(JavaClassName name, List parameter, int offset){
- super(name.toString(), offset);
- }
-
-
- /**
- * Wandelt die Parameter des RefTypes in TPHs um, sofern es sich um Generische Variablen handelt.
- * @return
- */
- public void GTV2TPH(SyntaxTreeNode environment){
- Menge paralist = new Menge();
- if(this.get_ParaList()!=null)for(Type t : this.get_ParaList()){
- if(t instanceof GenericTypeVar)paralist.add(((GenericTypeVar)t).getTypePlaceHolder(environment));
- else{
- if(t instanceof RefType)((RefType) t).GTV2TPH(environment);
- paralist.add(t);
- }
- }
- this.set_ParaList(paralist);
- }
-
- /**
- * HOTI
- * Diese Methode sucht in der Klassendefinition nach einen GTV, die
- * so heiÃt wie die im RefType definierte Variable. Wenn sie diese gefunden
- * hat, wird sie zurückgeben. Wenn dies nicht der Fall war, schaut sie, falls
- * angegeben in den Methodenparametern nach. Findet sie dort auch nichts, liefert
- * die Methode null.
- * @param type
- * @return
- */
- public GenericTypeVar findGenericType(Menge paralist, Menge methodParaList)
- {
- for(int i=0;i 0)
- para = para +", "+ t;
- else para = " " + t;
- }
- return name + "<"+para + " >" ;
- }*/
}
- // ino.end
- /**
- * Fügt eine Parameterliste an und tauscht zuvor alle GenerictTypeVars durch TPH aus.
- * In einem RefType dürfen keine GTVs enthalten sein.
- * @param v
- */
- // ino.method.set_ParaList.26661.definition
- public void set_ParaList(List v)
- // ino.end
- // ino.method.set_ParaList.26661.body
- {
- /*
- Menge paralist = new Menge();
- if(v!=null)for(Type t : v){
- if(t instanceof GenericTypeVar)paralist.add(((GenericTypeVar)t).getTypePlaceHolder());
- else paralist.add(t);
- }*/
- this.parameter = v;//paralist;
- }
- // ino.end
-
- /**
- * @return gibt bei leere Parameterliste null zurück. Ist entscheidend für unify-Algorithmus
- */
- // ino.method.get_ParaList.26664.definition
- public List get_ParaList()
- // ino.end
- // ino.method.get_ParaList.26664.body
- {
- if(this.parameter == null || this.parameter.size()==0)return null;
+ public List getParaList(){
+ if(this.parameter==null)return new ArrayList<>();
return this.parameter;
}
- // ino.end
-
- public List getParaList(){
- if(this.parameter==null)return new Menge<>();
- return this.parameter;
- }
-
- // ino.method.add_Parameter.26667.definition
- public void add_Parameter(Type o)
- // ino.end
- // ino.method.add_Parameter.26667.body
- {
- this.parameter.add(o);
- }
- // ino.end
-
- // ino.method.getTypeName.26670.definition
- public String getTypeName()
- // ino.end
- // ino.method.getTypeName.26670.body
- {
- // otth: Liefert den Namen des Typs, ohne Parameter, z.B. Stapel bei Stapel
- return name.toString();
- }
/**
* Author: Jrg Buerle
* @param Object
* @return
*/
- // ino.end
- // ino.method.equals.26685.definition
public boolean equals(Object obj)
- // ino.end
- // ino.method.equals.26685.body
{
if(obj instanceof RefType){
boolean ret = true;
@@ -293,12 +114,8 @@ public class RefType extends ObjectType implements IMatchable
return false;
}
}
- // ino.end
- // ino.method.clone.26688.definition
public RefType clone()
- // ino.end
- // ino.method.clone.26688.body
{
if(this.get_ParaList() != null )
{
@@ -320,12 +137,8 @@ public class RefType extends ObjectType implements IMatchable
return newRefType;
}
}
- // ino.end
- // ino.method.toString.26691.definition
public String toString()
- // ino.end
- // ino.method.toString.26691.body
{
String primitiveFlagMarker=primitiveFlag?"*":"";
if(parameter==null)
@@ -335,10 +148,10 @@ public class RefType extends ObjectType implements IMatchable
else
{
String para = new String();
- Iterator e=parameter.iterator();
+ Iterator e=parameter.iterator();
while(e.hasNext())
{
- Type ty = (Type)e.next();
+ RefType ty = e.next();
String t = ty.toString();
if(para.length() > 0)
para = para +", "+ t;
@@ -349,89 +162,15 @@ public class RefType extends ObjectType implements IMatchable
return ret + primitiveFlagMarker;//name + "<"+para + " >" +primitiveFlagMarker;
}
}
- // ino.end
-
- /*
- // ino.method.modifyToGenericTypeVar.26694.definition
- public GenericTypeVar modifyToGenericTypeVar(TypeInsertable parent)
- // ino.end
- // ino.method.modifyToGenericTypeVar.26694.body
- {
- return new GenericTypeVar(this.name.toString(),getOffset());
- }
- // ino.end
- */
-
- // ino.method.getSimpleName.26697.defdescription type=javadoc
- /**
- * HOTI
- * Liefert bei Klassen die fullyQualified angegeben wurden
- * nur den schlussendlichen Bezeichner
- * p.ex. de.dhbwstuttgart.typeinference.Menge => Menge
- * @return
- */
- public String getSimpleName()
- {
- return name.getName();
- }
-
-
- // ino.method.setPrimitiveFlag.29415.definition
- public void setPrimitiveFlag(boolean b)
- // ino.end
- // ino.method.setPrimitiveFlag.29415.body
- {
- this.primitiveFlag=b;
- }
- // ino.end
- // ino.method.getPrimitiveFlag.29418.definition
- public boolean getPrimitiveFlag()
- // ino.end
- // ino.method.getPrimitiveFlag.29418.body
- {
- return(this.primitiveFlag);
- }
- // ino.end
-
-
- /**
- * Author: Daniel Feinler
- * Handelt ab, ob der Typ eines Objekts ein Array ist, wenn true dann
- * wird im Bytecode ein flag gesetzt wenn nicht, dann halt nicht.
- * @return the IsArray
- */
- public boolean IsArray() {
- return IsArray;
- }
-
- /**
- * Author: Daniel Feinler
- * Handelt ab, ob der Typ eines Objekts ein Array ist, wenn true dann
- * wird im Bytecode ein flag gesetzt wenn nicht, dann halt nicht.
- * @param IsArray the IsArray to set
- */
- public void setArray(boolean IsArray) {
- this.IsArray = IsArray;
- }
-
- /**
- * Author: Arne Lüdtke
- * Gibt den Typen zurück, der bei einem match im Unify verwendet werden soll.
- * Wird über IMatchable implementiert.
- */
- public Type getMatchType()
- {
- return this;
- }
@Override
public JavaCodeResult printJavaCode(ResultSet resultSet) {
JavaCodeResult ret = new JavaCodeResult(this.name.toString());
if(this.getParaList()!=null && this.getParaList().size()>0){
ret .attach( "<" );
- Iterator it = this.getParaList().iterator();
+ Iterator it = this.getParaList().iterator();
while(it.hasNext()){
- Type t = it.next();
+ RefType t = it.next();
ret .attach( t.printJavaCode(resultSet));
if(it.hasNext())ret.attach(", ");
}
@@ -440,51 +179,14 @@ public class RefType extends ObjectType implements IMatchable
}
return ret;
}
-
- @Override
- public Type applyResultSet(ResultSet result) {
-
- return super.applyResultSet(result);
- }
- /**
- * Liefert alle SuperWildcardTypes, die in diesem Typ enthalten sind.
- * Dabei werden auch die parameter auf SuperWildcardTypes durchsucht.
- * @return
- */
- @Override
- public ArrayList getSuperWildcardTypes() {
- ArrayList ret = super.getSuperWildcardTypes();
- if(this.parameter!=null)for(Type paraType : this.parameter){
- if(paraType instanceof SuperWildcardType)ret.add((SuperWildcardType)paraType);
- }
- return ret;
- }
-
- @Override
public Menge getUnresolvedTPH(ResultSet resultSet) {
Menge ret = super.getUnresolvedTPH(resultSet);
- /*
- if(this.parameter!=null)for(Type t : this.parameter){
- if(t instanceof TypePlaceholder){
- TypePlaceholder tph = (TypePlaceholder)t;
- Type eq = resultSet.getTypeEqualTo(tph);
- if(eq instanceof TypePlaceholder)ret.add((TypePlaceholder)eq);
- }
- }
- */
ret.addAll(this.printJavaCode(resultSet).getUnresolvedTPH());
return ret;
}
- @Override
- public boolean involves(TypePlaceholder tph) {
- for(RefType param : parameter)
- return false;
- }
-
- @Override
- public Menge getInvolvedTypePlaceholder() {
+ public List getInvolvedTypePlaceholder() {
Menge ret = super.getInvolvedTypePlaceholder();
if(this.parameter == null)return ret;
for(Type param : this.parameter){
@@ -492,13 +194,6 @@ public class RefType extends ObjectType implements IMatchable
}
return ret;
}
-
- @Override
- public Type TYPE(TypeAssumptions ass, SyntaxTreeNode parent){
- Type t = super.TYPE(ass,parent);
- //((RefType)t.getType()).set_ParaList(this.get_ParaList());
- return t;
- }
@Override
public Menge getChildren() {
@@ -507,24 +202,7 @@ public class RefType extends ObjectType implements IMatchable
return ret;
}
- @Override
- public Type checkTYPE(TypeAssumptions ass, SyntaxTreeNode method) {
- Type t = ass.checkType(this, parent);
- if(t==null)
- throw new TypeinferenceException("Der Typ "+this.getName()+" ist nicht korrekt", parent);
- return t;
- }
-
- @Override
- public void parserPostProcessing(SyntaxTreeNode parent) {
- super.parserPostProcessing(parent);
- if(this.parameter != null)for(Type param : this.parameter){
- param.parserPostProcessing(this);
- }
- }
-
- @Override
- public org.apache.bcel.generic.Type getBytecodeType(ClassGenerator cg, TypeinferenceResultSet rs) {
+ public org.apache.bcel.generic.Type getBytecodeType(ClassGenerator cg, TypeinferenceResultSet rs) {
org.apache.bcel.generic.ObjectType ret = new org.apache.bcel.generic.ObjectType(getCombinedType(cg, rs));
if(this.IsArray()){
//Hier wird einfachhalber von einer Dimension ausgegangen. Arrays sind im Bytecode nur für main-Methode relevant
@@ -534,7 +212,6 @@ public class RefType extends ObjectType implements IMatchable
}
}
- @Override
public String getBytecodeSignature(ClassGenerator cg, TypeinferenceResultSet rs) {
String combinedType = getCombinedType(cg, rs);
/*
@@ -544,25 +221,23 @@ public class RefType extends ObjectType implements IMatchable
return ret;
}
- @Override
- public String getClassSignature(ClassGenerator cg, TypeinferenceResultSet rs) {
- return null;
- }
-
public String getCombinedType(ClassGenerator cg, TypeinferenceResultSet rs){
//Bsp.: Ljava/util/Vector;
StringBuilder sb = new StringBuilder();
String ret;
- List newParams = new ArrayList<>();
+ List newParams = new ArrayList<>();
if(parameter != null && parameter.size() > 0){
sb.append(getName().toString().replace(".", "%"));
sb.append("%%");
- for(Type type: parameter){
- Type newParameter;
+ for(RefType type: parameter){
+ RefType newParameter;
if(type instanceof RefType){
sb.append(((RefType) type).getCombinedType(cg, rs).replace(".", "%"));
newParameter = type;
}else if(type instanceof TypePlaceholder){
+ //TODO: Die Methode sollte keinen String, sondern einen BytecodeType zurückgeben.
+ //Auf sämtlichen RefTypes und TPHs muss eine Konvertierungsmethode aufgerufen werden, diese
+ // kann dann TPH dem entsprechenden Typ aus dem TypeinferenceResult zuweisen
newParameter = rs.getTypeOfPlaceholder((TypePlaceholder)type);
sb.append(((TypePlaceholder) type).getBytecodeType(cg, rs).toString().replace(".", "%"));
}else if(type instanceof WildcardType){
@@ -588,12 +263,5 @@ public class RefType extends ObjectType implements IMatchable
}
return ret;
}
-
- /*
- public GenericClassType getGenericClassType(){
- return new GenericClassType(getName().toString(), getParaList(), parent, getOffset());
- }
- */
}
-// ino.end
diff --git a/src/de/dhbwstuttgart/syntaxtree/type/SuperWildcardType.java b/src/de/dhbwstuttgart/syntaxtree/type/SuperWildcardType.java
index a4bbaedaa..c39120b16 100755
--- a/src/de/dhbwstuttgart/syntaxtree/type/SuperWildcardType.java
+++ b/src/de/dhbwstuttgart/syntaxtree/type/SuperWildcardType.java
@@ -10,6 +10,8 @@ import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
import de.dhbwstuttgart.typeinference.exceptions.DebugException;
+import java.util.List;
+
/**
* Stellt eine Wildcard mit unterer Grenze dar.
* z.B. void test(? super Integer var){..}
@@ -18,9 +20,9 @@ import de.dhbwstuttgart.typeinference.exceptions.DebugException;
*
*/
-public class SuperWildcardType extends WildcardType implements ITypeContainer, IMatchable{
+public class SuperWildcardType extends WildcardType{
- public SuperWildcardType(ObjectType innerType){
+ public SuperWildcardType(RefType innerType){
this(innerType.getOffset(), innerType);
}
@@ -28,7 +30,7 @@ public class SuperWildcardType extends WildcardType implements ITypeContainer, I
* Author: Arne Lüdtke
* Standard Konstruktor für eine SuperWildcard
*/
- public SuperWildcardType(int offset, ObjectType innerType)
+ public SuperWildcardType(int offset, RefType innerType)
{
super(innerType, offset);
}
@@ -39,7 +41,7 @@ public class SuperWildcardType extends WildcardType implements ITypeContainer, I
* Beispiel: ? super Integer.
* Integer wird zurückgegeben.
*/
- public ObjectType get_SuperType()
+ public RefType get_SuperType()
{
return this.innerType;
}
@@ -60,7 +62,7 @@ public class SuperWildcardType extends WildcardType implements ITypeContainer, I
*/
public SuperWildcardType clone()
{
- return new SuperWildcardType(getOffset(), (ObjectType) innerType.clone());
+ return new SuperWildcardType(getOffset(), innerType.clone());
}
/**
@@ -68,7 +70,7 @@ public class SuperWildcardType extends WildcardType implements ITypeContainer, I
* Das gleiche wie get_innerType().
* Ãberschreibt die Methode der Superklasse
*/
- public Type GetWildcardType()
+ public RefType GetWildcardType()
{
return this.get_SuperType();
}
@@ -78,7 +80,7 @@ public class SuperWildcardType extends WildcardType implements ITypeContainer, I
* Setzt den Typ in der Wildcard
* @param T - Type to be set
*/
- public void SetWildcardType(ObjectType T)
+ public void SetWildcardType(RefType T)
{
//if(T instanceof RefType)
this.innerType = (RefType)T;
@@ -89,7 +91,7 @@ public class SuperWildcardType extends WildcardType implements ITypeContainer, I
* Das gleiche wie get_innerType().
* Implementiert ITypeContainer
*/
- public Type getContainedType()
+ public RefType getContainedType()
{
return this.get_SuperType();
}
@@ -99,7 +101,7 @@ public class SuperWildcardType extends WildcardType implements ITypeContainer, I
* Gibt den Typen zurück, der bei einem match im Unify verwendet werden soll.
* Wird über IMatchable implementiert.
*/
- public Type getMatchType()
+ public RefType getMatchType()
{
return this.get_SuperType();
}
@@ -127,8 +129,8 @@ public class SuperWildcardType extends WildcardType implements ITypeContainer, I
}
@Override
- public Menge getInvolvedTypePlaceholder() {
- Menge ret = super.getInvolvedTypePlaceholder();
+ public List getInvolvedTypePlaceholder() {
+ List ret = super.getInvolvedTypePlaceholder();
ret.addAll(this.innerType.getInvolvedTypePlaceholder());
return ret;
}
@@ -139,28 +141,9 @@ public class SuperWildcardType extends WildcardType implements ITypeContainer, I
this.innerType.parserPostProcessing(this);
}
- @Override
- public Type TYPE(TypeAssumptions ass, SyntaxTreeNode parent) {
- this.innerType = (ObjectType) this.innerType.TYPE(ass, parent);
- return super.TYPE(ass, parent);
- }
-
- /*
- @Override
- public org.apache.bcel.generic.Type getBytecodeType(ClassGenerator cg) {
- //return new de.dhbwstuttgart.bytecode.WildcardType(this.innerType.get_Name(), "-");
- return this.innerType.getBytecodeType(cg);
- }
- */
-
@Override
public String getBytecodeSignature(ClassGenerator cg, TypeinferenceResultSet rs) {
return "-" + this.innerType.getBytecodeSignature(cg, rs);
}
- @Override
- public String get_Name() {
- return "? super "+this.innerType.get_Name();
- }
-
}
diff --git a/src/de/dhbwstuttgart/syntaxtree/type/TypePlaceholder.java b/src/de/dhbwstuttgart/syntaxtree/type/TypePlaceholder.java
index 7f69b2109..82f032edd 100755
--- a/src/de/dhbwstuttgart/syntaxtree/type/TypePlaceholder.java
+++ b/src/de/dhbwstuttgart/syntaxtree/type/TypePlaceholder.java
@@ -1,8 +1,4 @@
-// ino.module.TypePlaceholder.8678.package
package de.dhbwstuttgart.syntaxtree.type;
-// ino.end
-
-// ino.module.TypePlaceholder.8678.import
import java.util.Hashtable;
import java.util.Iterator;
@@ -24,7 +20,7 @@ import de.dhbwstuttgart.typeinference.exceptions.DebugException;
import de.dhbwstuttgart.typeinference.exceptions.TypeinferenceException;
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertPoint;
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
-// ino.class.TypePlaceholder.26780.description type=javadoc
+
/**
* Repr�sentiert einen Typparameter f�r einen vom Programmierer nicht angegeben
* Typ. Jede TypePlaceholder besitzt einen eindeutigen Namen aus einem Namenspool
@@ -33,16 +29,11 @@ import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
* @author J�rg B�uerle
* @version $Date: 2013/06/19 12:45:37 $
*/
-// ino.end
-// ino.class.TypePlaceholder.26780.declaration
-public class TypePlaceholder extends ObjectType
-// ino.end
-// ino.class.TypePlaceholder.26780.body
+public class TypePlaceholder extends RefType
{
private static final Logger log = Logger.getLogger(TypePlaceholder.class.getName());
private static Hashtable m_TypePlaceholdersRegistry = new Hashtable();
- // ino.end
private SyntaxTreeNode parent;
@@ -107,13 +98,7 @@ public class TypePlaceholder extends ObjectType
m_TypePlaceholdersRegistry.put(ret.getName().toString(), ret);
return ret;
}
-
- @Override
- public Menge getInvolvedTypePlaceholder() {
- Menge ret = super.getInvolvedTypePlaceholder();
- ret.add(this);
- return ret;
- }
+
/**
* Author: J�rg B�uerle
@@ -157,16 +142,7 @@ public class TypePlaceholder extends ObjectType
TypePlaceholder dolly = new TypePlaceholder(name.toString(), this.parent);
return dolly;
}
-
- /**
- * @author Andreas Stadelmeier, a10023
- * Ãberschreibt die get_Name-Methode der Type-Klasse. (Keine Ahnung wieso es überhaupt ein get_Name und ein getName gibt!)
- */
- @Override
- public String get_Name(){
- return getName().toString();
- }
-
+
public String toString()
{
return "TPH " + this.getName();
@@ -201,31 +177,7 @@ public class TypePlaceholder extends ObjectType
//return new TypePlaceholder(makeNewName());
}
- // ino.end
-
- // ino.method.backdoorSetName.26851.defdescription type=javadoc
- /**
- * Backdoor-Hilfsfunktion, die f�r makeFC()
und unify()
- * ben�tigt wird, um den Namen eines TypePlaceholders zu ver�ndern.
- * ACHTUNG: Diese TypePlaceholder
darf nicht Teil des abstrakten
- * Syntaxbaumes sein!!! Es muss sicher gestellt werden, dass die betreffende
- * TypePlaceholder
nicht �ber die Methode fresh()
,
- * sondern �ber backdoorCreate()
oder backdoorClone()
- * erzeugt worden ist.
- *
Author: J�rg B�uerle
- * @param varName Der Name des zu erzeugenden TypePlaceholders
- */
- // ino.end
- // ino.method.backdoorSetName.26851.definition
- public void backdoorSetName(String varName)
- // ino.end
- // ino.method.backdoorSetName.26851.body
- {
- name = new JavaClassName(varName);
- }
- // ino.end
-
- // ino.method.backdoorCreate.26854.defdescription type=javadoc
+
/**
* Backdoor-Hilfsfunktion, die f�r makeFC()
und unify()
* ben�tigt wird, zum Erzeugen eines TypePlaceholders
, der nicht in
@@ -253,7 +205,7 @@ public class TypePlaceholder extends ObjectType
///////////////////////////////////////////////////////////////////
private JavaCodeResult printJavaCodePr(ResultSet resultSet) {
- Type equalType = resultSet.getTypeEqualTo(this);
+ RefType equalType = resultSet.getTypeEqualTo(this);
if(equalType == null || equalType.equals(this)){
//Für den Fall das der TPH nicht aufgelöst werden konnte.
JavaCodeResult ret = new JavaCodeResult(this.getName().toString());
@@ -264,8 +216,7 @@ public class TypePlaceholder extends ObjectType
return equalType.printJavaCode(resultSet);
}
-
- @Override
+
public JavaCodeResult printJavaCode(ResultSet resultSet, boolean resolveTPHs){
if(resolveTPHs)return printJavaCodePr(resultSet);
return new JavaCodeResult(this.get_Name());
diff --git a/src/de/dhbwstuttgart/syntaxtree/type/Void.java b/src/de/dhbwstuttgart/syntaxtree/type/Void.java
deleted file mode 100755
index 8878c8e6c..000000000
--- a/src/de/dhbwstuttgart/syntaxtree/type/Void.java
+++ /dev/null
@@ -1,99 +0,0 @@
-// ino.module.Void.8679.package
-package de.dhbwstuttgart.syntaxtree.type;
-
-import de.dhbwstuttgart.bytecode.ClassGenerator;
-import de.dhbwstuttgart.core.IItemWithOffset;
-import de.dhbwstuttgart.syntaxtree.Method;
-import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
-import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
-import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
-import de.dhbwstuttgart.typeinference.exceptions.TypeinferenceException;
-
-// ino.end
-// ino.class.Void.26857.declaration
-public class Void extends RefType
-// ino.end
-// ino.class.Void.26857.body
-{
- public static final String VOID_NAME = "void";
- // ino.method.Void.26861.definition
- public Void(int offset)
- // ino.end
- // ino.method.Void.26861.body
- {
- super("void",offset);
- super.setName(VOID_NAME);
- }
- // ino.end
-
- // ino.method.equals.26864.defdescription type=javadoc
- /**
- * Author: J�rg B�uerle
- * @param Object
- * @return
- */
- // ino.end
- // ino.method.equals.26864.definition
- public boolean equals(Object obj)
- // ino.end
- // ino.method.equals.26864.body
- {
- if(obj instanceof RefType){
- boolean ret = true;
- ret &= super.equals(obj);
- // if(name==null){
- // ret &= ((Void)obj).get_Name()==null;
- // }
-
- //PL 05-07-31 auf void kann man nicht casten, da parameter in RefType private
- //ret &= name.equals(((Void)obj).getName());
- ret &= name.equals(((Type)obj).getName());
-
- return ret;
- }
- else{
- return false;
- }
- }
- // ino.end
-
- // ino.method.clone.26867.defdescription type=javadoc
- /**
- *
Author: J�rg B�uerle
- * @return
- */
- // ino.end
- // ino.method.clone.26867.definition
- public Void clone()
- // ino.end
- // ino.method.clone.26867.body
- {
- return new Void(getOffset());
- }
- // ino.end
-
- @Override
- public Type TYPE(TypeAssumptions ass, SyntaxTreeNode parent){
- return this;
- }
-
- @Override
- public Type checkTYPE(TypeAssumptions ass, SyntaxTreeNode method) {
- return this;//VOID ist immer korrekt, das wird vom Parser geprüft
- }
-
- @Override
- public org.apache.bcel.generic.Type getBytecodeType(ClassGenerator cg, TypeinferenceResultSet rs) {
- return org.apache.bcel.generic.Type.VOID;
- }
-
- @Override
- public String getBytecodeSignature(ClassGenerator cg, TypeinferenceResultSet rs) {
- return this.getBytecodeType(cg, rs).getSignature();
- }
-
- public String getBytecodeMethodSignature(ClassGenerator cg, TypeinferenceResultSet rs) {
- return this.getBytecodeSignature(cg, rs);
- }
-}
-// ino.end
diff --git a/src/de/dhbwstuttgart/syntaxtree/type/WildcardType.java b/src/de/dhbwstuttgart/syntaxtree/type/WildcardType.java
index cf5376e31..e2c99c68c 100755
--- a/src/de/dhbwstuttgart/syntaxtree/type/WildcardType.java
+++ b/src/de/dhbwstuttgart/syntaxtree/type/WildcardType.java
@@ -10,6 +10,7 @@ import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
import de.dhbwstuttgart.typeinference.exceptions.DebugException;
import de.dhbwstuttgart.typeinference.exceptions.NotImplementedException;
+import de.dhbwstuttgart.typeinference.exceptions.TypeinferenceException;
/**
* Stellt eine Wildcard in Java dar.
@@ -20,15 +21,16 @@ import de.dhbwstuttgart.typeinference.exceptions.NotImplementedException;
public abstract class WildcardType extends RefType{
- protected ObjectType innerType = null;
+ protected RefType innerType = null;
/**
* Author: Arne Lüdtke
* Standard Konstruktor für eine Wildcard
*/
- public WildcardType(ObjectType innerType, int offset)
+ public WildcardType(RefType innerType, int offset)
{
- super(innerType.name, offset);
+ super(innerType.getName(), offset);
+ if(innerType instanceof WildcardType)throw new TypeinferenceException("Ein Wildcardtype kann keinen Wildcardtype als innerType besitzen",this);
this.innerType = innerType;
}
@@ -50,7 +52,7 @@ public abstract class WildcardType extends RefType{
{
return null;
}
-
+
@Override
public JavaCodeResult printJavaCode(ResultSet resultSet) {
@@ -59,7 +61,7 @@ public abstract class WildcardType extends RefType{
@Override
public RefType TYPE(TypeAssumptions ass, SyntaxTreeNode parent) {
- this.innerType = (ObjectType) innerType.TYPE(ass, this);
+ this.innerType = innerType.TYPE(ass, this);
return this;
}
diff --git a/src/de/dhbwstuttgart/typeinference/Pair.java b/src/de/dhbwstuttgart/typeinference/Pair.java
index b0792868b..cbf3d26c7 100755
--- a/src/de/dhbwstuttgart/typeinference/Pair.java
+++ b/src/de/dhbwstuttgart/typeinference/Pair.java
@@ -1,13 +1,11 @@
-// ino.module.Pair.8673.package
package de.dhbwstuttgart.typeinference;
-// ino.end
-// ino.module.Pair.8673.import
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
+import java.util.ArrayList;
import java.util.Hashtable;
import java.util.List;
@@ -24,53 +22,17 @@ import de.dhbwstuttgart.syntaxtree.type.WildcardType;
-
-
-// ino.class.Pair.26540.description type=line
// Klasse, die ein Paar in der Menge Eq speichern kann
-// ino.end
-// ino.class.Pair.26540.declaration
public class Pair implements Serializable, DeepCloneable
-// ino.end
-// ino.class.Pair.26540.body
{
- // ino.attribute.TA1.26543.declaration
- public Type TA1;
- // ino.end
- // ino.attribute.TA2.26546.declaration
- public Type TA2;
- // ino.end
-
- // ino.attribute.bEqual.26549.declaration
- private PairOperator eOperator = PairOperator.SMALLER;
-
- // ino.end
- // ino.attribute.bSubst.26552.decldescription type=line
- // false <--> vorinitialisierter Wert
- // true <--> Dieses Paar entstand durch reduce1-Regel (=.)
- // --> Name von TA1 mu� gleich sein wie Name von TA2
- // Nur noch reduce2-Regel anwendbar
-
- // luar 15-04-2007
- // Der Unify mit Wildcards benötigt 3 verschiedene Operatoren.
- // Deshalb wurde der boolean durch einen Enum ersetzt.
- // Smaller <--> vorinitialisierter Wert
- // SmallerExtends <--> Kleiner extends (wie vorinitialisiert, nur mit einschluss der Wildcard)
- // Equal <--> Gleich: Name von TA1 und TA2 müssen gleich sein.
- // ino.end
-
- // ino.attribute.bSubst.26552.declaration
- public boolean bSubst; // speichert, ob die SUBST -Regel auf diese Paar
- // ino.end
- // ino.method.Pair.26555.defdescription type=line
- // schon angewandt wurde, Default = FALSE
- // ino.end
-
+ public RefType TA1;
+ public RefType TA2;
- // ino.method.Pair.26555.definition
- public Pair( Type TA1, Type TA2 )
- // ino.end
- // ino.method.Pair.26555.body
+ private PairOperator eOperator = PairOperator.SMALLER;
+
+ public boolean bSubst; // speichert, ob die SUBST -Regel auf diese Paar
+
+ public Pair( RefType TA1, RefType TA2 )
{
// Konstruktor
//if(TA1 == null || TA2 == null)throw new NullPointerException();
@@ -79,12 +41,8 @@ public class Pair implements Serializable, DeepCloneable
bSubst = false;
eOperator = PairOperator.SMALLER;
}
- // ino.end
- // ino.method.Pair.26558.definition
- public Pair( Type TA1, Type TA2, PairOperator eOp)
- // ino.end
- // ino.method.Pair.26558.body
+ public Pair( RefType TA1, RefType TA2, PairOperator eOp)
{
// Konstruktor
this(TA1,TA2);
@@ -93,7 +51,7 @@ public class Pair implements Serializable, DeepCloneable
// ino.end
// ino.method.Pair.26561.definition
- public Pair( Type TA1, Type TA2, PairOperator eOp, boolean bSubst )
+ public Pair( RefType TA1, RefType TA2, PairOperator eOp, boolean bSubst )
// ino.end
// ino.method.Pair.26561.body
{
@@ -130,12 +88,8 @@ public class Pair implements Serializable, DeepCloneable
/*- Equals: " + bEqual*/
}
- // ino.end
- // ino.method.isEqual.26567.definition
public boolean isEqual()
- // ino.end
- // ino.method.isEqual.26567.body
{
// otth: Prueft, ob TA1 == TA2
if( TA1 instanceof RefType && TA2 instanceof RefType )
@@ -213,15 +167,8 @@ public class Pair implements Serializable, DeepCloneable
}
- // ino.end
- // ino.method.copyType.26570.defdescription type=line
- // PL 05-01-22 static eingefuegt
- // ino.end
- // ino.method.copyType.26570.definition
- public static Type copyType( Type T )
- // ino.end
- // ino.method.copyType.26570.body
+ public static RefType copyType( RefType T )
{
// #JB# 22.05.2005
// ###########################################################
@@ -229,46 +176,13 @@ public class Pair implements Serializable, DeepCloneable
// ###########################################################
}
- // ino.end
- // ino.method.getTA1Copy.26573.definition
- public Type getTA1Copy( )
- // ino.end
- // ino.method.getTA1Copy.26573.body
- {
- return copyType( TA1 );
- }
- // ino.end
-
- // ino.method.getTA2Copy.26576.definition
- public Type getTA2Copy( )
- // ino.end
- // ino.method.getTA2Copy.26576.body
- {
- return copyType( TA2 );
- }
- // ino.end
-
- // ino.method.copyPair.26579.definition
- public Pair copyPair()
- // ino.end
- // ino.method.copyPair.26579.body
- {
- return new Pair(getTA1Copy(), getTA2Copy(), eOperator, bSubst);
- }
- // ino.end
-
- // ino.method.equals.26588.defdescription type=javadoc
/**
*
Author: J�rg B�uerle
* @param obj
* @return
*/
- // ino.end
- // ino.method.equals.26588.definition
public boolean equals(Object obj)
- // ino.end
- // ino.method.equals.26588.body
{
boolean ret = true;
ret &= (obj instanceof Pair);
@@ -277,16 +191,6 @@ public class Pair implements Serializable, DeepCloneable
ret &= ((Pair)obj).TA2.equals(this.TA2);
return ret;
}
- // ino.end
-
- /**
- * Author: Arne Lüdtke
- * Ãberprüft ob die Paare die gleichen Instanzen sind.
- */
- public boolean instanzeEquals(Object obj)
- {
- return super.equals(obj);
- }
/**
* Author: Arne Lüdtke
@@ -323,16 +227,7 @@ public class Pair implements Serializable, DeepCloneable
{
return eOperator;
}
-
- /**
- * Author: Arne Lüdtke
- * Setzt den Operator
- * @param operator - Operator to set.
- */
- public void SetOperator(PairOperator operator)
- {
- this.eOperator = operator;
- }
+
/**
* Author: Arne Lüdtke
@@ -358,8 +253,8 @@ public class Pair implements Serializable, DeepCloneable
/**
* @return Menge aus TA1 und TA2
*/
- public Menge getTypes(){
- Menge ret = new Menge<>();
+ public List getTypes(){
+ List ret = new ArrayList<>();
ret.add(this.TA1);
ret.add(this.TA2);
return ret;
@@ -384,4 +279,3 @@ public class Pair implements Serializable, DeepCloneable
return clone();
}
}
-// ino.end
diff --git a/src/de/dhbwstuttgart/typeinference/ResultSet.java b/src/de/dhbwstuttgart/typeinference/ResultSet.java
index 59de1ba0e..87c3ecbd6 100755
--- a/src/de/dhbwstuttgart/typeinference/ResultSet.java
+++ b/src/de/dhbwstuttgart/typeinference/ResultSet.java
@@ -1,6 +1,9 @@
package de.dhbwstuttgart.typeinference;
+import java.util.ArrayList;
import java.util.Iterator;
+import java.util.List;
+
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.syntaxtree.type.RefType;
import de.dhbwstuttgart.syntaxtree.type.Type;
@@ -37,7 +40,7 @@ public class ResultSet implements Iterable {
* @param type
* @return
*/
- public Type getTypeEqualTo(Type type) {
+ public RefType getTypeEqualTo(RefType type) {
return getTypeEqualTo(type,null);
}
@@ -46,8 +49,8 @@ public class ResultSet implements Iterable {
* @param type
* @return
*/
- public Type getTypeEqualTo(Type type, Menge ofType) {
- Type res = type;
+ public RefType getTypeEqualTo(RefType type, List ofType) {
+ RefType res = type;
Menge modifiedResultPairs = (Menge) resultPairs.clone();
Ret r = findPairWithTypeEqualTo(type, modifiedResultPairs);
while(r.i != -1 && r.ret != null){
@@ -64,14 +67,14 @@ public class ResultSet implements Iterable {
class Ret{
int i;
- Type ret;
- private Ret(int i, Type ret){
+ RefType ret;
+ private Ret(int i, RefType ret){
this.i = i;
this.ret = ret;
}
}
- private Ret findPairWithTypeEqualTo(Type type, Menge inResultPairs){
+ private Ret findPairWithTypeEqualTo(RefType type, Menge inResultPairs){
for(int i = 0; i {
* @param tA1
* @return true, falls der gesuchte Typ enthalten ist.
*/
- public boolean contains(Type tA1) {
+ public boolean contains(RefType tA1) {
for(Pair p : this){
if(p.TA1.equals(tA1)||p.TA2.equals(tA1))return true;
}
@@ -138,8 +141,8 @@ public class ResultSet implements Iterable {
* @param unresolvedTPH
* @return
*/
- public Menge getTypesInvolving(Menge unresolvedTPH) {
- Menge ret = new Menge();
+ public List getTypesInvolving(Menge unresolvedTPH) {
+ List ret = new ArrayList<>();
for(Pair p : this.resultPairs){
for(TypePlaceholder tph : unresolvedTPH){
if(p.TA1.involves(tph))ret.add(p.TA1);