forked from JavaTX/JavaCompilerCore
207 lines
6.1 KiB
Java
207 lines
6.1 KiB
Java
|
// ino.module.Return.8651.package
|
|||
|
package mycompiler.mystatement;
|
|||
|
// ino.end
|
|||
|
// ino.module.Return.8651.import
|
|||
|
import java.util.Hashtable;
|
|||
|
import java.util.Vector;
|
|||
|
import mycompiler.mybytecode.ClassFile;
|
|||
|
import mycompiler.mybytecode.CodeAttribute;
|
|||
|
import mycompiler.mybytecode.JVMCode;
|
|||
|
import mycompiler.myclass.Class;
|
|||
|
import mycompiler.myexception.CTypeReconstructionException;
|
|||
|
import mycompiler.myexception.JVMCodeException;
|
|||
|
import mycompiler.myexception.SCExcept;
|
|||
|
import mycompiler.myexception.SCStatementException;
|
|||
|
import mycompiler.mytype.GenericTypeVar;
|
|||
|
import mycompiler.mytype.Type;
|
|||
|
import mycompiler.mytype.TypePlaceholder;
|
|||
|
import mycompiler.mytypereconstruction.CSupportData;
|
|||
|
import mycompiler.mytypereconstruction.replacementlistener.CReplaceTypeEvent;
|
|||
|
import mycompiler.mytypereconstruction.set.CSubstitutionSet;
|
|||
|
import mycompiler.mytypereconstruction.set.CTripleSet;
|
|||
|
import mycompiler.mytypereconstruction.set.CTypeAssumptionSet;
|
|||
|
import mycompiler.mytypereconstruction.typeassumption.CTypeAssumption;
|
|||
|
|
|||
|
import org.apache.log4j.Logger;
|
|||
|
// ino.end
|
|||
|
|
|||
|
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
|
|||
|
import typinferenz.JavaCodeResult;
|
|||
|
import typinferenz.SingleConstraint;
|
|||
|
import typinferenz.ConstraintsSet;
|
|||
|
import typinferenz.FreshTypeVariable;
|
|||
|
import typinferenz.ResultSet;
|
|||
|
import typinferenz.TypeAssumptions;
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
// ino.class.Return.26150.declaration
|
|||
|
public class Return extends Statement
|
|||
|
// ino.end
|
|||
|
// ino.class.Return.26150.body
|
|||
|
{
|
|||
|
// ino.method.Return.26154.definition
|
|||
|
public Return(int offset,int variableLength)
|
|||
|
// ino.end
|
|||
|
// ino.method.Return.26154.body
|
|||
|
{
|
|||
|
super(offset,variableLength);
|
|||
|
}
|
|||
|
// ino.end
|
|||
|
// ino.attribute.retexpr.26157.declaration
|
|||
|
public Expr retexpr;
|
|||
|
// ino.end
|
|||
|
// ino.attribute.parserlog.26160.declaration
|
|||
|
protected static Logger parserlog = Logger.getLogger("parser");
|
|||
|
// ino.end
|
|||
|
|
|||
|
|
|||
|
|
|||
|
// ino.method.sc_check.26163.definition
|
|||
|
void sc_check(Vector<Class> classname, Hashtable ch, Hashtable<String, String> bh, boolean ext, Hashtable parach, Hashtable<String, Hashtable> parabh)
|
|||
|
throws SCStatementException
|
|||
|
// ino.end
|
|||
|
// ino.method.sc_check.26163.body
|
|||
|
{
|
|||
|
if(ext)
|
|||
|
parserlog.debug(" ---Return---");
|
|||
|
SCStatementException excep=null;
|
|||
|
if(ext)
|
|||
|
parserlog.debug("Semantik-Check pr<70>ft Return-Anweisung");
|
|||
|
try
|
|||
|
{
|
|||
|
retexpr.sc_check(classname,ch,bh,ext, parach, parabh);
|
|||
|
}
|
|||
|
catch (SCStatementException ex)
|
|||
|
{
|
|||
|
excep=ex;
|
|||
|
}
|
|||
|
String gefordert;
|
|||
|
String ist;
|
|||
|
ist=get_Type();
|
|||
|
gefordert=(String)bh.get("###_Method_Ret_Type");
|
|||
|
parserlog.debug(ist+gefordert);
|
|||
|
if(!ist.equals(gefordert))
|
|||
|
{
|
|||
|
if(ext)
|
|||
|
parserlog.error("FEHLER: R<>ckgabewert hat anderen Typ als von Methode gefordert sc_check-->Return");
|
|||
|
SCExcept exc=new SCExcept();
|
|||
|
exc.set_error("R<EFBFBD>ckgabewert hat anderen Typ als von Methode gefordert!");
|
|||
|
exc.set_statement("Return");
|
|||
|
if(excep==null)
|
|||
|
excep = new SCStatementException();
|
|||
|
excep.addException(exc);
|
|||
|
}
|
|||
|
if(excep!=null)
|
|||
|
throw excep;
|
|||
|
}
|
|||
|
// ino.end
|
|||
|
|
|||
|
// ino.method.set_ReturnExpr.26166.definition
|
|||
|
public Return set_ReturnExpr(Expr ret)
|
|||
|
// ino.end
|
|||
|
// ino.method.set_ReturnExpr.26166.body
|
|||
|
{
|
|||
|
this.retexpr=ret;
|
|||
|
return this;
|
|||
|
}
|
|||
|
// ino.end
|
|||
|
|
|||
|
// ino.method.get_Type.26169.definition
|
|||
|
public String get_Type()
|
|||
|
// ino.end
|
|||
|
// ino.method.get_Type.26169.body
|
|||
|
{
|
|||
|
return retexpr.getTypeName();
|
|||
|
}
|
|||
|
// ino.end
|
|||
|
|
|||
|
// ino.method.codegen.26172.definition
|
|||
|
public void codegen(ClassFile classfile, CodeAttribute code, Vector paralist)
|
|||
|
throws JVMCodeException
|
|||
|
// ino.end
|
|||
|
// ino.method.codegen.26172.body
|
|||
|
{
|
|||
|
retexpr.codegen(classfile, code, paralist);
|
|||
|
code.add_code(JVMCode.nreturn(retexpr.getTypeName()));
|
|||
|
}
|
|||
|
// ino.end
|
|||
|
|
|||
|
// ino.method.TRStatement.26175.defdescription type=javadoc
|
|||
|
/**
|
|||
|
* Implementierung des Algorithmus 5.22 von Martin Pl<EFBFBD>micke
|
|||
|
* <br>Author: J<EFBFBD>rg B<EFBFBD>uerle
|
|||
|
* @param sigma
|
|||
|
* @param V
|
|||
|
* @param supportData
|
|||
|
* @return
|
|||
|
* @throws CTypeReconstructionException
|
|||
|
*/
|
|||
|
// ino.end
|
|||
|
// ino.method.TRStatement.26175.definition
|
|||
|
public CTripleSet TRStatement(CSubstitutionSet sigma, CTypeAssumptionSet V, CSupportData supportData)
|
|||
|
throws CTypeReconstructionException
|
|||
|
// ino.end
|
|||
|
// ino.method.TRStatement.26175.body
|
|||
|
{
|
|||
|
return retexpr.TRExp(sigma, V, supportData);
|
|||
|
}
|
|||
|
// ino.end
|
|||
|
|
|||
|
// ino.method.toString.26178.definition
|
|||
|
public String toString()
|
|||
|
// ino.end
|
|||
|
// ino.method.toString.26178.body
|
|||
|
{
|
|||
|
return type + " Return " + retexpr.toString();
|
|||
|
}
|
|||
|
// ino.end
|
|||
|
// ino.method.wandleRefTypeAttributes2GenericAttributes.26181.definition
|
|||
|
public void wandleRefTypeAttributes2GenericAttributes(Vector<Type> paralist, Vector<GenericTypeVar> genericMethodParameters)
|
|||
|
// ino.end
|
|||
|
// ino.method.wandleRefTypeAttributes2GenericAttributes.26181.body
|
|||
|
{
|
|||
|
}
|
|||
|
// ino.end
|
|||
|
|
|||
|
public boolean addOffsetsToStatement(CTypeAssumption localAssumption, String NameVariable, boolean isMemberVariable)
|
|||
|
{
|
|||
|
retexpr.addOffsetsToExpression(localAssumption,NameVariable,isMemberVariable);
|
|||
|
return true;
|
|||
|
}
|
|||
|
|
|||
|
@Override
|
|||
|
public ConstraintsSet TYPEStmt(TypeAssumptions assumptions) {
|
|||
|
ConstraintsSet ret = new ConstraintsSet();
|
|||
|
ret.add(this.retexpr.TYPEExpr(assumptions));
|
|||
|
//this.setTypeVariable(TypePlaceholder.fresh("Return Type"));
|
|||
|
this.setTypeVariable(TypePlaceholder.fresh(this));
|
|||
|
ret.add(new SingleConstraint(retexpr.getTypeVariable(), this.getTypeVariable()));
|
|||
|
return ret;
|
|||
|
}
|
|||
|
|
|||
|
public void replaceType(CReplaceTypeEvent e) {
|
|||
|
super.replaceType(e);
|
|||
|
}
|
|||
|
|
|||
|
public int getTypeLineNumber() {
|
|||
|
return 0;
|
|||
|
}
|
|||
|
|
|||
|
@Override
|
|||
|
public String getTypeInformation(){
|
|||
|
String ret = this.getTypeVariable()+" :: (Return "+this.retexpr.getTypeInformation()+")";
|
|||
|
return ret;
|
|||
|
}
|
|||
|
|
|||
|
@Override
|
|||
|
public JavaCodeResult printJavaCode(ResultSet resultSet) {
|
|||
|
JavaCodeResult ret = new JavaCodeResult("return ");
|
|||
|
ret.attach(this.retexpr.printJavaCode(resultSet));
|
|||
|
return ret.attach(";");
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
// ino.end
|