From e84d6373c7ca155d73b3410d953e5ebe2a84aa16 Mon Sep 17 00:00:00 2001 From: JanUlrich Date: Thu, 15 Dec 2016 17:02:39 +0100 Subject: [PATCH] =?UTF-8?q?Aufr=C3=A4umen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dhbwstuttgart/syntaxtree/SourceFile.java | 15 ++++---- .../syntaxtree/factory/ASTFactory.java | 1 - .../syntaxtree/type/RefType.java | 36 +++++++++---------- 3 files changed, 24 insertions(+), 28 deletions(-) diff --git a/src/de/dhbwstuttgart/syntaxtree/SourceFile.java b/src/de/dhbwstuttgart/syntaxtree/SourceFile.java index c70b9326..67982275 100755 --- a/src/de/dhbwstuttgart/syntaxtree/SourceFile.java +++ b/src/de/dhbwstuttgart/syntaxtree/SourceFile.java @@ -4,7 +4,7 @@ import java.util.Iterator; import java.util.List; import java.util.Set; -import de.dhbwstuttgart.typeinference.Menge; +import de.dhbwstuttgart.typeinference.*; import java.util.stream.Stream; @@ -18,16 +18,10 @@ import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar; import de.dhbwstuttgart.syntaxtree.type.RefType; import de.dhbwstuttgart.syntaxtree.type.Type; import de.dhbwstuttgart.syntaxtree.type.Void; -import de.dhbwstuttgart.typeinference.ByteCodeResult; -import de.dhbwstuttgart.typeinference.ConstraintsSet; -import de.dhbwstuttgart.typeinference.Pair; -import de.dhbwstuttgart.typeinference.ResultSet; -import de.dhbwstuttgart.typeinference.TypeinferenceResultSet; -import de.dhbwstuttgart.typeinference.TypeinferenceResults; -import de.dhbwstuttgart.typeinference.UnifyConstraintsSet; import de.dhbwstuttgart.typeinference.assumptions.ClassAssumption; import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions; import de.dhbwstuttgart.typeinference.exceptions.DebugException; +import de.dhbwstuttgart.typeinference.exceptions.NotImplementedException; import de.dhbwstuttgart.typeinference.exceptions.TypeinferenceException; import de.dhbwstuttgart.typeinference.unify.TypeUnify; import de.dhbwstuttgart.typeinference.unify.Unifikationsalgorithmus; @@ -512,6 +506,11 @@ public class SourceFile extends SyntaxTreeNode return 0; } + @Override + public JavaCodeResult printJavaCode(ResultSet resultSet) { + throw new NotImplementedException(); + } + @Override public int getVariableLength() { // TODO Auto-generated method stub diff --git a/src/de/dhbwstuttgart/syntaxtree/factory/ASTFactory.java b/src/de/dhbwstuttgart/syntaxtree/factory/ASTFactory.java index b67245be..400fc1e1 100644 --- a/src/de/dhbwstuttgart/syntaxtree/factory/ASTFactory.java +++ b/src/de/dhbwstuttgart/syntaxtree/factory/ASTFactory.java @@ -14,7 +14,6 @@ import de.dhbwstuttgart.syntaxtree.modifier.Public; import de.dhbwstuttgart.syntaxtree.statement.Block; 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.typeinference.Menge; diff --git a/src/de/dhbwstuttgart/syntaxtree/type/RefType.java b/src/de/dhbwstuttgart/syntaxtree/type/RefType.java index d59e8ca5..c2d1fcbd 100755 --- a/src/de/dhbwstuttgart/syntaxtree/type/RefType.java +++ b/src/de/dhbwstuttgart/syntaxtree/type/RefType.java @@ -79,13 +79,13 @@ public class RefType extends SyntaxTreeNode return false; if(parameter==null || parameter.size()==0){ - ret &= (((RefType)obj).get_ParaList()==null || ((RefType)obj).get_ParaList().size()==0); + ret &= (((RefType)obj).getParaList()==null || ((RefType)obj).getParaList().size()==0); } else{ - if(((RefType)obj).get_ParaList()==null){ + if(((RefType)obj).getParaList()==null){ ret = false; } - else if(parameter.size() != ((RefType)obj).get_ParaList().size()) + else if(parameter.size() != ((RefType)obj).getParaList().size()) { ret = false; } @@ -93,7 +93,7 @@ public class RefType extends SyntaxTreeNode { for(int i = 0; i clonepara = new Menge(); + List para = this.getParaList(); + List clonepara = new ArrayList<>(); for(int i = 0; i< para.size(); i++) { - clonepara.addElement(((Type)para.get(i)).clone()); + clonepara.add(((RefType)para.get(i)).clone()); } - RefType newRefType=new RefType(this.getTypeName(), clonepara,this.getParent(),getOffset()); - newRefType.setPrimitiveFlag(this.getPrimitiveFlag()); + RefType newRefType=new RefType(this.getName(), clonepara, getOffset()); newRefType.IsArray = this.IsArray; return newRefType; } else { - RefType newRefType = new RefType(this.getTypeName(),getOffset()); - newRefType.setPrimitiveFlag(this.getPrimitiveFlag()); + RefType newRefType = new RefType(this.getName(),getOffset()); newRefType.IsArray = this.IsArray; return newRefType; } @@ -169,31 +167,31 @@ public class RefType extends SyntaxTreeNode return ret; } - public Menge getUnresolvedTPH(ResultSet resultSet) { - Menge ret = super.getUnresolvedTPH(resultSet); + public List getUnresolvedTPH(ResultSet resultSet) { + List ret = new ArrayList<>(); //super.getUnresolvedTPH(resultSet); ret.addAll(this.printJavaCode(resultSet).getUnresolvedTPH()); return ret; } public List getInvolvedTypePlaceholder() { - Menge ret = super.getInvolvedTypePlaceholder(); + List ret = new ArrayList<>(); //super.getInvolvedTypePlaceholder(); if(this.parameter == null)return ret; - for(Type param : this.parameter){ + for(RefType param : this.parameter){ ret.addAll(param.getInvolvedTypePlaceholder()); } return ret; } @Override - public Menge getChildren() { - Menge ret = super.getChildren(); + public List getChildren() { + List ret = new ArrayList<>(); //super.getChildren(); ret.addAll(this.getParaList()); return ret; } 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()){ + if(this.IsArray){ //Hier wird einfachhalber von einer Dimension ausgegangen. Arrays sind im Bytecode nur für main-Methode relevant return new org.apache.bcel.generic.ArrayType(ret, 1); }else{