2015-02-26 16:41:29 +00:00
|
|
|
// ino.module.This.8654.package
|
|
|
|
package de.dhbwstuttgart.syntaxtree.statement;
|
|
|
|
// ino.end
|
|
|
|
// ino.module.This.8654.import
|
|
|
|
import java.util.Hashtable;
|
2015-04-22 19:40:22 +00:00
|
|
|
import de.dhbwstuttgart.typeinference.Menge;
|
2015-02-26 16:41:29 +00:00
|
|
|
|
|
|
|
import de.dhbwstuttgart.logger.Logger;
|
|
|
|
import de.dhbwstuttgart.bytecode.ClassFile;
|
|
|
|
import de.dhbwstuttgart.bytecode.CodeAttribute;
|
|
|
|
import de.dhbwstuttgart.bytecode.JVMCode;
|
|
|
|
import de.dhbwstuttgart.myexception.CTypeReconstructionException;
|
|
|
|
import de.dhbwstuttgart.myexception.JVMCodeException;
|
|
|
|
import de.dhbwstuttgart.myexception.SCStatementException;
|
|
|
|
import de.dhbwstuttgart.syntaxtree.Class;
|
|
|
|
import de.dhbwstuttgart.syntaxtree.Constructor;
|
|
|
|
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
|
|
|
|
import de.dhbwstuttgart.syntaxtree.misc.ConstructorCall;
|
|
|
|
import de.dhbwstuttgart.syntaxtree.misc.UsedId;
|
|
|
|
import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar;
|
|
|
|
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
|
|
|
import de.dhbwstuttgart.syntaxtree.type.Type;
|
|
|
|
import de.dhbwstuttgart.syntaxtree.type.Void;
|
|
|
|
import de.dhbwstuttgart.typeinference.ConstraintsSet;
|
|
|
|
import de.dhbwstuttgart.typeinference.JavaCodeResult;
|
|
|
|
import de.dhbwstuttgart.typeinference.ResultSet;
|
|
|
|
import de.dhbwstuttgart.typeinference.assumptions.ConstructorAssumption;
|
|
|
|
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
|
|
|
|
import de.dhbwstuttgart.typeinference.exceptions.TypeinferenceException;
|
|
|
|
import de.dhbwstuttgart.typeinference.unify.CSubstitutionSet;
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-02-26 16:46:04 +00:00
|
|
|
public class SuperCall extends ThisCall
|
2015-02-26 16:41:29 +00:00
|
|
|
{
|
|
|
|
public SuperCall(int offset,int variableLength)
|
|
|
|
{
|
|
|
|
super(offset,variableLength);
|
|
|
|
}
|
|
|
|
|
|
|
|
public SuperCall(SyntaxTreeNode parent){
|
|
|
|
this(0,0);
|
|
|
|
this.parent = parent;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public ConstraintsSet TYPEExpr(TypeAssumptions assumptions) {
|
2015-02-26 16:46:04 +00:00
|
|
|
throw new TypeinferenceException("super(...)-Aufruf kann nicht als Ausdruck verwendet werden",this);
|
2015-02-26 16:41:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This kann auch als Konstruktoraufruf in einem Konstruktor-Block vorkommen.
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public ConstraintsSet TYPEStmt(TypeAssumptions assumptions) {
|
|
|
|
String className = this.getParentClass().getSuperClass().getName().toString();
|
|
|
|
ConstraintsSet ret = new ConstraintsSet();
|
|
|
|
this.setType(new Void(this,this.getOffset()));
|
|
|
|
//Kontrollieren, dass sich this(...) in einem Konstruktor und dort als erstes Statement befindet:
|
|
|
|
SyntaxTreeNode p = this.getGTVDeclarationContext();
|
|
|
|
if(p instanceof Constructor &&
|
|
|
|
((Constructor)p).get_Block().statements.firstElement().equals(this)){
|
|
|
|
//Constraints generieren:
|
|
|
|
|
|
|
|
MethodCall constructorCall = new ConstructorCall(new Receiver(new This(this)), className, arglist, this.getOffset());
|
|
|
|
ret.add(constructorCall.TYPEStmt(assumptions));
|
|
|
|
return ret;
|
|
|
|
}else{
|
|
|
|
//Ansonsten Fehler ausgeben:
|
2015-05-12 12:57:12 +00:00
|
|
|
throw new TypeinferenceException("super()-Aufruf hier nicht möglich", this);
|
2015-02-26 16:41:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public String toString()
|
|
|
|
{
|
|
|
|
//return receiver/*.toString()*/ + " " + usedid.toString();
|
|
|
|
return "(" + "super" +"(" + this.getArgumentList() + "))";
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public JavaCodeResult printJavaCode(ResultSet resultSet) {
|
|
|
|
return new JavaCodeResult("super("+this.getArgumentList().printJavaCode(resultSet)+")");
|
2015-02-26 16:46:04 +00:00
|
|
|
}
|
2015-02-26 16:41:29 +00:00
|
|
|
|
|
|
|
}
|