JavaPatternMatching/src/de/dhbwstuttgart/syntaxtree/operator/Operator.java

134 lines
4.3 KiB
Java
Raw Normal View History

2013-10-18 11:33:46 +00:00
// ino.module.Operator.8607.package
2014-09-02 08:33:54 +00:00
package de.dhbwstuttgart.syntaxtree.operator;
2013-10-18 11:33:46 +00:00
// 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 de.dhbwstuttgart.typeinference.Menge;
2014-04-23 15:59:39 +00:00
2014-09-04 14:35:44 +00:00
import de.dhbwstuttgart.bytecode.ClassFile;
import de.dhbwstuttgart.bytecode.CodeAttribute;
import de.dhbwstuttgart.bytecode.JVMCode;
2014-09-02 08:33:54 +00:00
import de.dhbwstuttgart.core.IItemWithOffset;
2014-09-04 14:35:44 +00:00
import de.dhbwstuttgart.myexception.CTypeReconstructionException;
import de.dhbwstuttgart.myexception.JVMCodeException;
2014-09-08 13:12:47 +00:00
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
2014-09-02 08:33:54 +00:00
import de.dhbwstuttgart.syntaxtree.statement.Binary;
import de.dhbwstuttgart.syntaxtree.statement.Expr;
import de.dhbwstuttgart.syntaxtree.type.RefType;
import de.dhbwstuttgart.syntaxtree.type.Type;
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
2014-09-08 13:12:47 +00:00
import de.dhbwstuttgart.typeinference.ConstraintType;
2014-09-02 08:33:54 +00:00
import de.dhbwstuttgart.typeinference.ConstraintsSet;
import de.dhbwstuttgart.typeinference.OderConstraint;
2014-09-08 13:12:47 +00:00
import de.dhbwstuttgart.typeinference.Pair;
2014-09-02 08:33:54 +00:00
import de.dhbwstuttgart.typeinference.SingleConstraint;
import de.dhbwstuttgart.typeinference.UndConstraint;
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
import de.dhbwstuttgart.typeinference.exceptions.TypeinferenceException;
2014-09-02 09:07:16 +00:00
import de.dhbwstuttgart.typeinference.unify.Unify;
2013-10-18 11:33:46 +00:00
// ino.class.Operator.24257.declaration
2014-09-08 13:12:47 +00:00
public abstract class Operator extends SyntaxTreeNode
2013-10-18 11:33:46 +00:00
// 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, Menge paralist)
2013-10-18 11:33:46 +00:00
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
*/
2014-09-08 13:12:47 +00:00
public abstract HashMap<ConstraintType,ConstraintType> getReturnTypes(TypeAssumptions ass);
2014-04-23 15:59:39 +00:00
2014-09-08 13:12:47 +00:00
@Override
public Menge<SyntaxTreeNode> getChildren() {
return new Menge<>();
2014-09-08 13:12:47 +00:00
}
2013-10-18 11:33:46 +00:00
}
// ino.end