JavaPatternMatching/src/mycompiler/myoperator/Operator.java

134 lines
4.1 KiB
Java
Raw Normal View History

2013-10-18 11:33:46 +00:00
// ino.module.Operator.8607.package
package mycompiler.myoperator;
// ino.end
// ino.module.Operator.8607.import
import java.util.HashMap;
2013-10-18 11:33:46 +00:00
import java.util.Hashtable;
import java.util.Iterator;
import java.util.Vector;
2014-04-23 15:59:39 +00:00
import typinferenz.ConstraintsSet;
import typinferenz.OderConstraint;
2014-04-23 15:59:39 +00:00
import typinferenz.SingleConstraint;
import typinferenz.UndConstraint;
2014-04-23 15:59:39 +00:00
import typinferenz.assumptions.TypeAssumptions;
import typinferenz.exceptions.TypeinferenceException;
2013-10-18 11:33:46 +00:00
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;
2014-04-23 15:59:39 +00:00
import mycompiler.mytype.Type;
import mycompiler.mytype.TypePlaceholder;
2013-10-18 11:33:46 +00:00
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<RefType, RefType> 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
2014-04-23 15:59:39 +00:00
/**
* Liefert eine HashMap der Form: HashMap<ResultType, InputType>
* @param ass
* @return
*/
public abstract HashMap<Type,Type> getReturnTypes(TypeAssumptions ass);
2014-04-23 15:59:39 +00:00
2013-10-18 11:33:46 +00:00
}
// ino.end