// 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.UsedId; import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar; import de.dhbwstuttgart.syntaxtree.type.RefType; import de.dhbwstuttgart.syntaxtree.type.Type; import de.dhbwstuttgart.typeinference.ConstraintsSet; import de.dhbwstuttgart.typeinference.JavaCodeResult; import de.dhbwstuttgart.typeinference.ResultSet; import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions; import de.dhbwstuttgart.typeinference.exceptions.TypeinferenceException; import de.dhbwstuttgart.typeinference.unify.CSubstitutionSet; // ino.class.This.26261.declaration public class This extends Expr // ino.end // ino.class.This.26261.body { // ino.method.This.26265.definition public This(int offset,int variableLength) // ino.end // ino.method.This.26265.body { super(offset,variableLength); } // ino.end public This(SyntaxTreeNode parent){ this(0,0); this.parent = parent; } // ino.attribute.arglist.26268.declaration public ArgumentList arglist; // ino.end // ino.attribute.parserlog.26271.declaration protected static Logger parserlog = Logger.getLogger("parser"); // ino.end // ino.method.set_ArgumentList.26274.definition public void set_ArgumentList(ArgumentList al) // ino.end // ino.method.set_ArgumentList.26274.body { this.arglist = al; } // ino.end public ArgumentList getArgumentList() { return this.arglist; } // ino.method.set_UsedId.26277.definition public void set_UsedId(UsedId ui) // ino.end // ino.method.set_UsedId.26277.body { this.usedid = ui; } // ino.end /* // ino.method.sc_check.26280.definition public void sc_check(Vector classname, Hashtable ch, Hashtable bh, boolean ext, Hashtable parach, Hashtable parabh) throws SCStatementException // ino.end // ino.method.sc_check.26280.body { if(ext) parserlog.debug(" ---This---"); } // ino.end */ // ino.method.codegen.26283.definition public void codegen(ClassFile classfile, CodeAttribute code, Vector paralist) throws JVMCodeException // ino.end // ino.method.codegen.26283.body { code.add_code(JVMCode.aload_0); } // ino.end // ino.method.get_Name.26286.definition public String get_Name() // ino.end // ino.method.get_Name.26286.body { return null; } // ino.end // ino.method.wandleRefTypeAttributes2GenericAttributes.26295.definition public void wandleRefTypeAttributes2GenericAttributes(Vector paralist, Vector genericMethodParameters) // ino.end // ino.method.wandleRefTypeAttributes2GenericAttributes.26295.body { } // ino.end @Override public ConstraintsSet TYPEExpr(TypeAssumptions assumptions) { ConstraintsSet ret = new ConstraintsSet(); //this.set_Type(new); //this.setType(assumptions.getThisValue());//Die Assumption für this als TypeVariable setzen. this.setType(this.getParentClass().getType()); return ret; } /** * This kann auch als Konstruktoraufruf in einem Konstruktor-Block vorkommen. */ @Override public ConstraintsSet TYPEStmt(TypeAssumptions assumptions) { ConstraintsSet ret = new ConstraintsSet(); //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 MethodCall(new Receiver(this), this.getParentClass().getName().toString(), arglist, this.getOffset()); ret.add(constructorCall.TYPEStmt(assumptions)); return ret; }else{ //Ansonsten Fehler ausgeben: throw new TypeinferenceException("This()-Aufruf hier nicht möglich", this); } } public String toString() // ino.end // ino.method.toString.25738.body { //return receiver/*.toString()*/ + " " + usedid.toString(); return type + " (" + "this" +"(" + this.getArgumentList() + "))"; } @Override public JavaCodeResult printJavaCode(ResultSet resultSet) { return new JavaCodeResult("this"); } @Override public Vector getChildren() { Vector ret = new Vector(); return ret; } } // ino.end