JavaPatternMatching/src/mycompiler/mystatement/Binary.java

282 lines
7.0 KiB
Java
Raw Normal View History

2013-10-18 11:33:46 +00:00
// ino.module.Binary.8623.package
package mycompiler.mystatement;
// ino.end
// ino.module.Binary.8623.import
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Vector;
import mycompiler.SyntaxTreeNode;
2013-10-18 11:33:46 +00:00
import mycompiler.mybytecode.ClassFile;
import mycompiler.mybytecode.CodeAttribute;
import mycompiler.mybytecode.JVMCode;
import mycompiler.myclass.Class;
import mycompiler.myexception.CTypeReconstructionException;
import mycompiler.myexception.JVMCodeException;
import mycompiler.myexception.SCExcept;
import mycompiler.myexception.SCStatementException;
import mycompiler.myoperator.AddOp;
import mycompiler.myoperator.LogOp;
import mycompiler.myoperator.MulOp;
import mycompiler.myoperator.Operator;
import mycompiler.myoperator.RelOp;
import mycompiler.mytype.GenericTypeVar;
import mycompiler.mytype.Type;
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
2013-10-18 11:33:46 +00:00
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
import typinferenz.ConstraintsSet;
import typinferenz.JavaCodeResult;
import typinferenz.ResultSet;
import typinferenz.assumptions.TypeAssumptions;
2013-10-18 11:33:46 +00:00
// 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<Type> paralist, Vector<GenericTypeVar> 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();
// TODO Implement Method stub
return ret;
}
@Override
public JavaCodeResult printJavaCode(ResultSet resultSet) {
throw new NotImplementedException();
}
@Override
public Vector<SyntaxTreeNode> getChildren() {
2014-04-09 13:54:20 +00:00
Vector<SyntaxTreeNode> ret = new Vector<SyntaxTreeNode>();
ret.add(this.expr1);
ret.add(this.expr2);
return ret;
}
2013-10-18 11:33:46 +00:00
}
// ino.end