From 81416b8bf447b9a7ef22667a71208f2d11165057 Mon Sep 17 00:00:00 2001 From: JanUlrich Date: Tue, 7 Oct 2014 15:36:18 +0200 Subject: [PATCH] Richtiger Import von Generischen Typen aus der JRE --- src/de/dhbwstuttgart/syntaxtree/Class.java | 21 ++++++++++ .../dhbwstuttgart/syntaxtree/SourceFile.java | 39 ++++++++++++------- .../syntaxtree/statement/Binary.java | 1 - .../syntaxtree/statement/Block.java | 2 +- .../syntaxtree/statement/DoubleLiteral.java | 2 - .../syntaxtree/statement/EmptyStmt.java | 4 +- .../syntaxtree/statement/Expr.java | 2 +- .../syntaxtree/statement/ForStmt.java | 3 +- .../syntaxtree/statement/IfStmt.java | 2 +- .../syntaxtree/statement/IntLiteral.java | 1 - .../syntaxtree/statement/LocalOrFieldVar.java | 1 - .../syntaxtree/statement/LongLiteral.java | 2 - .../syntaxtree/statement/Return.java | 1 - .../syntaxtree/statement/Statement.java | 1 - .../syntaxtree/statement/WhileStmt.java | 2 +- .../exceptions/NotImplementedException.java | 5 +++ 16 files changed, 58 insertions(+), 31 deletions(-) create mode 100644 src/de/dhbwstuttgart/typeinference/exceptions/NotImplementedException.java diff --git a/src/de/dhbwstuttgart/syntaxtree/Class.java b/src/de/dhbwstuttgart/syntaxtree/Class.java index 6bc3878f..c2a9dc2f 100755 --- a/src/de/dhbwstuttgart/syntaxtree/Class.java +++ b/src/de/dhbwstuttgart/syntaxtree/Class.java @@ -162,6 +162,26 @@ public class Class extends SyntaxTreeNode implements AClassOrInterface, IItemWit } // ino.end + /** + * Erstellt eine Klasse, welche nur für die Assumptions verwendet wird. + * Sie enthält keine unnötigen Informationen, wie Offset oder ClassBody. + * @param name + * @param superClass + * @param modifiers + * @param supertypeGenPara - Eine Liste von Namen, welche die Generischen Parameter der Klasse darstellen. + */ + public Class(String name, RefType superClass, Modifiers modifiers, + Vector supertypeGenPara) { + this(name,superClass,modifiers,0); + if(supertypeGenPara == null)return; + Vector gtvs = new Vector<>(); + for(String gname : supertypeGenPara){ + GenericTypeVar newGTV=new GenericTypeVar(gname,this,0); + gtvs.add(newGTV); + } + this.genericClassParameters = new GenericDeclarationList(gtvs,0); + } + public Class(String name, RefType superClass, Modifiers mod, int offset){ this(name,mod,offset); this.superClass = superClass; @@ -244,6 +264,7 @@ public class Class extends SyntaxTreeNode implements AClassOrInterface, IItemWit } // ino.end + public Vector getFields() { return fielddecl; diff --git a/src/de/dhbwstuttgart/syntaxtree/SourceFile.java b/src/de/dhbwstuttgart/syntaxtree/SourceFile.java index 50f7bdc2..623a4ca4 100755 --- a/src/de/dhbwstuttgart/syntaxtree/SourceFile.java +++ b/src/de/dhbwstuttgart/syntaxtree/SourceFile.java @@ -1179,7 +1179,7 @@ public class SourceFile GenericTypeVar newGTV=new GenericTypeVar(superclassTVS[tvi].getName(),parentClass,-1); supertypeGenPara.addElement(newGTV); } - + if(supertypeGenPara.size()==0){ supertypeGenPara=null; } @@ -1267,9 +1267,17 @@ public class SourceFile if(s == null){ return new Class("java.lang.Object",new Modifiers(), 0); } + + Vector supertypeGenPara = new Vector<>();//Die Generischen Parameter für die Superklasse berechnen: + java.lang.reflect.TypeVariable[] superclassTVS=s.getTypeParameters(); + for(int tvi=0;tvi