forked from JavaTX/JavaCompilerCore
Aufräumen
This commit is contained in:
parent
aff39ba442
commit
fc43cd11da
@ -70,7 +70,7 @@
|
|||||||
</a></div>
|
</a></div>
|
||||||
<!-- ========= END OF TOP NAVBAR ========= -->
|
<!-- ========= END OF TOP NAVBAR ========= -->
|
||||||
<div class="header">
|
<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>
|
||||||
<div class="classUseContainer">
|
<div class="classUseContainer">
|
||||||
<ul class="blockList">
|
<ul class="blockList">
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package de.dhbwstuttgart.bytecode;
|
package de.dhbwstuttgart.bytecode;
|
||||||
|
|
||||||
import de.dhbwstuttgart.syntaxtree.type.BoundedGenericTypeVar;
|
|
||||||
import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar;
|
import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar;
|
||||||
import de.dhbwstuttgart.syntaxtree.type.ObjectType;
|
import de.dhbwstuttgart.syntaxtree.type.ObjectType;
|
||||||
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
||||||
|
@ -16,7 +16,6 @@ import de.dhbwstuttgart.syntaxtree.statement.Statement;
|
|||||||
import de.dhbwstuttgart.syntaxtree.statement.SuperCall;
|
import de.dhbwstuttgart.syntaxtree.statement.SuperCall;
|
||||||
import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar;
|
import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar;
|
||||||
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
||||||
import de.dhbwstuttgart.syntaxtree.type.Type;
|
|
||||||
import de.dhbwstuttgart.typeinference.Menge;
|
import de.dhbwstuttgart.typeinference.Menge;
|
||||||
|
|
||||||
public class ASTFactory {
|
public class ASTFactory {
|
||||||
@ -111,7 +110,7 @@ public class ASTFactory {
|
|||||||
*/
|
*/
|
||||||
public Method createMethod(java.lang.reflect.Method jreMethod, java.lang.Class inClass){
|
public Method createMethod(java.lang.reflect.Method jreMethod, java.lang.Class inClass){
|
||||||
String name = jreMethod.getName();
|
String name = jreMethod.getName();
|
||||||
Type returnType = createType(jreMethod.getReturnType());
|
RefType returnType = createType(jreMethod.getReturnType());
|
||||||
Parameter[] jreParams = jreMethod.getParameters();
|
Parameter[] jreParams = jreMethod.getParameters();
|
||||||
List<FormalParameter> params = new ArrayList<>();
|
List<FormalParameter> params = new ArrayList<>();
|
||||||
for(Parameter jreParam : jreParams){
|
for(Parameter jreParam : jreParams){
|
||||||
@ -160,7 +159,7 @@ public class ASTFactory {
|
|||||||
public GenericTypeVar createGeneric(TypeVariable jreTypeVar, java.lang.Class inClass){
|
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
|
//TODO: Bei den Namen der Parameter des Generishen Typs nachschauen, ob er in der Klasse als Generic deklariert wurde
|
||||||
String name = jreTypeVar.getTypeName();
|
String name = jreTypeVar.getTypeName();
|
||||||
List<Type> genericBounds = new ArrayList<>();
|
List<RefType> genericBounds = new ArrayList<>();
|
||||||
java.lang.reflect.Type[] bounds = jreTypeVar.getBounds();
|
java.lang.reflect.Type[] bounds = jreTypeVar.getBounds();
|
||||||
if(bounds.length > 0){
|
if(bounds.length > 0){
|
||||||
for(java.lang.reflect.Type bound : bounds){
|
for(java.lang.reflect.Type bound : bounds){
|
||||||
|
@ -1,30 +1,19 @@
|
|||||||
// ino.module.Abstract.8585.package
|
|
||||||
package de.dhbwstuttgart.syntaxtree.modifier;
|
package de.dhbwstuttgart.syntaxtree.modifier;
|
||||||
|
|
||||||
import de.dhbwstuttgart.typeinference.JavaCodeResult;
|
import de.dhbwstuttgart.typeinference.JavaCodeResult;
|
||||||
import de.dhbwstuttgart.typeinference.ResultSet;
|
import de.dhbwstuttgart.typeinference.ResultSet;
|
||||||
|
|
||||||
|
|
||||||
// ino.class.Abstract.24015.description type=javadoc
|
|
||||||
/**
|
/**
|
||||||
* Stellt den Modifier Abstract dar.
|
* Stellt den Modifier Abstract dar.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
// ino.end
|
|
||||||
// ino.class.Abstract.24015.declaration
|
|
||||||
public class Abstract extends Modifier
|
public class Abstract extends Modifier
|
||||||
// ino.end
|
|
||||||
// ino.class.Abstract.24015.body
|
|
||||||
{
|
{
|
||||||
|
|
||||||
// ino.method.getBitmask.24019.definition
|
|
||||||
public short getBitmask()
|
public short getBitmask()
|
||||||
// ino.end
|
|
||||||
// ino.method.getBitmask.24019.body
|
|
||||||
{
|
{
|
||||||
return 0x0400;
|
return 0x0400;
|
||||||
}
|
}
|
||||||
// ino.end
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JavaCodeResult printJavaCode(ResultSet resultSet) {
|
public JavaCodeResult printJavaCode(ResultSet resultSet) {
|
||||||
@ -32,4 +21,3 @@ public class Abstract extends Modifier
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
// ino.end
|
|
||||||
|
@ -1,13 +1,15 @@
|
|||||||
package de.dhbwstuttgart.syntaxtree.type;
|
package de.dhbwstuttgart.syntaxtree.type;
|
||||||
|
|
||||||
|
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
|
||||||
import de.dhbwstuttgart.typeinference.Menge;
|
import de.dhbwstuttgart.typeinference.Menge;
|
||||||
|
|
||||||
import de.dhbwstuttgart.syntaxtree.Class;
|
|
||||||
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
|
|
||||||
import de.dhbwstuttgart.typeinference.ConstraintsSet;
|
import de.dhbwstuttgart.typeinference.ConstraintsSet;
|
||||||
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
|
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
|
||||||
import de.dhbwstuttgart.typeinference.exceptions.TypeinferenceException;
|
import de.dhbwstuttgart.typeinference.exceptions.TypeinferenceException;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Entspricht einem GenericTypeVar, jedoch mit Bounds
|
* Entspricht einem GenericTypeVar, jedoch mit Bounds
|
||||||
* (d.h. vorgaben, von welchem Typ die Typevar sein darf
|
* (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
|
* @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
|
* 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;
|
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);
|
super(s, offset);
|
||||||
if(bounds != null)for(Type t : bounds){
|
if(bounds != null)for(RefType t : bounds){
|
||||||
//if(t!=null)this.extendVars.add(t);
|
//if(t!=null)this.extendVars.add(t);
|
||||||
}
|
}
|
||||||
//this.genericTypeVar = new RefType(s,offset);
|
//this.genericTypeVar = new RefType(s,offset);
|
||||||
@ -42,33 +44,11 @@ public class BoundedGenericTypeVar extends GenericTypeVar
|
|||||||
return this.endOffset;
|
return this.endOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Menge<ObjectType> getBounds()
|
public List<RefType> getBounds()
|
||||||
{
|
{
|
||||||
return bounds;
|
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 fü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()
|
public BoundedGenericTypeVar clone()
|
||||||
{
|
{
|
||||||
return new BoundedGenericTypeVar(this.getName().toString(), this.getBounds(), getOffset(), this.getEndOffset());
|
return new BoundedGenericTypeVar(this.getName().toString(), this.getBounds(), getOffset(), this.getEndOffset());
|
||||||
|
@ -23,7 +23,7 @@ public class ExtendsWildcardType extends WildcardType implements ITypeContainer,
|
|||||||
* Author: Arne Lüdtke<br/>
|
* Author: Arne Lüdtke<br/>
|
||||||
* Standard Konstruktor für eine ExtendsWildcard
|
* Standard Konstruktor für eine ExtendsWildcard
|
||||||
*/
|
*/
|
||||||
public ExtendsWildcardType (int offset, ObjectType extendsType)
|
public ExtendsWildcardType (int offset, RefType extendsType)
|
||||||
{
|
{
|
||||||
super(extendsType, offset);
|
super(extendsType, offset);
|
||||||
this.name = new JavaClassName(this.toString());
|
this.name = new JavaClassName(this.toString());
|
||||||
|
@ -30,8 +30,8 @@ import de.dhbwstuttgart.typeinference.exceptions.TypeinferenceException;
|
|||||||
*/
|
*/
|
||||||
public class FunN extends RefType {
|
public class FunN extends RefType {
|
||||||
|
|
||||||
private Type R;
|
private RefType R;
|
||||||
private List<? extends Type> T;
|
private List<? extends RefType> T;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Andreas Stadelmeier, a10023
|
* @author Andreas Stadelmeier, a10023
|
||||||
@ -41,7 +41,7 @@ public class FunN extends RefType {
|
|||||||
* @param T
|
* @param T
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public FunN(Type R, List<? extends Type> T) {
|
public FunN(RefType R, List<? extends RefType> T) {
|
||||||
super("",0);
|
super("",0);
|
||||||
if(T==null || R == null)throw new NullPointerException();
|
if(T==null || R == null)throw new NullPointerException();
|
||||||
setT(T);
|
setT(T);
|
||||||
@ -69,7 +69,7 @@ public class FunN extends RefType {
|
|||||||
public FunN(int parameterCount) {
|
public FunN(int parameterCount) {
|
||||||
super("",0);
|
super("",0);
|
||||||
if(parameterCount<0)throw new RuntimeException("Anzahl der Parameter muss >0 sein");
|
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++){
|
for(int i=0;i<parameterCount;i++){
|
||||||
//t.add(TypePlaceholder.fresh(this));
|
//t.add(TypePlaceholder.fresh(this));
|
||||||
t.add(new GenericTypeVar(NameGenerator.makeNewName(), -1));
|
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 für den Typinferenzalgorithmus.
|
* Dabei werden bestimmte, von RefType geerbte, Parameter angepasst. Dies ist wichtig für den Typinferenzalgorithmus.
|
||||||
*/
|
*/
|
||||||
private void calculateNewParalist(){
|
private void calculateNewParalist(){
|
||||||
Menge<Type> t = new Menge<Type>();
|
List<RefType> t = new ArrayList<>();
|
||||||
if(R!=null)t.add(R);
|
if(R!=null)t.add(R);
|
||||||
if(T!=null)t.addAll(T);
|
if(T!=null)t.addAll(T);
|
||||||
for(Type type : t){
|
for(RefType type : t){
|
||||||
if(type instanceof WildcardType){
|
if(type instanceof WildcardType){
|
||||||
throw new DebugException("Der FunN-Typ darf keine Wildcards in den Parameter enthalten");
|
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;
|
this.T = list;
|
||||||
calculateNewParalist();
|
calculateNewParalist();
|
||||||
}
|
}
|
||||||
protected void setR(Type R){
|
|
||||||
|
protected void setR(RefType R){
|
||||||
this.R = R;
|
this.R = R;
|
||||||
calculateNewParalist();
|
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) {
|
public String getBytecodeInvokeDynamicSignature(ClassGenerator cg, TypeinferenceResultSet rs) {
|
||||||
String ret = "(";
|
String ret = "(";
|
||||||
for(Type t : T){
|
for(RefType t : T){
|
||||||
ret+=t.getBytecodeType(cg, rs).getSignature();
|
ret+=t.getBytecodeType(cg, rs).getSignature();
|
||||||
}
|
}
|
||||||
ret +=")";
|
ret +=")";
|
||||||
@ -135,62 +118,11 @@ public class FunN extends RefType {
|
|||||||
|
|
||||||
public String getBytecodeInvokeDynamicSignatureUpperBound(ClassGenerator cg) {
|
public String getBytecodeInvokeDynamicSignatureUpperBound(ClassGenerator cg) {
|
||||||
String ret = "(";
|
String ret = "(";
|
||||||
for(Type t : T){
|
for(RefType t : T){
|
||||||
ret+=cg.getInstructionFactory().createObjectType().getSignature();
|
ret+=cg.getInstructionFactory().createObjectType().getSignature();
|
||||||
}
|
}
|
||||||
ret +=")";
|
ret +=")";
|
||||||
ret += cg.getInstructionFactory().createObjectType().getSignature();
|
ret += cg.getInstructionFactory().createObjectType().getSignature();
|
||||||
return ret;
|
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;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
package de.dhbwstuttgart.syntaxtree.type;
|
package de.dhbwstuttgart.syntaxtree.type;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import de.dhbwstuttgart.typeinference.Menge;
|
import de.dhbwstuttgart.typeinference.Menge;
|
||||||
|
|
||||||
import de.dhbwstuttgart.parser.JavaClassName;
|
import de.dhbwstuttgart.parser.JavaClassName;
|
||||||
@ -19,8 +22,8 @@ import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
|
|||||||
*/
|
*/
|
||||||
public class FunVoidN extends FunN {
|
public class FunVoidN extends FunN {
|
||||||
|
|
||||||
private Type R;
|
private RefType R;
|
||||||
private Menge<Type> T;
|
private List<RefType> T;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Andreas Stadelmeier, a10023
|
* @author Andreas Stadelmeier, a10023
|
||||||
@ -29,7 +32,7 @@ public class FunVoidN extends FunN {
|
|||||||
* @param T
|
* @param T
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public FunVoidN(Menge<Type> T) {
|
public FunVoidN(List<RefType> T) {
|
||||||
super(null,T);
|
super(null,T);
|
||||||
this.setR(new Void(this, -1));
|
this.setR(new Void(this, -1));
|
||||||
this.name = new JavaClassName("FunVoid"+T.size());
|
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 für den Typinferenzalgorithmus.
|
* Dabei werden bestimmte, von RefType geerbte, Parameter angepasst. Dies ist wichtig für den Typinferenzalgorithmus.
|
||||||
*/
|
*/
|
||||||
private void calculateNewParalist(){
|
private void calculateNewParalist(){
|
||||||
Menge<Type> t = new Menge<Type>();
|
List<RefType> t = new ArrayList<>();
|
||||||
if(T!=null)t.addAll(T);
|
if(T!=null)t.addAll(T);
|
||||||
this.set_ParaList(t);
|
this.parameter = t;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -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()+";";
|
|
||||||
}
|
|
||||||
}
|
|
@ -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 J�rg B�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 f�r alle Generic-Instanzen, die vor der Bytecode-Generierung durch
|
|
||||||
* Ihre Superklasse ersetzt werden m�ssen. Siehe "Type Erasure" in Sun Spezifikation.
|
|
||||||
* <br/>Autor: J�rg B�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: J�rg B�uerle
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public GenericTypeVar clone()
|
|
||||||
{
|
|
||||||
return new GenericTypeVar(this.getName().toString(), getOffset());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <br/>Author: J�rg B�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 fü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 gü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 kö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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -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 müssen.
|
|
||||||
*
|
|
||||||
* @author Arne Lüdtke
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public interface IMatchable
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Author: Arne Lüdtke<br/>
|
|
||||||
* Gibt den Typen zurück, der bei einem match im Unify verwendet werden soll.
|
|
||||||
* Wird über IMatchable implementiert.
|
|
||||||
*/
|
|
||||||
Type getMatchType();
|
|
||||||
}
|
|
@ -1,19 +0,0 @@
|
|||||||
package de.dhbwstuttgart.syntaxtree.type;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Dieses Interface wird von allen Klassen implementiert, die weitere Klassen enthalten.
|
|
||||||
* Wird für diverse Hilfsmethoden verwendet.
|
|
||||||
*
|
|
||||||
* @author Arne Lüdtke
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
public interface ITypeContainer
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Author: Arne Lüdtke<br/>
|
|
||||||
* Das gleiche wie get_ExtendsType().
|
|
||||||
* Implementiert ITypeContainer
|
|
||||||
*/
|
|
||||||
Type getContainedType();
|
|
||||||
}
|
|
@ -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();
|
|
||||||
}
|
|
@ -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
|
|
@ -1,7 +1,4 @@
|
|||||||
// ino.module.RefType.8675.package
|
|
||||||
package de.dhbwstuttgart.syntaxtree.type;
|
package de.dhbwstuttgart.syntaxtree.type;
|
||||||
// ino.end
|
|
||||||
// ino.module.RefType.8675.import
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
import java.util.Hashtable;
|
import java.util.Hashtable;
|
||||||
@ -30,12 +27,7 @@ import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
|
|||||||
import de.dhbwstuttgart.typeinference.exceptions.TypeinferenceException;
|
import de.dhbwstuttgart.typeinference.exceptions.TypeinferenceException;
|
||||||
|
|
||||||
|
|
||||||
|
public class RefType extends SyntaxTreeNode
|
||||||
|
|
||||||
// ino.class.RefType.26621.declaration
|
|
||||||
public class RefType extends ObjectType implements IMatchable
|
|
||||||
// ino.end
|
|
||||||
// ino.class.RefType.26621.body
|
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Ist IsArray auf true, muss beim Codegen ein Zeichen [ gesetzt werden
|
* 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
|
* Bsp.: 9| tag = CONSTANT_Utf8, length = 21, (Ljava/lang/String;)V
|
||||||
*/
|
*/
|
||||||
private boolean IsArray = false;
|
private boolean IsArray = false;
|
||||||
|
protected JavaClassName name;
|
||||||
private List<RefType> parameter = null;
|
protected List<RefType> parameter = null;
|
||||||
/**
|
/**
|
||||||
* Ist primitiveFlag auf true, muss beim Codegen dieser Reftype durch
|
* Ist primitiveFlag auf true, muss beim Codegen dieser Reftype durch
|
||||||
* den primitiven Datentyp ersetzt werden
|
* den primitiven Datentyp ersetzt werden
|
||||||
@ -54,10 +46,10 @@ public class RefType extends ObjectType implements IMatchable
|
|||||||
*/
|
*/
|
||||||
private boolean primitiveFlag=false;
|
private boolean primitiveFlag=false;
|
||||||
|
|
||||||
public RefType(String fullyQualifiedName, int offset)
|
public RefType(JavaClassName fullyQualifiedName, int offset)
|
||||||
{
|
{
|
||||||
super(fullyQualifiedName,offset);
|
super(offset);
|
||||||
this.setName(fullyQualifiedName);
|
this.name = (fullyQualifiedName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -68,199 +60,28 @@ public class RefType extends ObjectType implements IMatchable
|
|||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ino.method.RefType.26640.definition
|
public RefType(JavaClassName fullyQualifiedName, List<RefType> parameter, int offset)
|
||||||
public RefType(String fullyQualifiedName, List<RefType> parameter, int offset)
|
|
||||||
// ino.end
|
|
||||||
// ino.method.RefType.26640.body
|
|
||||||
{
|
{
|
||||||
super(fullyQualifiedName,offset);
|
this(fullyQualifiedName, offset);
|
||||||
this.setName(fullyQualifiedName);
|
if(parameter != null && parameter.size()>0)this.parameter = parameter;
|
||||||
if(parameter != null && parameter.size()>0)this.set_ParaList(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()
|
public JavaClassName getName()
|
||||||
// ino.end
|
|
||||||
// ino.method.getName.26658.body
|
|
||||||
{
|
{
|
||||||
return name;
|
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
|
|
||||||
|
|
||||||
/**
|
public List<RefType> getParaList(){
|
||||||
* Fügt eine Parameterliste an und tauscht zuvor alle GenerictTypeVars durch TPH aus.
|
if(this.parameter==null)return new ArrayList<>();
|
||||||
* In einem RefType dü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 fü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;
|
|
||||||
return this.parameter;
|
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/>
|
* Author: Jrg Buerle<br/>
|
||||||
* @param Object
|
* @param Object
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
// ino.end
|
|
||||||
// ino.method.equals.26685.definition
|
|
||||||
public boolean equals(Object obj)
|
public boolean equals(Object obj)
|
||||||
// ino.end
|
|
||||||
// ino.method.equals.26685.body
|
|
||||||
{
|
{
|
||||||
if(obj instanceof RefType){
|
if(obj instanceof RefType){
|
||||||
boolean ret = true;
|
boolean ret = true;
|
||||||
@ -293,12 +114,8 @@ public class RefType extends ObjectType implements IMatchable
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// ino.end
|
|
||||||
|
|
||||||
// ino.method.clone.26688.definition
|
|
||||||
public RefType clone()
|
public RefType clone()
|
||||||
// ino.end
|
|
||||||
// ino.method.clone.26688.body
|
|
||||||
{
|
{
|
||||||
if(this.get_ParaList() != null )
|
if(this.get_ParaList() != null )
|
||||||
{
|
{
|
||||||
@ -320,12 +137,8 @@ public class RefType extends ObjectType implements IMatchable
|
|||||||
return newRefType;
|
return newRefType;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// ino.end
|
|
||||||
|
|
||||||
// ino.method.toString.26691.definition
|
|
||||||
public String toString()
|
public String toString()
|
||||||
// ino.end
|
|
||||||
// ino.method.toString.26691.body
|
|
||||||
{
|
{
|
||||||
String primitiveFlagMarker=primitiveFlag?"*":"";
|
String primitiveFlagMarker=primitiveFlag?"*":"";
|
||||||
if(parameter==null)
|
if(parameter==null)
|
||||||
@ -335,10 +148,10 @@ public class RefType extends ObjectType implements IMatchable
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
String para = new String();
|
String para = new String();
|
||||||
Iterator<Type> e=parameter.iterator();
|
Iterator<RefType> e=parameter.iterator();
|
||||||
while(e.hasNext())
|
while(e.hasNext())
|
||||||
{
|
{
|
||||||
Type ty = (Type)e.next();
|
RefType ty = e.next();
|
||||||
String t = ty.toString();
|
String t = ty.toString();
|
||||||
if(para.length() > 0)
|
if(para.length() > 0)
|
||||||
para = para +", "+ t;
|
para = para +", "+ t;
|
||||||
@ -349,89 +162,15 @@ public class RefType extends ObjectType implements IMatchable
|
|||||||
return ret + primitiveFlagMarker;//name + "<"+para + " >" +primitiveFlagMarker;
|
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 Lü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
|
@Override
|
||||||
public JavaCodeResult printJavaCode(ResultSet resultSet) {
|
public JavaCodeResult printJavaCode(ResultSet resultSet) {
|
||||||
JavaCodeResult ret = new JavaCodeResult(this.name.toString());
|
JavaCodeResult ret = new JavaCodeResult(this.name.toString());
|
||||||
if(this.getParaList()!=null && this.getParaList().size()>0){
|
if(this.getParaList()!=null && this.getParaList().size()>0){
|
||||||
ret .attach( "<" );
|
ret .attach( "<" );
|
||||||
Iterator<Type> it = this.getParaList().iterator();
|
Iterator<RefType> it = this.getParaList().iterator();
|
||||||
while(it.hasNext()){
|
while(it.hasNext()){
|
||||||
Type t = it.next();
|
RefType t = it.next();
|
||||||
ret .attach( t.printJavaCode(resultSet));
|
ret .attach( t.printJavaCode(resultSet));
|
||||||
if(it.hasNext())ret.attach(", ");
|
if(it.hasNext())ret.attach(", ");
|
||||||
}
|
}
|
||||||
@ -440,51 +179,14 @@ public class RefType extends ObjectType implements IMatchable
|
|||||||
}
|
}
|
||||||
return ret;
|
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) {
|
public Menge<TypePlaceholder> getUnresolvedTPH(ResultSet resultSet) {
|
||||||
Menge<TypePlaceholder> ret = super.getUnresolvedTPH(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());
|
ret.addAll(this.printJavaCode(resultSet).getUnresolvedTPH());
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public List<TypePlaceholder> getInvolvedTypePlaceholder() {
|
||||||
public boolean involves(TypePlaceholder tph) {
|
|
||||||
for(RefType param : parameter)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Menge<TypePlaceholder> getInvolvedTypePlaceholder() {
|
|
||||||
Menge<TypePlaceholder> ret = super.getInvolvedTypePlaceholder();
|
Menge<TypePlaceholder> ret = super.getInvolvedTypePlaceholder();
|
||||||
if(this.parameter == null)return ret;
|
if(this.parameter == null)return ret;
|
||||||
for(Type param : this.parameter){
|
for(Type param : this.parameter){
|
||||||
@ -492,13 +194,6 @@ public class RefType extends ObjectType implements IMatchable
|
|||||||
}
|
}
|
||||||
return ret;
|
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
|
@Override
|
||||||
public Menge<SyntaxTreeNode> getChildren() {
|
public Menge<SyntaxTreeNode> getChildren() {
|
||||||
@ -507,24 +202,7 @@ public class RefType extends ObjectType implements IMatchable
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public org.apache.bcel.generic.Type getBytecodeType(ClassGenerator cg, TypeinferenceResultSet rs) {
|
||||||
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) {
|
|
||||||
org.apache.bcel.generic.ObjectType ret = new org.apache.bcel.generic.ObjectType(getCombinedType(cg, 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
|
//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) {
|
public String getBytecodeSignature(ClassGenerator cg, TypeinferenceResultSet rs) {
|
||||||
String combinedType = getCombinedType(cg, rs);
|
String combinedType = getCombinedType(cg, rs);
|
||||||
/*
|
/*
|
||||||
@ -544,25 +221,23 @@ public class RefType extends ObjectType implements IMatchable
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getClassSignature(ClassGenerator cg, TypeinferenceResultSet rs) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getCombinedType(ClassGenerator cg, TypeinferenceResultSet rs){
|
public String getCombinedType(ClassGenerator cg, TypeinferenceResultSet rs){
|
||||||
//Bsp.: Ljava/util/Vector<Ljava/lang/String;>;
|
//Bsp.: Ljava/util/Vector<Ljava/lang/String;>;
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
String ret;
|
String ret;
|
||||||
List<Type> newParams = new ArrayList<>();
|
List<RefType> newParams = new ArrayList<>();
|
||||||
if(parameter != null && parameter.size() > 0){
|
if(parameter != null && parameter.size() > 0){
|
||||||
sb.append(getName().toString().replace(".", "%"));
|
sb.append(getName().toString().replace(".", "%"));
|
||||||
sb.append("%%");
|
sb.append("%%");
|
||||||
for(Type type: parameter){
|
for(RefType type: parameter){
|
||||||
Type newParameter;
|
RefType newParameter;
|
||||||
if(type instanceof RefType){
|
if(type instanceof RefType){
|
||||||
sb.append(((RefType) type).getCombinedType(cg, rs).replace(".", "%"));
|
sb.append(((RefType) type).getCombinedType(cg, rs).replace(".", "%"));
|
||||||
newParameter = type;
|
newParameter = type;
|
||||||
}else if(type instanceof TypePlaceholder){
|
}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);
|
newParameter = rs.getTypeOfPlaceholder((TypePlaceholder)type);
|
||||||
sb.append(((TypePlaceholder) type).getBytecodeType(cg, rs).toString().replace(".", "%"));
|
sb.append(((TypePlaceholder) type).getBytecodeType(cg, rs).toString().replace(".", "%"));
|
||||||
}else if(type instanceof WildcardType){
|
}else if(type instanceof WildcardType){
|
||||||
@ -588,12 +263,5 @@ public class RefType extends ObjectType implements IMatchable
|
|||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
public GenericClassType getGenericClassType(){
|
|
||||||
return new GenericClassType(getName().toString(), getParaList(), parent, getOffset());
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
// ino.end
|
|
||||||
|
|
||||||
|
@ -10,6 +10,8 @@ import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
|||||||
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
|
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
|
||||||
import de.dhbwstuttgart.typeinference.exceptions.DebugException;
|
import de.dhbwstuttgart.typeinference.exceptions.DebugException;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stellt eine Wildcard mit unterer Grenze dar.
|
* Stellt eine Wildcard mit unterer Grenze dar.
|
||||||
* z.B. void test(? super Integer var){..}
|
* 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);
|
this(innerType.getOffset(), innerType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -28,7 +30,7 @@ public class SuperWildcardType extends WildcardType implements ITypeContainer, I
|
|||||||
* Author: Arne Lüdtke<br/>
|
* Author: Arne Lüdtke<br/>
|
||||||
* Standard Konstruktor für eine SuperWildcard
|
* Standard Konstruktor für eine SuperWildcard
|
||||||
*/
|
*/
|
||||||
public SuperWildcardType(int offset, ObjectType innerType)
|
public SuperWildcardType(int offset, RefType innerType)
|
||||||
{
|
{
|
||||||
super(innerType, offset);
|
super(innerType, offset);
|
||||||
}
|
}
|
||||||
@ -39,7 +41,7 @@ public class SuperWildcardType extends WildcardType implements ITypeContainer, I
|
|||||||
* Beispiel: ? super Integer.
|
* Beispiel: ? super Integer.
|
||||||
* Integer wird zurückgegeben.
|
* Integer wird zurückgegeben.
|
||||||
*/
|
*/
|
||||||
public ObjectType get_SuperType()
|
public RefType get_SuperType()
|
||||||
{
|
{
|
||||||
return this.innerType;
|
return this.innerType;
|
||||||
}
|
}
|
||||||
@ -60,7 +62,7 @@ public class SuperWildcardType extends WildcardType implements ITypeContainer, I
|
|||||||
*/
|
*/
|
||||||
public SuperWildcardType clone()
|
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().
|
* Das gleiche wie get_innerType().
|
||||||
* Ãberschreibt die Methode der Superklasse
|
* Ãberschreibt die Methode der Superklasse
|
||||||
*/
|
*/
|
||||||
public Type GetWildcardType()
|
public RefType GetWildcardType()
|
||||||
{
|
{
|
||||||
return this.get_SuperType();
|
return this.get_SuperType();
|
||||||
}
|
}
|
||||||
@ -78,7 +80,7 @@ public class SuperWildcardType extends WildcardType implements ITypeContainer, I
|
|||||||
* Setzt den Typ in der Wildcard
|
* Setzt den Typ in der Wildcard
|
||||||
* @param T - Type to be set
|
* @param T - Type to be set
|
||||||
*/
|
*/
|
||||||
public void SetWildcardType(ObjectType T)
|
public void SetWildcardType(RefType T)
|
||||||
{
|
{
|
||||||
//if(T instanceof RefType)
|
//if(T instanceof RefType)
|
||||||
this.innerType = (RefType)T;
|
this.innerType = (RefType)T;
|
||||||
@ -89,7 +91,7 @@ public class SuperWildcardType extends WildcardType implements ITypeContainer, I
|
|||||||
* Das gleiche wie get_innerType().
|
* Das gleiche wie get_innerType().
|
||||||
* Implementiert ITypeContainer
|
* Implementiert ITypeContainer
|
||||||
*/
|
*/
|
||||||
public Type getContainedType()
|
public RefType getContainedType()
|
||||||
{
|
{
|
||||||
return this.get_SuperType();
|
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.
|
* Gibt den Typen zurück, der bei einem match im Unify verwendet werden soll.
|
||||||
* Wird über IMatchable implementiert.
|
* Wird über IMatchable implementiert.
|
||||||
*/
|
*/
|
||||||
public Type getMatchType()
|
public RefType getMatchType()
|
||||||
{
|
{
|
||||||
return this.get_SuperType();
|
return this.get_SuperType();
|
||||||
}
|
}
|
||||||
@ -127,8 +129,8 @@ public class SuperWildcardType extends WildcardType implements ITypeContainer, I
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Menge<TypePlaceholder> getInvolvedTypePlaceholder() {
|
public List<TypePlaceholder> getInvolvedTypePlaceholder() {
|
||||||
Menge<TypePlaceholder> ret = super.getInvolvedTypePlaceholder();
|
List<TypePlaceholder> ret = super.getInvolvedTypePlaceholder();
|
||||||
ret.addAll(this.innerType.getInvolvedTypePlaceholder());
|
ret.addAll(this.innerType.getInvolvedTypePlaceholder());
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -139,28 +141,9 @@ public class SuperWildcardType extends WildcardType implements ITypeContainer, I
|
|||||||
this.innerType.parserPostProcessing(this);
|
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
|
@Override
|
||||||
public String getBytecodeSignature(ClassGenerator cg, TypeinferenceResultSet rs) {
|
public String getBytecodeSignature(ClassGenerator cg, TypeinferenceResultSet rs) {
|
||||||
return "-" + this.innerType.getBytecodeSignature(cg, rs);
|
return "-" + this.innerType.getBytecodeSignature(cg, rs);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String get_Name() {
|
|
||||||
return "? super "+this.innerType.get_Name();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,4 @@
|
|||||||
// ino.module.TypePlaceholder.8678.package
|
|
||||||
package de.dhbwstuttgart.syntaxtree.type;
|
package de.dhbwstuttgart.syntaxtree.type;
|
||||||
// ino.end
|
|
||||||
|
|
||||||
// ino.module.TypePlaceholder.8678.import
|
|
||||||
import java.util.Hashtable;
|
import java.util.Hashtable;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
@ -24,7 +20,7 @@ import de.dhbwstuttgart.typeinference.exceptions.DebugException;
|
|||||||
import de.dhbwstuttgart.typeinference.exceptions.TypeinferenceException;
|
import de.dhbwstuttgart.typeinference.exceptions.TypeinferenceException;
|
||||||
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertPoint;
|
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertPoint;
|
||||||
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
|
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
|
||||||
// ino.class.TypePlaceholder.26780.description type=javadoc
|
|
||||||
/**
|
/**
|
||||||
* Repr�sentiert einen Typparameter f�r einen vom Programmierer nicht angegeben
|
* Repr�sentiert einen Typparameter f�r einen vom Programmierer nicht angegeben
|
||||||
* Typ. Jede TypePlaceholder besitzt einen eindeutigen Namen aus einem Namenspool
|
* Typ. Jede TypePlaceholder besitzt einen eindeutigen Namen aus einem Namenspool
|
||||||
@ -33,16 +29,11 @@ import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
|
|||||||
* @author J�rg B�uerle
|
* @author J�rg B�uerle
|
||||||
* @version $Date: 2013/06/19 12:45:37 $
|
* @version $Date: 2013/06/19 12:45:37 $
|
||||||
*/
|
*/
|
||||||
// ino.end
|
public class TypePlaceholder extends RefType
|
||||||
// ino.class.TypePlaceholder.26780.declaration
|
|
||||||
public class TypePlaceholder extends ObjectType
|
|
||||||
// ino.end
|
|
||||||
// ino.class.TypePlaceholder.26780.body
|
|
||||||
{
|
{
|
||||||
private static final Logger log = Logger.getLogger(TypePlaceholder.class.getName());
|
private static final Logger log = Logger.getLogger(TypePlaceholder.class.getName());
|
||||||
|
|
||||||
private static Hashtable<String, TypePlaceholder> m_TypePlaceholdersRegistry = new Hashtable<String, TypePlaceholder>();
|
private static Hashtable<String, TypePlaceholder> m_TypePlaceholdersRegistry = new Hashtable<String, TypePlaceholder>();
|
||||||
// ino.end
|
|
||||||
private SyntaxTreeNode parent;
|
private SyntaxTreeNode parent;
|
||||||
|
|
||||||
|
|
||||||
@ -107,13 +98,7 @@ public class TypePlaceholder extends ObjectType
|
|||||||
m_TypePlaceholdersRegistry.put(ret.getName().toString(), ret);
|
m_TypePlaceholdersRegistry.put(ret.getName().toString(), ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Menge<TypePlaceholder> getInvolvedTypePlaceholder() {
|
|
||||||
Menge<TypePlaceholder> ret = super.getInvolvedTypePlaceholder();
|
|
||||||
ret.add(this);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Author: J�rg B�uerle<br/>
|
* Author: J�rg B�uerle<br/>
|
||||||
@ -157,16 +142,7 @@ public class TypePlaceholder extends ObjectType
|
|||||||
TypePlaceholder dolly = new TypePlaceholder(name.toString(), this.parent);
|
TypePlaceholder dolly = new TypePlaceholder(name.toString(), this.parent);
|
||||||
return dolly;
|
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()
|
public String toString()
|
||||||
{
|
{
|
||||||
return "TPH " + this.getName();
|
return "TPH " + this.getName();
|
||||||
@ -201,31 +177,7 @@ public class TypePlaceholder extends ObjectType
|
|||||||
|
|
||||||
//return new TypePlaceholder(makeNewName());
|
//return new TypePlaceholder(makeNewName());
|
||||||
}
|
}
|
||||||
// ino.end
|
|
||||||
|
|
||||||
// ino.method.backdoorSetName.26851.defdescription type=javadoc
|
|
||||||
/**
|
|
||||||
* Backdoor-Hilfsfunktion, die f�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: J�rg B�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 f�r <code>makeFC()</code> und <code>unify()</code>
|
* Backdoor-Hilfsfunktion, die f�r <code>makeFC()</code> und <code>unify()</code>
|
||||||
* ben�tigt wird, zum Erzeugen eines <code>TypePlaceholders</code>, der nicht in
|
* 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) {
|
private JavaCodeResult printJavaCodePr(ResultSet resultSet) {
|
||||||
Type equalType = resultSet.getTypeEqualTo(this);
|
RefType equalType = resultSet.getTypeEqualTo(this);
|
||||||
if(equalType == null || equalType.equals(this)){
|
if(equalType == null || equalType.equals(this)){
|
||||||
//Für den Fall das der TPH nicht aufgelöst werden konnte.
|
//Für den Fall das der TPH nicht aufgelöst werden konnte.
|
||||||
JavaCodeResult ret = new JavaCodeResult(this.getName().toString());
|
JavaCodeResult ret = new JavaCodeResult(this.getName().toString());
|
||||||
@ -264,8 +216,7 @@ public class TypePlaceholder extends ObjectType
|
|||||||
|
|
||||||
return equalType.printJavaCode(resultSet);
|
return equalType.printJavaCode(resultSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public JavaCodeResult printJavaCode(ResultSet resultSet, boolean resolveTPHs){
|
public JavaCodeResult printJavaCode(ResultSet resultSet, boolean resolveTPHs){
|
||||||
if(resolveTPHs)return printJavaCodePr(resultSet);
|
if(resolveTPHs)return printJavaCodePr(resultSet);
|
||||||
return new JavaCodeResult(this.get_Name());
|
return new JavaCodeResult(this.get_Name());
|
||||||
|
@ -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: J�rg B�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: J�rg B�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
|
|
@ -10,6 +10,7 @@ import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
|||||||
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
|
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
|
||||||
import de.dhbwstuttgart.typeinference.exceptions.DebugException;
|
import de.dhbwstuttgart.typeinference.exceptions.DebugException;
|
||||||
import de.dhbwstuttgart.typeinference.exceptions.NotImplementedException;
|
import de.dhbwstuttgart.typeinference.exceptions.NotImplementedException;
|
||||||
|
import de.dhbwstuttgart.typeinference.exceptions.TypeinferenceException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stellt eine Wildcard in Java dar.
|
* Stellt eine Wildcard in Java dar.
|
||||||
@ -20,15 +21,16 @@ import de.dhbwstuttgart.typeinference.exceptions.NotImplementedException;
|
|||||||
|
|
||||||
public abstract class WildcardType extends RefType{
|
public abstract class WildcardType extends RefType{
|
||||||
|
|
||||||
protected ObjectType innerType = null;
|
protected RefType innerType = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Author: Arne Lüdtke<br/>
|
* Author: Arne Lüdtke<br/>
|
||||||
* Standard Konstruktor für eine Wildcard
|
* Standard Konstruktor fü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;
|
this.innerType = innerType;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,7 +52,7 @@ public abstract class WildcardType extends RefType{
|
|||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JavaCodeResult printJavaCode(ResultSet resultSet) {
|
public JavaCodeResult printJavaCode(ResultSet resultSet) {
|
||||||
@ -59,7 +61,7 @@ public abstract class WildcardType extends RefType{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RefType TYPE(TypeAssumptions ass, SyntaxTreeNode parent) {
|
public RefType TYPE(TypeAssumptions ass, SyntaxTreeNode parent) {
|
||||||
this.innerType = (ObjectType) innerType.TYPE(ass, this);
|
this.innerType = innerType.TYPE(ass, this);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,13 +1,11 @@
|
|||||||
// ino.module.Pair.8673.package
|
|
||||||
package de.dhbwstuttgart.typeinference;
|
package de.dhbwstuttgart.typeinference;
|
||||||
// ino.end
|
|
||||||
// ino.module.Pair.8673.import
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.ObjectInputStream;
|
import java.io.ObjectInputStream;
|
||||||
import java.io.ObjectOutputStream;
|
import java.io.ObjectOutputStream;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Hashtable;
|
import java.util.Hashtable;
|
||||||
import java.util.List;
|
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
|
// Klasse, die ein Paar in der Menge Eq speichern kann
|
||||||
// ino.end
|
|
||||||
// ino.class.Pair.26540.declaration
|
|
||||||
public class Pair implements Serializable, DeepCloneable
|
public class Pair implements Serializable, DeepCloneable
|
||||||
// ino.end
|
|
||||||
// ino.class.Pair.26540.body
|
|
||||||
{
|
{
|
||||||
// ino.attribute.TA1.26543.declaration
|
public RefType TA1;
|
||||||
public Type TA1;
|
public RefType TA2;
|
||||||
// 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 mü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
|
|
||||||
|
|
||||||
|
|
||||||
// ino.method.Pair.26555.definition
|
private PairOperator eOperator = PairOperator.SMALLER;
|
||||||
public Pair( Type TA1, Type TA2 )
|
|
||||||
// ino.end
|
public boolean bSubst; // speichert, ob die SUBST -Regel auf diese Paar
|
||||||
// ino.method.Pair.26555.body
|
|
||||||
|
public Pair( RefType TA1, RefType TA2 )
|
||||||
{
|
{
|
||||||
// Konstruktor
|
// Konstruktor
|
||||||
//if(TA1 == null || TA2 == null)throw new NullPointerException();
|
//if(TA1 == null || TA2 == null)throw new NullPointerException();
|
||||||
@ -79,12 +41,8 @@ public class Pair implements Serializable, DeepCloneable
|
|||||||
bSubst = false;
|
bSubst = false;
|
||||||
eOperator = PairOperator.SMALLER;
|
eOperator = PairOperator.SMALLER;
|
||||||
}
|
}
|
||||||
// ino.end
|
|
||||||
|
|
||||||
// ino.method.Pair.26558.definition
|
public Pair( RefType TA1, RefType TA2, PairOperator eOp)
|
||||||
public Pair( Type TA1, Type TA2, PairOperator eOp)
|
|
||||||
// ino.end
|
|
||||||
// ino.method.Pair.26558.body
|
|
||||||
{
|
{
|
||||||
// Konstruktor
|
// Konstruktor
|
||||||
this(TA1,TA2);
|
this(TA1,TA2);
|
||||||
@ -93,7 +51,7 @@ public class Pair implements Serializable, DeepCloneable
|
|||||||
// ino.end
|
// ino.end
|
||||||
|
|
||||||
// ino.method.Pair.26561.definition
|
// 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.end
|
||||||
// ino.method.Pair.26561.body
|
// ino.method.Pair.26561.body
|
||||||
{
|
{
|
||||||
@ -130,12 +88,8 @@ public class Pair implements Serializable, DeepCloneable
|
|||||||
|
|
||||||
/*- Equals: " + bEqual*/
|
/*- Equals: " + bEqual*/
|
||||||
}
|
}
|
||||||
// ino.end
|
|
||||||
|
|
||||||
// ino.method.isEqual.26567.definition
|
|
||||||
public boolean isEqual()
|
public boolean isEqual()
|
||||||
// ino.end
|
|
||||||
// ino.method.isEqual.26567.body
|
|
||||||
{
|
{
|
||||||
// otth: Prueft, ob TA1 == TA2
|
// otth: Prueft, ob TA1 == TA2
|
||||||
if( TA1 instanceof RefType && TA2 instanceof RefType )
|
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
|
public static RefType copyType( RefType T )
|
||||||
// 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
|
|
||||||
{
|
{
|
||||||
// #JB# 22.05.2005
|
// #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: J�rg B�uerle
|
* <br/>Author: J�rg B�uerle
|
||||||
* @param obj
|
* @param obj
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
// ino.end
|
|
||||||
// ino.method.equals.26588.definition
|
|
||||||
public boolean equals(Object obj)
|
public boolean equals(Object obj)
|
||||||
// ino.end
|
|
||||||
// ino.method.equals.26588.body
|
|
||||||
{
|
{
|
||||||
boolean ret = true;
|
boolean ret = true;
|
||||||
ret &= (obj instanceof Pair);
|
ret &= (obj instanceof Pair);
|
||||||
@ -277,16 +191,6 @@ public class Pair implements Serializable, DeepCloneable
|
|||||||
ret &= ((Pair)obj).TA2.equals(this.TA2);
|
ret &= ((Pair)obj).TA2.equals(this.TA2);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
// ino.end
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Author: Arne Lüdtke<br/>
|
|
||||||
* Ãberprüft ob die Paare die gleichen Instanzen sind.
|
|
||||||
*/
|
|
||||||
public boolean instanzeEquals(Object obj)
|
|
||||||
{
|
|
||||||
return super.equals(obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Author: Arne Lüdtke<br/>
|
* Author: Arne Lüdtke<br/>
|
||||||
@ -323,16 +227,7 @@ public class Pair implements Serializable, DeepCloneable
|
|||||||
{
|
{
|
||||||
return eOperator;
|
return eOperator;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Author: Arne Lüdtke<br/>
|
|
||||||
* Setzt den Operator
|
|
||||||
* @param operator - Operator to set.
|
|
||||||
*/
|
|
||||||
public void SetOperator(PairOperator operator)
|
|
||||||
{
|
|
||||||
this.eOperator = operator;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Author: Arne Lüdtke<br/>
|
* Author: Arne Lüdtke<br/>
|
||||||
@ -358,8 +253,8 @@ public class Pair implements Serializable, DeepCloneable
|
|||||||
/**
|
/**
|
||||||
* @return Menge aus TA1 und TA2
|
* @return Menge aus TA1 und TA2
|
||||||
*/
|
*/
|
||||||
public Menge<Type> getTypes(){
|
public List<RefType> getTypes(){
|
||||||
Menge<Type> ret = new Menge<>();
|
List<RefType> ret = new ArrayList<>();
|
||||||
ret.add(this.TA1);
|
ret.add(this.TA1);
|
||||||
ret.add(this.TA2);
|
ret.add(this.TA2);
|
||||||
return ret;
|
return ret;
|
||||||
@ -384,4 +279,3 @@ public class Pair implements Serializable, DeepCloneable
|
|||||||
return clone();
|
return clone();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// ino.end
|
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
package de.dhbwstuttgart.typeinference;
|
package de.dhbwstuttgart.typeinference;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import de.dhbwstuttgart.typeinference.Menge;
|
import de.dhbwstuttgart.typeinference.Menge;
|
||||||
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
||||||
import de.dhbwstuttgart.syntaxtree.type.Type;
|
import de.dhbwstuttgart.syntaxtree.type.Type;
|
||||||
@ -37,7 +40,7 @@ public class ResultSet implements Iterable<Pair> {
|
|||||||
* @param type
|
* @param type
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public Type getTypeEqualTo(Type type) {
|
public RefType getTypeEqualTo(RefType type) {
|
||||||
return getTypeEqualTo(type,null);
|
return getTypeEqualTo(type,null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,8 +49,8 @@ public class ResultSet implements Iterable<Pair> {
|
|||||||
* @param type
|
* @param type
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public Type getTypeEqualTo(Type type, Menge<TypePlaceholder> ofType) {
|
public RefType getTypeEqualTo(RefType type, List<TypePlaceholder> ofType) {
|
||||||
Type res = type;
|
RefType res = type;
|
||||||
Menge<Pair> modifiedResultPairs = (Menge<Pair>) resultPairs.clone();
|
Menge<Pair> modifiedResultPairs = (Menge<Pair>) resultPairs.clone();
|
||||||
Ret r = findPairWithTypeEqualTo(type, modifiedResultPairs);
|
Ret r = findPairWithTypeEqualTo(type, modifiedResultPairs);
|
||||||
while(r.i != -1 && r.ret != null){
|
while(r.i != -1 && r.ret != null){
|
||||||
@ -64,14 +67,14 @@ public class ResultSet implements Iterable<Pair> {
|
|||||||
|
|
||||||
class Ret{
|
class Ret{
|
||||||
int i;
|
int i;
|
||||||
Type ret;
|
RefType ret;
|
||||||
private Ret(int i, Type ret){
|
private Ret(int i, RefType ret){
|
||||||
this.i = i;
|
this.i = i;
|
||||||
this.ret = ret;
|
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++){
|
for(int i = 0; i<inResultPairs.size();i++){
|
||||||
Pair p = inResultPairs.elementAt(i);
|
Pair p = inResultPairs.elementAt(i);
|
||||||
if((p.OperatorEqual() || p.OperatorSmaller() || p.OperatorSmallerExtends()) && p.TA1.equals(type))
|
if((p.OperatorEqual() || p.OperatorSmaller() || p.OperatorSmallerExtends()) && p.TA1.equals(type))
|
||||||
@ -92,7 +95,7 @@ public class ResultSet implements Iterable<Pair> {
|
|||||||
* @param tA1
|
* @param tA1
|
||||||
* @return true, falls der gesuchte Typ enthalten ist.
|
* @return true, falls der gesuchte Typ enthalten ist.
|
||||||
*/
|
*/
|
||||||
public boolean contains(Type tA1) {
|
public boolean contains(RefType tA1) {
|
||||||
for(Pair p : this){
|
for(Pair p : this){
|
||||||
if(p.TA1.equals(tA1)||p.TA2.equals(tA1))return true;
|
if(p.TA1.equals(tA1)||p.TA2.equals(tA1))return true;
|
||||||
}
|
}
|
||||||
@ -138,8 +141,8 @@ public class ResultSet implements Iterable<Pair> {
|
|||||||
* @param unresolvedTPH
|
* @param unresolvedTPH
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public Menge<Type> getTypesInvolving(Menge<TypePlaceholder> unresolvedTPH) {
|
public List<RefType> getTypesInvolving(Menge<TypePlaceholder> unresolvedTPH) {
|
||||||
Menge<Type> ret = new Menge<Type>();
|
List<RefType> ret = new ArrayList<>();
|
||||||
for(Pair p : this.resultPairs){
|
for(Pair p : this.resultPairs){
|
||||||
for(TypePlaceholder tph : unresolvedTPH){
|
for(TypePlaceholder tph : unresolvedTPH){
|
||||||
if(p.TA1.involves(tph))ret.add(p.TA1);
|
if(p.TA1.involves(tph))ret.add(p.TA1);
|
||||||
|
Loading…
Reference in New Issue
Block a user