From ca8145e4a22dd07f8dd1c9f48e368ef36dcf57f8 Mon Sep 17 00:00:00 2001 From: JanUlrich Date: Wed, 10 Sep 2014 23:32:36 +0200 Subject: [PATCH] GenericTypeVar setParentClass entfernt --- bin/.gitignore | 13 +++++++------ src/de/dhbwstuttgart/syntaxtree/Class.java | 5 +++-- src/de/dhbwstuttgart/syntaxtree/Field.java | 1 + .../syntaxtree/FieldDeclaration.java | 1 - .../dhbwstuttgart/syntaxtree/SyntaxTreeNode.java | 2 +- .../syntaxtree/type/BoundedGenericTypeVar.java | 10 +++++++++- .../syntaxtree/type/GenericTypeVar.java | 15 +-------------- src/de/dhbwstuttgart/syntaxtree/type/Type.java | 6 +++--- 8 files changed, 25 insertions(+), 28 deletions(-) diff --git a/bin/.gitignore b/bin/.gitignore index 4ce50fc91..5b035d518 100644 --- a/bin/.gitignore +++ b/bin/.gitignore @@ -1,6 +1,7 @@ -/de -/plugindevelopment -/mycompiler -/mytypereconstruction -/syntaxTree -/userinterface +/bytecode/ +/de/ +/log4jTesting.xml +/mycompiler/ +/parser/ +/plugindevelopment/ +/syntaxTree/ diff --git a/src/de/dhbwstuttgart/syntaxtree/Class.java b/src/de/dhbwstuttgart/syntaxtree/Class.java index 275666ddd..2b2804418 100755 --- a/src/de/dhbwstuttgart/syntaxtree/Class.java +++ b/src/de/dhbwstuttgart/syntaxtree/Class.java @@ -1134,10 +1134,11 @@ public class Class extends SyntaxTreeNode implements AClassOrInterface, IItemWit if(t instanceof GenericTypeVar)this.genericClassParameters.add((GenericTypeVar)t); else this.genericClassParameters.add(new GenericTypeVar(t.get_Name(),this,-1)); } + /* for(GenericTypeVar gtv : this.getGenericParameter()){ gtv.setParentClass(this);; } - + */ //TODO: Umwandlung zu RefTypes funktioniert noch nicht richtig. (siehe LambdaTest2) //Als RefType geparste Generische Variablen umwandeln: this.wandleRefTypeAttributes2GenericAttributes(); @@ -1153,8 +1154,8 @@ public class Class extends SyntaxTreeNode implements AClassOrInterface, IItemWit Vector ret = new Vector(); for(Field f : this.getFields()){ ret.add(f); - ret.addAll(this.getGenericParameter()); } + ret.addAll(this.getGenericParameter()); return ret; } diff --git a/src/de/dhbwstuttgart/syntaxtree/Field.java b/src/de/dhbwstuttgart/syntaxtree/Field.java index baefadddb..51766f7a0 100644 --- a/src/de/dhbwstuttgart/syntaxtree/Field.java +++ b/src/de/dhbwstuttgart/syntaxtree/Field.java @@ -158,6 +158,7 @@ public abstract class Field extends SyntaxTreeNode implements TypeInsertable, Ty public Vector getChildren() { Vector ret = new Vector<>(); if(this.getType()!=null)ret.add(this.getType()); + ret.addAll(this.getGenericParameter()); return ret; } diff --git a/src/de/dhbwstuttgart/syntaxtree/FieldDeclaration.java b/src/de/dhbwstuttgart/syntaxtree/FieldDeclaration.java index ebf61dd93..3fb4cf61a 100644 --- a/src/de/dhbwstuttgart/syntaxtree/FieldDeclaration.java +++ b/src/de/dhbwstuttgart/syntaxtree/FieldDeclaration.java @@ -101,7 +101,6 @@ public class FieldDeclaration extends Field{ public void parserPostProcessing(SyntaxTreeNode parent){ super.parserPostProcessing(parent); if(this.getType() == null)this.setType(TypePlaceholder.fresh(this)); - } @Override diff --git a/src/de/dhbwstuttgart/syntaxtree/SyntaxTreeNode.java b/src/de/dhbwstuttgart/syntaxtree/SyntaxTreeNode.java index addee2d73..3eed701bb 100644 --- a/src/de/dhbwstuttgart/syntaxtree/SyntaxTreeNode.java +++ b/src/de/dhbwstuttgart/syntaxtree/SyntaxTreeNode.java @@ -103,7 +103,7 @@ public abstract class SyntaxTreeNode implements IItemWithOffset{ */ } - + } public boolean seesType(Type tA2) { diff --git a/src/de/dhbwstuttgart/syntaxtree/type/BoundedGenericTypeVar.java b/src/de/dhbwstuttgart/syntaxtree/type/BoundedGenericTypeVar.java index aad481a7a..d75715dfa 100755 --- a/src/de/dhbwstuttgart/syntaxtree/type/BoundedGenericTypeVar.java +++ b/src/de/dhbwstuttgart/syntaxtree/type/BoundedGenericTypeVar.java @@ -7,6 +7,7 @@ package de.dhbwstuttgart.syntaxtree.type; import java.util.Vector; import de.dhbwstuttgart.syntaxtree.Class; +import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode; import de.dhbwstuttgart.typeinference.ConstraintType; import de.dhbwstuttgart.typeinference.ConstraintsSet; import de.dhbwstuttgart.typeinference.SingleConstraint; @@ -55,7 +56,7 @@ public class BoundedGenericTypeVar extends GenericTypeVar */ // ino.method.BoundedGenericTypeVar.29409.definition - public BoundedGenericTypeVar(String s, Vector bounds, Class parentClass, int offset, int endOffset) + public BoundedGenericTypeVar(String s, Vector bounds, SyntaxTreeNode parentClass, int offset, int endOffset) // ino.end // ino.method.BoundedGenericTypeVar.29409.body { @@ -147,5 +148,12 @@ public class BoundedGenericTypeVar extends GenericTypeVar } // ino.end + @Override + public Vector getChildren() { + Vector ret = super.getChildren(); + ret.addAll(this.bounds); + return ret; + } + } // ino.end diff --git a/src/de/dhbwstuttgart/syntaxtree/type/GenericTypeVar.java b/src/de/dhbwstuttgart/syntaxtree/type/GenericTypeVar.java index c153ebd31..7a7d00510 100755 --- a/src/de/dhbwstuttgart/syntaxtree/type/GenericTypeVar.java +++ b/src/de/dhbwstuttgart/syntaxtree/type/GenericTypeVar.java @@ -36,7 +36,6 @@ public class GenericTypeVar extends Type //Type genericTypeVar; //Vector extendVars = new Vector(); protected Pair genericConstraint; - private Class parent; /** * 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. @@ -63,7 +62,7 @@ public class GenericTypeVar extends Type */ // ino.method.GenericTypeVar.26509.definition - public GenericTypeVar(String s, Class parentClass, int offset) + public GenericTypeVar(String s, SyntaxTreeNode parentClass, int offset) // ino.end // ino.method.GenericTypeVar.26509.body { @@ -218,18 +217,6 @@ public class GenericTypeVar extends Type public int getEndOffset() { return this.getOffset() + this.name.toString().length(); } - - public void setParentClass(Class parent){ - //TODO: Die Methode sollte mit neuem Parser raus und dafür nur noch im Konstruktor gesetzt werden. - this.parent = parent; - } - - public Class getParentClass() { - if(this.parent == null) - throw new DebugException("GenericTypeVar ohne Elternelement"); - return this.parent; - } - } // ino.end diff --git a/src/de/dhbwstuttgart/syntaxtree/type/Type.java b/src/de/dhbwstuttgart/syntaxtree/type/Type.java index b4ff52908..c2029e2b6 100755 --- a/src/de/dhbwstuttgart/syntaxtree/type/Type.java +++ b/src/de/dhbwstuttgart/syntaxtree/type/Type.java @@ -36,17 +36,17 @@ public class Type extends SyntaxTreeNode implements IItemWithOffset // ino.end // ino.method.Type.26729.definition - public Type(String s, int offset) + public Type(String s, SyntaxTreeNode parent, int offset) // ino.end // ino.method.Type.26729.body { - this(offset); + this(parent, offset); this.name = new JavaClassName(s); } // ino.end // ino.method.Type.26732.definition - public Type(int offset) + public Type(SyntaxTreeNode parent,int offset) // ino.end // ino.method.Type.26732.body {