Aufräumen

This commit is contained in:
JanUlrich 2016-12-15 15:35:14 +01:00
parent aff39ba442
commit fc43cd11da
21 changed files with 109 additions and 1186 deletions

View File

@ -70,7 +70,7 @@
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
<div class="header">
<h2 title="Uses of Class de.dhbwstuttgart.syntaxtree.type.BoundedGenericTypeVar" class="title">Uses of Class<br>de.dhbwstuttgart.syntaxtree.type.BoundedGenericTypeVar</h2>
<h2 title="Uses of Class de.dhbwstuttgart.syntaxtree.type.BoundedGenericTypeVar" class="title">Uses of Class<br>de.dhbwstuttgart.syntaxtree.BoundedGenericTypeVar</h2>
</div>
<div class="classUseContainer">
<ul class="blockList">

View File

@ -1,6 +1,5 @@
package de.dhbwstuttgart.bytecode;
import de.dhbwstuttgart.syntaxtree.type.BoundedGenericTypeVar;
import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar;
import de.dhbwstuttgart.syntaxtree.type.ObjectType;
import de.dhbwstuttgart.syntaxtree.type.RefType;

View File

@ -16,7 +16,6 @@ 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.syntaxtree.type.Type;
import de.dhbwstuttgart.typeinference.Menge;
public class ASTFactory {
@ -111,7 +110,7 @@ public class ASTFactory {
*/
public Method createMethod(java.lang.reflect.Method jreMethod, java.lang.Class inClass){
String name = jreMethod.getName();
Type returnType = createType(jreMethod.getReturnType());
RefType returnType = createType(jreMethod.getReturnType());
Parameter[] jreParams = jreMethod.getParameters();
List<FormalParameter> params = new ArrayList<>();
for(Parameter jreParam : jreParams){
@ -160,7 +159,7 @@ public class ASTFactory {
public GenericTypeVar createGeneric(TypeVariable jreTypeVar, java.lang.Class inClass){
//TODO: Bei den Namen der Parameter des Generishen Typs nachschauen, ob er in der Klasse als Generic deklariert wurde
String name = jreTypeVar.getTypeName();
List<Type> genericBounds = new ArrayList<>();
List<RefType> genericBounds = new ArrayList<>();
java.lang.reflect.Type[] bounds = jreTypeVar.getBounds();
if(bounds.length > 0){
for(java.lang.reflect.Type bound : bounds){

View File

@ -1,30 +1,19 @@
// ino.module.Abstract.8585.package
package de.dhbwstuttgart.syntaxtree.modifier;
import de.dhbwstuttgart.typeinference.JavaCodeResult;
import de.dhbwstuttgart.typeinference.ResultSet;
// ino.class.Abstract.24015.description type=javadoc
/**
* Stellt den Modifier Abstract dar.
*
*/
// ino.end
// ino.class.Abstract.24015.declaration
public class Abstract extends Modifier
// ino.end
// ino.class.Abstract.24015.body
{
// ino.method.getBitmask.24019.definition
public short getBitmask()
// ino.end
// ino.method.getBitmask.24019.body
{
return 0x0400;
}
// ino.end
@Override
public JavaCodeResult printJavaCode(ResultSet resultSet) {
@ -32,4 +21,3 @@ public class Abstract extends Modifier
}
}
// ino.end

View File

@ -1,13 +1,15 @@
package de.dhbwstuttgart.syntaxtree.type;
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.syntaxtree.Class;
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
import de.dhbwstuttgart.typeinference.ConstraintsSet;
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
import de.dhbwstuttgart.typeinference.exceptions.TypeinferenceException;
import java.util.ArrayList;
import java.util.List;
/**
* Entspricht einem GenericTypeVar, jedoch mit Bounds
* (d.h. vorgaben, von welchem Typ die Typevar sein darf
@ -17,19 +19,19 @@ import de.dhbwstuttgart.typeinference.exceptions.TypeinferenceException;
* @author hoti 4.5.06
*
*/
public class BoundedGenericTypeVar extends GenericTypeVar
public class BoundedGenericTypeVar extends SyntaxTreeNode
{
/**
* Hier sind die Bounds in Form von Type-Objekten abgespeichert
*/
Menge<ObjectType> bounds=new Menge<ObjectType>();
List<RefType> bounds=new ArrayList<RefType>();
private int endOffset;
public BoundedGenericTypeVar(String s, Menge<ObjectType> bounds, int offset, int endOffset)
public BoundedGenericTypeVar(String s, List<RefType> bounds, int offset, int endOffset)
{
super(s, offset);
if(bounds != null)for(Type t : bounds){
if(bounds != null)for(RefType t : bounds){
//if(t!=null)this.extendVars.add(t);
}
//this.genericTypeVar = new RefType(s,offset);
@ -42,33 +44,11 @@ public class BoundedGenericTypeVar extends GenericTypeVar
return this.endOffset;
}
public Menge<ObjectType> getBounds()
public List<RefType> getBounds()
{
return bounds;
}
@Override
//TODO: Die Constraints sollte nicht der TYPE Algorithmus generieren, sonder sollte der FC bekannt sein.
public ConstraintsSet TYPE(TypeAssumptions ass) {
ConstraintsSet ret = super.TYPE(ass);
//ass.addGenericVarAssumption(this);
//Die Type methode der BoundedGenericTypeVar schreibt zusätzlich noch die Constraints ¼r die bounds
Menge<ObjectType> tempBounds = new Menge<>();
if(this.bounds != null){
for(ObjectType ev : this.bounds){
Type extendsType = ev.TYPE(ass, this);
if(extendsType == null)throw new TypeinferenceException("Der Typ "+ev.getName()+" ist nicht korrekt", this);
//TODO: ??? stimmt der Cast???
tempBounds.add((ObjectType)extendsType);
//ret.add(new SingleConstraint(ass.getTypeFor(this, this), extendsType ));
}
}
this.bounds = tempBounds;
return ret;
}
public BoundedGenericTypeVar clone()
{
return new BoundedGenericTypeVar(this.getName().toString(), this.getBounds(), getOffset(), this.getEndOffset());

View File

@ -23,7 +23,7 @@ public class ExtendsWildcardType extends WildcardType implements ITypeContainer,
* Author: Arne ¼dtke<br/>
* Standard Konstruktor ¼r eine ExtendsWildcard
*/
public ExtendsWildcardType (int offset, ObjectType extendsType)
public ExtendsWildcardType (int offset, RefType extendsType)
{
super(extendsType, offset);
this.name = new JavaClassName(this.toString());

View File

@ -30,8 +30,8 @@ import de.dhbwstuttgart.typeinference.exceptions.TypeinferenceException;
*/
public class FunN extends RefType {
private Type R;
private List<? extends Type> T;
private RefType R;
private List<? extends RefType> T;
/**
* @author Andreas Stadelmeier, a10023
@ -41,7 +41,7 @@ public class FunN extends RefType {
* @param T
* @return
*/
public FunN(Type R, List<? extends Type> T) {
public FunN(RefType R, List<? extends RefType> T) {
super("",0);
if(T==null || R == null)throw new NullPointerException();
setT(T);
@ -69,7 +69,7 @@ public class FunN extends RefType {
public FunN(int parameterCount) {
super("",0);
if(parameterCount<0)throw new RuntimeException("Anzahl der Parameter muss >0 sein");
Menge<Type> t = new Menge<Type>();
List<RefType> t = new ArrayList<>();
for(int i=0;i<parameterCount;i++){
//t.add(TypePlaceholder.fresh(this));
t.add(new GenericTypeVar(NameGenerator.makeNewName(), -1));
@ -85,47 +85,30 @@ public class FunN extends RefType {
* Dabei werden bestimmte, von RefType geerbte, Parameter angepasst. Dies ist wichtig ¼r den Typinferenzalgorithmus.
*/
private void calculateNewParalist(){
Menge<Type> t = new Menge<Type>();
List<RefType> t = new ArrayList<>();
if(R!=null)t.add(R);
if(T!=null)t.addAll(T);
for(Type type : t){
for(RefType type : t){
if(type instanceof WildcardType){
throw new DebugException("Der FunN-Typ darf keine Wildcards in den Parameter enthalten");
}
}
this.set_ParaList(t);
this.parameter = t;
}
protected void setT(List<? extends Type> list){
protected void setT(List<? extends RefType> list){
this.T = list;
calculateNewParalist();
}
protected void setR(Type R){
protected void setR(RefType R){
this.R = R;
calculateNewParalist();
}
/*
@Override
public String getName(){
String ret = "FunN<"+R.toString();
for(Type t : T){
ret += ", " + t.toString();
}
ret += ">";
return ret;
}
*/
public int getTypeLineNumber() {
// TODO Auto-generated method stub
return 0;
}
public String getBytecodeInvokeDynamicSignature(ClassGenerator cg, TypeinferenceResultSet rs) {
String ret = "(";
for(Type t : T){
for(RefType t : T){
ret+=t.getBytecodeType(cg, rs).getSignature();
}
ret +=")";
@ -135,62 +118,11 @@ public class FunN extends RefType {
public String getBytecodeInvokeDynamicSignatureUpperBound(ClassGenerator cg) {
String ret = "(";
for(Type t : T){
for(RefType t : T){
ret+=cg.getInstructionFactory().createObjectType().getSignature();
}
ret +=")";
ret += cg.getInstructionFactory().createObjectType().getSignature();
return ret;
}
@Override
public Type TYPE(TypeAssumptions ass, SyntaxTreeNode parent){
//FunN Typen müssen nicht geprüft werden. Sie werden schließlich nur von unserem Typinferenzalgorithmus erstellt:
List<Type> paraList = new ArrayList<>();
for(Type t : this.T){
Type toAdd = t.TYPE(ass, parent);
//if(toAdd == null)throw new TypeinferenceException("Typ "+toAdd+" ist in den Assumptions nicht vorhanden",this);
paraList.add(toAdd);
}
FunN ret = new FunN(this.R.TYPE(ass, parent),paraList);
return ret;
}
public FunNInterface getCorrespondingInterface(){
return null;
}
/*
@Override
public JavaCodeResult printJavaCode(ResultSet resultSet){
//String ret = super.printJavaCode(resultSet) + (T!=null ? this.T.size() : 0) +"<";
JavaCodeResult ret = new JavaCodeResult("Fun" + (T!=null ? this.T.size() : 0) +"<");
ret .attach( this.R.printJavaCode(resultSet)).attach(", ");
Iterator<Type> it = T.iterator();
while(it.hasNext()){
Type t = it.next();
ret.attach( t.printJavaCode(resultSet));
if(it.hasNext())ret.attach(", ");
}
//ret = ret.substring(0, ret.length()-2);
return ret.attach(">");
}
*/
/**
* Die Clone-Methode von RefType darf von FunN NICHT überschrieben werden.
@Override
public FunN clone()
{
FunN ret = null;
Menge<Type> clonepara = new Menge<Type>();
for(int i = 0; i< this.T.size(); i++)
{
clonepara.addElement(((Type)this.T.elementAt(i)).clone());
}
ret = new FunN(this.R.clone(),clonepara);
ret.setPrimitiveFlag(this.getPrimitiveFlag());
return ret;
}
*/
}

View File

@ -1,7 +1,10 @@
package de.dhbwstuttgart.syntaxtree.type;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.parser.JavaClassName;
@ -19,8 +22,8 @@ import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
*/
public class FunVoidN extends FunN {
private Type R;
private Menge<Type> T;
private RefType R;
private List<RefType> T;
/**
* @author Andreas Stadelmeier, a10023
@ -29,7 +32,7 @@ public class FunVoidN extends FunN {
* @param T
* @return
*/
public FunVoidN(Menge<Type> T) {
public FunVoidN(List<RefType> T) {
super(null,T);
this.setR(new Void(this, -1));
this.name = new JavaClassName("FunVoid"+T.size());
@ -51,9 +54,9 @@ public class FunVoidN extends FunN {
* Dabei werden bestimmte, von RefType geerbte, Parameter angepasst. Dies ist wichtig ¼r den Typinferenzalgorithmus.
*/
private void calculateNewParalist(){
Menge<Type> t = new Menge<Type>();
List<RefType> t = new ArrayList<>();
if(T!=null)t.addAll(T);
this.set_ParaList(t);
this.parameter = t;
}
}

View File

@ -1,25 +0,0 @@
package de.dhbwstuttgart.syntaxtree.type;
import java.util.List;
import de.dhbwstuttgart.bytecode.ClassGenerator;
import de.dhbwstuttgart.parser.JavaClassName;
import de.dhbwstuttgart.syntaxtree.Class;
import de.dhbwstuttgart.syntaxtree.SourceFile;
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
import de.dhbwstuttgart.syntaxtree.factory.ASTFactory;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.typeinference.ResultSet;
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
public class GenericClassType extends RefType{
public GenericClassType(String fullyQualifiedName, List parameter, SyntaxTreeNode parent, int offset) {
super(fullyQualifiedName, parameter, parent, offset);
}
@Override
public String getBytecodeSignature(ClassGenerator cg, TypeinferenceResultSet rs) {
return "L"+getTypeName()+";";
}
}

View File

@ -1,215 +0,0 @@
// ino.module.GenericTypeVar.8671.package
package de.dhbwstuttgart.syntaxtree.type;
// ino.end
import java.util.ArrayList;
// ino.module.GenericTypeVar.8671.import
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.typeinference.ConstraintsSet;
import de.dhbwstuttgart.typeinference.JavaCodeResult;
import de.dhbwstuttgart.typeinference.Pair;
import de.dhbwstuttgart.typeinference.ResultSet;
import de.dhbwstuttgart.typeinference.TypeInsertable;
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
import de.dhbwstuttgart.typeinference.exceptions.DebugException;
import de.dhbwstuttgart.typeinference.exceptions.TypeinferenceException;
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertPoint;
import de.dhbwstuttgart.bytecode.ClassGenerator;
import de.dhbwstuttgart.parser.JavaClassName;
import de.dhbwstuttgart.syntaxtree.Class;
import de.dhbwstuttgart.syntaxtree.GTVDeclarationContext;
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
import de.dhbwstuttgart.syntaxtree.factory.ASTFactory;
/**
* TODO: Diese Klasse überarbeiten. Pair genericTypeVar ist nicht implementiert.
* @author ¯Â¿Â½rg ¯Â¿Â½uerle
* @version $Date: 2013/09/22 20:12:53 $
*/
public class GenericTypeVar extends ObjectType
{
//Type genericTypeVar;
//Menge<Type> extendVars = new Menge<Type>();
protected Pair genericConstraint;
/**
* Eine Registry ¯Â¿Â½r alle Generic-Instanzen, die vor der Bytecode-Generierung durch
* Ihre Superklasse ersetzt werden ¯Â¿Â½ssen. Siehe "Type Erasure" in Sun Spezifikation.
* <br/>Autor: ¯Â¿Â½rg ¯Â¿Â½uerle
*/
// private Hashtable<String, Menge<GenericTypeVar>> m_TypeErasureList;
private static HashMap<String,TypePlaceholder> tph = new HashMap<>();
/**
*
* @param genericTypeVarExtendsVar
public GenericTypeVar(Pair genericTypeVarExtendsVar, int offset){
super(offset);
genericTypeVar = genericTypeVarExtendsVar.TA1;
if(genericTypeVarExtendsVar.TA2!=null)this.extendVars.add(genericTypeVarExtendsVar.TA2);
else{
this.genericConstraint = genericTypeVarExtendsVar;
}
this.name = genericTypeVar.toString();
}
*/
public GenericTypeVar(String s, int offset)
{
super(s,offset);
this.name = new JavaClassName(s);
}
/*
public GenericTypeVar(Type tA1, int offset) {
this(new Pair(tA1,null),offset);
}
*/
/**
* <br>Author: ¯Â¿Â½rg ¯Â¿Â½uerle
* @return
*/
public GenericTypeVar clone()
{
return new GenericTypeVar(this.getName().toString(), getOffset());
}
/**
* <br/>Author: ¯Â¿Â½rg ¯Â¿Â½uerle
* @param obj
* @return
*/
public boolean equals(Object obj)
{
return super.equals(obj) && (obj instanceof GenericTypeVar);
}
public String toString()
{
return "GTV " + this.getName();
}
@Override
public int hashCode() {
return this.name.hashCode();
}
/**
* hoti 4.5.06
* Generische Typen werden im Bytecode
* aus Abwaertskompatiblitaet wie Object dargestellt
*/
public String get_codegen_Type(Menge paralist)
{
return("Ljava/lang/Object;");
}
public String getSignatureType(Menge paralist)
{
return "T" + name + ";";
}
@Override
public JavaCodeResult printJavaCode(ResultSet resultSet) {
/*
if(this.genericTypeVar!=null){
JavaCodeResult ret = new JavaCodeResult();
ret.attach(this.genericTypeVar.printJavaCode(resultSet));
if(this.extendVars.size()>0){
ret.attach(" extends ");
Iterator<Type> it = this.extendVars.iterator();
while(it.hasNext()){
Type extend = it.next();
ret.attach(extend.printJavaCode(resultSet));
if(it.hasNext())ret.attach(", ");
}
}
return ret;
}
*/
return new JavaCodeResult(this.name.toString());
}
public TypePlaceholder getTypePlaceHolder(SyntaxTreeNode environment) {
String hashValue = this.getName().toString()+environment.hashCode();
if(!GenericTypeVar.tph.containsKey(hashValue)){
GenericTypeVar.tph.put(hashValue, TypePlaceholder.fresh(hashValue,this));
}
return GenericTypeVar.tph.get(hashValue);
//return TypePlaceholder.fresh(this.getParent());
//if(this.tph == null)this.tph = TypePlaceholder.fresh();
//return this.tph;
}
@Override
public String get_Name() {
return this.getName().toString();
}
@Override
public JavaClassName getName() {
return this.name;
}
public TypeAssumptions createAssumptions(){
TypeAssumptions ret = new TypeAssumptions();
ret.addGenericVarAssumption(this);
return ret;
}
/**
* Die Type Methode auf generische Variablen angewandt sorgt ¼r deren Eintragung in die TypeAssumptions.
* @param ass
* @return
*/
public ConstraintsSet TYPE(TypeAssumptions ass){
ConstraintsSet ret = new ConstraintsSet();
ass.addGenericVarAssumption(this);
return ret;
}
@Override
public Type TYPE(TypeAssumptions ass, SyntaxTreeNode parent) {
ass.addGenericVarAssumption(this); //Eine GenericTypeVar kann nur an Stellen vorkommen, an denen sie auch ¼ltig ist. Daher kann sie den Assumptions hinzugefügt werden.
return super.TYPE(ass, parent);
}
public int getEndOffset() {
return this.getOffset() + this.name.toString().length();
}
@Override
public void parserPostProcessing(SyntaxTreeNode parent) {
//SyntaxTreeNode parentTemp = this.parent;
super.parserPostProcessing(parent);
//if(parentTemp != null)this.parent = parentTemp; //Der Parenttype einer GenericVar soll sich nicht ändern nnen, falls einmal gesetzt.
}
public GTVDeclarationContext getDeclarationContext() {
return this.getGTVDeclarationContext();
}
@Override
public org.apache.bcel.generic.Type getBytecodeType(ClassGenerator cg, TypeinferenceResultSet rs) {
// TODO Bytecode
return org.apache.bcel.generic.Type.getType(getSignatureType(null));// new org.apache.bcel.generic.ObjectType("Object");
}
public List<ObjectType> getBounds()
{
//Gibt eine Liste mit "java.lang.Object" zurück, da jede Generic von Object erbt
ArrayList<ObjectType> ret = new ArrayList<>();
ret.add(ASTFactory.createObjectType());
return ret;
}
}

View File

@ -1,18 +0,0 @@
package de.dhbwstuttgart.syntaxtree.type;
/**
* Dieses Interface wird von allen Klassen implementiert, die weitere Klassen
* enthalten, die im match des Unify beachtet werden ¼ssen.
*
* @author Arne ¼dtke
*
*/
public interface IMatchable
{
/**
* Author: Arne ¼dtke<br/>
* Gibt den Typen zurück, der bei einem match im Unify verwendet werden soll.
* Wird über IMatchable implementiert.
*/
Type getMatchType();
}

View File

@ -1,19 +0,0 @@
package de.dhbwstuttgart.syntaxtree.type;
/**
* Dieses Interface wird von allen Klassen implementiert, die weitere Klassen enthalten.
* Wird ¼r diverse Hilfsmethoden verwendet.
*
* @author Arne ¼dtke
*
*/
public interface ITypeContainer
{
/**
* Author: Arne ¼dtke<br/>
* Das gleiche wie get_ExtendsType().
* Implementiert ITypeContainer
*/
Type getContainedType();
}

View File

@ -1,17 +0,0 @@
package de.dhbwstuttgart.syntaxtree.type;
import de.dhbwstuttgart.parser.JavaClassName;
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
/**
* Der ObjectType repräsentiert einen Typ ohne Wildcards.
* Eine Trennung zwischen Wildcard-Typen und anderen Typen ist notwendig.
* Ein WildcardTyp kann nur ObjectTypes aufnehmen: ? extends ObjectType
*/
public abstract class ObjectType extends Type {
public ObjectType(JavaClassName s, int offset) {
super(s, offset);
}
public abstract ObjectType clone();
}

View File

@ -1,86 +0,0 @@
// ino.module.ParaList.8674.package
package de.dhbwstuttgart.syntaxtree.type;
// ino.end
// ino.module.ParaList.8674.import
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.logger.Logger;
// ino.end
import de.dhbwstuttgart.logger.Section;
// ino.class.ParaList.26591.declaration
public class ParaList extends Menge<Type>
// ino.end
// ino.class.ParaList.26591.body
{
// ino.attribute.paralist.26594.declaration
//protected Menge<Type> paralist = new Menge<Type>();
// ino.end
// ino.attribute.parserlog.26597.declaration
protected static Logger parserlog = Logger.getLogger("parser");
// ino.end
// ino.method.ParaList.26600.definition
public ParaList()
// ino.end
// ino.method.ParaList.26600.body
{}
// ino.end
// ino.method.ParaList.26603.definition
ParaList(Type t)
// ino.end
// ino.method.ParaList.26603.body
{
parserlog.debug( "ParaList: " + t, Section.PARSER );
this.addElement(t);
}
// ino.end
// ino.method.get_ParaList.26606.definition
public Menge<Type> get_ParaList()
// ino.end
// ino.method.get_ParaList.26606.body
{
return this;
}
// ino.end
// ino.method.add_ParaList.26609.definition
public void add_ParaList(Type obj)
// ino.end
// ino.method.add_ParaList.26609.body
{
this.addElement(obj);
}
// ino.end
// ino.method.get_firstElement.26612.definition
public Object get_firstElement()
// ino.end
// ino.method.get_firstElement.26612.body
{
return firstElement();
}
// ino.end
// ino.method.getParalist.26615.definition
public Menge<Type> getParalist()
// ino.end
// ino.method.getParalist.26615.body
{
return this;
}
// ino.end
// ino.method.setParalist.26618.definition
public void setParalist(Menge<Type> paralist)
// ino.end
// ino.method.setParalist.26618.body
{
this.removeAllElements();
this.addAll(paralist);
}
// ino.end
}
// ino.end

View File

@ -1,7 +1,4 @@
// ino.module.RefType.8675.package
package de.dhbwstuttgart.syntaxtree.type;
// ino.end
// ino.module.RefType.8675.import
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.Hashtable;
@ -30,12 +27,7 @@ import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
import de.dhbwstuttgart.typeinference.exceptions.TypeinferenceException;
// ino.class.RefType.26621.declaration
public class RefType extends ObjectType implements IMatchable
// ino.end
// ino.class.RefType.26621.body
public class RefType extends SyntaxTreeNode
{
/**
* Ist IsArray auf true, muss beim Codegen ein Zeichen [ gesetzt werden
@ -44,8 +36,8 @@ public class RefType extends ObjectType implements IMatchable
* Bsp.: 9| tag = CONSTANT_Utf8, length = 21, (Ljava/lang/String;)V
*/
private boolean IsArray = false;
private List<RefType> parameter = null;
protected JavaClassName name;
protected List<RefType> parameter = null;
/**
* Ist primitiveFlag auf true, muss beim Codegen dieser Reftype durch
* den primitiven Datentyp ersetzt werden
@ -54,10 +46,10 @@ public class RefType extends ObjectType implements IMatchable
*/
private boolean primitiveFlag=false;
public RefType(String fullyQualifiedName, int offset)
public RefType(JavaClassName fullyQualifiedName, int offset)
{
super(fullyQualifiedName,offset);
this.setName(fullyQualifiedName);
super(offset);
this.name = (fullyQualifiedName);
}
@Override
@ -68,199 +60,28 @@ public class RefType extends ObjectType implements IMatchable
return hash;
}
// ino.method.RefType.26640.definition
public RefType(String fullyQualifiedName, List<RefType> parameter, int offset)
// ino.end
// ino.method.RefType.26640.body
public RefType(JavaClassName fullyQualifiedName, List<RefType> parameter, int offset)
{
super(fullyQualifiedName,offset);
this.setName(fullyQualifiedName);
if(parameter != null && parameter.size()>0)this.set_ParaList(parameter);
this(fullyQualifiedName, offset);
if(parameter != null && parameter.size()>0)this.parameter = parameter;
}
public RefType( RefType R, SyntaxTreeNode parent,int offset )
{
super(R.name.toString(),offset);
// otth: Copy-Konstruktor
this.setName(R.getTypeName());
this.set_ParaList(R.getParaList());
}
// ino.end
public RefType(JavaClassName name, List<Type> parameter, int offset){
super(name.toString(), offset);
}
/**
* Wandelt die Parameter des RefTypes in TPHs um, sofern es sich um Generische Variablen handelt.
* @return
*/
public void GTV2TPH(SyntaxTreeNode environment){
Menge<Type> paralist = new Menge<Type>();
if(this.get_ParaList()!=null)for(Type t : this.get_ParaList()){
if(t instanceof GenericTypeVar)paralist.add(((GenericTypeVar)t).getTypePlaceHolder(environment));
else{
if(t instanceof RefType)((RefType) t).GTV2TPH(environment);
paralist.add(t);
}
}
this.set_ParaList(paralist);
}
/**
* HOTI
* Diese Methode sucht in der Klassendefinition nach einen GTV, die
* so heißt wie die im RefType definierte Variable. Wenn sie diese gefunden
* hat, wird sie zurückgeben. Wenn dies nicht der Fall war, schaut sie, falls
* angegeben in den Methodenparametern nach. Findet sie dort auch nichts, liefert
* die Methode <b>null</b>.
* @param type
* @return
*/
public GenericTypeVar findGenericType(Menge<Type> paralist, Menge<GenericTypeVar> methodParaList)
{
for(int i=0;i<paralist.size();i++){
if(paralist.get(i) instanceof GenericTypeVar){
GenericTypeVar gtv=(GenericTypeVar)paralist.get(i);
if(gtv.getName().equals(this.getName())){
return gtv;
}
}
}
if(methodParaList!=null){
for(int i=0;i<methodParaList.size();i++){
GenericTypeVar gtv=methodParaList.elementAt(i);
if(gtv.getName().equals(this.getName())){
return gtv;
}
}
}
//Auch die Parameterliste nach GenericTypeVars durchsuchen:
if(this.get_ParaList() != null)for(Type t : this.get_ParaList()){
if(t instanceof RefType)((RefType)t).findGenericType(paralist, methodParaList);
}
return(null);
}
// ino.method.setName.26655.definition
public void setName( String name )
// ino.end
// ino.method.setName.26655.body
{
this.name = new JavaClassName(name);
}
// ino.end
public void setName( JavaClassName name ){
if(name == null)throw new NullPointerException();
this.name = name;
}
@Override
public String get_Name()
{
return getName().toString();
}
// ino.method.getName.26658.definition
public JavaClassName getName()
// ino.end
// ino.method.getName.26658.body
{
return name;
// Damit wir hier konsistent bleiben, gibts nur
// den Typ, keine Generics! Sonst gibts Probleme mit der BCG
/* if(parameter==null)
{
return name;
}
else
{
String para = new String();
Enumeration e=parameter.elements();
while(e.hasMoreElements())
{
Type ty = (Type)e.nextElement();
String t = ty.getName();
if(para.length() > 0)
para = para +", "+ t;
else para = " " + t;
}
return name + "<"+para + " >" ;
}*/
}
// ino.end
/**
* ¼gt eine Parameterliste an und tauscht zuvor alle GenerictTypeVars durch TPH aus.
* In einem RefType ¼rfen keine GTVs enthalten sein.
* @param v
*/
// ino.method.set_ParaList.26661.definition
public void set_ParaList(List<Type> v)
// ino.end
// ino.method.set_ParaList.26661.body
{
/*
Menge<Type> paralist = new Menge<Type>();
if(v!=null)for(Type t : v){
if(t instanceof GenericTypeVar)paralist.add(((GenericTypeVar)t).getTypePlaceHolder());
else paralist.add(t);
}*/
this.parameter = v;//paralist;
}
// ino.end
/**
* @return gibt bei leere Parameterliste null zurück. Ist entscheidend ¼r unify-Algorithmus
*/
// ino.method.get_ParaList.26664.definition
public List<Type> get_ParaList()
// ino.end
// ino.method.get_ParaList.26664.body
{
if(this.parameter == null || this.parameter.size()==0)return null;
public List<RefType> getParaList(){
if(this.parameter==null)return new ArrayList<>();
return this.parameter;
}
// ino.end
public List<Type> getParaList(){
if(this.parameter==null)return new Menge<>();
return this.parameter;
}
// ino.method.add_Parameter.26667.definition
public void add_Parameter(Type o)
// ino.end
// ino.method.add_Parameter.26667.body
{
this.parameter.add(o);
}
// ino.end
// ino.method.getTypeName.26670.definition
public String getTypeName()
// ino.end
// ino.method.getTypeName.26670.body
{
// otth: Liefert den Namen des Typs, ohne Parameter, z.B. Stapel bei Stapel<IntZahl>
return name.toString();
}
/**
* Author: Jrg Buerle<br/>
* @param Object
* @return
*/
// ino.end
// ino.method.equals.26685.definition
public boolean equals(Object obj)
// ino.end
// ino.method.equals.26685.body
{
if(obj instanceof RefType){
boolean ret = true;
@ -293,12 +114,8 @@ public class RefType extends ObjectType implements IMatchable
return false;
}
}
// ino.end
// ino.method.clone.26688.definition
public RefType clone()
// ino.end
// ino.method.clone.26688.body
{
if(this.get_ParaList() != null )
{
@ -320,12 +137,8 @@ public class RefType extends ObjectType implements IMatchable
return newRefType;
}
}
// ino.end
// ino.method.toString.26691.definition
public String toString()
// ino.end
// ino.method.toString.26691.body
{
String primitiveFlagMarker=primitiveFlag?"*":"";
if(parameter==null)
@ -335,10 +148,10 @@ public class RefType extends ObjectType implements IMatchable
else
{
String para = new String();
Iterator<Type> e=parameter.iterator();
Iterator<RefType> e=parameter.iterator();
while(e.hasNext())
{
Type ty = (Type)e.next();
RefType ty = e.next();
String t = ty.toString();
if(para.length() > 0)
para = para +", "+ t;
@ -349,89 +162,15 @@ public class RefType extends ObjectType implements IMatchable
return ret + primitiveFlagMarker;//name + "<"+para + " >" +primitiveFlagMarker;
}
}
// ino.end
/*
// ino.method.modifyToGenericTypeVar.26694.definition
public GenericTypeVar modifyToGenericTypeVar(TypeInsertable parent)
// ino.end
// ino.method.modifyToGenericTypeVar.26694.body
{
return new GenericTypeVar(this.name.toString(),getOffset());
}
// ino.end
*/
// ino.method.getSimpleName.26697.defdescription type=javadoc
/**
* HOTI
* Liefert bei Klassen die fullyQualified angegeben wurden
* nur den schlussendlichen Bezeichner
* p.ex. de.dhbwstuttgart.typeinference.Menge => Menge
* @return
*/
public String getSimpleName()
{
return name.getName();
}
// ino.method.setPrimitiveFlag.29415.definition
public void setPrimitiveFlag(boolean b)
// ino.end
// ino.method.setPrimitiveFlag.29415.body
{
this.primitiveFlag=b;
}
// ino.end
// ino.method.getPrimitiveFlag.29418.definition
public boolean getPrimitiveFlag()
// ino.end
// ino.method.getPrimitiveFlag.29418.body
{
return(this.primitiveFlag);
}
// ino.end
/**
* Author: Daniel Feinler<br/>
* Handelt ab, ob der Typ eines Objekts ein Array ist, wenn true dann
* wird im Bytecode ein flag gesetzt wenn nicht, dann halt nicht.
* @return the IsArray
*/
public boolean IsArray() {
return IsArray;
}
/**
* Author: Daniel Feinler<br/>
* Handelt ab, ob der Typ eines Objekts ein Array ist, wenn true dann
* wird im Bytecode ein flag gesetzt wenn nicht, dann halt nicht.
* @param IsArray the IsArray to set
*/
public void setArray(boolean IsArray) {
this.IsArray = IsArray;
}
/**
* Author: Arne ¼dtke<br/>
* Gibt den Typen zurück, der bei einem match im Unify verwendet werden soll.
* Wird über IMatchable implementiert.
*/
public Type getMatchType()
{
return this;
}
@Override
public JavaCodeResult printJavaCode(ResultSet resultSet) {
JavaCodeResult ret = new JavaCodeResult(this.name.toString());
if(this.getParaList()!=null && this.getParaList().size()>0){
ret .attach( "<" );
Iterator<Type> it = this.getParaList().iterator();
Iterator<RefType> it = this.getParaList().iterator();
while(it.hasNext()){
Type t = it.next();
RefType t = it.next();
ret .attach( t.printJavaCode(resultSet));
if(it.hasNext())ret.attach(", ");
}
@ -440,51 +179,14 @@ public class RefType extends ObjectType implements IMatchable
}
return ret;
}
@Override
public Type applyResultSet(ResultSet result) {
return super.applyResultSet(result);
}
/**
* Liefert alle SuperWildcardTypes, die in diesem Typ enthalten sind.
* Dabei werden auch die parameter auf SuperWildcardTypes durchsucht.
* @return
*/
@Override
public ArrayList<SuperWildcardType> getSuperWildcardTypes() {
ArrayList<SuperWildcardType> ret = super.getSuperWildcardTypes();
if(this.parameter!=null)for(Type paraType : this.parameter){
if(paraType instanceof SuperWildcardType)ret.add((SuperWildcardType)paraType);
}
return ret;
}
@Override
public Menge<TypePlaceholder> getUnresolvedTPH(ResultSet resultSet) {
Menge<TypePlaceholder> ret = super.getUnresolvedTPH(resultSet);
/*
if(this.parameter!=null)for(Type t : this.parameter){
if(t instanceof TypePlaceholder){
TypePlaceholder tph = (TypePlaceholder)t;
Type eq = resultSet.getTypeEqualTo(tph);
if(eq instanceof TypePlaceholder)ret.add((TypePlaceholder)eq);
}
}
*/
ret.addAll(this.printJavaCode(resultSet).getUnresolvedTPH());
return ret;
}
@Override
public boolean involves(TypePlaceholder tph) {
for(RefType param : parameter)
return false;
}
@Override
public Menge<TypePlaceholder> getInvolvedTypePlaceholder() {
public List<TypePlaceholder> getInvolvedTypePlaceholder() {
Menge<TypePlaceholder> ret = super.getInvolvedTypePlaceholder();
if(this.parameter == null)return ret;
for(Type param : this.parameter){
@ -492,13 +194,6 @@ public class RefType extends ObjectType implements IMatchable
}
return ret;
}
@Override
public Type TYPE(TypeAssumptions ass, SyntaxTreeNode parent){
Type t = super.TYPE(ass,parent);
//((RefType)t.getType()).set_ParaList(this.get_ParaList());
return t;
}
@Override
public Menge<SyntaxTreeNode> getChildren() {
@ -507,24 +202,7 @@ public class RefType extends ObjectType implements IMatchable
return ret;
}
@Override
public Type checkTYPE(TypeAssumptions ass, SyntaxTreeNode method) {
Type t = ass.checkType(this, parent);
if(t==null)
throw new TypeinferenceException("Der Typ "+this.getName()+" ist nicht korrekt", parent);
return t;
}
@Override
public void parserPostProcessing(SyntaxTreeNode parent) {
super.parserPostProcessing(parent);
if(this.parameter != null)for(Type param : this.parameter){
param.parserPostProcessing(this);
}
}
@Override
public org.apache.bcel.generic.Type getBytecodeType(ClassGenerator cg, TypeinferenceResultSet rs) {
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()){
//Hier wird einfachhalber von einer Dimension ausgegangen. Arrays sind im Bytecode nur für main-Methode relevant
@ -534,7 +212,6 @@ public class RefType extends ObjectType implements IMatchable
}
}
@Override
public String getBytecodeSignature(ClassGenerator cg, TypeinferenceResultSet rs) {
String combinedType = getCombinedType(cg, rs);
/*
@ -544,25 +221,23 @@ public class RefType extends ObjectType implements IMatchable
return ret;
}
@Override
public String getClassSignature(ClassGenerator cg, TypeinferenceResultSet rs) {
return null;
}
public String getCombinedType(ClassGenerator cg, TypeinferenceResultSet rs){
//Bsp.: Ljava/util/Vector<Ljava/lang/String;>;
StringBuilder sb = new StringBuilder();
String ret;
List<Type> newParams = new ArrayList<>();
List<RefType> newParams = new ArrayList<>();
if(parameter != null && parameter.size() > 0){
sb.append(getName().toString().replace(".", "%"));
sb.append("%%");
for(Type type: parameter){
Type newParameter;
for(RefType type: parameter){
RefType newParameter;
if(type instanceof RefType){
sb.append(((RefType) type).getCombinedType(cg, rs).replace(".", "%"));
newParameter = type;
}else if(type instanceof TypePlaceholder){
//TODO: Die Methode sollte keinen String, sondern einen BytecodeType zurückgeben.
//Auf sämtlichen RefTypes und TPHs muss eine Konvertierungsmethode aufgerufen werden, diese
// kann dann TPH dem entsprechenden Typ aus dem TypeinferenceResult zuweisen
newParameter = rs.getTypeOfPlaceholder((TypePlaceholder)type);
sb.append(((TypePlaceholder) type).getBytecodeType(cg, rs).toString().replace(".", "%"));
}else if(type instanceof WildcardType){
@ -588,12 +263,5 @@ public class RefType extends ObjectType implements IMatchable
}
return ret;
}
/*
public GenericClassType getGenericClassType(){
return new GenericClassType(getName().toString(), getParaList(), parent, getOffset());
}
*/
}
// ino.end

View File

@ -10,6 +10,8 @@ import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
import de.dhbwstuttgart.typeinference.exceptions.DebugException;
import java.util.List;
/**
* Stellt eine Wildcard mit unterer Grenze dar.
* z.B. void test(? super Integer var){..}
@ -18,9 +20,9 @@ import de.dhbwstuttgart.typeinference.exceptions.DebugException;
*
*/
public class SuperWildcardType extends WildcardType implements ITypeContainer, IMatchable{
public class SuperWildcardType extends WildcardType{
public SuperWildcardType(ObjectType innerType){
public SuperWildcardType(RefType innerType){
this(innerType.getOffset(), innerType);
}
@ -28,7 +30,7 @@ public class SuperWildcardType extends WildcardType implements ITypeContainer, I
* Author: Arne ¼dtke<br/>
* Standard Konstruktor ¼r eine SuperWildcard
*/
public SuperWildcardType(int offset, ObjectType innerType)
public SuperWildcardType(int offset, RefType innerType)
{
super(innerType, offset);
}
@ -39,7 +41,7 @@ public class SuperWildcardType extends WildcardType implements ITypeContainer, I
* Beispiel: ? super Integer.
* Integer wird zurückgegeben.
*/
public ObjectType get_SuperType()
public RefType get_SuperType()
{
return this.innerType;
}
@ -60,7 +62,7 @@ public class SuperWildcardType extends WildcardType implements ITypeContainer, I
*/
public SuperWildcardType clone()
{
return new SuperWildcardType(getOffset(), (ObjectType) innerType.clone());
return new SuperWildcardType(getOffset(), innerType.clone());
}
/**
@ -68,7 +70,7 @@ public class SuperWildcardType extends WildcardType implements ITypeContainer, I
* Das gleiche wie get_innerType().
* Überschreibt die Methode der Superklasse
*/
public Type GetWildcardType()
public RefType GetWildcardType()
{
return this.get_SuperType();
}
@ -78,7 +80,7 @@ public class SuperWildcardType extends WildcardType implements ITypeContainer, I
* Setzt den Typ in der Wildcard
* @param T - Type to be set
*/
public void SetWildcardType(ObjectType T)
public void SetWildcardType(RefType T)
{
//if(T instanceof RefType)
this.innerType = (RefType)T;
@ -89,7 +91,7 @@ public class SuperWildcardType extends WildcardType implements ITypeContainer, I
* Das gleiche wie get_innerType().
* Implementiert ITypeContainer
*/
public Type getContainedType()
public RefType getContainedType()
{
return this.get_SuperType();
}
@ -99,7 +101,7 @@ public class SuperWildcardType extends WildcardType implements ITypeContainer, I
* Gibt den Typen zurück, der bei einem match im Unify verwendet werden soll.
* Wird über IMatchable implementiert.
*/
public Type getMatchType()
public RefType getMatchType()
{
return this.get_SuperType();
}
@ -127,8 +129,8 @@ public class SuperWildcardType extends WildcardType implements ITypeContainer, I
}
@Override
public Menge<TypePlaceholder> getInvolvedTypePlaceholder() {
Menge<TypePlaceholder> ret = super.getInvolvedTypePlaceholder();
public List<TypePlaceholder> getInvolvedTypePlaceholder() {
List<TypePlaceholder> ret = super.getInvolvedTypePlaceholder();
ret.addAll(this.innerType.getInvolvedTypePlaceholder());
return ret;
}
@ -139,28 +141,9 @@ public class SuperWildcardType extends WildcardType implements ITypeContainer, I
this.innerType.parserPostProcessing(this);
}
@Override
public Type TYPE(TypeAssumptions ass, SyntaxTreeNode parent) {
this.innerType = (ObjectType) this.innerType.TYPE(ass, parent);
return super.TYPE(ass, parent);
}
/*
@Override
public org.apache.bcel.generic.Type getBytecodeType(ClassGenerator cg) {
//return new de.dhbwstuttgart.bytecode.WildcardType(this.innerType.get_Name(), "-");
return this.innerType.getBytecodeType(cg);
}
*/
@Override
public String getBytecodeSignature(ClassGenerator cg, TypeinferenceResultSet rs) {
return "-" + this.innerType.getBytecodeSignature(cg, rs);
}
@Override
public String get_Name() {
return "? super "+this.innerType.get_Name();
}
}

View File

@ -1,8 +1,4 @@
// ino.module.TypePlaceholder.8678.package
package de.dhbwstuttgart.syntaxtree.type;
// ino.end
// ino.module.TypePlaceholder.8678.import
import java.util.Hashtable;
import java.util.Iterator;
@ -24,7 +20,7 @@ import de.dhbwstuttgart.typeinference.exceptions.DebugException;
import de.dhbwstuttgart.typeinference.exceptions.TypeinferenceException;
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertPoint;
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
// ino.class.TypePlaceholder.26780.description type=javadoc
/**
* Repr�sentiert einen Typparameter ¯Â¿Â½r einen vom Programmierer nicht angegeben
* Typ. Jede TypePlaceholder besitzt einen eindeutigen Namen aus einem Namenspool
@ -33,16 +29,11 @@ import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
* @author ¯Â¿Â½rg ¯Â¿Â½uerle
* @version $Date: 2013/06/19 12:45:37 $
*/
// ino.end
// ino.class.TypePlaceholder.26780.declaration
public class TypePlaceholder extends ObjectType
// ino.end
// ino.class.TypePlaceholder.26780.body
public class TypePlaceholder extends RefType
{
private static final Logger log = Logger.getLogger(TypePlaceholder.class.getName());
private static Hashtable<String, TypePlaceholder> m_TypePlaceholdersRegistry = new Hashtable<String, TypePlaceholder>();
// ino.end
private SyntaxTreeNode parent;
@ -107,13 +98,7 @@ public class TypePlaceholder extends ObjectType
m_TypePlaceholdersRegistry.put(ret.getName().toString(), ret);
return ret;
}
@Override
public Menge<TypePlaceholder> getInvolvedTypePlaceholder() {
Menge<TypePlaceholder> ret = super.getInvolvedTypePlaceholder();
ret.add(this);
return ret;
}
/**
* Author: ¯Â¿Â½rg ¯Â¿Â½uerle<br/>
@ -157,16 +142,7 @@ public class TypePlaceholder extends ObjectType
TypePlaceholder dolly = new TypePlaceholder(name.toString(), this.parent);
return dolly;
}
/**
* @author Andreas Stadelmeier, a10023
* Überschreibt die get_Name-Methode der Type-Klasse. (Keine Ahnung wieso es überhaupt ein get_Name und ein getName gibt!)
*/
@Override
public String get_Name(){
return getName().toString();
}
public String toString()
{
return "TPH " + this.getName();
@ -201,31 +177,7 @@ public class TypePlaceholder extends ObjectType
//return new TypePlaceholder(makeNewName());
}
// ino.end
// ino.method.backdoorSetName.26851.defdescription type=javadoc
/**
* Backdoor-Hilfsfunktion, die ¯Â¿Â½r <code>makeFC()</code> und <code>unify()</code>
* ben�tigt wird, um den Namen eines TypePlaceholders zu ver�ndern.<br/>
* ACHTUNG: Diese <code>TypePlaceholder</code> darf nicht Teil des abstrakten
* Syntaxbaumes sein!!! Es muss sicher gestellt werden, dass die betreffende
* <code>TypePlaceholder</code> nicht �ber die Methode <code>fresh()</code>,
* sondern �ber <code>backdoorCreate()</code> oder <code>backdoorClone()</code>
* erzeugt worden ist.
* <br>Author: ¯Â¿Â½rg ¯Â¿Â½uerle
* @param varName Der Name des zu erzeugenden <code>TypePlaceholders</code>
*/
// ino.end
// ino.method.backdoorSetName.26851.definition
public void backdoorSetName(String varName)
// ino.end
// ino.method.backdoorSetName.26851.body
{
name = new JavaClassName(varName);
}
// ino.end
// ino.method.backdoorCreate.26854.defdescription type=javadoc
/**
* Backdoor-Hilfsfunktion, die ¯Â¿Â½r <code>makeFC()</code> und <code>unify()</code>
* ben�tigt wird, zum Erzeugen eines <code>TypePlaceholders</code>, der nicht in
@ -253,7 +205,7 @@ public class TypePlaceholder extends ObjectType
///////////////////////////////////////////////////////////////////
private JavaCodeResult printJavaCodePr(ResultSet resultSet) {
Type equalType = resultSet.getTypeEqualTo(this);
RefType equalType = resultSet.getTypeEqualTo(this);
if(equalType == null || equalType.equals(this)){
//¼r den Fall das der TPH nicht aufgelÃst werden konnte.
JavaCodeResult ret = new JavaCodeResult(this.getName().toString());
@ -264,8 +216,7 @@ public class TypePlaceholder extends ObjectType
return equalType.printJavaCode(resultSet);
}
@Override
public JavaCodeResult printJavaCode(ResultSet resultSet, boolean resolveTPHs){
if(resolveTPHs)return printJavaCodePr(resultSet);
return new JavaCodeResult(this.get_Name());

View File

@ -1,99 +0,0 @@
// ino.module.Void.8679.package
package de.dhbwstuttgart.syntaxtree.type;
import de.dhbwstuttgart.bytecode.ClassGenerator;
import de.dhbwstuttgart.core.IItemWithOffset;
import de.dhbwstuttgart.syntaxtree.Method;
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
import de.dhbwstuttgart.typeinference.exceptions.TypeinferenceException;
// ino.end
// ino.class.Void.26857.declaration
public class Void extends RefType
// ino.end
// ino.class.Void.26857.body
{
public static final String VOID_NAME = "void";
// ino.method.Void.26861.definition
public Void(int offset)
// ino.end
// ino.method.Void.26861.body
{
super("void",offset);
super.setName(VOID_NAME);
}
// ino.end
// ino.method.equals.26864.defdescription type=javadoc
/**
* Author: ¯Â¿Â½rg ¯Â¿Â½uerle<br/>
* @param Object
* @return
*/
// ino.end
// ino.method.equals.26864.definition
public boolean equals(Object obj)
// ino.end
// ino.method.equals.26864.body
{
if(obj instanceof RefType){
boolean ret = true;
ret &= super.equals(obj);
// if(name==null){
// ret &= ((Void)obj).get_Name()==null;
// }
//PL 05-07-31 auf void kann man nicht casten, da parameter in RefType private
//ret &= name.equals(((Void)obj).getName());
ret &= name.equals(((Type)obj).getName());
return ret;
}
else{
return false;
}
}
// ino.end
// ino.method.clone.26867.defdescription type=javadoc
/**
* <br>Author: ¯Â¿Â½rg ¯Â¿Â½uerle
* @return
*/
// ino.end
// ino.method.clone.26867.definition
public Void clone()
// ino.end
// ino.method.clone.26867.body
{
return new Void(getOffset());
}
// ino.end
@Override
public Type TYPE(TypeAssumptions ass, SyntaxTreeNode parent){
return this;
}
@Override
public Type checkTYPE(TypeAssumptions ass, SyntaxTreeNode method) {
return this;//VOID ist immer korrekt, das wird vom Parser geprüft
}
@Override
public org.apache.bcel.generic.Type getBytecodeType(ClassGenerator cg, TypeinferenceResultSet rs) {
return org.apache.bcel.generic.Type.VOID;
}
@Override
public String getBytecodeSignature(ClassGenerator cg, TypeinferenceResultSet rs) {
return this.getBytecodeType(cg, rs).getSignature();
}
public String getBytecodeMethodSignature(ClassGenerator cg, TypeinferenceResultSet rs) {
return this.getBytecodeSignature(cg, rs);
}
}
// ino.end

View File

@ -10,6 +10,7 @@ import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
import de.dhbwstuttgart.typeinference.exceptions.DebugException;
import de.dhbwstuttgart.typeinference.exceptions.NotImplementedException;
import de.dhbwstuttgart.typeinference.exceptions.TypeinferenceException;
/**
* Stellt eine Wildcard in Java dar.
@ -20,15 +21,16 @@ import de.dhbwstuttgart.typeinference.exceptions.NotImplementedException;
public abstract class WildcardType extends RefType{
protected ObjectType innerType = null;
protected RefType innerType = null;
/**
* Author: Arne ¼dtke<br/>
* Standard Konstruktor ¼r eine Wildcard
*/
public WildcardType(ObjectType innerType, int offset)
public WildcardType(RefType innerType, int offset)
{
super(innerType.name, offset);
super(innerType.getName(), offset);
if(innerType instanceof WildcardType)throw new TypeinferenceException("Ein Wildcardtype kann keinen Wildcardtype als innerType besitzen",this);
this.innerType = innerType;
}
@ -50,7 +52,7 @@ public abstract class WildcardType extends RefType{
{
return null;
}
@Override
public JavaCodeResult printJavaCode(ResultSet resultSet) {
@ -59,7 +61,7 @@ public abstract class WildcardType extends RefType{
@Override
public RefType TYPE(TypeAssumptions ass, SyntaxTreeNode parent) {
this.innerType = (ObjectType) innerType.TYPE(ass, this);
this.innerType = innerType.TYPE(ass, this);
return this;
}

View File

@ -1,13 +1,11 @@
// ino.module.Pair.8673.package
package de.dhbwstuttgart.typeinference;
// ino.end
// ino.module.Pair.8673.import
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.List;
@ -24,53 +22,17 @@ import de.dhbwstuttgart.syntaxtree.type.WildcardType;
// ino.class.Pair.26540.description type=line
// Klasse, die ein Paar in der Menge Eq speichern kann
// ino.end
// ino.class.Pair.26540.declaration
public class Pair implements Serializable, DeepCloneable
// ino.end
// ino.class.Pair.26540.body
{
// ino.attribute.TA1.26543.declaration
public Type TA1;
// ino.end
// ino.attribute.TA2.26546.declaration
public Type TA2;
// ino.end
// ino.attribute.bEqual.26549.declaration
private PairOperator eOperator = PairOperator.SMALLER;
// ino.end
// ino.attribute.bSubst.26552.decldescription type=line
// false <--> vorinitialisierter Wert
// true <--> Dieses Paar entstand durch reduce1-Regel (=.)
// --> Name von TA1 mu� gleich sein wie Name von TA2
// Nur noch reduce2-Regel anwendbar
// luar 15-04-2007
// Der Unify mit Wildcards benÃtigt 3 verschiedene Operatoren.
// Deshalb wurde der boolean durch einen Enum ersetzt.
// Smaller <--> vorinitialisierter Wert
// SmallerExtends <--> Kleiner extends (wie vorinitialisiert, nur mit einschluss der Wildcard)
// Equal <--> Gleich: Name von TA1 und TA2 ¼ssen gleich sein.
// ino.end
// ino.attribute.bSubst.26552.declaration
public boolean bSubst; // speichert, ob die SUBST -Regel auf diese Paar
// ino.end
// ino.method.Pair.26555.defdescription type=line
// schon angewandt wurde, Default = FALSE
// ino.end
public RefType TA1;
public RefType TA2;
// ino.method.Pair.26555.definition
public Pair( Type TA1, Type TA2 )
// ino.end
// ino.method.Pair.26555.body
private PairOperator eOperator = PairOperator.SMALLER;
public boolean bSubst; // speichert, ob die SUBST -Regel auf diese Paar
public Pair( RefType TA1, RefType TA2 )
{
// Konstruktor
//if(TA1 == null || TA2 == null)throw new NullPointerException();
@ -79,12 +41,8 @@ public class Pair implements Serializable, DeepCloneable
bSubst = false;
eOperator = PairOperator.SMALLER;
}
// ino.end
// ino.method.Pair.26558.definition
public Pair( Type TA1, Type TA2, PairOperator eOp)
// ino.end
// ino.method.Pair.26558.body
public Pair( RefType TA1, RefType TA2, PairOperator eOp)
{
// Konstruktor
this(TA1,TA2);
@ -93,7 +51,7 @@ public class Pair implements Serializable, DeepCloneable
// ino.end
// ino.method.Pair.26561.definition
public Pair( Type TA1, Type TA2, PairOperator eOp, boolean bSubst )
public Pair( RefType TA1, RefType TA2, PairOperator eOp, boolean bSubst )
// ino.end
// ino.method.Pair.26561.body
{
@ -130,12 +88,8 @@ public class Pair implements Serializable, DeepCloneable
/*- Equals: " + bEqual*/
}
// ino.end
// ino.method.isEqual.26567.definition
public boolean isEqual()
// ino.end
// ino.method.isEqual.26567.body
{
// otth: Prueft, ob TA1 == TA2
if( TA1 instanceof RefType && TA2 instanceof RefType )
@ -213,15 +167,8 @@ public class Pair implements Serializable, DeepCloneable
}
// ino.end
// ino.method.copyType.26570.defdescription type=line
// PL 05-01-22 static eingefuegt
// ino.end
// ino.method.copyType.26570.definition
public static Type copyType( Type T )
// ino.end
// ino.method.copyType.26570.body
public static RefType copyType( RefType T )
{
// #JB# 22.05.2005
// ###########################################################
@ -229,46 +176,13 @@ public class Pair implements Serializable, DeepCloneable
// ###########################################################
}
// ino.end
// ino.method.getTA1Copy.26573.definition
public Type getTA1Copy( )
// ino.end
// ino.method.getTA1Copy.26573.body
{
return copyType( TA1 );
}
// ino.end
// ino.method.getTA2Copy.26576.definition
public Type getTA2Copy( )
// ino.end
// ino.method.getTA2Copy.26576.body
{
return copyType( TA2 );
}
// ino.end
// ino.method.copyPair.26579.definition
public Pair copyPair()
// ino.end
// ino.method.copyPair.26579.body
{
return new Pair(getTA1Copy(), getTA2Copy(), eOperator, bSubst);
}
// ino.end
// ino.method.equals.26588.defdescription type=javadoc
/**
* <br/>Author: ¯Â¿Â½rg ¯Â¿Â½uerle
* @param obj
* @return
*/
// ino.end
// ino.method.equals.26588.definition
public boolean equals(Object obj)
// ino.end
// ino.method.equals.26588.body
{
boolean ret = true;
ret &= (obj instanceof Pair);
@ -277,16 +191,6 @@ public class Pair implements Serializable, DeepCloneable
ret &= ((Pair)obj).TA2.equals(this.TA2);
return ret;
}
// ino.end
/**
* Author: Arne ¼dtke<br/>
* Überprüft ob die Paare die gleichen Instanzen sind.
*/
public boolean instanzeEquals(Object obj)
{
return super.equals(obj);
}
/**
* Author: Arne ¼dtke<br/>
@ -323,16 +227,7 @@ public class Pair implements Serializable, DeepCloneable
{
return eOperator;
}
/**
* Author: Arne ¼dtke<br/>
* Setzt den Operator
* @param operator - Operator to set.
*/
public void SetOperator(PairOperator operator)
{
this.eOperator = operator;
}
/**
* Author: Arne ¼dtke<br/>
@ -358,8 +253,8 @@ public class Pair implements Serializable, DeepCloneable
/**
* @return Menge aus TA1 und TA2
*/
public Menge<Type> getTypes(){
Menge<Type> ret = new Menge<>();
public List<RefType> getTypes(){
List<RefType> ret = new ArrayList<>();
ret.add(this.TA1);
ret.add(this.TA2);
return ret;
@ -384,4 +279,3 @@ public class Pair implements Serializable, DeepCloneable
return clone();
}
}
// ino.end

View File

@ -1,6 +1,9 @@
package de.dhbwstuttgart.typeinference;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.syntaxtree.type.RefType;
import de.dhbwstuttgart.syntaxtree.type.Type;
@ -37,7 +40,7 @@ public class ResultSet implements Iterable<Pair> {
* @param type
* @return
*/
public Type getTypeEqualTo(Type type) {
public RefType getTypeEqualTo(RefType type) {
return getTypeEqualTo(type,null);
}
@ -46,8 +49,8 @@ public class ResultSet implements Iterable<Pair> {
* @param type
* @return
*/
public Type getTypeEqualTo(Type type, Menge<TypePlaceholder> ofType) {
Type res = type;
public RefType getTypeEqualTo(RefType type, List<TypePlaceholder> ofType) {
RefType res = type;
Menge<Pair> modifiedResultPairs = (Menge<Pair>) resultPairs.clone();
Ret r = findPairWithTypeEqualTo(type, modifiedResultPairs);
while(r.i != -1 && r.ret != null){
@ -64,14 +67,14 @@ public class ResultSet implements Iterable<Pair> {
class Ret{
int i;
Type ret;
private Ret(int i, Type ret){
RefType ret;
private Ret(int i, RefType ret){
this.i = i;
this.ret = ret;
}
}
private Ret findPairWithTypeEqualTo(Type type, Menge<Pair> inResultPairs){
private Ret findPairWithTypeEqualTo(RefType type, Menge<Pair> inResultPairs){
for(int i = 0; i<inResultPairs.size();i++){
Pair p = inResultPairs.elementAt(i);
if((p.OperatorEqual() || p.OperatorSmaller() || p.OperatorSmallerExtends()) && p.TA1.equals(type))
@ -92,7 +95,7 @@ public class ResultSet implements Iterable<Pair> {
* @param tA1
* @return true, falls der gesuchte Typ enthalten ist.
*/
public boolean contains(Type tA1) {
public boolean contains(RefType tA1) {
for(Pair p : this){
if(p.TA1.equals(tA1)||p.TA2.equals(tA1))return true;
}
@ -138,8 +141,8 @@ public class ResultSet implements Iterable<Pair> {
* @param unresolvedTPH
* @return
*/
public Menge<Type> getTypesInvolving(Menge<TypePlaceholder> unresolvedTPH) {
Menge<Type> ret = new Menge<Type>();
public List<RefType> getTypesInvolving(Menge<TypePlaceholder> unresolvedTPH) {
List<RefType> ret = new ArrayList<>();
for(Pair p : this.resultPairs){
for(TypePlaceholder tph : unresolvedTPH){
if(p.TA1.involves(tph))ret.add(p.TA1);