forked from JavaTX/JavaCompilerCore
270 lines
8.9 KiB
Java
270 lines
8.9 KiB
Java
|
// ino.module.NotExpr.8643.package
|
|||
|
package mycompiler.mystatement;
|
|||
|
// ino.end
|
|||
|
// ino.module.NotExpr.8643.import
|
|||
|
import java.util.Hashtable;
|
|||
|
import java.util.Iterator;
|
|||
|
import java.util.Vector;
|
|||
|
import mycompiler.mybytecode.ClassFile;
|
|||
|
import mycompiler.mybytecode.CodeAttribute;
|
|||
|
import mycompiler.myclass.Class;
|
|||
|
import mycompiler.myexception.CTypeReconstructionException;
|
|||
|
import mycompiler.myexception.JVMCodeException;
|
|||
|
import mycompiler.myexception.SCStatementException;
|
|||
|
import mycompiler.mytype.GenericTypeVar;
|
|||
|
import mycompiler.mytype.Pair;
|
|||
|
import mycompiler.mytype.RefType;
|
|||
|
import mycompiler.mytype.Type;
|
|||
|
import mycompiler.mytype.Void;
|
|||
|
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 mycompiler.mytypereconstruction.unify.Unify;
|
|||
|
import org.apache.log4j.Logger;
|
|||
|
// ino.end
|
|||
|
|
|||
|
import typinferenz.ConstraintsSet;
|
|||
|
import typinferenz.JavaCodeResult;
|
|||
|
import typinferenz.ResultSet;
|
|||
|
import typinferenz.TypeAssumptions;
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
// ino.class.NotExpr.25873.declaration
|
|||
|
public class NotExpr extends UnaryExpr
|
|||
|
// ino.end
|
|||
|
// ino.class.NotExpr.25873.body
|
|||
|
{
|
|||
|
// ino.method.NotExpr.25877.definition
|
|||
|
public NotExpr(int offset,int variableLength)
|
|||
|
// ino.end
|
|||
|
// ino.method.NotExpr.25877.body
|
|||
|
{
|
|||
|
super(offset,variableLength);
|
|||
|
}
|
|||
|
// ino.end
|
|||
|
// ino.attribute.not.25880.declaration
|
|||
|
private UnaryNot not;
|
|||
|
// ino.end
|
|||
|
// ino.attribute.expr.25883.declaration
|
|||
|
public Expr expr;
|
|||
|
// ino.end
|
|||
|
// ino.attribute.parserlog.25886.declaration
|
|||
|
protected static Logger parserlog = Logger.getLogger("parser");
|
|||
|
// ino.end
|
|||
|
|
|||
|
|
|||
|
|
|||
|
// ino.method.sc_check.25889.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.25889.body
|
|||
|
{
|
|||
|
if(ext)
|
|||
|
parserlog.debug(" ---NotExpr---");
|
|||
|
SCStatementException except=null;
|
|||
|
try
|
|||
|
{
|
|||
|
expr.sc_check(classname, ch, bh,ext, parach, parabh);
|
|||
|
}
|
|||
|
catch (SCStatementException ex)
|
|||
|
{
|
|||
|
except=ex;
|
|||
|
}
|
|||
|
this.setType(new Type( "boolean",getOffset()));
|
|||
|
/*if(expr.get_Type() != "int" || expr.get_Type() != "boolean")
|
|||
|
{
|
|||
|
if(ext)
|
|||
|
System.out.println("Warnung -- Typfehler!! Moeglicher Datenverlust --> NegativeExpr.sc_check()");
|
|||
|
scexcept exception =new scexcept();
|
|||
|
exception.set_error("Warnung!!! Moeglicher Datenverlust!!!");
|
|||
|
exception.set_statement("NotExpr");
|
|||
|
if(except==null)
|
|||
|
except=new SCStatementException();
|
|||
|
except.addException(exception);
|
|||
|
}*/
|
|||
|
if(except!=null)
|
|||
|
throw except;
|
|||
|
}
|
|||
|
// ino.end
|
|||
|
|
|||
|
// ino.method.get_Name.25892.definition
|
|||
|
public String get_Name()
|
|||
|
// ino.end
|
|||
|
// ino.method.get_Name.25892.body
|
|||
|
{
|
|||
|
return null;
|
|||
|
}
|
|||
|
// ino.end
|
|||
|
|
|||
|
// ino.method.get_Expr.25895.definition
|
|||
|
public Expr get_Expr()
|
|||
|
// ino.end
|
|||
|
// ino.method.get_Expr.25895.body
|
|||
|
{
|
|||
|
return expr;
|
|||
|
}
|
|||
|
// ino.end
|
|||
|
|
|||
|
// ino.method.set_UnaryNot.25898.definition
|
|||
|
public void set_UnaryNot(UnaryNot unot)
|
|||
|
// ino.end
|
|||
|
// ino.method.set_UnaryNot.25898.body
|
|||
|
{
|
|||
|
this.not = unot;
|
|||
|
}
|
|||
|
// ino.end
|
|||
|
|
|||
|
// ino.method.set_Expr.25901.definition
|
|||
|
public void set_Expr(Expr ex)
|
|||
|
// ino.end
|
|||
|
// ino.method.set_Expr.25901.body
|
|||
|
{
|
|||
|
this.expr = ex;
|
|||
|
}
|
|||
|
// ino.end
|
|||
|
|
|||
|
// ino.method.codegen.25904.definition
|
|||
|
public void codegen(ClassFile classfile, CodeAttribute code, Vector paralist)
|
|||
|
throws JVMCodeException
|
|||
|
// ino.end
|
|||
|
// ino.method.codegen.25904.body
|
|||
|
{
|
|||
|
if(expr instanceof Binary) ((Binary)expr).not_codegen(classfile, code, paralist);
|
|||
|
else if(expr instanceof NotExpr) ((NotExpr)expr).not_codegen(classfile, code, paralist);
|
|||
|
else {
|
|||
|
expr.codegen(classfile, code, paralist);
|
|||
|
not.codegen(classfile, code, true);
|
|||
|
}
|
|||
|
}
|
|||
|
// ino.end
|
|||
|
|
|||
|
// ino.method.not_codegen.25907.definition
|
|||
|
public void not_codegen(ClassFile classfile, CodeAttribute code, Vector paralist)
|
|||
|
throws JVMCodeException
|
|||
|
// ino.end
|
|||
|
// ino.method.not_codegen.25907.body
|
|||
|
{
|
|||
|
if(expr instanceof Binary) ((Binary)expr).codegen(classfile, code, paralist);
|
|||
|
else if(expr instanceof NotExpr) ((NotExpr)expr).codegen(classfile, code, paralist);
|
|||
|
else {
|
|||
|
expr.codegen(classfile, code, paralist);
|
|||
|
not.codegen(classfile, code, false);
|
|||
|
}
|
|||
|
}
|
|||
|
// ino.end
|
|||
|
/*
|
|||
|
public void if_codegen(ClassFile classfile, Code_attribute code, boolean sw) throws JVMCodeException {
|
|||
|
if(expr instanceof NotExpr) if_codegen(classfile, code, !sw);
|
|||
|
else {
|
|||
|
expr.codegen(classfile, code);
|
|||
|
not.if_codegen(classfile, code, sw);
|
|||
|
}
|
|||
|
}
|
|||
|
*/
|
|||
|
|
|||
|
// ino.method.TRExp.25910.defdescription type=javadoc
|
|||
|
/**
|
|||
|
* Implementierung des Algorithmus 5.42 von Martin Pl<EFBFBD>micke
|
|||
|
* <br/>Achtung Workaround: Wenn die BaseTypes endlich korrekt implementiert sind,
|
|||
|
* dann sollte der RefType "Boolean" <EFBFBD>berall durch den BaseType "BooleanType"
|
|||
|
* ersetzt werden!!! <br>Author: J<EFBFBD>rg B<EFBFBD>uerle
|
|||
|
* @param sigma
|
|||
|
* @param V
|
|||
|
* @param supportData
|
|||
|
* @return
|
|||
|
*/
|
|||
|
// ino.end
|
|||
|
// ino.method.TRExp.25910.definition
|
|||
|
public CTripleSet TRExp(CSubstitutionSet sigma, CTypeAssumptionSet V, CSupportData supportData)
|
|||
|
// ino.end
|
|||
|
// ino.method.TRExp.25910.body
|
|||
|
{
|
|||
|
CTripleSet returnSet = new CTripleSet();
|
|||
|
// --------------------------
|
|||
|
// TRExpr f<>r Expr rufen:
|
|||
|
// --------------------------
|
|||
|
CTripleSet exprSet = expr.TRExp(sigma, V, supportData);
|
|||
|
// --------------------------
|
|||
|
// Alle Triple durchgehen:
|
|||
|
// --------------------------
|
|||
|
Iterator<CTriple> exprIt = exprSet.getIterator();
|
|||
|
while(exprIt.hasNext()){
|
|||
|
CTriple exprTriple = exprIt.next();
|
|||
|
// --------------------------
|
|||
|
// ReturnType mit Integer unifizieren:
|
|||
|
// --------------------------
|
|||
|
Vector<Vector<Pair>> unifierPossibilities = Unify.unify(exprTriple.getResultType(), new RefType("java.lang.Boolean",getOffset()), supportData.getFiniteClosure());
|
|||
|
// --------------------------
|
|||
|
// Wenn Unifier vorhanden, dann
|
|||
|
// anwenden und Triple hinzuf<75>gen:
|
|||
|
// --------------------------
|
|||
|
if(unifierPossibilities.size()!=0){
|
|||
|
// --------------------------
|
|||
|
// Subset bauen:
|
|||
|
// --------------------------
|
|||
|
CTripleSet subSet = new CTripleSet();
|
|||
|
// --------------------------
|
|||
|
// Alle m<>glichen Unifier anwenden:
|
|||
|
// --------------------------
|
|||
|
for(int i=0; i<unifierPossibilities.size(); i++){
|
|||
|
CSubstitutionSet unifier = new CSubstitutionSet(unifierPossibilities.elementAt(i));
|
|||
|
CTriple boolTriple = exprTriple.cloneAndApplyUnify(unifier);
|
|||
|
subSet.addElement(boolTriple);
|
|||
|
}
|
|||
|
returnSet.unite(subSet);
|
|||
|
}
|
|||
|
}
|
|||
|
if(returnSet.getCardinality()==0){
|
|||
|
throw new CTypeReconstructionException("NotExpr.TRExp(): Keiner der m<>glichen Typen l<>sst sich mit Typ \"Boolean\" unifizieren.",this);
|
|||
|
}
|
|||
|
return returnSet;
|
|||
|
}
|
|||
|
// ino.end
|
|||
|
|
|||
|
// ino.method.TRStatement.25913.definition
|
|||
|
public CTripleSet TRStatement(CSubstitutionSet sigma, CTypeAssumptionSet V, CSupportData supportData)
|
|||
|
// ino.end
|
|||
|
// ino.method.TRStatement.25913.body
|
|||
|
{
|
|||
|
CTripleSet tripleSet = this.TRExp(sigma, V, supportData).deepCopy();
|
|||
|
Iterator<CTriple> tripleIt = tripleSet.getIterator();
|
|||
|
while(tripleIt.hasNext()){
|
|||
|
tripleIt.next().setResultType(new Void(getOffset()));
|
|||
|
}
|
|||
|
return tripleSet;
|
|||
|
}
|
|||
|
// ino.end
|
|||
|
// ino.method.wandleRefTypeAttributes2GenericAttributes.25916.definition
|
|||
|
public void wandleRefTypeAttributes2GenericAttributes(Vector<Type> paralist, Vector<GenericTypeVar> genericMethodParameters)
|
|||
|
// ino.end
|
|||
|
// ino.method.wandleRefTypeAttributes2GenericAttributes.25916.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) {
|
|||
|
// TODO Auto-generated method stub
|
|||
|
return null;
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
// ino.end
|