2013-10-18 13:33:46 +02:00
|
|
|
|
// ino.module.MethodCall.8639.package
|
2014-09-02 10:33:54 +02:00
|
|
|
|
package de.dhbwstuttgart.syntaxtree.statement;
|
2013-10-18 13:33:46 +02:00
|
|
|
|
// ino.end
|
|
|
|
|
// ino.module.MethodCall.8639.import
|
|
|
|
|
import java.util.Hashtable;
|
|
|
|
|
import java.util.Vector;
|
2014-02-09 16:07:31 +01:00
|
|
|
|
|
2014-10-09 12:01:16 +02:00
|
|
|
|
import de.dhbwstuttgart.logger.Logger;
|
2014-09-04 16:35:44 +02:00
|
|
|
|
|
|
|
|
|
import de.dhbwstuttgart.bytecode.ClassFile;
|
|
|
|
|
import de.dhbwstuttgart.bytecode.CodeAttribute;
|
|
|
|
|
import de.dhbwstuttgart.myexception.JVMCodeException;
|
2014-09-02 10:33:54 +02:00
|
|
|
|
import de.dhbwstuttgart.syntaxtree.Method;
|
2014-09-04 16:35:44 +02:00
|
|
|
|
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
|
2014-09-02 10:33:54 +02:00
|
|
|
|
import de.dhbwstuttgart.syntaxtree.misc.UsedId;
|
|
|
|
|
import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar;
|
|
|
|
|
import de.dhbwstuttgart.syntaxtree.type.Type;
|
|
|
|
|
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
|
|
|
|
import de.dhbwstuttgart.syntaxtree.type.Void;
|
|
|
|
|
import de.dhbwstuttgart.typeinference.ConstraintsSet;
|
|
|
|
|
import de.dhbwstuttgart.typeinference.JavaCodeResult;
|
|
|
|
|
import de.dhbwstuttgart.typeinference.Overloading;
|
|
|
|
|
import de.dhbwstuttgart.typeinference.ResultSet;
|
|
|
|
|
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
|
2013-10-18 13:33:46 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ino.class.MethodCall.25623.declaration
|
|
|
|
|
public class MethodCall extends Expr
|
|
|
|
|
// ino.end
|
|
|
|
|
// ino.class.MethodCall.25623.body
|
|
|
|
|
{
|
|
|
|
|
// ino.method.MethodCall.25627.definition
|
|
|
|
|
public MethodCall(int offset, int variableLength)
|
|
|
|
|
// ino.end
|
|
|
|
|
// ino.method.MethodCall.25627.body
|
|
|
|
|
{
|
|
|
|
|
super(offset,variableLength);
|
|
|
|
|
}
|
|
|
|
|
// ino.end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ino.attribute.receiver.25639.declaration
|
|
|
|
|
/**
|
|
|
|
|
* Diese Variable speichert die Expression, welche die Klasse von welcher die Methode aufgerufen wird darstellt.
|
|
|
|
|
*/
|
|
|
|
|
private Receiver receiver;
|
|
|
|
|
// ino.end
|
|
|
|
|
// ino.attribute.arglist.25642.declaration
|
2014-02-22 04:58:49 +01:00
|
|
|
|
private ArgumentList arglist=new ArgumentList();
|
|
|
|
|
|
2013-10-18 13:33:46 +02:00
|
|
|
|
// ino.attribute.parserlog.25663.declaration
|
|
|
|
|
protected static Logger parserlog = Logger.getLogger("parser");
|
|
|
|
|
// ino.end
|
|
|
|
|
|
|
|
|
|
// ino.method.set_ArgumentList.25666.definition
|
|
|
|
|
public void set_ArgumentList(ArgumentList al)
|
|
|
|
|
// ino.end
|
|
|
|
|
// ino.method.set_ArgumentList.25666.body
|
|
|
|
|
{
|
|
|
|
|
this.arglist = al;
|
|
|
|
|
}
|
|
|
|
|
// ino.end
|
|
|
|
|
|
|
|
|
|
// ino.method.getArgumentList.25669.definition
|
|
|
|
|
public ArgumentList getArgumentList()
|
|
|
|
|
// ino.end
|
|
|
|
|
// ino.method.getArgumentList.25669.body
|
|
|
|
|
{
|
|
|
|
|
if(this.arglist==null)return this.arglist = new ArgumentList();
|
|
|
|
|
return this.arglist;
|
|
|
|
|
}
|
|
|
|
|
// ino.end
|
|
|
|
|
|
|
|
|
|
// ino.method.get_Receiver.25672.definition
|
|
|
|
|
public Receiver get_Receiver()
|
|
|
|
|
// ino.end
|
|
|
|
|
// ino.method.get_Receiver.25672.body
|
|
|
|
|
{
|
|
|
|
|
return receiver;
|
|
|
|
|
}
|
|
|
|
|
// ino.end
|
|
|
|
|
|
|
|
|
|
// ino.method.get_Name.25675.definition
|
|
|
|
|
public String get_Name()
|
|
|
|
|
// ino.end
|
|
|
|
|
// ino.method.get_Name.25675.body
|
|
|
|
|
{
|
|
|
|
|
return this.usedid.name.firstElement();
|
|
|
|
|
}
|
|
|
|
|
// ino.end
|
|
|
|
|
|
|
|
|
|
public void set_Name(String name){
|
|
|
|
|
|
|
|
|
|
this.usedid = new UsedId(name, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ino.method.set_Receiver.25693.definition
|
|
|
|
|
public void set_Receiver(Receiver rec)
|
|
|
|
|
// ino.end
|
|
|
|
|
// ino.method.set_Receiver.25693.body
|
|
|
|
|
{
|
|
|
|
|
receiver=rec;
|
|
|
|
|
}
|
|
|
|
|
// ino.end
|
|
|
|
|
|
|
|
|
|
// ino.method.set_UsedId.25696.definition
|
|
|
|
|
public void set_UsedId(UsedId u)
|
|
|
|
|
// ino.end
|
|
|
|
|
// ino.method.set_UsedId.25696.body
|
|
|
|
|
{
|
|
|
|
|
usedid=u;
|
|
|
|
|
}
|
|
|
|
|
// ino.end
|
|
|
|
|
|
|
|
|
|
// ino.method.set_Expr_Vector.25699.definition
|
|
|
|
|
public void set_Expr_Vector(Vector<Expr> v)
|
|
|
|
|
// ino.end
|
|
|
|
|
// ino.method.set_Expr_Vector.25699.body
|
|
|
|
|
{
|
|
|
|
|
arglist.expr=v;
|
|
|
|
|
}
|
|
|
|
|
// ino.end
|
|
|
|
|
|
|
|
|
|
// ino.method.add_Expr.25702.definition
|
|
|
|
|
public void add_Expr(Expr e)
|
|
|
|
|
// ino.end
|
|
|
|
|
// ino.method.add_Expr.25702.body
|
|
|
|
|
{
|
|
|
|
|
arglist.expr.addElement(e);
|
|
|
|
|
}
|
|
|
|
|
// ino.end
|
|
|
|
|
|
2014-09-05 11:49:31 +02:00
|
|
|
|
|
2013-10-18 13:33:46 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ino.method.toString.25738.defdescription type=javadoc
|
|
|
|
|
/**
|
|
|
|
|
* <br/>Author: Martin Pl<EFBFBD>micke
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
// ino.end
|
|
|
|
|
// ino.method.toString.25738.definition
|
|
|
|
|
public String toString()
|
|
|
|
|
// ino.end
|
|
|
|
|
// ino.method.toString.25738.body
|
|
|
|
|
{
|
|
|
|
|
//return receiver/*.toString()*/ + " " + usedid.toString();
|
|
|
|
|
return type + " (" + this.get_Receiver() + "." + this.get_Name() +"(" + this.getArgumentList() + "))";
|
|
|
|
|
}
|
|
|
|
|
// ino.end
|
|
|
|
|
|
|
|
|
|
// ino.method.wandleRefTypeAttributes2GenericAttributes.25741.definition
|
|
|
|
|
public void wandleRefTypeAttributes2GenericAttributes(Vector<Type> paralist, Vector<GenericTypeVar> genericMethodParameters)
|
|
|
|
|
// ino.end
|
|
|
|
|
// ino.method.wandleRefTypeAttributes2GenericAttributes.25741.body
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
// ino.end
|
2014-09-05 11:49:31 +02:00
|
|
|
|
|
2013-10-18 13:33:46 +02:00
|
|
|
|
/**
|
|
|
|
|
* @author Andreas Stadelmeier, a10023
|
|
|
|
|
* @return der Name der Methode, welcher dieser MethodCall aufruft.
|
|
|
|
|
*/
|
|
|
|
|
public String getName(){
|
|
|
|
|
return this.usedid.toString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @author AI10023 - Andreas Stadelmeier
|
|
|
|
|
*
|
|
|
|
|
* M<EFBFBD>gliche Probleme:
|
|
|
|
|
* Wenn die Methode ohne Angabe eines Receivers im Quelltext steht:
|
|
|
|
|
* methodCall(param); -> (bedeutet:) this.methodCall(param);
|
2014-09-09 11:15:10 +02:00
|
|
|
|
* Parser m<EFBFBD>glicherweise anpassen (siehe JavaParser.jay Zeile 1858 ff)
|
2013-10-18 13:33:46 +02:00
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public ConstraintsSet TYPEExpr(TypeAssumptions assumptions) {
|
|
|
|
|
//Hier der Ablauf f<>r einen Methodenaufruf:
|
|
|
|
|
ConstraintsSet ret = new ConstraintsSet();
|
|
|
|
|
//Der Return-Type des MEthodenaufrufs ist zun<75>chst unbekannt:
|
2014-02-11 16:30:38 +01:00
|
|
|
|
this.setType(TypePlaceholder.fresh(this));
|
2013-10-18 13:33:46 +02:00
|
|
|
|
//Berechne die Constraints des Receivers
|
|
|
|
|
if(receiver == null){
|
2014-04-24 01:53:35 +02:00
|
|
|
|
receiver = new Receiver(new This(this));
|
2013-10-18 13:33:46 +02:00
|
|
|
|
}
|
|
|
|
|
ret.add(receiver.get_Expr().TYPEExpr(assumptions));
|
|
|
|
|
|
|
|
|
|
//Berechne die Constraints der Argumente aus der Argumentlist (also der Parameter, welche der Funktion <20>bergeben wurden)
|
|
|
|
|
if(this.arglist != null)for(Expr arg : this.arglist.expr){
|
|
|
|
|
ret.add(arg.TYPEExpr(assumptions));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Noch das Overloading-Constraint anh<6E>ngen:
|
2014-02-11 16:30:38 +01:00
|
|
|
|
ret.add(new Overloading(assumptions, this, this.getType()).generateConsstraints());
|
2013-10-18 13:33:46 +02:00
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Spezifikation:
|
|
|
|
|
* TYPEStmt( Ass, stmt ) =
|
|
|
|
|
* let (stmt : rty, ConS) = TYPEExpr( Ass, stmt )
|
|
|
|
|
* in (stmt : Void, ConS)
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public ConstraintsSet TYPEStmt(TypeAssumptions assumptions){
|
|
|
|
|
ConstraintsSet ret = this.TYPEExpr(assumptions); //TypeExpr aufrufen
|
2014-09-14 18:38:43 +02:00
|
|
|
|
this.setType(new Void(this,0)); //Typ des Statments auf Void setzen, da als alleinstehendes Statement
|
2013-10-18 13:33:46 +02:00
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
|
|
public JavaCodeResult printJavaCode(ResultSet resultSet) {
|
|
|
|
|
JavaCodeResult ret = new JavaCodeResult();
|
|
|
|
|
if(this.receiver != null)ret.attach( this.receiver.printJavaCode(resultSet)).attach(".");
|
|
|
|
|
ret .attach( this.get_Name());
|
|
|
|
|
ret .attach( "(" ).attach( this.getArgumentList().printJavaCode(resultSet)).attach( ")");
|
|
|
|
|
return ret.attach(";");
|
|
|
|
|
|
|
|
|
|
}
|
2014-02-22 04:58:49 +01:00
|
|
|
|
@Override
|
|
|
|
|
public Vector<SyntaxTreeNode> getChildren() {
|
|
|
|
|
Vector<SyntaxTreeNode> ret = new Vector<SyntaxTreeNode>();
|
|
|
|
|
for(Expr e : this.arglist.expr){
|
|
|
|
|
ret.add(e);
|
|
|
|
|
}
|
|
|
|
|
if(this.receiver!=null)ret.add(this.receiver.get_Expr());
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void parserPostProcessing(SyntaxTreeNode parent) {
|
|
|
|
|
super.parserPostProcessing(parent);
|
|
|
|
|
}
|
2014-09-05 11:49:31 +02:00
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void codegen(ClassFile classfile, CodeAttribute code, Vector paralist)
|
|
|
|
|
throws JVMCodeException {
|
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
|
|
|
|
|
|
}
|
2014-02-22 04:58:49 +01:00
|
|
|
|
|
2013-10-18 13:33:46 +02:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
// ino.end
|