forked from JavaTX/JavaCompilerCore
Versuch, MethodGen in Method.java zu implementieren
This commit is contained in:
parent
c6502600cc
commit
253ba6518b
@ -1,5 +1,6 @@
|
|||||||
// ino.module.Method.8564.package
|
// ino.module.Method.8564.package
|
||||||
package de.dhbwstuttgart.syntaxtree;
|
package de.dhbwstuttgart.syntaxtree;
|
||||||
|
|
||||||
// ino.end
|
// ino.end
|
||||||
// ino.module.Method.8564.import
|
// ino.module.Method.8564.import
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
@ -42,13 +43,12 @@ import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
|
|||||||
import de.dhbwstuttgart.typeinference.exceptions.TypeinferenceException;
|
import de.dhbwstuttgart.typeinference.exceptions.TypeinferenceException;
|
||||||
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertPoint;
|
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertPoint;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ino.class.Method.23482.declaration
|
// ino.class.Method.23482.declaration
|
||||||
/**
|
/**
|
||||||
* Stellt eine Methode dar.
|
* Stellt eine Methode dar. Problem: Parser kann nicht zwischen Methode und
|
||||||
* Problem: Parser kann nicht zwischen Methode und Konstruktor unterscheiden. Daher kann diese Klasse beides sein. Dies wird mit dem ParserPostProcessing behoben.
|
* Konstruktor unterscheiden. Daher kann diese Klasse beides sein. Dies wird mit
|
||||||
|
* dem ParserPostProcessing behoben.
|
||||||
|
*
|
||||||
* @author janulrich
|
* @author janulrich
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -71,14 +71,14 @@ public class Method extends Field implements IItemWithOffset, TypeInsertable
|
|||||||
|
|
||||||
// ino.attribute.genericMethodParameters.23500.decldescription type=javadoc
|
// ino.attribute.genericMethodParameters.23500.decldescription type=javadoc
|
||||||
/**
|
/**
|
||||||
* HOTI 4.5.06
|
* HOTI 4.5.06 Dieser Vektor beinhaltet alle Generischen Typen und v.a. die
|
||||||
* Dieser Vektor beinhaltet alle Generischen Typen und v.a. die
|
* F-Bounded-Generics, die die Methode besitzt size()==0, falls es keine
|
||||||
* F-Bounded-Generics, die die Methode besitzt
|
* gibt
|
||||||
* size()==0, falls es keine gibt
|
|
||||||
*/
|
*/
|
||||||
// ino.end
|
// ino.end
|
||||||
// ino.attribute.genericMethodParameters.23500.declaration
|
// ino.attribute.genericMethodParameters.23500.declaration
|
||||||
//private Menge<GenericTypeVar> genericMethodParameters=new Menge<GenericTypeVar>();
|
// private Menge<GenericTypeVar> genericMethodParameters=new
|
||||||
|
// Menge<GenericTypeVar>();
|
||||||
// ino.end
|
// ino.end
|
||||||
|
|
||||||
// ino.attribute.overloadedID.23503.declaration
|
// ino.attribute.overloadedID.23503.declaration
|
||||||
@ -93,24 +93,26 @@ public class Method extends Field implements IItemWithOffset, TypeInsertable
|
|||||||
// ino.attribute.m_LineNumber.23512.declaration
|
// ino.attribute.m_LineNumber.23512.declaration
|
||||||
private int m_LineNumber = MyCompiler.NO_LINENUMBER;
|
private int m_LineNumber = MyCompiler.NO_LINENUMBER;
|
||||||
// ino.end
|
// ino.end
|
||||||
private int m_Offset = -1; //hinzugef�gt hoth: 07.04.2006
|
private int m_Offset = -1; // hinzugef�gt hoth: 07.04.2006
|
||||||
// ino.attribute.inferencelog.23515.declaration
|
// ino.attribute.inferencelog.23515.declaration
|
||||||
protected static Logger inferencelog = Logger.getLogger("inference");
|
protected static Logger inferencelog = Logger.getLogger("inference");
|
||||||
// ino.end
|
// ino.end
|
||||||
// ino.attribute.parserlog.23518.declaration
|
// ino.attribute.parserlog.23518.declaration
|
||||||
protected static Logger parserlog = Logger.getLogger("parser");
|
protected static Logger parserlog = Logger.getLogger("parser");
|
||||||
|
|
||||||
// ino.end
|
// ino.end
|
||||||
|
|
||||||
public Method(int offset){
|
public Method(int offset) {
|
||||||
super(offset);
|
super(offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Method(String name, Type returnType, ParameterList parameterList, Block block, GenericDeclarationList gtvDeclarations, int offset){
|
public Method(String name, Type returnType, ParameterList parameterList,
|
||||||
|
Block block, GenericDeclarationList gtvDeclarations, int offset) {
|
||||||
this(offset);
|
this(offset);
|
||||||
/*
|
/*
|
||||||
if(parameterList != null)parameterList.parserPostProcessing(this);
|
* if(parameterList != null)parameterList.parserPostProcessing(this);
|
||||||
if(block != null)block.parserPostProcessing(this);
|
* if(block != null)block.parserPostProcessing(this); if(gtvDeclarations
|
||||||
if(gtvDeclarations != null)gtvDeclarations.parserPostProcessing(this);
|
* != null)gtvDeclarations.parserPostProcessing(this);
|
||||||
*/
|
*/
|
||||||
this.set_Method_Name(name);
|
this.set_Method_Name(name);
|
||||||
this.setParameterList(parameterList);
|
this.setParameterList(parameterList);
|
||||||
@ -120,65 +122,40 @@ public class Method extends Field implements IItemWithOffset, TypeInsertable
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
// ino.method.setGenericMethodParameters.23521.definition
|
* // ino.method.setGenericMethodParameters.23521.definition public void
|
||||||
public void setGenericMethodParameters(Menge<GenericTypeVar> genericMethodParameters)
|
* setGenericMethodParameters(Menge<GenericTypeVar> genericMethodParameters)
|
||||||
// ino.end
|
* // ino.end // ino.method.setGenericMethodParameters.23521.body {
|
||||||
// ino.method.setGenericMethodParameters.23521.body
|
* this.genericMethodParameters=genericMethodParameters; } // ino.end //
|
||||||
{
|
* ino.method.getGenericMethodParameters.23524.definition public
|
||||||
this.genericMethodParameters=genericMethodParameters;
|
* Menge<GenericTypeVar> getGenericMethodParameters() // ino.end //
|
||||||
}
|
* ino.method.getGenericMethodParameters.23524.body {
|
||||||
// ino.end
|
* return(genericMethodParameters); } // ino.end
|
||||||
// ino.method.getGenericMethodParameters.23524.definition
|
|
||||||
public Menge<GenericTypeVar> getGenericMethodParameters()
|
|
||||||
// ino.end
|
|
||||||
// ino.method.getGenericMethodParameters.23524.body
|
|
||||||
{
|
|
||||||
return(genericMethodParameters);
|
|
||||||
}
|
|
||||||
// ino.end
|
|
||||||
*/
|
*/
|
||||||
/*
|
/*
|
||||||
// ino.method.sc_init_parameterlist.23530.definition
|
* // ino.method.sc_init_parameterlist.23530.definition public void
|
||||||
public void sc_init_parameterlist(boolean ext)
|
* sc_init_parameterlist(boolean ext) // ino.end //
|
||||||
// ino.end
|
* ino.method.sc_init_parameterlist.23530.body { DeclId hilf=null;
|
||||||
// ino.method.sc_init_parameterlist.23530.body
|
* Menge<FormalParameter> list; FormalParameter para; String typeofpara; int
|
||||||
{
|
* i=1; if(this.getParameterList()!=null) //es gibt Parameter, dann: {
|
||||||
DeclId hilf=null;
|
* hilf=declid.elementAt(0); if(ext)
|
||||||
Menge<FormalParameter> list;
|
* parserlog.debug("Semantik-Check hat in Methode "
|
||||||
FormalParameter para;
|
* +hilf.get_Name()+" bergabewerte gefunden:");
|
||||||
String typeofpara;
|
* list=this.getParameterList().sc_get_Formalparalist(); //Menge
|
||||||
int i=1;
|
* Formalparalist aus FormalParameterList wird zwischen gesichert
|
||||||
if(this.getParameterList()!=null) //es gibt Parameter, dann:
|
* for(Enumeration<FormalParameter> el2=list.elements();
|
||||||
{
|
* el2.hasMoreElements();) { para=el2.nextElement();
|
||||||
hilf=declid.elementAt(0);
|
* typeofpara=para.getTypeName(); if(ext)
|
||||||
if(ext)
|
* parserlog.debug(" "+i+". Parameter hat Typ "+typeofpara);
|
||||||
parserlog.debug("Semantik-Check hat in Methode "+hilf.get_Name()+" bergabewerte gefunden:");
|
* types_in_parameterlist.addElement(typeofpara); //Typ der Parameter werden
|
||||||
list=this.getParameterList().sc_get_Formalparalist(); //Menge Formalparalist aus FormalParameterList wird zwischen gesichert
|
* im Menge abgelegt i++; } } else //keine Parameter vorhanden: { if(ext) {
|
||||||
for(Enumeration<FormalParameter> el2=list.elements(); el2.hasMoreElements();)
|
* hilf=declid.elementAt(0);
|
||||||
{
|
* parserlog.debug("Semantik-Check hat in Methode "
|
||||||
para=el2.nextElement();
|
* +hilf.get_Name()+" keine bergabewerte gefunden."); } } if(ext) {
|
||||||
typeofpara=para.getTypeName();
|
* parserlog.debug("Semantik-Check hat in Methode "+hilf.get_Name()+" "+
|
||||||
if(ext)
|
* types_in_parameterlist.size()+" bergabeparameter gefunden.");
|
||||||
parserlog.debug(" "+i+". Parameter hat Typ "+typeofpara);
|
* parserlog.debug
|
||||||
types_in_parameterlist.addElement(typeofpara); //Typ der Parameter werden im Menge abgelegt
|
* (" namentlich: "+types_in_parameterlist.toString()); } } //
|
||||||
i++;
|
* ino.end
|
||||||
}
|
|
||||||
}
|
|
||||||
else //keine Parameter vorhanden:
|
|
||||||
{
|
|
||||||
if(ext)
|
|
||||||
{
|
|
||||||
hilf=declid.elementAt(0);
|
|
||||||
parserlog.debug("Semantik-Check hat in Methode "+hilf.get_Name()+" keine bergabewerte gefunden.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(ext)
|
|
||||||
{
|
|
||||||
parserlog.debug("Semantik-Check hat in Methode "+hilf.get_Name()+" "+ types_in_parameterlist.size()+" bergabeparameter gefunden.");
|
|
||||||
parserlog.debug(" namentlich: "+types_in_parameterlist.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// ino.end
|
|
||||||
*/
|
*/
|
||||||
// ino.method.getTypeName.23533.defdescription type=line
|
// ino.method.getTypeName.23533.defdescription type=line
|
||||||
// Eine der beiden Funktionen ist ueberflssig. Wer sich daran strt kann die
|
// Eine der beiden Funktionen ist ueberflssig. Wer sich daran strt kann die
|
||||||
@ -190,11 +167,12 @@ public class Method extends Field implements IItemWithOffset, TypeInsertable
|
|||||||
// ino.end
|
// ino.end
|
||||||
// ino.method.getTypeName.23533.body
|
// ino.method.getTypeName.23533.body
|
||||||
{
|
{
|
||||||
if( this.getType() == null )
|
if (this.getType() == null)
|
||||||
return null;
|
return null;
|
||||||
else
|
else
|
||||||
return this.getType().getName();
|
return this.getType().getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ino.end
|
// ino.end
|
||||||
|
|
||||||
// ino.method.get_Block.23536.definition
|
// ino.method.get_Block.23536.definition
|
||||||
@ -204,11 +182,14 @@ public class Method extends Field implements IItemWithOffset, TypeInsertable
|
|||||||
{
|
{
|
||||||
return block;
|
return block;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ino.end
|
// ino.end
|
||||||
|
|
||||||
// ino.method.setReturnType.23539.defdescription type=javadoc
|
// ino.method.setReturnType.23539.defdescription type=javadoc
|
||||||
/**
|
/**
|
||||||
* <br/>Author: Jrg Buerle
|
* <br/>
|
||||||
|
* Author: Jrg Buerle
|
||||||
|
*
|
||||||
* @param type
|
* @param type
|
||||||
*/
|
*/
|
||||||
// ino.end
|
// ino.end
|
||||||
@ -219,16 +200,19 @@ public class Method extends Field implements IItemWithOffset, TypeInsertable
|
|||||||
{
|
{
|
||||||
this.returntype = type;
|
this.returntype = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ino.end
|
// ino.end
|
||||||
|
|
||||||
// ino.method.set_Block.23542.definition
|
// ino.method.set_Block.23542.definition
|
||||||
public void set_Block( Block blo)
|
public void set_Block(Block blo)
|
||||||
// ino.end
|
// ino.end
|
||||||
// ino.method.set_Block.23542.body
|
// ino.method.set_Block.23542.body
|
||||||
{
|
{
|
||||||
if(blo.getType() == null)blo.setType(this.returntype);
|
if (blo.getType() == null)
|
||||||
|
blo.setType(this.returntype);
|
||||||
this.block = blo;
|
this.block = blo;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ino.end
|
// ino.end
|
||||||
|
|
||||||
// ino.method.set_Modifiers.23545.definition
|
// ino.method.set_Modifiers.23545.definition
|
||||||
@ -239,6 +223,7 @@ public class Method extends Field implements IItemWithOffset, TypeInsertable
|
|||||||
declid.firstElement().set_Modifiers(modif);
|
declid.firstElement().set_Modifiers(modif);
|
||||||
// this.modi = modif;
|
// this.modi = modif;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ino.end
|
// ino.end
|
||||||
|
|
||||||
// ino.method.set_ExceptionList.23548.definition
|
// ino.method.set_ExceptionList.23548.definition
|
||||||
@ -248,30 +233,34 @@ public class Method extends Field implements IItemWithOffset, TypeInsertable
|
|||||||
{
|
{
|
||||||
this.exceptionlist = exlist;
|
this.exceptionlist = exlist;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ino.end
|
// ino.end
|
||||||
|
|
||||||
// ino.method.setParameterList.23551.definition
|
// ino.method.setParameterList.23551.definition
|
||||||
public void setParameterList( ParameterList paralist )
|
public void setParameterList(ParameterList paralist)
|
||||||
// ino.end
|
// ino.end
|
||||||
// ino.method.setParameterList.23551.body
|
// ino.method.setParameterList.23551.body
|
||||||
{
|
{
|
||||||
this.parameterlist = paralist;
|
this.parameterlist = paralist;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ino.end
|
// ino.end
|
||||||
|
|
||||||
// ino.method.getParameterList.23554.definition
|
// ino.method.getParameterList.23554.definition
|
||||||
public ParameterList getParameterList( )
|
public ParameterList getParameterList()
|
||||||
// ino.end
|
// ino.end
|
||||||
// ino.method.getParameterList.23554.body
|
// ino.method.getParameterList.23554.body
|
||||||
{
|
{
|
||||||
// otth: gibt die Parameterliste zurueck
|
// otth: gibt die Parameterliste zurueck
|
||||||
return this.parameterlist;
|
return this.parameterlist;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ino.end
|
// ino.end
|
||||||
|
|
||||||
// ino.method.getParameterCount.23557.defdescription type=javadoc
|
// ino.method.getParameterCount.23557.defdescription type=javadoc
|
||||||
/**
|
/**
|
||||||
* Author: Jrg Buerle<br/>
|
* Author: Jrg Buerle<br/>
|
||||||
|
*
|
||||||
* @return Die Anzahl der Methoden-Paramater
|
* @return Die Anzahl der Methoden-Paramater
|
||||||
*/
|
*/
|
||||||
// ino.end
|
// ino.end
|
||||||
@ -280,11 +269,12 @@ public class Method extends Field implements IItemWithOffset, TypeInsertable
|
|||||||
// ino.end
|
// ino.end
|
||||||
// ino.method.getParameterCount.23557.body
|
// ino.method.getParameterCount.23557.body
|
||||||
{
|
{
|
||||||
if(this.getParameterList() == null)
|
if (this.getParameterList() == null)
|
||||||
return 0;
|
return 0;
|
||||||
else
|
else
|
||||||
return this.getParameterList().getParameterCount();
|
return this.getParameterList().getParameterCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ino.end
|
// ino.end
|
||||||
|
|
||||||
// ino.method.get_ExceptionList.23560.definition
|
// ino.method.get_ExceptionList.23560.definition
|
||||||
@ -295,6 +285,7 @@ public class Method extends Field implements IItemWithOffset, TypeInsertable
|
|||||||
// otth: gibt die Exceptionliste zurueck
|
// otth: gibt die Exceptionliste zurueck
|
||||||
return this.exceptionlist;
|
return this.exceptionlist;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ino.end
|
// ino.end
|
||||||
|
|
||||||
// ino.method.getOverloadedID.23563.definition
|
// ino.method.getOverloadedID.23563.definition
|
||||||
@ -302,8 +293,9 @@ public class Method extends Field implements IItemWithOffset, TypeInsertable
|
|||||||
// ino.end
|
// ino.end
|
||||||
// ino.method.getOverloadedID.23563.body
|
// ino.method.getOverloadedID.23563.body
|
||||||
{
|
{
|
||||||
return(overloadedID);
|
return (overloadedID);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ino.end
|
// ino.end
|
||||||
|
|
||||||
// ino.method.setOverloadedID.23566.definition
|
// ino.method.setOverloadedID.23566.definition
|
||||||
@ -311,22 +303,20 @@ public class Method extends Field implements IItemWithOffset, TypeInsertable
|
|||||||
// ino.end
|
// ino.end
|
||||||
// ino.method.setOverloadedID.23566.body
|
// ino.method.setOverloadedID.23566.body
|
||||||
{
|
{
|
||||||
this.overloadedID=overloadedID;
|
this.overloadedID = overloadedID;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ino.end
|
// ino.end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ino.method.get_Method_Name.23575.definition
|
// ino.method.get_Method_Name.23575.definition
|
||||||
public String get_Method_Name()
|
public String get_Method_Name()
|
||||||
// ino.end
|
// ino.end
|
||||||
// ino.method.get_Method_Name.23575.body
|
// ino.method.get_Method_Name.23575.body
|
||||||
{
|
{
|
||||||
DeclId hilf=declid.elementAt(0);
|
DeclId hilf = declid.elementAt(0);
|
||||||
return hilf.get_Name();
|
return hilf.get_Name();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ino.end
|
// ino.end
|
||||||
|
|
||||||
// ino.method.get_Type_Paralist.23578.definition
|
// ino.method.get_Type_Paralist.23578.definition
|
||||||
@ -336,10 +326,9 @@ public class Method extends Field implements IItemWithOffset, TypeInsertable
|
|||||||
{
|
{
|
||||||
return types_in_parameterlist;
|
return types_in_parameterlist;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ino.end
|
// ino.end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ino.method.getLineNumber.23584.definition
|
// ino.method.getLineNumber.23584.definition
|
||||||
public int getLineNumber()
|
public int getLineNumber()
|
||||||
// ino.end
|
// ino.end
|
||||||
@ -347,6 +336,7 @@ public class Method extends Field implements IItemWithOffset, TypeInsertable
|
|||||||
{
|
{
|
||||||
return m_LineNumber;
|
return m_LineNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ino.end
|
// ino.end
|
||||||
|
|
||||||
// ino.method.setLineNumber.23587.definition
|
// ino.method.setLineNumber.23587.definition
|
||||||
@ -356,6 +346,7 @@ public class Method extends Field implements IItemWithOffset, TypeInsertable
|
|||||||
{
|
{
|
||||||
m_LineNumber = lineNumber;
|
m_LineNumber = lineNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ino.end
|
// ino.end
|
||||||
|
|
||||||
// ino.method.getOffset.23590.defdescription type=line
|
// ino.method.getOffset.23590.defdescription type=line
|
||||||
@ -368,6 +359,7 @@ public class Method extends Field implements IItemWithOffset, TypeInsertable
|
|||||||
{
|
{
|
||||||
return m_Offset;
|
return m_Offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ino.end
|
// ino.end
|
||||||
|
|
||||||
// ino.method.getVariableLength.23593.definition
|
// ino.method.getVariableLength.23593.definition
|
||||||
@ -377,6 +369,7 @@ public class Method extends Field implements IItemWithOffset, TypeInsertable
|
|||||||
{
|
{
|
||||||
return get_Method_Name().length();
|
return get_Method_Name().length();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ino.end
|
// ino.end
|
||||||
|
|
||||||
// ino.method.setOffset.23596.defdescription type=line
|
// ino.method.setOffset.23596.defdescription type=line
|
||||||
@ -389,12 +382,14 @@ public class Method extends Field implements IItemWithOffset, TypeInsertable
|
|||||||
{
|
{
|
||||||
m_Offset = Offset;
|
m_Offset = Offset;
|
||||||
}
|
}
|
||||||
// ino.end
|
|
||||||
|
|
||||||
|
// ino.end
|
||||||
|
|
||||||
// ino.method.getTypeLineNumber.23602.defdescription type=javadoc
|
// ino.method.getTypeLineNumber.23602.defdescription type=javadoc
|
||||||
/**
|
/**
|
||||||
* <br>Author: Jrg Buerle
|
* <br>
|
||||||
|
* Author: Jrg Buerle
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
// ino.end
|
// ino.end
|
||||||
@ -405,11 +400,14 @@ public class Method extends Field implements IItemWithOffset, TypeInsertable
|
|||||||
{
|
{
|
||||||
return this.getLineNumber();
|
return this.getLineNumber();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ino.end
|
// ino.end
|
||||||
|
|
||||||
// ino.method.toString.23605.defdescription type=javadoc
|
// ino.method.toString.23605.defdescription type=javadoc
|
||||||
/**
|
/**
|
||||||
* <br/>Author: Martin Pl�micke
|
* <br/>
|
||||||
|
* Author: Martin Pl�micke
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
// ino.end
|
// ino.end
|
||||||
@ -418,14 +416,16 @@ public class Method extends Field implements IItemWithOffset, TypeInsertable
|
|||||||
// ino.end
|
// ino.end
|
||||||
// ino.method.toString.23605.body
|
// ino.method.toString.23605.body
|
||||||
{
|
{
|
||||||
return this.getType() + " "+ this.get_Name() +( (block!=null)?block.toString():"");
|
return this.getType() + " " + this.get_Name()
|
||||||
|
+ ((block != null) ? block.toString() : "");
|
||||||
}
|
}
|
||||||
|
|
||||||
// ino.end
|
// ino.end
|
||||||
|
|
||||||
// ino.method.setAbstract.23608.defdescription type=javadoc
|
// ino.method.setAbstract.23608.defdescription type=javadoc
|
||||||
/**
|
/**
|
||||||
* Legt fuer die ByteCodeGen fest, ob Bytecode
|
* Legt fuer die ByteCodeGen fest, ob Bytecode innerhalb der Methode
|
||||||
* innerhalb der Methode generiert wird.
|
* generiert wird.
|
||||||
*/
|
*/
|
||||||
// ino.end
|
// ino.end
|
||||||
// ino.method.setAbstract.23608.definition
|
// ino.method.setAbstract.23608.definition
|
||||||
@ -435,12 +435,12 @@ public class Method extends Field implements IItemWithOffset, TypeInsertable
|
|||||||
{
|
{
|
||||||
isAbstract = b;
|
isAbstract = b;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ino.end
|
// ino.end
|
||||||
|
|
||||||
// ino.method.isAbstract.23611.defdescription type=javadoc
|
// ino.method.isAbstract.23611.defdescription type=javadoc
|
||||||
/**
|
/**
|
||||||
* Gibt zurueck, ob ByteCode innerhabl der Methode
|
* Gibt zurueck, ob ByteCode innerhabl der Methode generiert wird.
|
||||||
* generiert wird.
|
|
||||||
*/
|
*/
|
||||||
// ino.end
|
// ino.end
|
||||||
// ino.method.isAbstract.23611.definition
|
// ino.method.isAbstract.23611.definition
|
||||||
@ -452,93 +452,92 @@ public class Method extends Field implements IItemWithOffset, TypeInsertable
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void wandleRefTypeAttributes2GenericAttributes(Menge<Type> classParalist)
|
public void wandleRefTypeAttributes2GenericAttributes(
|
||||||
{
|
Menge<Type> classParalist) {
|
||||||
/*
|
/*
|
||||||
Menge<Type> paralist = new Menge<Type>();//Mit den Generischen Typen der Methode
|
* Menge<Type> paralist = new Menge<Type>();//Mit den Generischen Typen
|
||||||
paralist.addAll(classParalist);
|
* der Methode paralist.addAll(classParalist);
|
||||||
paralist.addAll(this.genericMethodParameters);
|
* paralist.addAll(this.genericMethodParameters);
|
||||||
|
*
|
||||||
// Zuerst Returntype untersuchen
|
* // Zuerst Returntype untersuchen Type returnType=getType(); Type
|
||||||
Type returnType=getType();
|
* pendantReturnType = null; if(returnType instanceof
|
||||||
Type pendantReturnType = null;
|
* RefType)pendantReturnType =
|
||||||
if(returnType instanceof RefType)pendantReturnType = ((RefType)returnType).findGenericType(paralist, new Menge<GenericTypeVar>());
|
* ((RefType)returnType).findGenericType(paralist, new
|
||||||
//GenericTypeVar pendantReturnType=ClassHelper.findGenericType(returnType, paralist,genericMethodParameters);
|
* Menge<GenericTypeVar>()); //GenericTypeVar
|
||||||
if(pendantReturnType!=null){ //Wenn generisch, dann modifizieren
|
* pendantReturnType=ClassHelper.findGenericType(returnType,
|
||||||
setReturnType(pendantReturnType);
|
* paralist,genericMethodParameters); if(pendantReturnType!=null){
|
||||||
}
|
* //Wenn generisch, dann modifizieren setReturnType(pendantReturnType);
|
||||||
|
* }
|
||||||
// Dann parameterlist untersuchen
|
*
|
||||||
for(int par=0;par<getParameterCount();par++){
|
* // Dann parameterlist untersuchen for(int
|
||||||
FormalParameter fp=parameterlist.formalparameter.get(par);
|
* par=0;par<getParameterCount();par++){ FormalParameter
|
||||||
Type fpType=fp.getType();
|
* fp=parameterlist.formalparameter.get(par); Type fpType=fp.getType();
|
||||||
// Nur wenn es sich um ein RefType-Field handelt
|
* // Nur wenn es sich um ein RefType-Field handelt Type pendantPara =
|
||||||
Type pendantPara = null;
|
* null; if(fpType instanceof RefType)pendantPara =
|
||||||
if(fpType instanceof RefType)pendantPara = ((RefType)fpType).findGenericType(paralist, new Menge<GenericTypeVar>());
|
* ((RefType)fpType).findGenericType(paralist, new
|
||||||
//GenericTypeVar pendantPara=ClassHelper.findGenericType(fpType,paralist,genericMethodParameters);
|
* Menge<GenericTypeVar>()); //GenericTypeVar
|
||||||
if(pendantPara!=null){ //Wenn generisch, dann modifizieren
|
* pendantPara=ClassHelper.findGenericType
|
||||||
fp.setType(pendantPara);
|
* (fpType,paralist,genericMethodParameters); if(pendantPara!=null){
|
||||||
}
|
* //Wenn generisch, dann modifizieren fp.setType(pendantPara); } }
|
||||||
}
|
*
|
||||||
|
* // Zuletzt alle Lokalen Variablendeklarationen durchgehen
|
||||||
// Zuletzt alle Lokalen Variablendeklarationen durchgehen
|
* if(block!=null){
|
||||||
if(block!=null){
|
* block.wandleRefTypeAttributes2GenericAttributes(paralist
|
||||||
block.wandleRefTypeAttributes2GenericAttributes(paralist,genericMethodParameters);
|
* ,genericMethodParameters); }
|
||||||
}
|
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
public void set_Method_Name(String string)
|
public void set_Method_Name(String string) {
|
||||||
{
|
if (declid.size() == 0)
|
||||||
if(declid.size()==0)declid.add(0, new DeclId(string));
|
declid.add(0, new DeclId(string));
|
||||||
declid.set(0,new DeclId(string));
|
declid.set(0, new DeclId(string));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public ConstraintsSet TYPE(TypeAssumptions ass) {
|
public ConstraintsSet TYPE(TypeAssumptions ass) {
|
||||||
ConstraintsSet ret = new ConstraintsSet();
|
ConstraintsSet ret = new ConstraintsSet();
|
||||||
TypeAssumptions localAss = new TypeAssumptions();
|
TypeAssumptions localAss = new TypeAssumptions();
|
||||||
localAss.add(ass); //Die globalen Assumptions anhängen
|
localAss.add(ass); // Die globalen Assumptions anhängen
|
||||||
//Generische Parameterdeklarationen den Assumptions anfügen:
|
// Generische Parameterdeklarationen den Assumptions anfügen:
|
||||||
for(GenericTypeVar gtv : this.getGenericParameter()){
|
for (GenericTypeVar gtv : this.getGenericParameter()) {
|
||||||
localAss.add(gtv.createAssumptions());
|
localAss.add(gtv.createAssumptions());
|
||||||
}
|
}
|
||||||
for(GenericTypeVar gtv : this.getGenericParameter()){
|
for (GenericTypeVar gtv : this.getGenericParameter()) {
|
||||||
ret.add(gtv.TYPE(localAss));
|
ret.add(gtv.TYPE(localAss));
|
||||||
}
|
}
|
||||||
|
|
||||||
//TypeCheck, falls es sich um einen RefType handelt:
|
// TypeCheck, falls es sich um einen RefType handelt:
|
||||||
this.returntype = this.returntype.checkTYPE(localAss, this);
|
this.returntype = this.returntype.checkTYPE(localAss, this);
|
||||||
/*
|
/*
|
||||||
if(this.returntype!=null && (this.returntype instanceof RefType)&&
|
* if(this.returntype!=null && (this.returntype instanceof RefType)&&
|
||||||
!(this.returntype instanceof mycompiler.mytype.Void)){//Sonderfall der Methode: Ihr Typ darf Void definiert werden.
|
* !(this.returntype instanceof mycompiler.mytype.Void)){//Sonderfall
|
||||||
Type replaceType = null;
|
* der Methode: Ihr Typ darf Void definiert werden. Type replaceType =
|
||||||
replaceType = ass.getTypeFor((RefType)this.returntype);
|
* null; replaceType = ass.getTypeFor((RefType)this.returntype);
|
||||||
if(replaceType == null)throw new TypeinferenceException("Der Typ "+this.getType().getName()+" ist nicht korrekt",this);
|
* if(replaceType == null)throw new
|
||||||
this.returntype = replaceType;
|
* TypeinferenceException("Der Typ "+this
|
||||||
}
|
* .getType().getName()+" ist nicht korrekt",this); this.returntype =
|
||||||
|
* replaceType; }
|
||||||
*/
|
*/
|
||||||
//Die Parameter zu den Assumptions hinzufügen:
|
// Die Parameter zu den Assumptions hinzufügen:
|
||||||
if(this.parameterlist!=null)for(FormalParameter param : this.parameterlist){
|
if (this.parameterlist != null)
|
||||||
|
for (FormalParameter param : this.parameterlist) {
|
||||||
|
|
||||||
param.setType(param.getType().checkTYPE(localAss, this));
|
param.setType(param.getType().checkTYPE(localAss, this));
|
||||||
/*
|
/*
|
||||||
if(param.getType() instanceof RefType)
|
* if(param.getType() instanceof RefType) { Type replaceType =
|
||||||
{
|
* null; replaceType = ass.getTypeFor((RefType)param.getType());
|
||||||
Type replaceType = null;
|
* if(replaceType == null) throw new
|
||||||
replaceType = ass.getTypeFor((RefType)param.getType());
|
* TypeinferenceException("Der Typ "
|
||||||
if(replaceType == null)
|
* +param.getType().getName()+" ist nicht korrekt",param);
|
||||||
throw new TypeinferenceException("Der Typ "+param.getType().getName()+" ist nicht korrekt",param);
|
* param.setType(replaceType); }
|
||||||
param.setType(replaceType);
|
|
||||||
}
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
localAss.addAssumption(new ParameterAssumption(param));
|
localAss.addAssumption(new ParameterAssumption(param));
|
||||||
}
|
}
|
||||||
ret.add(this.block.TYPEStmt(localAss));
|
ret.add(this.block.TYPEStmt(localAss));
|
||||||
//eine Verknüpfung mit der Type Assumption aus dem Assumption Set und dem ermittelten Typ der Methode:
|
// eine Verknüpfung mit der Type Assumption aus dem Assumption Set
|
||||||
ret.add(new SingleConstraint(this.block.getType().TYPE(localAss, this), this.returntype.TYPE(localAss, this)));
|
// und dem ermittelten Typ der Methode:
|
||||||
|
ret.add(new SingleConstraint(this.block.getType().TYPE(localAss, this),
|
||||||
|
this.returntype.TYPE(localAss, this)));
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -546,15 +545,22 @@ public class Method extends Field implements IItemWithOffset, TypeInsertable
|
|||||||
* @author Andreas Stadelmeier, a10023
|
* @author Andreas Stadelmeier, a10023
|
||||||
* @return die TypInformationen der Statements dieser Methode.
|
* @return die TypInformationen der Statements dieser Methode.
|
||||||
*/
|
*/
|
||||||
public String getTypeInformation(){
|
public String getTypeInformation() {
|
||||||
if(this.parameterlist!=null)return "Methode "+this.get_Name()+ " Parameter: "+this.parameterlist.getTypeInformation()+", Block: "+this.block.getTypeInformation();
|
if (this.parameterlist != null)
|
||||||
return "Methode "+this.get_Name()+" : "+this.getType()+", Block: "+this.block.getTypeInformation();
|
return "Methode " + this.get_Name() + " Parameter: "
|
||||||
|
+ this.parameterlist.getTypeInformation() + ", Block: "
|
||||||
|
+ this.block.getTypeInformation();
|
||||||
|
return "Methode " + this.get_Name() + " : " + this.getType()
|
||||||
|
+ ", Block: " + this.block.getTypeInformation();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JavaCodeResult printJavaCode(ResultSet resultSet) {
|
public JavaCodeResult printJavaCode(ResultSet resultSet) {
|
||||||
JavaCodeResult ret = new JavaCodeResult();
|
JavaCodeResult ret = new JavaCodeResult();
|
||||||
ret.attach(this.getType().printJavaCode(resultSet)).attach(" ").attach(this.get_Method_Name()).attach("(").attach(this.getParameterList().printJavaCode(resultSet)).attach(")\n");
|
ret.attach(this.getType().printJavaCode(resultSet)).attach(" ")
|
||||||
|
.attach(this.get_Method_Name()).attach("(")
|
||||||
|
.attach(this.getParameterList().printJavaCode(resultSet))
|
||||||
|
.attach(")\n");
|
||||||
ret.attach(this.block.printJavaCode(resultSet));
|
ret.attach(this.block.printJavaCode(resultSet));
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@ -565,107 +571,110 @@ public class Method extends Field implements IItemWithOffset, TypeInsertable
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public TypeAssumptions createTypeAssumptions(Class classmember) {
|
public TypeAssumptions createTypeAssumptions(Class classmember) {
|
||||||
Class parentClass = classmember;//this.getParentClass();
|
Class parentClass = classmember;// this.getParentClass();
|
||||||
TypeAssumptions ret = new TypeAssumptions();
|
TypeAssumptions ret = new TypeAssumptions();
|
||||||
ret.addAssumption(new MethodAssumption(this, parentClass));
|
ret.addAssumption(new MethodAssumption(this, parentClass));
|
||||||
return ret;
|
return ret;
|
||||||
/*
|
/*
|
||||||
TypeAssumptions assumptions = new TypeAssumptions();
|
* TypeAssumptions assumptions = new TypeAssumptions(); this.assumedType
|
||||||
this.assumedType = null;
|
* = null; //if((this.get_Method_Name().equals(classmember.getName()) ||
|
||||||
//if((this.get_Method_Name().equals(classmember.getName()) || this.get_Method_Name().equals("<init>")) && ((this.getType().equals(new mycompiler.mytype.Void(0))) || this.getType() instanceof TypePlaceholder)){
|
* this.get_Method_Name().equals("<init>")) &&
|
||||||
if((this.get_Method_Name().equals(classmember.getName()) || this.get_Method_Name().equals("<init>"))) {
|
* ((this.getType().equals(new mycompiler.mytype.Void(0))) ||
|
||||||
this.set_Method_Name("<init>");
|
* this.getType() instanceof TypePlaceholder)){
|
||||||
this.assumedType = new RefType(classmember.getName(),0);
|
* if((this.get_Method_Name().equals(classmember.getName()) ||
|
||||||
this.setReturnType(this.assumedType);
|
* this.get_Method_Name().equals("<init>"))) {
|
||||||
this.assumedType = new RefType("void",0);
|
* this.set_Method_Name("<init>"); this.assumedType = new
|
||||||
//Return constructorReturnStatement = new Return(0,0);
|
* RefType(classmember.getName(),0);
|
||||||
//constructorReturnStatement.retexpr =
|
* this.setReturnType(this.assumedType); this.assumedType = new
|
||||||
//this.block.statements.add(constructorReturnStatement);
|
* RefType("void",0); //Return constructorReturnStatement = new
|
||||||
}
|
* Return(0,0); //constructorReturnStatement.retexpr =
|
||||||
//hoth: 06.04.2006
|
* //this.block.statements.add(constructorReturnStatement); } //hoth:
|
||||||
//durchlaufe Block und suche nach Objektvariablen fuer Offset-Markierung
|
* 06.04.2006 //durchlaufe Block und suche nach Objektvariablen fuer
|
||||||
Iterator<CTypeAssumption> fieldVarIterator = assumptions.iterator();
|
* Offset-Markierung Iterator<CTypeAssumption> fieldVarIterator =
|
||||||
while (fieldVarIterator.hasNext())
|
* assumptions.iterator(); while (fieldVarIterator.hasNext()) { //Wenn
|
||||||
{
|
* ObjektVariable CTypeAssumption dieAssum = fieldVarIterator.next();
|
||||||
//Wenn ObjektVariable
|
* if(dieAssum instanceof CInstVarTypeAssumption) {
|
||||||
CTypeAssumption dieAssum = fieldVarIterator.next();
|
* Class.isFirstLocalVarDecl=false; if(this.get_Block() != null)
|
||||||
if(dieAssum instanceof CInstVarTypeAssumption)
|
* this.get_Block
|
||||||
{
|
* ().addOffsetsToAssumption(dieAssum,dieAssum.getIdentifier(),true); }
|
||||||
Class.isFirstLocalVarDecl=false;
|
* }
|
||||||
if(this.get_Block() != null)
|
*
|
||||||
this.get_Block().addOffsetsToAssumption(dieAssum,dieAssum.getIdentifier(),true);
|
* //methodList.addElement(method);
|
||||||
}
|
*
|
||||||
}
|
* //F�r V_fields_methods: CMethodTypeAssumption methodAssum
|
||||||
|
* = new CMethodTypeAssumption(classmember.getType(),
|
||||||
//methodList.addElement(method);
|
* this.get_Method_Name(), this.getType(),
|
||||||
|
* this.getParameterCount(),this.getLineNumber(),this.getOffset(),new
|
||||||
//F�r V_fields_methods:
|
* Menge<Integer>(),this.getGenericMethodParameters()); // Typannahme
|
||||||
CMethodTypeAssumption methodAssum = new CMethodTypeAssumption(classmember.getType(), this.get_Method_Name(), this.getType(), this.getParameterCount(),this.getLineNumber(),this.getOffset(),new Menge<Integer>(),this.getGenericMethodParameters()); // Typannahme bauen...
|
* bauen...
|
||||||
|
*
|
||||||
|
*
|
||||||
//Methode in V_Fields_methods ablegen
|
* //Methode in V_Fields_methods ablegen //Dabei wird die
|
||||||
//Dabei wird die OverloadedMethodID ermittelt !!
|
* OverloadedMethodID ermittelt !! //=> Method setzenuct
|
||||||
//=> Method setzenuct
|
*
|
||||||
|
*
|
||||||
|
* assumptions.add(methodAssum);
|
||||||
assumptions.add(methodAssum);
|
* this.setOverloadedID(methodAssum.getHashSetKey
|
||||||
this.setOverloadedID(methodAssum.getHashSetKey().getOverloadedMethodID());
|
* ().getOverloadedMethodID());
|
||||||
|
*
|
||||||
|
*
|
||||||
//F�r die V_i:
|
* //F�r die V_i: CTypeAssumptionSet localAssum = new
|
||||||
CTypeAssumptionSet localAssum = new CTypeAssumptionSet();
|
* CTypeAssumptionSet();
|
||||||
|
*
|
||||||
//Bauen...
|
* //Bauen... ParameterList parameterList = this.getParameterList();
|
||||||
ParameterList parameterList = this.getParameterList();
|
* if(parameterList!=null){ for(int i=0;
|
||||||
if(parameterList!=null){
|
* i<parameterList.sc_get_Formalparalist().size(); i++){ FormalParameter
|
||||||
for(int i=0; i<parameterList.sc_get_Formalparalist().size(); i++){
|
* para = parameterList.sc_get_Formalparalist().elementAt(i); //
|
||||||
FormalParameter para = parameterList.sc_get_Formalparalist().elementAt(i);
|
* F�r V_fields_methods: CParaTypeAssumption paraAssum = new
|
||||||
// F�r V_fields_methods:
|
* CParaTypeAssumption(classmember.getName(), this.get_Method_Name(),
|
||||||
CParaTypeAssumption paraAssum = new CParaTypeAssumption(classmember.getName(), this.get_Method_Name(), this.getParameterCount(), this.getOverloadedID(),para.get_Name(), para.getType(), para.getLineNumber(),para.getOffset(),new Menge<Integer>());
|
* this.getParameterCount(), this.getOverloadedID(),para.get_Name(),
|
||||||
//fuege Offsets fuer Parameter hinzu, hoth: 06.04.2006
|
* para.getType(), para.getLineNumber(),para.getOffset(),new
|
||||||
Class.isFirstLocalVarDecl=false;
|
* Menge<Integer>()); //fuege Offsets fuer Parameter hinzu, hoth:
|
||||||
|
* 06.04.2006 Class.isFirstLocalVarDecl=false;
|
||||||
if(this.get_Block() != null)
|
*
|
||||||
this.get_Block().addOffsetsToAssumption(paraAssum,paraAssum.getIdentifier(),true);
|
* if(this.get_Block() != null)
|
||||||
|
* this.get_Block().addOffsetsToAssumption(paraAssum
|
||||||
methodAssum.addParaAssumption(paraAssum);
|
* ,paraAssum.getIdentifier(),true);
|
||||||
|
*
|
||||||
// F�r die V_i:
|
* methodAssum.addParaAssumption(paraAssum);
|
||||||
CLocalVarTypeAssumption varAssum = new CLocalVarTypeAssumption(classmember.getName(), this.get_Method_Name(), this.getParameterCount(), this.getOverloadedID(),"1", para.get_Name(),para.getType(), para.getLineNumber(),para.getOffset(),new Menge<Integer>());
|
*
|
||||||
localAssum.addElement(varAssum);
|
* // F�r die V_i: CLocalVarTypeAssumption varAssum = new
|
||||||
//rememberLocals.addElement(varAssum);
|
* CLocalVarTypeAssumption(classmember.getName(),
|
||||||
}
|
* this.get_Method_Name(), this.getParameterCount(),
|
||||||
}
|
* this.getOverloadedID(),"1", para.get_Name(),para.getType(),
|
||||||
//...und hinzuf�gen:
|
* para.getLineNumber(),para.getOffset(),new Menge<Integer>());
|
||||||
|
* localAssum.addElement(varAssum);
|
||||||
assumptions.add(localAssum);//Assumptions für lokale Variablen den Assumptions hinzufügen
|
* //rememberLocals.addElement(varAssum); } } //...und
|
||||||
|
* hinzuf�gen:
|
||||||
//Hier wird der Typ der als Assumption eingetragen wird in die Variable assumedType dieser Klasse geschrieben:
|
*
|
||||||
if(this.assumedType == null) // Falls der Typ nicht schon gesetzt ist. Das ist der Fall, falls die Methode ein Konstruktor ist
|
* assumptions.add(localAssum);//Assumptions für lokale Variablen den
|
||||||
this.assumedType = methodAssum.getAssumedType();
|
* Assumptions hinzufügen
|
||||||
|
*
|
||||||
return assumptions;
|
* //Hier wird der Typ der als Assumption eingetragen wird in die
|
||||||
|
* Variable assumedType dieser Klasse geschrieben: if(this.assumedType
|
||||||
|
* == null) // Falls der Typ nicht schon gesetzt ist. Das ist der Fall,
|
||||||
|
* falls die Methode ein Konstruktor ist this.assumedType =
|
||||||
|
* methodAssum.getAssumedType();
|
||||||
|
*
|
||||||
|
* return assumptions;
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void parserPostProcessing(SyntaxTreeNode parent){
|
public void parserPostProcessing(SyntaxTreeNode parent) {
|
||||||
if(this.getType()==null)this.setType(TypePlaceholder.fresh(this));
|
if (this.getType() == null)
|
||||||
//Bei dem Elterntyp der Methode darf es sich nur um eine Klasse handeln, daher Cast ohne Prüfung:
|
this.setType(TypePlaceholder.fresh(this));
|
||||||
//Class parentClass = (Class)parent;
|
// Bei dem Elterntyp der Methode darf es sich nur um eine Klasse
|
||||||
if(this.returntype == null)this.returntype = TypePlaceholder.fresh(this);
|
// handeln, daher Cast ohne Prüfung:
|
||||||
|
// Class parentClass = (Class)parent;
|
||||||
|
if (this.returntype == null)
|
||||||
|
this.returntype = TypePlaceholder.fresh(this);
|
||||||
super.parserPostProcessing(parent);
|
super.parserPostProcessing(parent);
|
||||||
/*
|
/*
|
||||||
this.returntype.parserPostProcessing(this);
|
* this.returntype.parserPostProcessing(this); if(this.parameterlist !=
|
||||||
if(this.parameterlist != null){
|
* null){ for(FormalParameter fp : this.parameterlist){
|
||||||
for(FormalParameter fp : this.parameterlist){
|
* fp.parserPostProcessing(this); } } for(GenericTypeVar gtv :
|
||||||
fp.parserPostProcessing(this);
|
* this.getGenericParameter()){ gtv.parserPostProcessing(this); }
|
||||||
}
|
|
||||||
}
|
|
||||||
for(GenericTypeVar gtv : this.getGenericParameter()){
|
|
||||||
gtv.parserPostProcessing(this);
|
|
||||||
}
|
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -680,64 +689,74 @@ public class Method extends Field implements IItemWithOffset, TypeInsertable
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setType(Type t){
|
public void setType(Type t) {
|
||||||
// Methode und Block teilen sich einen ReturnType:
|
// Methode und Block teilen sich einen ReturnType:
|
||||||
//this.block.setType(t);
|
// this.block.setType(t);
|
||||||
this.returntype = t;
|
this.returntype = t;
|
||||||
this.returntype.parent = this; //TODO: Dieser Hack sollte nicht nötig sein. (Parser ändern)
|
this.returntype.parent = this; // TODO: Dieser Hack sollte nicht
|
||||||
|
// nötig sein. (Parser ändern)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Der Typ einer Methode ist ihr Returntype
|
* Der Typ einer Methode ist ihr Returntype
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Type getType(){
|
public Type getType() {
|
||||||
//Methode und Block teilen sich einen ReturnType:
|
// Methode und Block teilen sich einen ReturnType:
|
||||||
return this.returntype;
|
return this.returntype;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Method createEmptyMethod(String withSignature, Class parent){
|
public static Method createEmptyMethod(String withSignature, Class parent) {
|
||||||
Method ret = new Method(0);
|
Method ret = new Method(0);
|
||||||
DeclId DImethod = new DeclId();
|
DeclId DImethod = new DeclId();
|
||||||
DImethod.set_Name(withSignature);
|
DImethod.set_Name(withSignature);
|
||||||
ret.set_DeclId(DImethod);
|
ret.set_DeclId(DImethod);
|
||||||
Block tempBlock = new Block();
|
Block tempBlock = new Block();
|
||||||
//tempBlock.setType(new RefType(parent.getName(),0));
|
// tempBlock.setType(new RefType(parent.getName(),0));
|
||||||
ret.set_Block(tempBlock);
|
ret.set_Block(tempBlock);
|
||||||
ret.parserPostProcessing(parent);
|
ret.parserPostProcessing(parent);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj){
|
public boolean equals(Object obj) {
|
||||||
if(!(obj instanceof Method))return false;
|
if (!(obj instanceof Method))
|
||||||
|
return false;
|
||||||
Method equals = (Method) obj;
|
Method equals = (Method) obj;
|
||||||
if((this.returntype!=null && equals.returntype==null))return false;
|
if ((this.returntype != null && equals.returntype == null))
|
||||||
if((this.returntype==null && equals.returntype!=null))return false;
|
return false;
|
||||||
if(this.returntype!=null && equals.returntype!=null)if(!this.returntype.equals(equals.returntype))return false;
|
if ((this.returntype == null && equals.returntype != null))
|
||||||
if(!this.parameterlist.equals(equals.parameterlist))return false;
|
return false;
|
||||||
|
if (this.returntype != null && equals.returntype != null)
|
||||||
|
if (!this.returntype.equals(equals.returntype))
|
||||||
|
return false;
|
||||||
|
if (!this.parameterlist.equals(equals.parameterlist))
|
||||||
|
return false;
|
||||||
return super.equals(obj);
|
return super.equals(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void genByteCode(ClassGen cg) {
|
public void genByteCode(ClassGen cg) {
|
||||||
//ConstantPoolGen _cp = cg.getConstantPool();
|
ConstantPoolGen _cp = cg.getConstantPool();
|
||||||
//InstructionFactory _factory = new InstructionFactory(cg, _cp);
|
// InstructionFactory _factory = new InstructionFactory(cg, _cp);
|
||||||
//InstructionList il = new InstructionList();
|
InstructionList il = new InstructionList();
|
||||||
Class parentClass = this.getParentClass();
|
Class parentClass = this.getParentClass();
|
||||||
//TODO: Hier return type und Argument-Typen dynamisch generieren. return type mittels method.getReturnType() ermitteln
|
// TODO: Hier return type und Argument-Typen dynamisch generieren.
|
||||||
|
// return type mittels method.getReturnType() ermitteln
|
||||||
|
|
||||||
|
for (Statement statements : block.get_Statement()) {
|
||||||
//Über Constructor iterieren, um alle Methoden zu bekommen
|
|
||||||
for(Method methode : ){
|
|
||||||
|
|
||||||
//Über Statements iterieren um den Block abzurufen
|
|
||||||
for(Statement statements : block.get_Statement()){
|
|
||||||
statements.genByteCode(cg);
|
statements.genByteCode(cg);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
//GenByteCode Constructor
|
MethodGen method = new MethodGen(Constants.ACC_PUBLIC,
|
||||||
|
org.apache.bcel.generic.Type.getReturnType(Method method.getType()
|
||||||
|
.get_Name()), org.apache.bcel.generic.Type.NO_ARGS,
|
||||||
|
new String[] {}, "<init>", parentClass.name, il, _cp);
|
||||||
|
|
||||||
|
// Über Statements iterieren um den Block abzurufen
|
||||||
|
|
||||||
|
|
||||||
|
// GenByteCode Constructor
|
||||||
|
|
||||||
method.setMaxStack();
|
method.setMaxStack();
|
||||||
method.setMaxLocals();
|
method.setMaxLocals();
|
||||||
@ -745,7 +764,5 @@ public class Method extends Field implements IItemWithOffset, TypeInsertable
|
|||||||
// il.dispose();
|
// il.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
// ino.end
|
// ino.end
|
||||||
|
Loading…
Reference in New Issue
Block a user