From 66b37482dbaf1986da5c618c6aba909d1914c6db Mon Sep 17 00:00:00 2001 From: JanUlrich Date: Thu, 22 Oct 2015 16:46:06 +0200 Subject: [PATCH] =?UTF-8?q?Support=20f=C3=BCr=20eindimensionale=20Arrays?= =?UTF-8?q?=20von=20RefTypes=20angef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/de/dhbwstuttgart/syntaxtree/type/RefType.java | 11 +++++++++-- .../typeinference/assumptions/TypeAssumptions.java | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/de/dhbwstuttgart/syntaxtree/type/RefType.java b/src/de/dhbwstuttgart/syntaxtree/type/RefType.java index 5b96e961..a83054d6 100755 --- a/src/de/dhbwstuttgart/syntaxtree/type/RefType.java +++ b/src/de/dhbwstuttgart/syntaxtree/type/RefType.java @@ -602,12 +602,13 @@ public class RefType extends ObjectType implements IMatchable } RefType newRefType=new RefType(this.getTypeName(), clonepara,this.getParent(),getOffset()); newRefType.setPrimitiveFlag(this.getPrimitiveFlag()); + newRefType.IsArray = this.IsArray; return newRefType; } else { RefType newRefType = new RefType(this.getTypeName(), null,getOffset()); newRefType.setPrimitiveFlag(this.getPrimitiveFlag()); - + newRefType.IsArray = this.IsArray; return newRefType; } } @@ -814,7 +815,13 @@ public class RefType extends ObjectType implements IMatchable } public org.apache.commons.bcel6.generic.Type getBytecodeType(ClassGenerator cg) { - return new org.apache.commons.bcel6.generic.ObjectType(this.getTypeName()); + org.apache.commons.bcel6.generic.ObjectType ret = new org.apache.commons.bcel6.generic.ObjectType(this.getTypeName()); + if(this.IsArray()){ + //Hier wird einfachhalber von einer Dimension ausgegangen. Arrays sind im Bytecode nur für main-Methode relevant + return new org.apache.commons.bcel6.generic.ArrayType(ret, 1); + }else{ + return ret; + } } @Override diff --git a/src/de/dhbwstuttgart/typeinference/assumptions/TypeAssumptions.java b/src/de/dhbwstuttgart/typeinference/assumptions/TypeAssumptions.java index f809a843..d80ad80c 100755 --- a/src/de/dhbwstuttgart/typeinference/assumptions/TypeAssumptions.java +++ b/src/de/dhbwstuttgart/typeinference/assumptions/TypeAssumptions.java @@ -305,7 +305,7 @@ public class TypeAssumptions { if(match && t instanceof RefType){ RefType tr = (RefType)t; RefType ret = ass.getAssumedClass().getType(); //Dadurch erhält der RefType den vollen Namen (bsp. java.lang.Integer) - + ret.setArray(((RefType) t).IsArray()); //Falls der RefType mit Parametern angegeben wurde, so müssen diese erhalten bleiben: if(tr.get_ParaList()!=null && tr.getParaList().size()>0){ ret.set_ParaList(tr.getParaList());