// ino.module.This.8654.package package de.dhbwstuttgart.syntaxtree.statement; // ino.end // ino.module.This.8654.import import java.util.Hashtable; import java.util.Vector; 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; public class SuperCall extends ThisCall { 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) { throw new TypeinferenceException("super(...)-Aufruf kann nicht als Ausdruck verwendet werden",this); } /** * 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: throw new TypeinferenceException("super()-Aufruf hier nicht möglich", this); } } 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)+")"); } }