// ino.module.Binary.8623.package package de.dhbwstuttgart.syntaxtree.statement; // ino.end // ino.module.Binary.8623.import import java.util.Enumeration; import java.util.HashMap; import java.util.Hashtable; import java.util.Vector; import mycompiler.mybytecode.ClassFile; import mycompiler.mybytecode.CodeAttribute; import mycompiler.mybytecode.JVMCode; import mycompiler.myexception.CTypeReconstructionException; import mycompiler.myexception.JVMCodeException; import mycompiler.myexception.SCExcept; import mycompiler.myexception.SCStatementException; import mycompiler.mytypereconstruction.CSupportData; 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 de.dhbwstuttgart.core.SyntaxTreeNode; import de.dhbwstuttgart.syntaxtree.Class; import de.dhbwstuttgart.syntaxtree.operator.AddOp; import de.dhbwstuttgart.syntaxtree.operator.LogOp; import de.dhbwstuttgart.syntaxtree.operator.MulOp; import de.dhbwstuttgart.syntaxtree.operator.Operator; import de.dhbwstuttgart.syntaxtree.operator.RelOp; import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar; import de.dhbwstuttgart.syntaxtree.type.Pair; import de.dhbwstuttgart.syntaxtree.type.RefType; import de.dhbwstuttgart.syntaxtree.type.Type; import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder; import de.dhbwstuttgart.typeinference.ConstraintsSet; import de.dhbwstuttgart.typeinference.JavaCodeResult; import de.dhbwstuttgart.typeinference.OderConstraint; import de.dhbwstuttgart.typeinference.ResultSet; import de.dhbwstuttgart.typeinference.SingleConstraint; import de.dhbwstuttgart.typeinference.UndConstraint; import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions; import sun.reflect.generics.reflectiveObjects.NotImplementedException; // ino.class.Binary.24966.description type=line // neu von Felix // ino.end // ino.class.Binary.24966.declaration public class Binary extends BinaryExpr // ino.end // ino.class.Binary.24966.body { // ino.method.Binary.24970.definition public Binary(int offset, int variableLength) // ino.end // ino.method.Binary.24970.body { super(offset,variableLength); } // ino.end // ino.attribute.parserlog.24973.decldescription type=javadoc /** * Logger: log4j */ // ino.end // ino.attribute.parserlog.24973.declaration protected static Logger parserlog = Logger.getLogger("parser"); // ino.end // ino.attribute.expr1.24976.declaration public Expr expr1; // ino.end // ino.attribute.op.24979.declaration public Operator op; // ino.end // ino.attribute.expr2.24982.declaration public Expr expr2; // ino.end // ino.method.set_Expr1.24988.definition public void set_Expr1(Expr exp) // ino.end // ino.method.set_Expr1.24988.body { this.expr1=exp; } // ino.end // ino.method.set_Expr2.24991.definition public void set_Expr2(Expr exp) // ino.end // ino.method.set_Expr2.24991.body { this.expr2=exp; } // ino.end // ino.method.set_Operator.24994.definition public void set_Operator(Operator Op) // ino.end // ino.method.set_Operator.24994.body { this.op=Op; } // ino.end // ino.method.get_Name.24997.definition public String get_Name() // ino.end // ino.method.get_Name.24997.body { return null; } // ino.end // ino.method.get_Operator.25000.definition public Operator get_Operator() // ino.end // ino.method.get_Operator.25000.body { return op; } // ino.end // ino.method.get_Expr1.25003.definition public Expr get_Expr1() // ino.end // ino.method.get_Expr1.25003.body { return expr1; } // ino.end // ino.method.get_Expr2.25006.definition public Expr get_Expr2() // ino.end // ino.method.get_Expr2.25006.body { return expr2; } // ino.end // ino.method.codegen.25009.definition public void codegen(ClassFile classfile, CodeAttribute code, Vector paralist) throws JVMCodeException // ino.end // ino.method.codegen.25009.body { if(type_check(code)) { op.codegen(classfile, code, this, false, paralist); } else { throw new JVMCodeException("JVMCodeException: Binary: void codegen(ClassFile classfile, Code_attribute code)"); } } // ino.end // ino.method.not_codegen.25012.definition public void not_codegen(ClassFile classfile, CodeAttribute code, Vector paralist) throws JVMCodeException // ino.end // ino.method.not_codegen.25012.body { if(((op instanceof RelOp) || (op instanceof LogOp)) && type_check(code)) { op.codegen(classfile, code, this, true, paralist); } else { throw new JVMCodeException("JVMCodeException: Binary: void not_codegen(ClassFile classfile, Code_attribute code)"); } } // ino.end // ino.method.neg_codegen.25015.definition public void neg_codegen(ClassFile classfile, CodeAttribute code, Vector paralist) throws JVMCodeException // ino.end // ino.method.neg_codegen.25015.body { if(((op instanceof AddOp) || (op instanceof MulOp)) && type_check(code)) { op.codegen(classfile, code, this, true, paralist); } else { throw new JVMCodeException("JVMCodeException: Binary: void neg_codegen(ClassFile classfile, Code_attribute code)"); } } // ino.end // ino.method.type_check.25018.definition public boolean type_check(CodeAttribute code) throws JVMCodeException // ino.end // ino.method.type_check.25018.body { int type1 = JVMCode.get_nType(expr1.getTypeName()); int type2 = JVMCode.get_nType(expr2.getTypeName()); if((type1 < type2) || ((type1==0 || type1==1) && (type2==2 || type2==3))) { return false; } if(type1 != type2) { code.add_code(JVMCode.n2n(expr2.getTypeName(), expr1.getTypeName())); } return true; } // ino.end // ino.method.wandleRefTypeAttributes2GenericAttributes.25027.definition public void wandleRefTypeAttributes2GenericAttributes(Vector paralist, Vector genericMethodParameters) // ino.end // ino.method.wandleRefTypeAttributes2GenericAttributes.25027.body { } // ino.end public void addOffsetsToExpression(CTypeAssumption localAssumption,String NameVariable,boolean isMemberVariable) { expr1.addOffsetsToExpression(localAssumption,NameVariable,isMemberVariable); expr2.addOffsetsToExpression(localAssumption,NameVariable,isMemberVariable); } @Override public ConstraintsSet TYPEExpr(TypeAssumptions assumptions) { ConstraintsSet ret = new ConstraintsSet(); ret.add(this.expr1.TYPEExpr(assumptions)); ret.add(this.expr2.TYPEExpr(assumptions)); /** * Berechnet die Constraints dieses Operators für die 2 gegebenen Parameter * Die Operatoren sind meistens überladen. Es entstehen mehrere Oder-Verknüpfte Constraints. * @param expr1 * @param expr2 * @return */ if(this.getType()==null)this.set_Type(TypePlaceholder.fresh(this)); OderConstraint oderCons = new OderConstraint(); HashMap rMap = this.op.getReturnTypes(assumptions); for(Type rT : rMap.keySet()){ UndConstraint c = new UndConstraint(); c.addConstraint(this.getType(),rT); c.addConstraint(this.expr1.getType(), rMap.get(rT)); c.addConstraint(this.expr2.getType(), rMap.get(rT)); oderCons.addConstraint(c); } ret.add(oderCons); return ret; } @Override public JavaCodeResult printJavaCode(ResultSet resultSet) { JavaCodeResult ret = new JavaCodeResult(); ret.attach(this.expr1.printJavaCode(resultSet)).attach(" "); ret.attach(this.op.toString()+" "); ret.attach(this.expr2.printJavaCode(resultSet)); return ret; } @Override public Vector getChildren() { Vector ret = new Vector(); ret.add(this.expr1); ret.add(this.expr2); return ret; } } // ino.end