// ino.module.Operator.8607.package package mycompiler.myoperator; // ino.end // ino.module.Operator.8607.import import java.util.Hashtable; import java.util.Iterator; import java.util.Vector; import typinferenz.ConstraintsSet; import typinferenz.SingleConstraint; import typinferenz.assumptions.TypeAssumptions; import mycompiler.IItemWithOffset; import mycompiler.mybytecode.ClassFile; import mycompiler.mybytecode.CodeAttribute; import mycompiler.mybytecode.JVMCode; import mycompiler.myexception.CTypeReconstructionException; import mycompiler.myexception.JVMCodeException; import mycompiler.mystatement.Binary; import mycompiler.mystatement.Expr; import mycompiler.mytype.Pair; import mycompiler.mytype.RefType; 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.unify.Unify; // ino.end // ino.class.Operator.24257.declaration public abstract class Operator implements IItemWithOffset // ino.end // ino.class.Operator.24257.body { // ino.attribute.offset.24261.declaration private int offset; // ino.end // ino.attribute.variableLength.24264.declaration private int variableLength; // ino.end // ino.method.Operator.24267.definition public Operator(int offset,int variableLength) // ino.end // ino.method.Operator.24267.body { this.offset=offset; this.variableLength=variableLength; } // ino.end // ino.method.getOffset.24270.definition public int getOffset() // ino.end // ino.method.getOffset.24270.body { return offset; } // ino.end // ino.method.getVariableLength.24273.definition public int getVariableLength() // ino.end // ino.method.getVariableLength.24273.body { return variableLength; } // ino.end // ino.method.codegen.24276.declaration public abstract void codegen(ClassFile classfile, CodeAttribute code, Expr expr, boolean neg_not, Vector paralist) throws JVMCodeException; // ino.end /** * @author timo * This is cool: * we call the abstract parent to it him what operator-types he expects. the rest of the algorithm * is implemented in this class because it's always the same... * @see Design Pattern: Template Method */ protected abstract Hashtable getOperatorTypes( ); // ino.method.makePrimitive.29391.defdescription type=line // Unter der Annahme, dass sich ein Integer-Objekt auf dem Stack // befindet, wird dieses in den primitiven Typ int umgewandelt. // ino.end // ino.method.makePrimitive.29391.definition public void makePrimitive(ClassFile classfile, CodeAttribute code) // ino.end // ino.method.makePrimitive.29391.body { code.add_code(JVMCode.invokevirtual); code.add_code_short(classfile.add_method_ref("java/lang/Integer", "intValue", "()I")); } // ino.end // ino.method.makeWrapper.29394.defdescription type=line // Unter der Annahame, dass ein primitiver int-Typ auf dem Stack liegt, // wird dieser in den Wrapper-Typ Integer umgewandelt. // ino.end // ino.method.makeWrapper.29394.definition public void makeWrapper(ClassFile classfile, CodeAttribute code) // ino.end // ino.method.makeWrapper.29394.body { code.add_code(JVMCode.invokestatic); code.add_code_short(classfile.add_method_ref("java/lang/Integer", "valueOf", "(I)Ljava/lang/Integer;")); } // ino.end /** * Berechnet die Constraints dieses Operators für die 2 gegebenen Parameter * @param expr1 * @param expr2 * @return */ public ConstraintsSet TYPEExpr(Expr expr1, Expr expr2, TypeAssumptions ass) { ConstraintsSet ret = new ConstraintsSet(); ret.add(new SingleConstraint(expr1.getType(), this.getReturnType(ass))); ret.add(new SingleConstraint(expr2.getType(), this.getReturnType(ass))); return ret; } public abstract Type getReturnType(TypeAssumptions ass); } // ino.end