From 6505c985e045f29a85bed63e8aa727cb87f4f0fb Mon Sep 17 00:00:00 2001 From: JanUlrich Date: Sun, 14 Sep 2014 18:38:43 +0200 Subject: [PATCH] Konstruktor von Type muss mit Elternelement im Syntaxbaum aufgerufen werden --- .../dhbwstuttgart/core/AClassOrInterface.java | 6 ++- src/de/dhbwstuttgart/syntaxtree/Class.java | 28 +++++++++++--- .../dhbwstuttgart/syntaxtree/SourceFile.java | 38 ++++++++++--------- .../syntaxtree/operator/AddOp.java | 20 +++++----- .../syntaxtree/operator/LogOp.java | 4 +- .../syntaxtree/operator/MulOp.java | 8 ++-- .../syntaxtree/operator/RelOp.java | 16 ++++---- .../syntaxtree/statement/Assign.java | 3 +- .../syntaxtree/statement/Block.java | 5 +-- .../syntaxtree/statement/BoolLiteral.java | 4 +- .../syntaxtree/statement/CharLiteral.java | 2 +- .../syntaxtree/statement/DoubleLiteral.java | 4 +- .../syntaxtree/statement/FloatLiteral.java | 2 +- .../syntaxtree/statement/IfStmt.java | 5 +-- .../syntaxtree/statement/InstVar.java | 1 - .../syntaxtree/statement/InstanceOf.java | 2 +- .../syntaxtree/statement/IntLiteral.java | 4 +- .../statement/LambdaExpression.java | 1 - .../syntaxtree/statement/LocalOrFieldVar.java | 1 - .../syntaxtree/statement/LocalVarDecl.java | 3 +- .../syntaxtree/statement/LongLiteral.java | 2 +- .../syntaxtree/statement/MethodCall.java | 2 +- .../syntaxtree/statement/NewClass.java | 7 ++-- .../syntaxtree/statement/NotExpr.java | 2 +- .../syntaxtree/statement/Null.java | 2 +- .../syntaxtree/statement/Return.java | 1 - .../syntaxtree/statement/Statement.java | 2 +- .../syntaxtree/statement/StringLiteral.java | 4 +- .../syntaxtree/statement/UnaryExpr.java | 6 +-- .../syntaxtree/statement/WhileStmt.java | 2 +- .../syntaxtree/type/BaseType.java | 8 ++-- .../syntaxtree/type/BooleanType.java | 7 ++-- .../syntaxtree/type/CharacterType.java | 7 ++-- .../syntaxtree/type/DoubleType.java | 7 ++-- .../syntaxtree/type/ExtendsWildcardType.java | 5 ++- .../syntaxtree/type/FloatType.java | 7 ++-- .../type/FreshExtendsWildcardType.java | 12 +++--- .../type/FreshSuperWildcardType.java | 12 +++--- .../syntaxtree/type/FreshWildcardType.java | 13 ++++--- .../syntaxtree/type/GenericTypeVar.java | 3 +- .../syntaxtree/type/IntegerType.java | 7 ++-- .../syntaxtree/type/LongType.java | 7 ++-- .../syntaxtree/type/RefType.java | 22 +++++------ .../syntaxtree/type/ReturnType.java | 2 +- .../syntaxtree/type/SuperWildcardType.java | 5 ++- .../dhbwstuttgart/syntaxtree/type/Type.java | 3 +- .../syntaxtree/type/TypePlaceholder.java | 3 +- .../dhbwstuttgart/syntaxtree/type/Void.java | 6 +-- .../syntaxtree/type/WildcardType.java | 9 +++-- .../typeinference/FreshTypeVariable.java | 38 ------------------- src/de/dhbwstuttgart/typeinference/Pair.java | 4 +- 51 files changed, 180 insertions(+), 194 deletions(-) delete mode 100755 src/de/dhbwstuttgart/typeinference/FreshTypeVariable.java diff --git a/src/de/dhbwstuttgart/core/AClassOrInterface.java b/src/de/dhbwstuttgart/core/AClassOrInterface.java index 93323e790..16a6f16f3 100755 --- a/src/de/dhbwstuttgart/core/AClassOrInterface.java +++ b/src/de/dhbwstuttgart/core/AClassOrInterface.java @@ -14,8 +14,10 @@ import org.apache.log4j.Logger; + import de.dhbwstuttgart.myexception.JVMCodeException; import de.dhbwstuttgart.parser.JavaClassName; +import de.dhbwstuttgart.syntaxtree.Interface; import de.dhbwstuttgart.syntaxtree.misc.UsedId; import de.dhbwstuttgart.syntaxtree.modifier.Modifiers; @@ -35,8 +37,8 @@ public interface AClassOrInterface { public JavaClassName getName(); - public Vector getSuperInterfaces(); - public void setSuperInterfaces(Vector vector); + public Vector getSuperInterfaces(); + public void setSuperInterfaces(Vector vector); /* // ino.attribute.inferencelog.21189.decldescription type=javadoc diff --git a/src/de/dhbwstuttgart/syntaxtree/Class.java b/src/de/dhbwstuttgart/syntaxtree/Class.java index 2b2804418..60163eff9 100755 --- a/src/de/dhbwstuttgart/syntaxtree/Class.java +++ b/src/de/dhbwstuttgart/syntaxtree/Class.java @@ -51,7 +51,7 @@ public class Class extends SyntaxTreeNode implements AClassOrInterface, IItemWit protected Modifiers modifiers; protected String name; - private Vector superif = new Vector(); + private Vector superif = new Vector(); public UsedId getPackageName() { @@ -88,11 +88,13 @@ public class Class extends SyntaxTreeNode implements AClassOrInterface, IItemWit } return ret; } - public Vector getSuperInterfaces() + + public Vector getSuperInterfaces() { return superif; } - public void setSuperInterfaces(Vector superif) + + public void setSuperInterfaces(Vector superif) { this.superif = superif; } @@ -142,6 +144,7 @@ public class Class extends SyntaxTreeNode implements AClassOrInterface, IItemWit private Vector fielddecl = new Vector(); private GenericDeclarationList genericClassParameters; private int offset; + private Class superClass; // ino.method.Class.23041.definition @@ -154,9 +157,16 @@ public class Class extends SyntaxTreeNode implements AClassOrInterface, IItemWit superclassid=null; } this.offset = offset; + if(!name.equals("Object"))//Alle Klassen außer Object erben von Object: + this.superClass = new Class("Object", -1); } // ino.end + public Class(String name, Class superClass, int offset){ + this(name,offset); + this.superClass = superClass; + } + // ino.method.Class.23044.definition public Class(String name, Modifiers mod, int offset) // ino.end @@ -179,7 +189,7 @@ public class Class extends SyntaxTreeNode implements AClassOrInterface, IItemWit // ino.end // ino.method.Class.23047.definition public Class(String name, Modifiers mod, ClassBody cb, Vector ct, Vector usedIdsToCheck, - UsedId superclass, Vector superif, Vector paralist, int offset) + UsedId superclass, Vector superif, Vector paralist, int offset) // ino.end // ino.method.Class.23047.body { @@ -1072,7 +1082,7 @@ public class Class extends SyntaxTreeNode implements AClassOrInterface, IItemWit parameter.add(((GenericTypeVar)param).getTypePlaceHolder());//(TypePlaceholder.fresh()); //Hier ist kein ReplacementListener notwendig. Der Typ soll nie eingesetzt werden. Der TPH wird nur gebraucht, damit das Unifizieren funktioniert. } */ - return new RefType(this.getName().toString(), this.get_ParaList(), 0); + return new RefType(this.getName().toString(), this.get_ParaList(),this, 0); } @@ -1208,6 +1218,12 @@ public class Class extends SyntaxTreeNode implements AClassOrInterface, IItemWit } } - + /** + * Die Super Klasse dieser Klasse. + * @return null für Klasse Object + */ + public Class getSuperClass(){ + return this.superClass; + } } // ino.end diff --git a/src/de/dhbwstuttgart/syntaxtree/SourceFile.java b/src/de/dhbwstuttgart/syntaxtree/SourceFile.java index 69ce984a8..241e3cd56 100755 --- a/src/de/dhbwstuttgart/syntaxtree/SourceFile.java +++ b/src/de/dhbwstuttgart/syntaxtree/SourceFile.java @@ -248,7 +248,7 @@ public class SourceFile */ // ino.end // ino.method.createPairFromClassAndSuperclass.21400.definition - private Pair createPairFromClassAndSuperclass(JavaClassName className, JavaClassName superclassName, Vector classParaOrg, Vector superclassParaOrg) + private Pair createPairFromClassAndSuperclass(Class baseClass, Class superclass, Vector classParaOrg, Vector superclassParaOrg) // ino.end // ino.method.createPairFromClassAndSuperclass.21400.body { @@ -259,10 +259,13 @@ public class SourceFile if(superclassParaOrg!=null && superclassParaOrg.size()==0){ superclassParaOrg=null; } + /* Pair P = new Pair( new RefType( className.toString(), classParaOrg,-1), new RefType( superclassName.toString(), superclassParaOrg,-1) ); + */ + Pair P = new Pair(baseClass.getType(), superclass.getType()); //PL 04-12-29 freshe Variablen ANFANG RefType r1 = (RefType)P.getTA1Copy(); RefType r2 = (RefType)P.getTA2Copy(); @@ -305,17 +308,16 @@ public class SourceFile { Class tempKlasse = KlassenVektor.elementAt(i); inferencelog.debug("Verarbeite "+tempKlasse.getName()); - + //TODO: SuperKlasse erstellen, dies sollte am besten beim Konstruktoraufruf von Class geschehen. Diese kann dann mit getSuperClass abgefragt werden. if( tempKlasse.superclassid != null ) { // Klasse hat Superklasse - Pair P=createPairFromClassAndSuperclass(tempKlasse.getName(),tempKlasse.get_Superclass_Name(),tempKlasse.get_ParaList(),tempKlasse.superclassid.get_ParaList()); + Pair P=createPairFromClassAndSuperclass(tempKlasse,tempKlasse.getSuperClass(),tempKlasse.get_ParaList(),tempKlasse.superclassid.get_ParaList()); vFC.add( P ); } if(tempKlasse.getSuperInterfaces()!=null){ - Iterator interfaceIterator=tempKlasse.getSuperInterfaces().iterator(); + Iterator interfaceIterator=tempKlasse.getSuperInterfaces().iterator(); while(interfaceIterator.hasNext()){ - UsedId intf=interfaceIterator.next(); - JavaClassName interfaceName=intf.getQualifiedName(); - Pair P=createPairFromClassAndSuperclass(tempKlasse.getName(),interfaceName,tempKlasse.get_ParaList(),intf.get_ParaList()); + Interface intf=interfaceIterator.next(); + Pair P=createPairFromClassAndSuperclass(tempKlasse,intf,tempKlasse.get_ParaList(),intf.get_ParaList()); vFC.add( P ); } @@ -324,11 +326,10 @@ public class SourceFile for(int i=0; i interfaceIterator=intf.getSuperInterfaces().iterator(); + Iterator interfaceIterator=intf.getSuperInterfaces().iterator(); while(interfaceIterator.hasNext()){ - UsedId superintf=interfaceIterator.next(); - JavaClassName superinterfaceName=superintf.getQualifiedName(); - Pair P=createPairFromClassAndSuperclass(intf.getName(),superinterfaceName,intf.getParaList(), superintf.get_ParaList()); + Interface superintf=interfaceIterator.next(); + Pair P=createPairFromClassAndSuperclass(intf,superintf,intf.getParaList(), superintf.get_ParaList()); vFC.add( P ); } @@ -1168,7 +1169,7 @@ public class SourceFile for(int j=0;j getOperatorTypes() { Hashtable types = new Hashtable(); - types.put(new RefType("java.lang.Integer",-1),new RefType("java.lang.Integer",-1)); - types.put(new RefType("java.lang.Double",-1),new RefType("java.lang.Double",-1)); - types.put(new RefType("java.lang.Float",-1), new RefType("java.lang.Float",-1)); - types.put(new RefType("java.lang.Long",-1), new RefType("java.lang.Long",-1)); - types.put(new RefType("java.lang.String",-1), new RefType("java.lang.String",-1)); + types.put(new RefType("java.lang.Integer",this,-1),new RefType("java.lang.Integer",this,-1)); + types.put(new RefType("java.lang.Double",this,-1),new RefType("java.lang.Double",this,-1)); + types.put(new RefType("java.lang.Float",this,-1), new RefType("java.lang.Float",this,-1)); + types.put(new RefType("java.lang.Long",this,-1), new RefType("java.lang.Long",this,-1)); + types.put(new RefType("java.lang.String",this,-1), new RefType("java.lang.String",this,-1)); return types; } @@ -62,11 +62,11 @@ public abstract class AddOp extends Operator @Override public HashMap getReturnTypes(TypeAssumptions ass) { HashMap ret = new HashMap(); - ret.put(ass.getTypeFor(new RefType("java.lang.Integer",-1), this), ass.getTypeFor(new RefType("java.lang.Integer",-1),this)); - ret.put(ass.getTypeFor(new RefType("java.lang.Double",-1), this), ass.getTypeFor(new RefType("java.lang.Double",-1),this)); - ret.put(ass.getTypeFor(new RefType("java.lang.Float",-1), this), ass.getTypeFor(new RefType("java.lang.Float",-1),this)); - ret.put(ass.getTypeFor(new RefType("java.lang.Long",-1), this), ass.getTypeFor(new RefType("java.lang.Long",-1),this)); - ret.put(ass.getTypeFor(new RefType("java.lang.String",-1),this), ass.getTypeFor(new RefType("java.lang.String",-1),this)); + ret.put(ass.getTypeFor(new RefType("java.lang.Integer",this,-1), this), ass.getTypeFor(new RefType("java.lang.Integer",this,-1),this)); + ret.put(ass.getTypeFor(new RefType("java.lang.Double",this,-1), this), ass.getTypeFor(new RefType("java.lang.Double",this,-1),this)); + ret.put(ass.getTypeFor(new RefType("java.lang.Float",this,-1), this), ass.getTypeFor(new RefType("java.lang.Float",this,-1),this)); + ret.put(ass.getTypeFor(new RefType("java.lang.Long",this,-1), this), ass.getTypeFor(new RefType("java.lang.Long",this,-1),this)); + ret.put(ass.getTypeFor(new RefType("java.lang.String",this,-1),this), ass.getTypeFor(new RefType("java.lang.String",this,-1),this)); return ret; } diff --git a/src/de/dhbwstuttgart/syntaxtree/operator/LogOp.java b/src/de/dhbwstuttgart/syntaxtree/operator/LogOp.java index 511cc9b79..ce80cd9b1 100755 --- a/src/de/dhbwstuttgart/syntaxtree/operator/LogOp.java +++ b/src/de/dhbwstuttgart/syntaxtree/operator/LogOp.java @@ -224,7 +224,7 @@ public abstract class LogOp extends Operator protected Hashtable getOperatorTypes() { Hashtable types = new Hashtable(); - types.put(new RefType("java.lang.Boolean",-1), new RefType("java.lang.Boolean",-1)); + types.put(new RefType("java.lang.Boolean",this,-1), new RefType("java.lang.Boolean",this,-1)); return types; } @@ -232,7 +232,7 @@ public abstract class LogOp extends Operator @Override public HashMap getReturnTypes(TypeAssumptions ass) { HashMap ret = new HashMap<>(); - ret.put(ass.getTypeFor(new RefType("java.lang.Boolean",-1), this), ass.getTypeFor(new RefType("java.lang.Boolean",-1), this)); + ret.put(ass.getTypeFor(new RefType("java.lang.Boolean",this,-1), this), ass.getTypeFor(new RefType("java.lang.Boolean",this,-1), this)); return ret; } diff --git a/src/de/dhbwstuttgart/syntaxtree/operator/MulOp.java b/src/de/dhbwstuttgart/syntaxtree/operator/MulOp.java index f28819ade..e3b37f082 100755 --- a/src/de/dhbwstuttgart/syntaxtree/operator/MulOp.java +++ b/src/de/dhbwstuttgart/syntaxtree/operator/MulOp.java @@ -43,10 +43,10 @@ public abstract class MulOp extends Operator @Override public HashMap getReturnTypes(TypeAssumptions ass) { HashMap ret = new HashMap<>(); - ret.put(ass.getTypeFor(new RefType("java.lang.Integer",-1), this), ass.getTypeFor(new RefType("java.lang.Integer",-1), this)); - ret.put(ass.getTypeFor(new RefType("java.lang.Double",-1), this), ass.getTypeFor(new RefType("java.lang.Double",-1), this)); - ret.put(ass.getTypeFor(new RefType("java.lang.Float",-1), this), ass.getTypeFor(new RefType("java.lang.Float",-1), this)); - ret.put(ass.getTypeFor(new RefType("java.lang.Long",-1), this), ass.getTypeFor(new RefType("java.lang.Long",-1), this)); + ret.put(ass.getTypeFor(new RefType("java.lang.Integer",this,-1), this), ass.getTypeFor(new RefType("java.lang.Integer",this,-1), this)); + ret.put(ass.getTypeFor(new RefType("java.lang.Double",this,-1), this), ass.getTypeFor(new RefType("java.lang.Double",this,-1), this)); + ret.put(ass.getTypeFor(new RefType("java.lang.Float",this,-1), this), ass.getTypeFor(new RefType("java.lang.Float",this,-1), this)); + ret.put(ass.getTypeFor(new RefType("java.lang.Long",this,-1), this), ass.getTypeFor(new RefType("java.lang.Long",this,-1), this)); return ret; } diff --git a/src/de/dhbwstuttgart/syntaxtree/operator/RelOp.java b/src/de/dhbwstuttgart/syntaxtree/operator/RelOp.java index 0c75a3592..c07187745 100755 --- a/src/de/dhbwstuttgart/syntaxtree/operator/RelOp.java +++ b/src/de/dhbwstuttgart/syntaxtree/operator/RelOp.java @@ -43,10 +43,10 @@ public abstract class RelOp extends Operator protected Hashtable getOperatorTypes() { Hashtable types = new Hashtable(); - types.put(new RefType("java.lang.Integer",-1), new RefType("java.lang.Boolean",-1)); - types.put(new RefType("java.lang.Double",-1), new RefType("java.lang.Boolean",-1)); - types.put(new RefType("java.lang.Float",-1), new RefType("java.lang.Boolean",-1)); - types.put(new RefType("java.lang.Long",-1), new RefType("java.lang.Boolean",-1)); + types.put(new RefType("java.lang.Integer",this,-1), new RefType("java.lang.Boolean",this,-1)); + types.put(new RefType("java.lang.Double",this,-1), new RefType("java.lang.Boolean",this,-1)); + types.put(new RefType("java.lang.Float",this,-1), new RefType("java.lang.Boolean",this,-1)); + types.put(new RefType("java.lang.Long",this,-1), new RefType("java.lang.Boolean",this,-1)); return types; } @@ -54,10 +54,10 @@ public abstract class RelOp extends Operator @Override public HashMap getReturnTypes(TypeAssumptions ass) { HashMap ret = new HashMap<>(); - ret.put(ass.getTypeFor(new RefType("java.lang.Boolean",-1), this), ass.getTypeFor(new RefType("java.lang.Integer",-1), this)); - ret.put(ass.getTypeFor(new RefType("java.lang.Boolean",-1), this), ass.getTypeFor(new RefType("java.lang.Double",-1), this)); - ret.put(ass.getTypeFor(new RefType("java.lang.Boolean",-1), this), ass.getTypeFor(new RefType("java.lang.Float",-1), this)); - ret.put(ass.getTypeFor(new RefType("java.lang.Boolean",-1), this), ass.getTypeFor(new RefType("java.lang.Long",-1), this)); + ret.put(ass.getTypeFor(new RefType("java.lang.Boolean",this,-1), this), ass.getTypeFor(new RefType("java.lang.Integer",this,-1), this)); + ret.put(ass.getTypeFor(new RefType("java.lang.Boolean",this,-1), this), ass.getTypeFor(new RefType("java.lang.Double",this,-1), this)); + ret.put(ass.getTypeFor(new RefType("java.lang.Boolean",this,-1), this), ass.getTypeFor(new RefType("java.lang.Float",this,-1), this)); + ret.put(ass.getTypeFor(new RefType("java.lang.Boolean",this,-1), this), ass.getTypeFor(new RefType("java.lang.Long",this,-1), this)); return ret; } diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/Assign.java b/src/de/dhbwstuttgart/syntaxtree/statement/Assign.java index e10cded54..04bffdb17 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/Assign.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/Assign.java @@ -24,7 +24,6 @@ import de.dhbwstuttgart.syntaxtree.type.Type; import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder; import de.dhbwstuttgart.syntaxtree.type.Void; import de.dhbwstuttgart.typeinference.ConstraintsSet; -import de.dhbwstuttgart.typeinference.FreshTypeVariable; import de.dhbwstuttgart.typeinference.JavaCodeResult; import de.dhbwstuttgart.typeinference.Pair; import de.dhbwstuttgart.typeinference.ResultSet; @@ -203,7 +202,7 @@ public class Assign extends Expr @Override public ConstraintsSet TYPEStmt(TypeAssumptions assumptions){ ConstraintsSet ret = this.TYPEExpr(assumptions); //TypeExpr aufrufen - this.setType(new Void(0)); //Typ des Statments auf Void setzen. + this.setType(new Void(this,0)); //Typ des Statments auf Void setzen. return ret; } diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/Block.java b/src/de/dhbwstuttgart/syntaxtree/statement/Block.java index 5ae6bba8e..87a16aa66 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/Block.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/Block.java @@ -23,7 +23,6 @@ import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder; import de.dhbwstuttgart.syntaxtree.type.Void; import de.dhbwstuttgart.typeinference.ConstraintType; import de.dhbwstuttgart.typeinference.ConstraintsSet; -import de.dhbwstuttgart.typeinference.FreshTypeVariable; import de.dhbwstuttgart.typeinference.JavaCodeResult; import de.dhbwstuttgart.typeinference.ResultSet; import de.dhbwstuttgart.typeinference.SingleConstraint; @@ -169,7 +168,7 @@ public class Block extends Statement @Override public ConstraintsSet TYPEStmt(TypeAssumptions assumptions) { ConstraintsSet ret = new ConstraintsSet(); - if(statements.size()==0)this.setType(new Void(0)); + if(statements.size()==0)this.setType(new Void(this,0)); /* this.setTypeVariable(TypePlaceholder.fresh(this)); */ for(Statement stmt : statements){ typinferenceLog.debug("Prozessing statement: "+stmt); @@ -199,7 +198,7 @@ public class Block extends Statement } } }else{ - this.setType(new Void(0)); + this.setType(new Void(this,0)); } return ret; } diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/BoolLiteral.java b/src/de/dhbwstuttgart/syntaxtree/statement/BoolLiteral.java index 39c4b6fa4..7516e1f22 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/BoolLiteral.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/BoolLiteral.java @@ -47,7 +47,7 @@ public class BoolLiteral extends Literal super(-1,-1); // #JB# 20.04.2005 // ########################################################### - this.setType(new BooleanType()); + this.setType(new BooleanType(this)); //this.setType(new Type("boolean")); // ########################################################### } @@ -126,7 +126,7 @@ public class BoolLiteral extends Literal @Override public ConstraintsSet TYPEExpr(TypeAssumptions assumptions) { - this.type = assumptions.getTypeFor(new RefType("java.lang.Boolean",-1), this).getType(); + this.type = assumptions.getTypeFor(new RefType("java.lang.Boolean",this,-1), this).getType(); return new ConstraintsSet(); } diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/CharLiteral.java b/src/de/dhbwstuttgart/syntaxtree/statement/CharLiteral.java index b8163af1f..a8b3e8f6d 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/CharLiteral.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/CharLiteral.java @@ -46,7 +46,7 @@ public class CharLiteral extends Literal super(-1,-1); // #JB# 20.04.2005 // ########################################################### - this.setType(new CharacterType()); + this.setType(new CharacterType(this)); //this.setType(new Type("char")); // ########################################################### } diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/DoubleLiteral.java b/src/de/dhbwstuttgart/syntaxtree/statement/DoubleLiteral.java index 97fc74067..aedce5931 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/DoubleLiteral.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/DoubleLiteral.java @@ -52,7 +52,7 @@ public class DoubleLiteral extends Literal { super(-1,-1); - this.setType(new DoubleType()); + this.setType(new DoubleType(this)); } // ino.end @@ -164,7 +164,7 @@ public class DoubleLiteral extends Literal @Override public ConstraintsSet TYPEExpr(TypeAssumptions assumptions) { - this.setType(assumptions.getTypeFor(new RefType("Double",this.getOffset()), this).getType()); + this.setType(assumptions.getTypeFor(new RefType("Double",this,this.getOffset()), this).getType()); return new ConstraintsSet(); } diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/FloatLiteral.java b/src/de/dhbwstuttgart/syntaxtree/statement/FloatLiteral.java index 80bd8526e..b1e1bb2b1 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/FloatLiteral.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/FloatLiteral.java @@ -45,7 +45,7 @@ public class FloatLiteral extends Literal { super(-1,-1); - this.setType(new FloatType()); + this.setType(new FloatType(this)); } // ino.end diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/IfStmt.java b/src/de/dhbwstuttgart/syntaxtree/statement/IfStmt.java index fe0a14362..e57cd48f5 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/IfStmt.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/IfStmt.java @@ -28,7 +28,6 @@ import de.dhbwstuttgart.syntaxtree.type.Type; import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder; import de.dhbwstuttgart.syntaxtree.type.Void; import de.dhbwstuttgart.typeinference.ConstraintsSet; -import de.dhbwstuttgart.typeinference.FreshTypeVariable; import de.dhbwstuttgart.typeinference.JavaCodeResult; import de.dhbwstuttgart.typeinference.Pair; import de.dhbwstuttgart.typeinference.ResultSet; @@ -259,10 +258,10 @@ public class IfStmt extends Statement ret.add(this.else_block.TYPEStmt(assumptions)); if(!(else_block.getType() instanceof Void))ret.add(new SingleConstraint(else_block.getType().TYPE(assumptions, this),this.getType().TYPE(assumptions, this))); } - ret.add(new SingleConstraint(expr.getType().TYPE(assumptions, this),assumptions.getTypeFor(new RefType("Boolean",0), this))); //(expressionDesIfStmt)<.boolean + ret.add(new SingleConstraint(expr.getType().TYPE(assumptions, this),assumptions.getTypeFor(new RefType("Boolean",this,0), this))); //(expressionDesIfStmt)<.boolean if(!(then_block.getType() instanceof Void))ret.add(new SingleConstraint(then_block.getType().TYPE(assumptions, this),this.getType().TYPE(assumptions, this))); if(then_block.getType() instanceof Void && - (else_block == null || else_block.getType() instanceof Void))this.setType(new Void(this.getOffset())); + (else_block == null || else_block.getType() instanceof Void))this.setType(new Void(this,this.getOffset())); return ret; } diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/InstVar.java b/src/de/dhbwstuttgart/syntaxtree/statement/InstVar.java index c78108bac..28fa843b3 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/InstVar.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/InstVar.java @@ -22,7 +22,6 @@ import de.dhbwstuttgart.syntaxtree.type.RefType; import de.dhbwstuttgart.syntaxtree.type.Type; import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder; import de.dhbwstuttgart.typeinference.ConstraintsSet; -import de.dhbwstuttgart.typeinference.FreshTypeVariable; import de.dhbwstuttgart.typeinference.JavaCodeResult; import de.dhbwstuttgart.typeinference.OderConstraint; import de.dhbwstuttgart.typeinference.Pair; diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/InstanceOf.java b/src/de/dhbwstuttgart/syntaxtree/statement/InstanceOf.java index 2178ba464..79276d895 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/InstanceOf.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/InstanceOf.java @@ -56,7 +56,7 @@ public class InstanceOf extends BinaryExpr super(offset,variableLength); // #JB# 20.04.2005 // ########################################################### - this.setType(new BooleanType()); + this.setType(new BooleanType(this)); //this.setType(new Type("boolean")); // ########################################################### } diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/IntLiteral.java b/src/de/dhbwstuttgart/syntaxtree/statement/IntLiteral.java index c06c6d679..212cc0eb7 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/IntLiteral.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/IntLiteral.java @@ -48,7 +48,7 @@ public class IntLiteral extends Literal super(-1,-1); // #JB# 20.04.2005 // ########################################################### - this.setType(new IntegerType()); + this.setType(new IntegerType(this)); //this.setType(new Type("int")); // ########################################################### } @@ -161,7 +161,7 @@ public class IntLiteral extends Literal public ConstraintsSet TYPEExpr(TypeAssumptions assumptions) { ConstraintsSet ret = new ConstraintsSet(); //this.setType(new IntegerType()); - this.set_Type(assumptions.getTypeFor(new RefType("java.lang.Integer",-1), this).getType()); + this.set_Type(assumptions.getTypeFor(new RefType("java.lang.Integer",this,-1), this).getType()); return ret; } diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/LambdaExpression.java b/src/de/dhbwstuttgart/syntaxtree/statement/LambdaExpression.java index b65fad8ef..f20a6161c 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/LambdaExpression.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/LambdaExpression.java @@ -20,7 +20,6 @@ import de.dhbwstuttgart.syntaxtree.type.RefType; import de.dhbwstuttgart.syntaxtree.type.Type; import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder; import de.dhbwstuttgart.typeinference.ConstraintsSet; -import de.dhbwstuttgart.typeinference.FreshTypeVariable; import de.dhbwstuttgart.typeinference.FunN; import de.dhbwstuttgart.typeinference.JavaCodeResult; import de.dhbwstuttgart.typeinference.ResultSet; diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/LocalOrFieldVar.java b/src/de/dhbwstuttgart/syntaxtree/statement/LocalOrFieldVar.java index 4f03ddae7..1fb623b3c 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/LocalOrFieldVar.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/LocalOrFieldVar.java @@ -22,7 +22,6 @@ import de.dhbwstuttgart.syntaxtree.type.RefType; import de.dhbwstuttgart.syntaxtree.type.Type; import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder; import de.dhbwstuttgart.typeinference.ConstraintsSet; -import de.dhbwstuttgart.typeinference.FreshTypeVariable; import de.dhbwstuttgart.typeinference.JavaCodeResult; import de.dhbwstuttgart.typeinference.ResultSet; import de.dhbwstuttgart.typeinference.SingleConstraint; diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/LocalVarDecl.java b/src/de/dhbwstuttgart/syntaxtree/statement/LocalVarDecl.java index 0f4ff5b1f..3da735a15 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/LocalVarDecl.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/LocalVarDecl.java @@ -24,7 +24,6 @@ import de.dhbwstuttgart.syntaxtree.type.Type; import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder; import de.dhbwstuttgart.syntaxtree.type.Void; import de.dhbwstuttgart.typeinference.ConstraintsSet; -import de.dhbwstuttgart.typeinference.FreshTypeVariable; import de.dhbwstuttgart.typeinference.JavaCodeResult; import de.dhbwstuttgart.typeinference.ResultSet; import de.dhbwstuttgart.typeinference.SingleConstraint; @@ -385,7 +384,7 @@ public class LocalVarDecl extends Statement implements TypeInsertable assumptions.addAssumption(new LocalVarAssumption(this, this.getType())); //Bevor der Typ auf Void gesetzt wird. ret.add(new SingleConstraint(this.getType().TYPE(assumptions, this), this.getType().TYPE(assumptions, this))); //assumptions.remove(null); // falls Variable mit diesem Namen bereits vorhanden. - this.setReturnType(new Void(0)); //Return typ einer Variablendeklaration ist Void + this.setReturnType(new Void(this,0)); //Return typ einer Variablendeklaration ist Void return ret; } diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/LongLiteral.java b/src/de/dhbwstuttgart/syntaxtree/statement/LongLiteral.java index ed134118b..b4e0da4ec 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/LongLiteral.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/LongLiteral.java @@ -51,7 +51,7 @@ public class LongLiteral extends Literal { super(-1,-1); - this.setType(new LongType()); + this.setType(new LongType(this)); } // ino.end diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/MethodCall.java b/src/de/dhbwstuttgart/syntaxtree/statement/MethodCall.java index ff1f891e2..a2c418d04 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/MethodCall.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/MethodCall.java @@ -209,7 +209,7 @@ public class MethodCall extends Expr @Override public ConstraintsSet TYPEStmt(TypeAssumptions assumptions){ ConstraintsSet ret = this.TYPEExpr(assumptions); //TypeExpr aufrufen - this.setType(new Void(0)); //Typ des Statments auf Void setzen, da als alleinstehendes Statement + this.setType(new Void(this,0)); //Typ des Statments auf Void setzen, da als alleinstehendes Statement return ret; } diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/NewClass.java b/src/de/dhbwstuttgart/syntaxtree/statement/NewClass.java index 4269bc312..8270ab74c 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/NewClass.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/NewClass.java @@ -25,7 +25,6 @@ import de.dhbwstuttgart.syntaxtree.type.Type; import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder; import de.dhbwstuttgart.syntaxtree.type.Void; import de.dhbwstuttgart.typeinference.ConstraintsSet; -import de.dhbwstuttgart.typeinference.FreshTypeVariable; import de.dhbwstuttgart.typeinference.FunN; import de.dhbwstuttgart.typeinference.JavaCodeResult; import de.dhbwstuttgart.typeinference.Overloading; @@ -108,7 +107,7 @@ public class NewClass extends Expr parserlog.debug("Vergleiche "+usedid+" mit "+next); if(usedid.equals(next)) { - this.set_Type(new Type(next,getOffset())); + this.set_Type(new Type(next,this,getOffset())); break; } else next = null; @@ -225,7 +224,7 @@ public class NewClass extends Expr // ret.add(arg.TYPEExpr(assumptions)); //} - this.setType(assumptions.getTypeFor(new RefType(this.get_Name(),0), this).getType()); + this.setType(assumptions.getTypeFor(new RefType(this.get_Name(),this,0), this).getType()); /* @@ -249,7 +248,7 @@ public class NewClass extends Expr @Override public ConstraintsSet TYPEStmt(TypeAssumptions assumptions){ ConstraintsSet ret = this.TYPEExpr(assumptions); //TypeExpr aufrufen - this.setType(new Void(0)); //Typ des Statments auf Void setzen. + this.setType(new Void(this,0)); //Typ des Statments auf Void setzen. return ret; } diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/NotExpr.java b/src/de/dhbwstuttgart/syntaxtree/statement/NotExpr.java index f08cae562..0b7a2a55d 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/NotExpr.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/NotExpr.java @@ -145,7 +145,7 @@ public class NotExpr extends UnaryExpr public ConstraintsSet TYPEExpr(TypeAssumptions assumptions) { ConstraintsSet ret = new ConstraintsSet(); OderConstraint constraint = new OderConstraint(); - constraint.addConstraint(this.getType().TYPE(assumptions, this), assumptions.getTypeFor(new RefType("Boolean",-1),this)); + constraint.addConstraint(this.getType().TYPE(assumptions, this), assumptions.getTypeFor(new RefType("Boolean",this,-1),this)); ret.add(constraint); return ret; } diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/Null.java b/src/de/dhbwstuttgart/syntaxtree/statement/Null.java index 53e739172..66bc356c8 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/Null.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/Null.java @@ -42,7 +42,7 @@ public class Null extends Literal // ino.method.Null.25926.body { super(-1,-1); - this.setType(new Type("__NULL__",getOffset())); + this.setType(new Type("__NULL__",this,getOffset())); } // ino.end diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/Return.java b/src/de/dhbwstuttgart/syntaxtree/statement/Return.java index 9e606d6a7..407133fd8 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/Return.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/Return.java @@ -19,7 +19,6 @@ import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar; import de.dhbwstuttgart.syntaxtree.type.Type; import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder; import de.dhbwstuttgart.typeinference.ConstraintsSet; -import de.dhbwstuttgart.typeinference.FreshTypeVariable; import de.dhbwstuttgart.typeinference.JavaCodeResult; import de.dhbwstuttgart.typeinference.ResultSet; import de.dhbwstuttgart.typeinference.SingleConstraint; diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/Statement.java b/src/de/dhbwstuttgart/syntaxtree/statement/Statement.java index c93de1a95..b4b9b8ae0 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/Statement.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/Statement.java @@ -128,7 +128,7 @@ public abstract class Statement extends SyntaxTreeNode implements IItemWithOffse } public Type getReturnType(){ - return new de.dhbwstuttgart.syntaxtree.type.Void(-1); + return new de.dhbwstuttgart.syntaxtree.type.Void(this,-1); } } // ino.end diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/StringLiteral.java b/src/de/dhbwstuttgart/syntaxtree/statement/StringLiteral.java index 948755858..56fbe6acc 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/StringLiteral.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/StringLiteral.java @@ -49,7 +49,7 @@ public class StringLiteral extends Literal super(-1,-1); // #JB# 20.04.2005 // ########################################################### - this.setType(new RefType("java.lang.String",getOffset())); + this.setType(new RefType("java.lang.String",this,getOffset())); //this.setType(new Type("String")); // ########################################################### } @@ -121,7 +121,7 @@ public class StringLiteral extends Literal @Override public ConstraintsSet TYPEExpr(TypeAssumptions assumptions) { - this.set_Type(assumptions.getTypeFor(new RefType("String",0), this).getType()); + this.set_Type(assumptions.getTypeFor(new RefType("String",this,0), this).getType()); return new ConstraintsSet(); } diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/UnaryExpr.java b/src/de/dhbwstuttgart/syntaxtree/statement/UnaryExpr.java index 9b73b842e..19a2ff5d1 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/UnaryExpr.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/UnaryExpr.java @@ -40,9 +40,9 @@ public abstract class UnaryExpr extends Expr private Vector getNumericTypes(){ Vector ret = new Vector<>(); - ret.add(new RefType("Integer",-1)); - ret.add(new RefType("Long",-1)); - ret.add(new RefType("Double",-1)); + ret.add(new RefType("Integer",this,-1)); + ret.add(new RefType("Long",this,-1)); + ret.add(new RefType("Double",this,-1)); return ret ; } diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/WhileStmt.java b/src/de/dhbwstuttgart/syntaxtree/statement/WhileStmt.java index 4a4bf8952..9cef41940 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/WhileStmt.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/WhileStmt.java @@ -165,7 +165,7 @@ public class WhileStmt extends Statement public ConstraintsSet TYPEStmt(TypeAssumptions assumptions) { ConstraintsSet ret = new ConstraintsSet(); ret.add(expr.TYPEExpr(assumptions)); - SingleConstraint exprMustBeBool = new SingleConstraint(expr.getType().TYPE(assumptions, this), assumptions.getTypeFor(new RefType("Boolean", 0), this)); // while(expr){}; expr <. boolean + SingleConstraint exprMustBeBool = new SingleConstraint(expr.getType().TYPE(assumptions, this), assumptions.getTypeFor(new RefType("Boolean",this, 0), this)); // while(expr){}; expr <. boolean ret.add(exprMustBeBool); ret.add(this.loop_block.TYPEStmt(assumptions)); this.setType(loop_block.getType()); diff --git a/src/de/dhbwstuttgart/syntaxtree/type/BaseType.java b/src/de/dhbwstuttgart/syntaxtree/type/BaseType.java index 3730ca917..3c4899fc8 100755 --- a/src/de/dhbwstuttgart/syntaxtree/type/BaseType.java +++ b/src/de/dhbwstuttgart/syntaxtree/type/BaseType.java @@ -21,20 +21,20 @@ public abstract class BaseType extends Type private boolean IsArray = false; // ino.method.BaseType.26439.definition - public BaseType(int offset) + public BaseType(SyntaxTreeNode parent, int offset) // ino.end // ino.method.BaseType.26439.body { - super(offset); + super(parent, offset); } // ino.end // ino.method.BaseType.26442.definition - public BaseType(String name,int offset) + public BaseType(String name,SyntaxTreeNode parent,int offset) // ino.end // ino.method.BaseType.26442.body { - super(name, offset); + super(name,parent, offset); } // ino.end diff --git a/src/de/dhbwstuttgart/syntaxtree/type/BooleanType.java b/src/de/dhbwstuttgart/syntaxtree/type/BooleanType.java index 2b8dce528..cd912907f 100755 --- a/src/de/dhbwstuttgart/syntaxtree/type/BooleanType.java +++ b/src/de/dhbwstuttgart/syntaxtree/type/BooleanType.java @@ -1,6 +1,7 @@ // ino.module.BooleanType.8668.package package de.dhbwstuttgart.syntaxtree.type; +import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode; import de.dhbwstuttgart.typeinference.JavaCodeResult; import de.dhbwstuttgart.typeinference.ResultSet; @@ -11,11 +12,11 @@ public class BooleanType extends BaseType // ino.class.BooleanType.26451.body { // ino.method.BooleanType.26455.definition - public BooleanType() + public BooleanType(SyntaxTreeNode parent) // ino.end // ino.method.BooleanType.26455.body { - super("boolean",-1); + super("boolean",parent, -1); } // ino.end @@ -51,7 +52,7 @@ public class BooleanType extends BaseType // ino.end // ino.method.clone.26461.body { - return new BooleanType(); + return new BooleanType(this.getParent()); } // ino.end diff --git a/src/de/dhbwstuttgart/syntaxtree/type/CharacterType.java b/src/de/dhbwstuttgart/syntaxtree/type/CharacterType.java index 0b7d61bee..7f36e0381 100755 --- a/src/de/dhbwstuttgart/syntaxtree/type/CharacterType.java +++ b/src/de/dhbwstuttgart/syntaxtree/type/CharacterType.java @@ -1,6 +1,7 @@ // ino.module.CharacterType.8670.package package de.dhbwstuttgart.syntaxtree.type; +import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode; import de.dhbwstuttgart.typeinference.JavaCodeResult; import de.dhbwstuttgart.typeinference.ResultSet; @@ -11,11 +12,11 @@ public class CharacterType extends BaseType // ino.class.CharacterType.26492.body { // ino.method.CharacterType.26496.definition - public CharacterType() + public CharacterType(SyntaxTreeNode parent) // ino.end // ino.method.CharacterType.26496.body { - super("char",-1); + super("char",parent,-1); } // ino.end @@ -51,7 +52,7 @@ public class CharacterType extends BaseType // ino.end // ino.method.clone.26502.body { - return new CharacterType(); + return new CharacterType(this.getParent()); } // ino.end diff --git a/src/de/dhbwstuttgart/syntaxtree/type/DoubleType.java b/src/de/dhbwstuttgart/syntaxtree/type/DoubleType.java index 975afd927..83e2c803b 100755 --- a/src/de/dhbwstuttgart/syntaxtree/type/DoubleType.java +++ b/src/de/dhbwstuttgart/syntaxtree/type/DoubleType.java @@ -1,6 +1,7 @@ // ino.module.IntegerType.8672.package package de.dhbwstuttgart.syntaxtree.type; +import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode; import de.dhbwstuttgart.typeinference.JavaCodeResult; import de.dhbwstuttgart.typeinference.ResultSet; @@ -11,11 +12,11 @@ public class DoubleType extends BaseType // ino.class.IntegerType.26527.body { // ino.method.IntegerType.26531.definition - public DoubleType() + public DoubleType(SyntaxTreeNode parent) // ino.end // ino.method.IntegerType.26531.body { - super("double",-1); + super("double",parent,-1); } // ino.end @@ -51,7 +52,7 @@ public class DoubleType extends BaseType // ino.end // ino.method.clone.26537.body { - return new DoubleType(); + return new DoubleType(this.getParent()); } // ino.end diff --git a/src/de/dhbwstuttgart/syntaxtree/type/ExtendsWildcardType.java b/src/de/dhbwstuttgart/syntaxtree/type/ExtendsWildcardType.java index b409a8d63..ed154e205 100755 --- a/src/de/dhbwstuttgart/syntaxtree/type/ExtendsWildcardType.java +++ b/src/de/dhbwstuttgart/syntaxtree/type/ExtendsWildcardType.java @@ -1,5 +1,6 @@ package de.dhbwstuttgart.syntaxtree.type; +import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode; import de.dhbwstuttgart.typeinference.JavaCodeResult; import de.dhbwstuttgart.typeinference.ResultSet; @@ -22,7 +23,7 @@ public class ExtendsWildcardType extends WildcardType implements ITypeContainer, */ public ExtendsWildcardType (int offset, Type extendsType) { - super(offset); + super(extendsType.getParent(), offset); this.extendsType = extendsType; } @@ -81,7 +82,7 @@ public class ExtendsWildcardType extends WildcardType implements ITypeContainer, */ public FreshExtendsWildcardType GetFreshWildcardType() { - return new FreshExtendsWildcardType(this.extendsType,-1); + return new FreshExtendsWildcardType(this.extendsType,this.getParent(),-1); } /** diff --git a/src/de/dhbwstuttgart/syntaxtree/type/FloatType.java b/src/de/dhbwstuttgart/syntaxtree/type/FloatType.java index fa5e7a9ca..32cfc5df0 100755 --- a/src/de/dhbwstuttgart/syntaxtree/type/FloatType.java +++ b/src/de/dhbwstuttgart/syntaxtree/type/FloatType.java @@ -1,6 +1,7 @@ // ino.module.IntegerType.8672.package package de.dhbwstuttgart.syntaxtree.type; +import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode; import de.dhbwstuttgart.typeinference.JavaCodeResult; import de.dhbwstuttgart.typeinference.ResultSet; @@ -11,11 +12,11 @@ public class FloatType extends BaseType // ino.class.IntegerType.26527.body { // ino.method.IntegerType.26531.definition - public FloatType() + public FloatType(SyntaxTreeNode parent) // ino.end // ino.method.IntegerType.26531.body { - super("float",-1); + super("float", parent,-1); } // ino.end @@ -51,7 +52,7 @@ public class FloatType extends BaseType // ino.end // ino.method.clone.26537.body { - return new FloatType(); + return new FloatType(this.getParent()); } // ino.end diff --git a/src/de/dhbwstuttgart/syntaxtree/type/FreshExtendsWildcardType.java b/src/de/dhbwstuttgart/syntaxtree/type/FreshExtendsWildcardType.java index 2dec8d7b2..eda214ece 100755 --- a/src/de/dhbwstuttgart/syntaxtree/type/FreshExtendsWildcardType.java +++ b/src/de/dhbwstuttgart/syntaxtree/type/FreshExtendsWildcardType.java @@ -1,5 +1,7 @@ package de.dhbwstuttgart.syntaxtree.type; +import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode; + public class FreshExtendsWildcardType extends FreshWildcardType implements IMatchable { private Type extendsBoundType; @@ -8,9 +10,9 @@ public class FreshExtendsWildcardType extends FreshWildcardType implements IMatc * Author: Arne Lüdtke
* Standard Konstruktor für eine FreshExtendsWildcard */ - public FreshExtendsWildcardType(Type extendsBound ,int offset) + public FreshExtendsWildcardType(Type extendsBound,SyntaxTreeNode parent ,int offset) { - super(offset); + super(parent,offset); this.extendsBoundType = extendsBound; } @@ -18,9 +20,9 @@ public class FreshExtendsWildcardType extends FreshWildcardType implements IMatc * Author: Arne Lüdtke
* Privater Konstruktor für clone */ - private FreshExtendsWildcardType(Type extendsBound ,int offset, String name) + private FreshExtendsWildcardType(Type extendsBound ,SyntaxTreeNode parent,int offset, String name) { - super(offset,name); + super(parent,offset,name); this.extendsBoundType = extendsBound; } @@ -44,7 +46,7 @@ public class FreshExtendsWildcardType extends FreshWildcardType implements IMatc */ public FreshExtendsWildcardType clone() { - return new FreshExtendsWildcardType(this.extendsBoundType.clone(),getOffset(),this.name.toString()); + return new FreshExtendsWildcardType(this.extendsBoundType.clone(),this.getParent(),getOffset(),this.name.toString()); } /** diff --git a/src/de/dhbwstuttgart/syntaxtree/type/FreshSuperWildcardType.java b/src/de/dhbwstuttgart/syntaxtree/type/FreshSuperWildcardType.java index f8086c299..411cd1a81 100755 --- a/src/de/dhbwstuttgart/syntaxtree/type/FreshSuperWildcardType.java +++ b/src/de/dhbwstuttgart/syntaxtree/type/FreshSuperWildcardType.java @@ -1,5 +1,7 @@ package de.dhbwstuttgart.syntaxtree.type; +import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode; + public class FreshSuperWildcardType extends FreshWildcardType implements IMatchable { private Type superBoundType; @@ -8,9 +10,9 @@ public class FreshSuperWildcardType extends FreshWildcardType implements IMatcha * Author: Arne Lüdtke
* Standard Konstruktor für eine FreshSuperWildcard */ - public FreshSuperWildcardType(Type superBound ,int offset) + public FreshSuperWildcardType(Type superBound ,SyntaxTreeNode parent, int offset) { - super(offset); + super(parent,offset); this.superBoundType = superBound; } @@ -18,9 +20,9 @@ public class FreshSuperWildcardType extends FreshWildcardType implements IMatcha * Author: Arne Lüdtke
* Privater Konstruktor für clone */ - private FreshSuperWildcardType(Type superBound,int offset, String name) + private FreshSuperWildcardType(Type superBound,SyntaxTreeNode parent,int offset, String name) { - super(offset,name); + super(parent,offset,name); this.superBoundType = superBound; } @@ -44,7 +46,7 @@ public class FreshSuperWildcardType extends FreshWildcardType implements IMatcha */ public FreshSuperWildcardType clone() { - return new FreshSuperWildcardType(this.superBoundType.clone(),getOffset(),this.name.toString()); + return new FreshSuperWildcardType(this.superBoundType.clone(),this.getParent(),getOffset(),this.name.toString()); } /** diff --git a/src/de/dhbwstuttgart/syntaxtree/type/FreshWildcardType.java b/src/de/dhbwstuttgart/syntaxtree/type/FreshWildcardType.java index d3bd6f3fa..364681db4 100755 --- a/src/de/dhbwstuttgart/syntaxtree/type/FreshWildcardType.java +++ b/src/de/dhbwstuttgart/syntaxtree/type/FreshWildcardType.java @@ -3,6 +3,7 @@ package de.dhbwstuttgart.syntaxtree.type; import java.util.Vector; import de.dhbwstuttgart.parser.JavaClassName; +import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode; import de.dhbwstuttgart.typeinference.JavaCodeResult; import de.dhbwstuttgart.typeinference.ResultSet; import sun.reflect.generics.reflectiveObjects.NotImplementedException; @@ -16,9 +17,9 @@ public class FreshWildcardType extends Type { * Author: Arne Lüdtke
* Standard Konstruktor für eine FreshWildcard */ - public FreshWildcardType(int offset) + public FreshWildcardType(SyntaxTreeNode parent, int offset) { - super(offset); + super(parent, offset); this.name = makeNewName(); } @@ -27,9 +28,9 @@ public class FreshWildcardType extends Type { * Protected Konstruktor für clone. * Protected, da vererbte Klassen ihn verwenden müssen. */ - protected FreshWildcardType(int offset, String name) + protected FreshWildcardType(SyntaxTreeNode parent, int offset, String name) { - super(offset); + super(parent, offset); this.name = new JavaClassName(name); } @@ -61,7 +62,7 @@ public class FreshWildcardType extends Type { */ public FreshWildcardType clone() { - return new FreshWildcardType(getOffset(),this.name.toString()); + return new FreshWildcardType(this.getParent(),getOffset(),this.name.toString()); } /** @@ -146,7 +147,7 @@ public class FreshWildcardType extends Type { */ public WildcardType get_WildcardType() { - return new WildcardType(this.getOffset()); + return new WildcardType(this.getParent(),this.getOffset()); } /** * Author: Arne Lüdtke
diff --git a/src/de/dhbwstuttgart/syntaxtree/type/GenericTypeVar.java b/src/de/dhbwstuttgart/syntaxtree/type/GenericTypeVar.java index 7a7d00510..405f84b56 100755 --- a/src/de/dhbwstuttgart/syntaxtree/type/GenericTypeVar.java +++ b/src/de/dhbwstuttgart/syntaxtree/type/GenericTypeVar.java @@ -66,9 +66,8 @@ public class GenericTypeVar extends Type // ino.end // ino.method.GenericTypeVar.26509.body { - super(offset); + super(parentClass,offset); this.name = new JavaClassName(s); - this.parent = parentClass; } // ino.end diff --git a/src/de/dhbwstuttgart/syntaxtree/type/IntegerType.java b/src/de/dhbwstuttgart/syntaxtree/type/IntegerType.java index 1bd61acf4..e94dc34e0 100755 --- a/src/de/dhbwstuttgart/syntaxtree/type/IntegerType.java +++ b/src/de/dhbwstuttgart/syntaxtree/type/IntegerType.java @@ -1,6 +1,7 @@ // ino.module.IntegerType.8672.package package de.dhbwstuttgart.syntaxtree.type; +import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode; import de.dhbwstuttgart.typeinference.JavaCodeResult; import de.dhbwstuttgart.typeinference.ResultSet; @@ -11,11 +12,11 @@ public class IntegerType extends BaseType // ino.class.IntegerType.26527.body { // ino.method.IntegerType.26531.definition - public IntegerType() + public IntegerType(SyntaxTreeNode parent) // ino.end // ino.method.IntegerType.26531.body { - super("int",-1); + super("int",parent,-1); } // ino.end @@ -51,7 +52,7 @@ public class IntegerType extends BaseType // ino.end // ino.method.clone.26537.body { - return new IntegerType(); + return new IntegerType(this.getParent()); } // ino.end diff --git a/src/de/dhbwstuttgart/syntaxtree/type/LongType.java b/src/de/dhbwstuttgart/syntaxtree/type/LongType.java index 53612cb3c..a465dcd89 100755 --- a/src/de/dhbwstuttgart/syntaxtree/type/LongType.java +++ b/src/de/dhbwstuttgart/syntaxtree/type/LongType.java @@ -1,6 +1,7 @@ // ino.module.IntegerType.8672.package package de.dhbwstuttgart.syntaxtree.type; +import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode; import de.dhbwstuttgart.typeinference.JavaCodeResult; import de.dhbwstuttgart.typeinference.ResultSet; @@ -11,11 +12,11 @@ public class LongType extends BaseType // ino.class.IntegerType.26527.body { // ino.method.IntegerType.26531.definition - public LongType() + public LongType(SyntaxTreeNode parent) // ino.end // ino.method.IntegerType.26531.body { - super("long",-1); + super("long", parent,-1); } // ino.end @@ -51,7 +52,7 @@ public class LongType extends BaseType // ino.end // ino.method.clone.26537.body { - return new LongType(); + return new LongType(this.getParent()); } // ino.end diff --git a/src/de/dhbwstuttgart/syntaxtree/type/RefType.java b/src/de/dhbwstuttgart/syntaxtree/type/RefType.java index a25994b4f..801eb60f7 100755 --- a/src/de/dhbwstuttgart/syntaxtree/type/RefType.java +++ b/src/de/dhbwstuttgart/syntaxtree/type/RefType.java @@ -66,20 +66,20 @@ public class RefType extends Type implements IMatchable // ino.method.RefType.26634.definition - public RefType(int offset) + public RefType(SyntaxTreeNode parent, int offset) // ino.end // ino.method.RefType.26634.body { - super(offset); + super(parent,offset); } // ino.end // ino.method.RefType.26637.definition - public RefType(String fullyQualifiedName, int offset) + public RefType(String fullyQualifiedName,SyntaxTreeNode parent, int offset) // ino.end // ino.method.RefType.26637.body { - super(offset); + super(parent,offset); this.setName(fullyQualifiedName); } // ino.end @@ -93,22 +93,22 @@ public class RefType extends Type implements IMatchable } // ino.method.RefType.26640.definition - public RefType(String fullyQualifiedName, Vector parameter, int offset) + public RefType(String fullyQualifiedName, Vector parameter,SyntaxTreeNode parent, int offset) // ino.end // ino.method.RefType.26640.body { - super(offset); + super(parent,offset); this.setName(fullyQualifiedName); if(parameter != null && parameter.size()>0)this.set_ParaList(parameter); } // ino.end // ino.method.RefType.26643.definition - public RefType( RefType R, int offset ) + public RefType( RefType R, SyntaxTreeNode parent,int offset ) // ino.end // ino.method.RefType.26643.body { - super(offset); + super(parent,offset); // otth: Copy-Konstruktor this.setName(R.getTypeName()); this.set_ParaList(R.getParaList()); @@ -120,8 +120,8 @@ public class RefType extends Type implements IMatchable * Dabei wird der Name und der Offset des baseType's übernommen. * @param baseType */ - public RefType( Type baseType ){ - super(baseType.getOffset()); + public RefType( Type baseType){ + super(baseType.getParent(),baseType.getOffset()); this.setName(baseType.name.toString()); //this.parameter = null; } @@ -596,7 +596,7 @@ public class RefType extends Type implements IMatchable { clonepara.addElement(((Type)para.elementAt(i)).clone()); } - RefType newRefType=new RefType(this.getTypeName(), clonepara,getOffset()); + RefType newRefType=new RefType(this.getTypeName(), clonepara,this.getParent(),getOffset()); newRefType.setPrimitiveFlag(this.getPrimitiveFlag()); return newRefType; } diff --git a/src/de/dhbwstuttgart/syntaxtree/type/ReturnType.java b/src/de/dhbwstuttgart/syntaxtree/type/ReturnType.java index 0d93f65fa..9426f88fa 100755 --- a/src/de/dhbwstuttgart/syntaxtree/type/ReturnType.java +++ b/src/de/dhbwstuttgart/syntaxtree/type/ReturnType.java @@ -15,7 +15,7 @@ public class ReturnType extends Type // ino.end // ino.method.ReturnType.26707.body { - super(offset); + super(null,offset); } // ino.end diff --git a/src/de/dhbwstuttgart/syntaxtree/type/SuperWildcardType.java b/src/de/dhbwstuttgart/syntaxtree/type/SuperWildcardType.java index cae2538dd..289154cc3 100755 --- a/src/de/dhbwstuttgart/syntaxtree/type/SuperWildcardType.java +++ b/src/de/dhbwstuttgart/syntaxtree/type/SuperWildcardType.java @@ -1,5 +1,6 @@ package de.dhbwstuttgart.syntaxtree.type; +import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode; import de.dhbwstuttgart.typeinference.JavaCodeResult; import de.dhbwstuttgart.typeinference.ResultSet; @@ -21,7 +22,7 @@ public class SuperWildcardType extends WildcardType implements ITypeContainer, I */ public SuperWildcardType(int offset, Type superType) { - super(offset); + super(superType.getParent(),offset); this.superType = superType; } @@ -79,7 +80,7 @@ public class SuperWildcardType extends WildcardType implements ITypeContainer, I */ public FreshSuperWildcardType GetFreshWildcardType() { - return new FreshSuperWildcardType(this.superType,-1); + return new FreshSuperWildcardType(this.superType,this.getParent(),-1); } /** diff --git a/src/de/dhbwstuttgart/syntaxtree/type/Type.java b/src/de/dhbwstuttgart/syntaxtree/type/Type.java index c2029e2b6..13f22fd79 100755 --- a/src/de/dhbwstuttgart/syntaxtree/type/Type.java +++ b/src/de/dhbwstuttgart/syntaxtree/type/Type.java @@ -50,6 +50,7 @@ public class Type extends SyntaxTreeNode implements IItemWithOffset // ino.end // ino.method.Type.26732.body { + this.parent = parent; this.offset=offset; } // ino.end @@ -199,7 +200,7 @@ public class Type extends SyntaxTreeNode implements IItemWithOffset // ino.end // ino.method.clone.26768.body { - return new Type(this.getName().toString(),getOffset()); + return new Type(this.getName().toString(), this.getParent(),getOffset()); } // ino.end diff --git a/src/de/dhbwstuttgart/syntaxtree/type/TypePlaceholder.java b/src/de/dhbwstuttgart/syntaxtree/type/TypePlaceholder.java index 2e65d172b..b8b20c44b 100755 --- a/src/de/dhbwstuttgart/syntaxtree/type/TypePlaceholder.java +++ b/src/de/dhbwstuttgart/syntaxtree/type/TypePlaceholder.java @@ -53,9 +53,8 @@ public class TypePlaceholder extends Type // ino.end // ino.method.TypePlaceholder.26794.body { - super(-1); + super(parent, -1); this.name = new JavaClassName(typeName); - this.parent = parent; } // ino.end diff --git a/src/de/dhbwstuttgart/syntaxtree/type/Void.java b/src/de/dhbwstuttgart/syntaxtree/type/Void.java index 54d732771..2ef1cd1c3 100755 --- a/src/de/dhbwstuttgart/syntaxtree/type/Void.java +++ b/src/de/dhbwstuttgart/syntaxtree/type/Void.java @@ -15,11 +15,11 @@ public class Void extends RefType // ino.class.Void.26857.body { // ino.method.Void.26861.definition - public Void(int offset) + public Void(SyntaxTreeNode parent,int offset) // ino.end // ino.method.Void.26861.body { - super(offset); + super(parent,offset); super.setName("void"); } // ino.end @@ -66,7 +66,7 @@ public class Void extends RefType // ino.end // ino.method.clone.26867.body { - return new Void(getOffset()); + return new Void(this.getParent(),getOffset()); } // ino.end diff --git a/src/de/dhbwstuttgart/syntaxtree/type/WildcardType.java b/src/de/dhbwstuttgart/syntaxtree/type/WildcardType.java index 6d653a33a..0a28db061 100755 --- a/src/de/dhbwstuttgart/syntaxtree/type/WildcardType.java +++ b/src/de/dhbwstuttgart/syntaxtree/type/WildcardType.java @@ -1,5 +1,6 @@ package de.dhbwstuttgart.syntaxtree.type; +import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode; import de.dhbwstuttgart.typeinference.JavaCodeResult; import de.dhbwstuttgart.typeinference.ResultSet; import sun.reflect.generics.reflectiveObjects.NotImplementedException; @@ -17,9 +18,9 @@ public class WildcardType extends Type{ * Author: Arne Lüdtke
* Standard Konstruktor für eine Wildcard */ - public WildcardType(int offset) + public WildcardType(SyntaxTreeNode parent, int offset) { - super(offset); + super(parent, offset); } /** @@ -37,7 +38,7 @@ public class WildcardType extends Type{ */ public WildcardType clone() { - return new WildcardType(getOffset()); + return new WildcardType(this.getParent(), getOffset()); } /** @@ -65,7 +66,7 @@ public class WildcardType extends Type{ */ public FreshWildcardType GetFreshWildcardType() { - return new FreshWildcardType(-1); + return new FreshWildcardType(this.getParent(),-1); } /** diff --git a/src/de/dhbwstuttgart/typeinference/FreshTypeVariable.java b/src/de/dhbwstuttgart/typeinference/FreshTypeVariable.java deleted file mode 100755 index 1d3394fcf..000000000 --- a/src/de/dhbwstuttgart/typeinference/FreshTypeVariable.java +++ /dev/null @@ -1,38 +0,0 @@ -package de.dhbwstuttgart.typeinference; - -import de.dhbwstuttgart.syntaxtree.type.Type; -import sun.reflect.generics.reflectiveObjects.NotImplementedException; - -public class FreshTypeVariable extends Type{ - - private String hint = ""; - - public FreshTypeVariable(int offset) { - super(offset); - } - - /** - * Aufruf für Debug-Zwecke. - * @param hint - Eine Message die von der toString - Methode ausgegeben wird. - */ - public FreshTypeVariable(String hint){ - this(0); - this.hint = hint; - } - - public FreshTypeVariable(){ - this(0); - } - - @Override - public String toString(){ - if(hint.length()>0)return hint+" : a"; - return "FreshTypeVariable"; - } - - @Override - - public JavaCodeResult printJavaCode(ResultSet resultSet) { - throw new NotImplementedException(); - } -} diff --git a/src/de/dhbwstuttgart/typeinference/Pair.java b/src/de/dhbwstuttgart/typeinference/Pair.java index e76fdba21..b3126aa46 100755 --- a/src/de/dhbwstuttgart/typeinference/Pair.java +++ b/src/de/dhbwstuttgart/typeinference/Pair.java @@ -273,8 +273,8 @@ public class Pair hilfsvector3.addElement(p.TA1); hilfsvector4.addElement(p.TA2); //return (((RefType)TA1).is_Equiv((RefType)p.TA1, ht) && ((RefType)TA2).is_Equiv((RefType)p.TA2, ht)); - return (new RefType("dummy", hilfsvector3,-1)).is_Equiv(new RefType("dummy", hilfsvector1,-1), ht) && - (new RefType("dummy", hilfsvector4,-1)).is_Equiv(new RefType("dummy", hilfsvector2,-1), ht); + return (new RefType("dummy", hilfsvector3,null,-1)).is_Equiv(new RefType("dummy", hilfsvector1,null,-1), ht) && + (new RefType("dummy", hilfsvector4,null,-1)).is_Equiv(new RefType("dummy", hilfsvector2,null,-1), ht); } // ino.end