forked from JavaTX/JavaCompilerCore
229 lines
6.5 KiB
Java
229 lines
6.5 KiB
Java
|
// ino.module.CastExpr.8627.package
|
|||
|
package mycompiler.mystatement;
|
|||
|
// ino.end
|
|||
|
// ino.module.CastExpr.8627.import
|
|||
|
import java.util.Hashtable;
|
|||
|
import java.util.Iterator;
|
|||
|
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.mytypereconstruction.CSupportData;
|
|||
|
import mycompiler.mytypereconstruction.CTriple;
|
|||
|
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 typinferenz.ConstraintsSet;
|
|||
|
import typinferenz.JavaCodeResult;
|
|||
|
import typinferenz.ResultSet;
|
|||
|
import typinferenz.TypeAssumptions;
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
// ino.class.CastExpr.25126.declaration
|
|||
|
public class CastExpr extends UnaryExpr
|
|||
|
// ino.end
|
|||
|
// ino.class.CastExpr.25126.body
|
|||
|
{
|
|||
|
// ino.method.CastExpr.25130.definition
|
|||
|
public CastExpr(int offset,int variableLength)
|
|||
|
// ino.end
|
|||
|
// ino.method.CastExpr.25130.body
|
|||
|
{
|
|||
|
super(offset,variableLength);
|
|||
|
}
|
|||
|
// ino.end
|
|||
|
|
|||
|
// ino.attribute.type.25133.declaration
|
|||
|
private Type type;
|
|||
|
// ino.end
|
|||
|
// ino.attribute.expr.25136.declaration
|
|||
|
public Expr expr;
|
|||
|
// ino.end
|
|||
|
// ino.attribute.parserlog.25139.declaration
|
|||
|
protected static Logger parserlog = Logger.getLogger("parser");
|
|||
|
// ino.end
|
|||
|
|
|||
|
|
|||
|
// ino.method.sc_check.25142.definition
|
|||
|
public 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.25142.body
|
|||
|
{
|
|||
|
if(ext)
|
|||
|
parserlog.debug(" ---CastExpr---");
|
|||
|
SCStatementException except=null;
|
|||
|
if(ext)
|
|||
|
parserlog.debug("CastExpr.sc_check() berechnet Typ von expr und ceckt kompatibilitaet");
|
|||
|
try
|
|||
|
{
|
|||
|
expr.sc_check(classname, ch, bh, ext, parach, parabh);
|
|||
|
}
|
|||
|
catch(SCStatementException ex)
|
|||
|
{
|
|||
|
except=ex;
|
|||
|
}
|
|||
|
if(this.type.getName() != expr.getTypeName())
|
|||
|
{
|
|||
|
if(ext)
|
|||
|
parserlog.error("Typinkompatibilitaet - moeglicher Datenverlust --> CastExpr.sc_check() ");
|
|||
|
SCExcept neu=new SCExcept();
|
|||
|
neu.set_error("Typfehler");
|
|||
|
neu.set_statement("ArrayAccess");
|
|||
|
if(except==null)
|
|||
|
except=new SCStatementException();
|
|||
|
except.addException(neu);
|
|||
|
}
|
|||
|
if(except!=null)
|
|||
|
throw except;
|
|||
|
}
|
|||
|
// ino.end
|
|||
|
|
|||
|
|
|||
|
|
|||
|
// ino.method.get_Name.25145.definition
|
|||
|
public String get_Name()
|
|||
|
// ino.end
|
|||
|
// ino.method.get_Name.25145.body
|
|||
|
{
|
|||
|
return null;
|
|||
|
}
|
|||
|
// ino.end
|
|||
|
|
|||
|
|
|||
|
|
|||
|
// ino.method.set_Type.25148.definition
|
|||
|
public void set_Type(Type ty)
|
|||
|
// ino.end
|
|||
|
// ino.method.set_Type.25148.body
|
|||
|
{
|
|||
|
this.type = ty;
|
|||
|
}
|
|||
|
// ino.end
|
|||
|
|
|||
|
|
|||
|
|
|||
|
// ino.method.set_Expr.25151.definition
|
|||
|
public void set_Expr(Expr ex)
|
|||
|
// ino.end
|
|||
|
// ino.method.set_Expr.25151.body
|
|||
|
{
|
|||
|
this.expr = ex;
|
|||
|
}
|
|||
|
// ino.end
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
// ino.method.codegen.25154.definition
|
|||
|
public void codegen(ClassFile classfile, CodeAttribute code, Vector paralist)
|
|||
|
throws JVMCodeException
|
|||
|
// ino.end
|
|||
|
// ino.method.codegen.25154.body
|
|||
|
{
|
|||
|
int itype = JVMCode.get_nType(type.getName());
|
|||
|
int iexpr = JVMCode.get_nType(expr.getTypeName());
|
|||
|
if(itype != iexpr)
|
|||
|
{
|
|||
|
if((itype == 4) || (iexpr == 4))
|
|||
|
{
|
|||
|
throw new JVMCodeException("JVMCodeException: CastExpr: void codegen(ClassFile classfile, Code_attribute code)");
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
expr.set_Type(type);
|
|||
|
code.add_code(JVMCode.n2n(expr.getTypeName(), type.getName()));
|
|||
|
}
|
|||
|
}
|
|||
|
else if(itype == 4) expr.set_Type(type);
|
|||
|
}
|
|||
|
// ino.end
|
|||
|
|
|||
|
// ino.method.TRExp.25157.defdescription type=javadoc
|
|||
|
/**
|
|||
|
* Implementierung des Algorithmus 5.43 von Martin Pl<EFBFBD>micke
|
|||
|
* <br>Author: J<EFBFBD>rg B<EFBFBD>uerle
|
|||
|
* @param sigma
|
|||
|
* @param V
|
|||
|
* @param supportData
|
|||
|
* @return
|
|||
|
*/
|
|||
|
// ino.end
|
|||
|
// ino.method.TRExp.25157.definition
|
|||
|
public CTripleSet TRExp(CSubstitutionSet sigma, CTypeAssumptionSet V, CSupportData supportData)
|
|||
|
// ino.end
|
|||
|
// ino.method.TRExp.25157.body
|
|||
|
{
|
|||
|
CTripleSet returnSet = new CTripleSet();
|
|||
|
// --------------------------
|
|||
|
// TRExpr f<>r Expr rufen:
|
|||
|
// --------------------------
|
|||
|
CTripleSet exprSet = expr.TRExp(sigma, V, supportData);
|
|||
|
// --------------------------
|
|||
|
// ReturnType der Triple <20>ndern:
|
|||
|
// --------------------------
|
|||
|
Iterator<CTriple> exprIt = exprSet.deepCopy().getIterator();
|
|||
|
while(exprIt.hasNext()){
|
|||
|
CTriple exprTriple = exprIt.next();
|
|||
|
exprTriple.setResultType(this.type);
|
|||
|
returnSet.addElement(exprTriple);
|
|||
|
}
|
|||
|
return returnSet;
|
|||
|
}
|
|||
|
// ino.end
|
|||
|
|
|||
|
// ino.method.TRStatement.25160.definition
|
|||
|
public CTripleSet TRStatement(CSubstitutionSet sigma, CTypeAssumptionSet V, CSupportData supportData)
|
|||
|
// ino.end
|
|||
|
// ino.method.TRStatement.25160.body
|
|||
|
{
|
|||
|
throw CTypeReconstructionException.createNotImplementedException();
|
|||
|
}
|
|||
|
// ino.end
|
|||
|
|
|||
|
// ino.method.wandleRefTypeAttributes2GenericAttributes.25163.definition
|
|||
|
public void wandleRefTypeAttributes2GenericAttributes(Vector<Type> paralist, Vector<GenericTypeVar> genericMethodParameters)
|
|||
|
// ino.end
|
|||
|
// ino.method.wandleRefTypeAttributes2GenericAttributes.25163.body
|
|||
|
{
|
|||
|
}
|
|||
|
// ino.end
|
|||
|
|
|||
|
public void addOffsetsToExpression(CTypeAssumption localAssumption,String NameVariable,boolean isMemberVariable)
|
|||
|
{
|
|||
|
expr.addOffsetsToExpression(localAssumption,NameVariable,isMemberVariable);
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
@Override
|
|||
|
public ConstraintsSet TYPEExpr(TypeAssumptions assumptions) {
|
|||
|
// TODO Auto-generated method stub
|
|||
|
return null;
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
@Override
|
|||
|
public JavaCodeResult printJavaCode(ResultSet resultSet) {
|
|||
|
return new JavaCodeResult("(("+this.usedid+")").attach(this.expr.printJavaCode(resultSet)).attach(")");
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
// ino.end
|