Tests für verschiedene Statements angelegt

If, IfElse Implementiert
Fehlende Interface Implementierungen mit NotImplementedException hinzugefügt
This commit is contained in:
Enrico Schrödter 2015-10-13 19:25:51 +02:00
parent eb3db718ad
commit bcbe82c64e
37 changed files with 321 additions and 77 deletions

View File

@ -0,0 +1,10 @@
package de.dhbwstuttgart.myexception;
public class NotImplementedException extends RuntimeException {
/**
*
*/
private static final long serialVersionUID = 1L;
}

View File

@ -10,6 +10,7 @@ import org.apache.commons.bcel6.generic.ClassGen;
import org.apache.commons.bcel6.generic.InstructionList; import org.apache.commons.bcel6.generic.InstructionList;
import de.dhbwstuttgart.typeinference.Menge; import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.bytecode.ClassGenerator;
import de.dhbwstuttgart.logger.Logger; import de.dhbwstuttgart.logger.Logger;
import de.dhbwstuttgart.myexception.CTypeReconstructionException; import de.dhbwstuttgart.myexception.CTypeReconstructionException;
import de.dhbwstuttgart.myexception.JVMCodeException; import de.dhbwstuttgart.myexception.JVMCodeException;
@ -214,10 +215,14 @@ public JavaCodeResult printJavaCode(ResultSet resultSet) {
return ret; return ret;
} }
private InstructionList genUnboxByteCode(ClassGen _cg, Type t){
return null;
}
@Override @Override
public InstructionList genByteCode(ClassGen _cg, TypeAssumptions ass) { public InstructionList genByteCode(ClassGenerator _cg) {
InstructionList linkeSeite = this.expr1.genByteCode(_cg); InstructionList linkeSeite = this.expr1.genByteCode(_cg);
InstructionList rechteSeite = this.expr2.genByteCode(_cg); InstructionList rechteSeite = this.expr2.genByteCode(_cg);
if(this.getReturnType().getName().equals(new JavaClassName("String"))){ if(this.getReturnType().getName().equals(new JavaClassName("String"))){
@ -227,9 +232,5 @@ public JavaCodeResult printJavaCode(ResultSet resultSet) {
return null; return null;
} }
private InstructionList genUnboxByteCode(ClassGen _cg, Type t){
return null;
}
} }
// ino.end // ino.end

View File

@ -5,10 +5,12 @@ package de.dhbwstuttgart.syntaxtree.statement;
import java.util.Hashtable; import java.util.Hashtable;
import org.apache.commons.bcel6.generic.ClassGen; import org.apache.commons.bcel6.generic.ClassGen;
import org.apache.commons.bcel6.generic.InstructionConstants;
import org.apache.commons.bcel6.generic.InstructionFactory; import org.apache.commons.bcel6.generic.InstructionFactory;
import org.apache.commons.bcel6.generic.InstructionList; import org.apache.commons.bcel6.generic.InstructionList;
import de.dhbwstuttgart.typeinference.Menge; import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.bytecode.ClassGenerator;
import de.dhbwstuttgart.logger.Logger; import de.dhbwstuttgart.logger.Logger;
import de.dhbwstuttgart.myexception.CTypeReconstructionException; import de.dhbwstuttgart.myexception.CTypeReconstructionException;
import de.dhbwstuttgart.myexception.JVMCodeException; import de.dhbwstuttgart.myexception.JVMCodeException;
@ -128,17 +130,16 @@ public class BoolLiteral extends Literal
} }
@Override @Override
public InstructionList genByteCode(ClassGen cg) { public InstructionList genByteCode(ClassGenerator _cg) {
InstructionFactory _factory = new InstructionFactory(cg, cg.getConstantPool()); InstructionFactory _factory = new InstructionFactory(_cg, _cg.getConstantPool());
InstructionList il = new InstructionList(); InstructionList il = new InstructionList();
if (Bool == true){ if (Bool == true){
il.append(_factory.ICONST_1); il.append(InstructionConstants.ICONST_1);
}else { }else {
il.append(_factory.ICONST_0); il.append(InstructionConstants.ICONST_0);
} }
return il; return il;
} }

View File

@ -6,11 +6,14 @@ import java.util.Hashtable;
import java.util.Iterator; import java.util.Iterator;
import org.apache.commons.bcel6.generic.ClassGen; import org.apache.commons.bcel6.generic.ClassGen;
import org.apache.commons.bcel6.generic.InstructionList;
import de.dhbwstuttgart.typeinference.Menge; import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.bytecode.ClassGenerator;
import de.dhbwstuttgart.logger.Logger; import de.dhbwstuttgart.logger.Logger;
import de.dhbwstuttgart.myexception.CTypeReconstructionException; import de.dhbwstuttgart.myexception.CTypeReconstructionException;
import de.dhbwstuttgart.myexception.JVMCodeException; import de.dhbwstuttgart.myexception.JVMCodeException;
import de.dhbwstuttgart.myexception.NotImplementedException;
import de.dhbwstuttgart.myexception.SCExcept; import de.dhbwstuttgart.myexception.SCExcept;
import de.dhbwstuttgart.myexception.SCStatementException; import de.dhbwstuttgart.myexception.SCStatementException;
import de.dhbwstuttgart.syntaxtree.Class; import de.dhbwstuttgart.syntaxtree.Class;
@ -119,12 +122,10 @@ public class CastExpr extends UnaryExpr
return ret; return ret;
} }
@Override @Override
public void genByteCode(ClassGen _cg) { public InstructionList genByteCode(ClassGenerator _cg) {
// TODO Auto-generated method stub // TODO Bytecode
throw new NotImplementedException();
} }

View File

@ -10,6 +10,7 @@ import org.apache.commons.bcel6.generic.InstructionFactory;
import org.apache.commons.bcel6.generic.InstructionList; import org.apache.commons.bcel6.generic.InstructionList;
import de.dhbwstuttgart.typeinference.Menge; import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.bytecode.ClassGenerator;
import de.dhbwstuttgart.logger.Logger; import de.dhbwstuttgart.logger.Logger;
import de.dhbwstuttgart.myexception.CTypeReconstructionException; import de.dhbwstuttgart.myexception.CTypeReconstructionException;
import de.dhbwstuttgart.myexception.JVMCodeException; import de.dhbwstuttgart.myexception.JVMCodeException;
@ -121,9 +122,11 @@ public class CharLiteral extends Literal
{ {
return Char; return Char;
} }
@Override @Override
public InstructionList genByteCode(ClassGen cg) { public InstructionList genByteCode(ClassGenerator _cg) {
InstructionFactory _factory = new InstructionFactory(cg, cg.getConstantPool()); InstructionFactory _factory = new InstructionFactory(_cg, _cg.getConstantPool());
InstructionList il = new InstructionList(); InstructionList il = new InstructionList();
il.append(new BIPUSH((byte) get_Char())); il.append(new BIPUSH((byte) get_Char()));
return il; return il;

View File

@ -13,6 +13,7 @@ import org.apache.commons.bcel6.generic.LDC;
import org.apache.commons.bcel6.generic.LDC2_W; import org.apache.commons.bcel6.generic.LDC2_W;
import de.dhbwstuttgart.typeinference.Menge; import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.bytecode.ClassGenerator;
import de.dhbwstuttgart.logger.Logger; import de.dhbwstuttgart.logger.Logger;
import de.dhbwstuttgart.myexception.CTypeReconstructionException; import de.dhbwstuttgart.myexception.CTypeReconstructionException;
import de.dhbwstuttgart.myexception.JVMCodeException; import de.dhbwstuttgart.myexception.JVMCodeException;
@ -144,15 +145,14 @@ public JavaCodeResult printJavaCode(ResultSet resultSet) {
}*/ }*/
@Override @Override
public InstructionList genByteCode(ClassGen cg) { public InstructionList genByteCode(ClassGenerator _cg) {
ConstantPoolGen cp = cg.getConstantPool(); ConstantPoolGen cp = _cg.getConstantPool();
//InstructionFactory _factory = new InstructionFactory(cg, cp); //InstructionFactory _factory = new InstructionFactory(cg, cp);
InstructionList il = new InstructionList(); InstructionList il = new InstructionList();
cp.addDouble(get_Double()); cp.addDouble(get_Double());
il.append(new LDC2_W(cp.getSize()-1)); il.append(new LDC2_W(cp.getSize()-1));
return il; return il;
} }
} }

View File

@ -5,8 +5,10 @@ package de.dhbwstuttgart.syntaxtree.statement;
import java.util.Hashtable; import java.util.Hashtable;
import org.apache.commons.bcel6.generic.ClassGen; import org.apache.commons.bcel6.generic.ClassGen;
import org.apache.commons.bcel6.generic.InstructionList;
import de.dhbwstuttgart.typeinference.Menge; import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.bytecode.ClassGenerator;
import de.dhbwstuttgart.logger.Logger; import de.dhbwstuttgart.logger.Logger;
import de.dhbwstuttgart.myexception.CTypeReconstructionException; import de.dhbwstuttgart.myexception.CTypeReconstructionException;
import de.dhbwstuttgart.myexception.JVMCodeException; import de.dhbwstuttgart.myexception.JVMCodeException;
@ -86,11 +88,10 @@ public class EmptyStmt extends Statement
return new Menge<SyntaxTreeNode>(); return new Menge<SyntaxTreeNode>();
} }
@Override @Override
public void genByteCode(ClassGen _cg) { public InstructionList genByteCode(ClassGenerator _cg) {
// TODO Auto-generated method stub // TODO Bytecode
throw new NotImplementedException();
} }
} }

View File

@ -11,6 +11,7 @@ import org.apache.commons.bcel6.generic.LDC;
import org.apache.commons.bcel6.generic.LDC2_W; import org.apache.commons.bcel6.generic.LDC2_W;
import de.dhbwstuttgart.typeinference.Menge; import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.bytecode.ClassGenerator;
import de.dhbwstuttgart.logger.Logger; import de.dhbwstuttgart.logger.Logger;
import de.dhbwstuttgart.myexception.CTypeReconstructionException; import de.dhbwstuttgart.myexception.CTypeReconstructionException;
import de.dhbwstuttgart.myexception.JVMCodeException; import de.dhbwstuttgart.myexception.JVMCodeException;
@ -132,14 +133,13 @@ public JavaCodeResult printJavaCode(ResultSet resultSet) {
} }
@Override @Override
public InstructionList genByteCode(ClassGen cg) { public InstructionList genByteCode(ClassGenerator _cg) {
ConstantPoolGen cp = cg.getConstantPool(); ConstantPoolGen cp = _cg.getConstantPool();
InstructionList il = new InstructionList(); InstructionList il = new InstructionList();
cp.addFloat(get_Float()); cp.addFloat(get_Float());
il.append(new LDC(cp.getSize()-1)); il.append(new LDC(cp.getSize()-1));
return il; return il;
} }
} }
// ino.end // ino.end

View File

@ -5,8 +5,10 @@ import java.util.Hashtable;
import java.util.Iterator; import java.util.Iterator;
import org.apache.commons.bcel6.generic.ClassGen; import org.apache.commons.bcel6.generic.ClassGen;
import org.apache.commons.bcel6.generic.InstructionList;
import de.dhbwstuttgart.typeinference.Menge; import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.bytecode.ClassGenerator;
import de.dhbwstuttgart.logger.Logger; import de.dhbwstuttgart.logger.Logger;
import de.dhbwstuttgart.myexception.CTypeReconstructionException; import de.dhbwstuttgart.myexception.CTypeReconstructionException;
import de.dhbwstuttgart.myexception.JVMCodeException; import de.dhbwstuttgart.myexception.JVMCodeException;
@ -118,8 +120,8 @@ public JavaCodeResult printJavaCode(ResultSet resultSet) {
} }
@Override @Override
public void genByteCode(ClassGen _cg) { public InstructionList genByteCode(ClassGenerator _cg) {
// TODO Auto-generated method stub // TODO Bytecode
throw new NotImplementedException();
} }
} }

View File

@ -6,10 +6,26 @@ import java.util.Enumeration;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.Iterator; import java.util.Iterator;
import org.apache.commons.bcel6.Constants;
import org.apache.commons.bcel6.generic.ALOAD;
import org.apache.commons.bcel6.generic.ASTORE;
import org.apache.commons.bcel6.generic.BranchInstruction;
import org.apache.commons.bcel6.generic.ClassGen; import org.apache.commons.bcel6.generic.ClassGen;
import org.apache.commons.bcel6.generic.GOTO;
import org.apache.commons.bcel6.generic.GotoInstruction;
import org.apache.commons.bcel6.generic.IFEQ;
import org.apache.commons.bcel6.generic.IFNONNULL;
import org.apache.commons.bcel6.generic.IfInstruction;
import org.apache.commons.bcel6.generic.Instruction;
import org.apache.commons.bcel6.generic.InstructionFactory;
import org.apache.commons.bcel6.generic.InstructionHandle;
import org.apache.commons.bcel6.generic.InstructionList;
import org.apache.commons.bcel6.generic.NOP;
import de.dhbwstuttgart.typeinference.Menge; import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.bytecode.ClassGenerator;
import de.dhbwstuttgart.logger.Logger; import de.dhbwstuttgart.logger.Logger;
import de.dhbwstuttgart.logger.Section;
import de.dhbwstuttgart.myexception.CTypeReconstructionException; import de.dhbwstuttgart.myexception.CTypeReconstructionException;
import de.dhbwstuttgart.myexception.JVMCodeException; import de.dhbwstuttgart.myexception.JVMCodeException;
import de.dhbwstuttgart.myexception.SCExcept; import de.dhbwstuttgart.myexception.SCExcept;
@ -161,12 +177,27 @@ public class IfStmt extends Statement
return ret; return ret;
} }
@Override @Override
public void genByteCode(ClassGen _cg) { public InstructionList genByteCode(ClassGenerator _cg) {
// TODO Auto-generated method stub InstructionFactory _factory = new InstructionFactory(_cg, _cg.getConstantPool());
InstructionList il = new InstructionList();
IfInstruction ifInstruction = new IFEQ(null);
il.append(expr.genByteCode(_cg));
il.append(ifInstruction);
il.append(then_block.genByteCode(_cg));
if(else_block != null && !(else_block instanceof EmptyStmt)){
GotoInstruction gotoInstruction = new GOTO(null);
il.append(gotoInstruction);
ifInstruction.setTarget(il.append(else_block.genByteCode(_cg)));
gotoInstruction.setTarget(il.append(new NOP()));
}else{
ifInstruction.setTarget(il.append(new NOP()));
}
return il;
} }
} }
// ino.end // ino.end

View File

@ -7,11 +7,14 @@ import java.util.Hashtable;
import java.util.Iterator; import java.util.Iterator;
import org.apache.commons.bcel6.generic.ClassGen; import org.apache.commons.bcel6.generic.ClassGen;
import org.apache.commons.bcel6.generic.InstructionList;
import de.dhbwstuttgart.typeinference.Menge; import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.bytecode.ClassGenerator;
import de.dhbwstuttgart.logger.Logger; import de.dhbwstuttgart.logger.Logger;
import de.dhbwstuttgart.myexception.CTypeReconstructionException; import de.dhbwstuttgart.myexception.CTypeReconstructionException;
import de.dhbwstuttgart.myexception.JVMCodeException; import de.dhbwstuttgart.myexception.JVMCodeException;
import de.dhbwstuttgart.myexception.NotImplementedException;
import de.dhbwstuttgart.syntaxtree.Class; import de.dhbwstuttgart.syntaxtree.Class;
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode; import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
import de.dhbwstuttgart.syntaxtree.misc.UsedId; import de.dhbwstuttgart.syntaxtree.misc.UsedId;
@ -217,9 +220,9 @@ public class InstVar extends Expr
} }
@Override @Override
public void genByteCode(ClassGen _cg) { public InstructionList genByteCode(ClassGenerator _cg) {
// TODO Auto-generated method stub // TODO Bytecode
throw new NotImplementedException();
} }
} }
// ino.end // ino.end

View File

@ -6,11 +6,14 @@ import java.util.Enumeration;
import java.util.Hashtable; import java.util.Hashtable;
import org.apache.commons.bcel6.generic.ClassGen; import org.apache.commons.bcel6.generic.ClassGen;
import org.apache.commons.bcel6.generic.InstructionList;
import de.dhbwstuttgart.typeinference.Menge; import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.bytecode.ClassGenerator;
import de.dhbwstuttgart.logger.Logger; import de.dhbwstuttgart.logger.Logger;
import de.dhbwstuttgart.myexception.CTypeReconstructionException; import de.dhbwstuttgart.myexception.CTypeReconstructionException;
import de.dhbwstuttgart.myexception.JVMCodeException; import de.dhbwstuttgart.myexception.JVMCodeException;
import de.dhbwstuttgart.myexception.NotImplementedException;
import de.dhbwstuttgart.myexception.SCStatementException; import de.dhbwstuttgart.myexception.SCStatementException;
import de.dhbwstuttgart.syntaxtree.Class; import de.dhbwstuttgart.syntaxtree.Class;
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode; import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
@ -116,9 +119,9 @@ public JavaCodeResult printJavaCode(ResultSet resultSet) {
} }
@Override @Override
public void genByteCode(ClassGen _cg) { public InstructionList genByteCode(ClassGenerator _cg) {
// TODO Auto-generated method stub // TODO Bytecode
throw new NotImplementedException();
} }

View File

@ -10,6 +10,7 @@ import org.apache.commons.bcel6.generic.InstructionList;
import org.apache.commons.bcel6.generic.LDC2_W; import org.apache.commons.bcel6.generic.LDC2_W;
import de.dhbwstuttgart.typeinference.Menge; import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.bytecode.ClassGenerator;
import de.dhbwstuttgart.logger.Logger; import de.dhbwstuttgart.logger.Logger;
import de.dhbwstuttgart.myexception.CTypeReconstructionException; import de.dhbwstuttgart.myexception.CTypeReconstructionException;
import de.dhbwstuttgart.myexception.JVMCodeException; import de.dhbwstuttgart.myexception.JVMCodeException;
@ -128,15 +129,14 @@ public JavaCodeResult printJavaCode(ResultSet resultSet) {
} }
@Override @Override
public InstructionList genByteCode(ClassGen cg) { public InstructionList genByteCode(ClassGenerator _cg) {
ConstantPoolGen cp = cg.getConstantPool(); ConstantPoolGen cp = _cg.getConstantPool();
//InstructionFactory _factory = new InstructionFactory(cg, cp); //InstructionFactory _factory = new InstructionFactory(cg, cp);
InstructionList il = new InstructionList(); InstructionList il = new InstructionList();
cp.addLong(get_Long()); cp.addLong(get_Long());
il.append(new LDC2_W(cp.getSize()-1)); il.append(new LDC2_W(cp.getSize()-1));
return il; return il;
} }
} }
// ino.end // ino.end

View File

@ -6,11 +6,14 @@ import java.util.Hashtable;
import java.util.Iterator; import java.util.Iterator;
import org.apache.commons.bcel6.generic.ClassGen; import org.apache.commons.bcel6.generic.ClassGen;
import org.apache.commons.bcel6.generic.InstructionList;
import de.dhbwstuttgart.typeinference.Menge; import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.bytecode.ClassGenerator;
import de.dhbwstuttgart.logger.Logger; import de.dhbwstuttgart.logger.Logger;
import de.dhbwstuttgart.myexception.CTypeReconstructionException; import de.dhbwstuttgart.myexception.CTypeReconstructionException;
import de.dhbwstuttgart.myexception.JVMCodeException; import de.dhbwstuttgart.myexception.JVMCodeException;
import de.dhbwstuttgart.myexception.NotImplementedException;
import de.dhbwstuttgart.myexception.SCExcept; import de.dhbwstuttgart.myexception.SCExcept;
import de.dhbwstuttgart.myexception.SCStatementException; import de.dhbwstuttgart.myexception.SCStatementException;
import de.dhbwstuttgart.syntaxtree.Class; import de.dhbwstuttgart.syntaxtree.Class;
@ -109,9 +112,9 @@ public class NegativeExpr extends UnaryExpr
} }
@Override @Override
public void genByteCode(ClassGen _cg) { public InstructionList genByteCode(ClassGenerator _cg) {
// TODO Auto-generated method stub // TODO Bytecode
throw new NotImplementedException();
} }
} }

View File

@ -9,6 +9,7 @@ import org.apache.commons.bcel6.generic.InstructionFactory;
import org.apache.commons.bcel6.generic.InstructionList; import org.apache.commons.bcel6.generic.InstructionList;
import de.dhbwstuttgart.typeinference.Menge; import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.bytecode.ClassGenerator;
import de.dhbwstuttgart.logger.Logger; import de.dhbwstuttgart.logger.Logger;
import de.dhbwstuttgart.myexception.CTypeReconstructionException; import de.dhbwstuttgart.myexception.CTypeReconstructionException;
import de.dhbwstuttgart.myexception.JVMCodeException; import de.dhbwstuttgart.myexception.JVMCodeException;
@ -146,12 +147,11 @@ public JavaCodeResult printJavaCode(ResultSet resultSet) {
} }
@Override @Override
public InstructionList genByteCode(ClassGen cg) { public InstructionList genByteCode(ClassGenerator _cg) {
InstructionFactory _factory = new InstructionFactory(_cg, _cg.getConstantPool());
InstructionFactory _factory = new InstructionFactory(cg, cg.getConstantPool());
InstructionList il = new InstructionList(); InstructionList il = new InstructionList();
il.append(expr.elementAt(0).genByteCode(cg)); il.append(expr.elementAt(0).genByteCode(_cg));
il.append(_factory.createNewArray( org.apache.commons.bcel6.generic.Type.getType(getTypeName()), (short)1)); il.append(_factory.createNewArray( org.apache.commons.bcel6.generic.Type.getType(getTypeName()), (short)1));

View File

@ -7,11 +7,14 @@ import java.util.Hashtable;
import java.util.Iterator; import java.util.Iterator;
import org.apache.commons.bcel6.generic.ClassGen; import org.apache.commons.bcel6.generic.ClassGen;
import org.apache.commons.bcel6.generic.InstructionList;
import de.dhbwstuttgart.typeinference.Menge; import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.bytecode.ClassGenerator;
import de.dhbwstuttgart.logger.Logger; import de.dhbwstuttgart.logger.Logger;
import de.dhbwstuttgart.myexception.CTypeReconstructionException; import de.dhbwstuttgart.myexception.CTypeReconstructionException;
import de.dhbwstuttgart.myexception.JVMCodeException; import de.dhbwstuttgart.myexception.JVMCodeException;
import de.dhbwstuttgart.myexception.NotImplementedException;
import de.dhbwstuttgart.myexception.SCExcept; import de.dhbwstuttgart.myexception.SCExcept;
import de.dhbwstuttgart.myexception.SCStatementException; import de.dhbwstuttgart.myexception.SCStatementException;
import de.dhbwstuttgart.syntaxtree.Class; import de.dhbwstuttgart.syntaxtree.Class;
@ -204,9 +207,9 @@ public class NewClass extends Expr
} }
@Override @Override
public void genByteCode(ClassGen _cg) { public InstructionList genByteCode(ClassGenerator _cg) {
// TODO Auto-generated method stub // TODO Bytecode
throw new NotImplementedException();
} }

View File

@ -6,11 +6,14 @@ import java.util.Hashtable;
import java.util.Iterator; import java.util.Iterator;
import org.apache.commons.bcel6.generic.ClassGen; import org.apache.commons.bcel6.generic.ClassGen;
import org.apache.commons.bcel6.generic.InstructionList;
import de.dhbwstuttgart.typeinference.Menge; import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.bytecode.ClassGenerator;
import de.dhbwstuttgart.logger.Logger; import de.dhbwstuttgart.logger.Logger;
import de.dhbwstuttgart.myexception.CTypeReconstructionException; import de.dhbwstuttgart.myexception.CTypeReconstructionException;
import de.dhbwstuttgart.myexception.JVMCodeException; import de.dhbwstuttgart.myexception.JVMCodeException;
import de.dhbwstuttgart.myexception.NotImplementedException;
import de.dhbwstuttgart.myexception.SCStatementException; import de.dhbwstuttgart.myexception.SCStatementException;
import de.dhbwstuttgart.syntaxtree.Class; import de.dhbwstuttgart.syntaxtree.Class;
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode; import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
@ -133,9 +136,9 @@ public JavaCodeResult printJavaCode(ResultSet resultSet) {
} }
@Override @Override
public void genByteCode(ClassGen _cg) { public InstructionList genByteCode(ClassGenerator _cg) {
// TODO Auto-generated method stub // TODO Bytecode
throw new NotImplementedException();
} }
} }

View File

@ -5,11 +5,14 @@ package de.dhbwstuttgart.syntaxtree.statement;
import java.util.Hashtable; import java.util.Hashtable;
import org.apache.commons.bcel6.generic.ClassGen; import org.apache.commons.bcel6.generic.ClassGen;
import org.apache.commons.bcel6.generic.InstructionList;
import de.dhbwstuttgart.typeinference.Menge; import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.bytecode.ClassGenerator;
import de.dhbwstuttgart.logger.Logger; import de.dhbwstuttgart.logger.Logger;
import de.dhbwstuttgart.myexception.CTypeReconstructionException; import de.dhbwstuttgart.myexception.CTypeReconstructionException;
import de.dhbwstuttgart.myexception.JVMCodeException; import de.dhbwstuttgart.myexception.JVMCodeException;
import de.dhbwstuttgart.myexception.NotImplementedException;
import de.dhbwstuttgart.syntaxtree.Class; import de.dhbwstuttgart.syntaxtree.Class;
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode; import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar; import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar;
@ -117,9 +120,9 @@ public JavaCodeResult printJavaCode(ResultSet resultSet) {
} }
@Override @Override
public void genByteCode(ClassGen _cg) { public InstructionList genByteCode(ClassGenerator _cg) {
// TODO Auto-generated method stub // TODO Bytecode
throw new NotImplementedException();
} }
} }

View File

@ -6,11 +6,14 @@ import java.util.Hashtable;
import java.util.Iterator; import java.util.Iterator;
import org.apache.commons.bcel6.generic.ClassGen; import org.apache.commons.bcel6.generic.ClassGen;
import org.apache.commons.bcel6.generic.InstructionList;
import de.dhbwstuttgart.typeinference.Menge; import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.bytecode.ClassGenerator;
import de.dhbwstuttgart.logger.Logger; import de.dhbwstuttgart.logger.Logger;
import de.dhbwstuttgart.myexception.CTypeReconstructionException; import de.dhbwstuttgart.myexception.CTypeReconstructionException;
import de.dhbwstuttgart.myexception.JVMCodeException; import de.dhbwstuttgart.myexception.JVMCodeException;
import de.dhbwstuttgart.myexception.NotImplementedException;
import de.dhbwstuttgart.myexception.SCExcept; import de.dhbwstuttgart.myexception.SCExcept;
import de.dhbwstuttgart.myexception.SCStatementException; import de.dhbwstuttgart.myexception.SCStatementException;
import de.dhbwstuttgart.syntaxtree.Class; import de.dhbwstuttgart.syntaxtree.Class;
@ -90,9 +93,9 @@ public JavaCodeResult printJavaCode(ResultSet resultSet) {
} }
@Override @Override
public void genByteCode(ClassGen _cg) { public InstructionList genByteCode(ClassGenerator _cg) {
// TODO Auto-generated method stub // TODO Bytecode
throw new NotImplementedException();
} }
} }

View File

@ -12,6 +12,7 @@ import org.apache.commons.bcel6.generic.InstructionFactory;
import org.apache.commons.bcel6.generic.InstructionList; import org.apache.commons.bcel6.generic.InstructionList;
import de.dhbwstuttgart.typeinference.Menge; import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.bytecode.ClassGenerator;
import de.dhbwstuttgart.logger.Logger; import de.dhbwstuttgart.logger.Logger;
import de.dhbwstuttgart.myexception.CTypeReconstructionException; import de.dhbwstuttgart.myexception.CTypeReconstructionException;
import de.dhbwstuttgart.myexception.JVMCodeException; import de.dhbwstuttgart.myexception.JVMCodeException;
@ -100,9 +101,10 @@ public JavaCodeResult printJavaCode(ResultSet resultSet) {
} }
public static int counterPostInc = 0; public static int counterPostInc = 0;
@Override @Override
public InstructionList genByteCode(ClassGen cg) { public InstructionList genByteCode(ClassGenerator _cg) {
InstructionFactory _factory = new InstructionFactory(cg, cg.getConstantPool()); InstructionFactory _factory = new InstructionFactory(_cg, _cg.getConstantPool());
InstructionList il = new InstructionList(); InstructionList il = new InstructionList();
counterPostInc++; counterPostInc++;
il.append(new IINC(counterPostInc,1)); il.append(new IINC(counterPostInc,1));

View File

@ -6,11 +6,14 @@ import java.util.Hashtable;
import java.util.Iterator; import java.util.Iterator;
import org.apache.commons.bcel6.generic.ClassGen; import org.apache.commons.bcel6.generic.ClassGen;
import org.apache.commons.bcel6.generic.InstructionList;
import de.dhbwstuttgart.typeinference.Menge; import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.bytecode.ClassGenerator;
import de.dhbwstuttgart.logger.Logger; import de.dhbwstuttgart.logger.Logger;
import de.dhbwstuttgart.myexception.CTypeReconstructionException; import de.dhbwstuttgart.myexception.CTypeReconstructionException;
import de.dhbwstuttgart.myexception.JVMCodeException; import de.dhbwstuttgart.myexception.JVMCodeException;
import de.dhbwstuttgart.myexception.NotImplementedException;
import de.dhbwstuttgart.myexception.SCExcept; import de.dhbwstuttgart.myexception.SCExcept;
import de.dhbwstuttgart.myexception.SCStatementException; import de.dhbwstuttgart.myexception.SCStatementException;
import de.dhbwstuttgart.syntaxtree.Class; import de.dhbwstuttgart.syntaxtree.Class;
@ -87,10 +90,11 @@ public class PreDecExpr extends UnaryExpr
ret.add(this.expr); ret.add(this.expr);
return ret; return ret;
} }
@Override
public void genByteCode(ClassGen _cg) {
// TODO Auto-generated method stub
@Override
public InstructionList genByteCode(ClassGenerator _cg) {
// TODO Bytecode
throw new NotImplementedException();
} }
} }

View File

@ -6,11 +6,14 @@ import java.util.Hashtable;
import java.util.Iterator; import java.util.Iterator;
import org.apache.commons.bcel6.generic.ClassGen; import org.apache.commons.bcel6.generic.ClassGen;
import org.apache.commons.bcel6.generic.InstructionList;
import de.dhbwstuttgart.typeinference.Menge; import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.bytecode.ClassGenerator;
import de.dhbwstuttgart.logger.Logger; import de.dhbwstuttgart.logger.Logger;
import de.dhbwstuttgart.myexception.CTypeReconstructionException; import de.dhbwstuttgart.myexception.CTypeReconstructionException;
import de.dhbwstuttgart.myexception.JVMCodeException; import de.dhbwstuttgart.myexception.JVMCodeException;
import de.dhbwstuttgart.myexception.NotImplementedException;
import de.dhbwstuttgart.myexception.SCExcept; import de.dhbwstuttgart.myexception.SCExcept;
import de.dhbwstuttgart.myexception.SCStatementException; import de.dhbwstuttgart.myexception.SCStatementException;
import de.dhbwstuttgart.syntaxtree.Class; import de.dhbwstuttgart.syntaxtree.Class;
@ -91,9 +94,9 @@ public JavaCodeResult printJavaCode(ResultSet resultSet) {
} }
@Override @Override
public void genByteCode(ClassGen _cg) { public InstructionList genByteCode(ClassGenerator _cg) {
// TODO Auto-generated method stub // TODO Bytecode
throw new NotImplementedException();
} }
} }

View File

@ -7,8 +7,10 @@ import java.util.Hashtable;
import java.util.Iterator; import java.util.Iterator;
import org.apache.commons.bcel6.generic.ClassGen; import org.apache.commons.bcel6.generic.ClassGen;
import org.apache.commons.bcel6.generic.InstructionList;
import de.dhbwstuttgart.typeinference.Menge; import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.bytecode.ClassGenerator;
import de.dhbwstuttgart.logger.Logger; import de.dhbwstuttgart.logger.Logger;
import de.dhbwstuttgart.myexception.CTypeReconstructionException; import de.dhbwstuttgart.myexception.CTypeReconstructionException;
import de.dhbwstuttgart.myexception.JVMCodeException; import de.dhbwstuttgart.myexception.JVMCodeException;
@ -135,9 +137,9 @@ public class WhileStmt extends Statement
} }
@Override @Override
public void genByteCode(ClassGen _cg) { public InstructionList genByteCode(ClassGenerator _cg) {
// TODO Auto-generated method stub // TODO Bytecode
throw new NotImplementedException();
} }
} }
// ino.end // ino.end

View File

@ -1,7 +1,7 @@
package de.dhbwstuttgart.syntaxtree.type; package de.dhbwstuttgart.syntaxtree.type;
import de.dhbwstuttgart.typeinference.Menge; import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.bytecode.ClassGenerator;
import de.dhbwstuttgart.parser.JavaClassName; import de.dhbwstuttgart.parser.JavaClassName;
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode; import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
import de.dhbwstuttgart.typeinference.JavaCodeResult; import de.dhbwstuttgart.typeinference.JavaCodeResult;
@ -170,4 +170,10 @@ public class FreshWildcardType extends Type {
public JavaCodeResult printJavaCode(ResultSet resultSet) { public JavaCodeResult printJavaCode(ResultSet resultSet) {
throw new NotImplementedException(); throw new NotImplementedException();
} }
@Override
public org.apache.commons.bcel6.generic.Type getBytecodeType(ClassGenerator cg) {
// TODO: Bytecode
return null;
}
} }

View File

@ -17,6 +17,7 @@ import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
import de.dhbwstuttgart.typeinference.exceptions.DebugException; import de.dhbwstuttgart.typeinference.exceptions.DebugException;
import de.dhbwstuttgart.typeinference.exceptions.TypeinferenceException; import de.dhbwstuttgart.typeinference.exceptions.TypeinferenceException;
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertPoint; import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertPoint;
import de.dhbwstuttgart.bytecode.ClassGenerator;
import de.dhbwstuttgart.parser.JavaClassName; import de.dhbwstuttgart.parser.JavaClassName;
import de.dhbwstuttgart.syntaxtree.Class; import de.dhbwstuttgart.syntaxtree.Class;
import de.dhbwstuttgart.syntaxtree.GTVDeclarationContext; import de.dhbwstuttgart.syntaxtree.GTVDeclarationContext;
@ -230,6 +231,12 @@ public class GenericTypeVar extends ObjectType
return this.getGTVDeclarationContext(); return this.getGTVDeclarationContext();
} }
@Override
public org.apache.commons.bcel6.generic.Type getBytecodeType(ClassGenerator cg) {
// TODO Bytecode
return null;
}
} }
// ino.end // ino.end

View File

@ -0,0 +1,7 @@
class IfElse{
method(){
while(true){
}
}
}

View File

@ -0,0 +1,14 @@
package bytecode;
import org.junit.Test;
public class ForTest {
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
public final static String testFile = "ForTest.jav";
public final static String outputFile = "ForTest.class";
@Test
public void test() {
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
}
}

View File

@ -0,0 +1,9 @@
class IfElseStatement{
method(flag){
if(flag){
}else if(flag){
}
}
}

View File

@ -0,0 +1,14 @@
package bytecode;
import org.junit.Test;
public class IfElseIfStatementTest {
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
public final static String testFile = "IfElseIfStatement.jav";
public final static String outputFile = "IfElseIfStatement.class";
@Test
public void test() {
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
}
}

View File

@ -0,0 +1,9 @@
class IfElseStatement{
method(flag){
if(flag){
}else{
}
}
}

View File

@ -0,0 +1,14 @@
package bytecode;
import org.junit.Test;
public class IfElseStatementTest {
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
public final static String testFile = "IfElseStatement.jav";
public final static String outputFile = "IfElseStatement.class";
@Test
public void test() {
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
}
}

View File

@ -0,0 +1,7 @@
class IfStatement{
method(flag){
if(flag){
}
}
}

View File

@ -0,0 +1,14 @@
package bytecode;
import org.junit.Test;
public class IfStatementTest {
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
public final static String testFile = "IfStatement.jav";
public final static String outputFile = "IfStatement.class";
@Test
public void test() {
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
}
}

View File

@ -0,0 +1,6 @@
class PostIncrement{
void method() {a; a = 20; a--;}
}

View File

@ -0,0 +1,34 @@
package bytecode;
import static org.junit.Assert.*;
import java.io.File;
import java.io.IOException;
import junit.framework.TestCase;
import org.junit.Test;
import plugindevelopment.TypeInsertTester;
import de.dhbwstuttgart.core.MyCompiler;
import de.dhbwstuttgart.core.MyCompilerAPI;
import de.dhbwstuttgart.logger.LoggerConfiguration;
import de.dhbwstuttgart.logger.Section;
import de.dhbwstuttgart.parser.JavaParser.yyException;
import de.dhbwstuttgart.typeinference.ByteCodeResult;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
public class PostDecrement {
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
public final static String testFile = "PostDecrement.jav";
public final static String outputFile = "PostDecrement.class";
@Test
public void test() {
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
}
}

View File

@ -0,0 +1,7 @@
class IfElse{
method(){
while(true){
}
}
}

View File

@ -0,0 +1,14 @@
package bytecode;
import org.junit.Test;
public class WhileTest {
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
public final static String testFile = "WhileTest.jav";
public final static String outputFile = "WhileTest.class";
@Test
public void test() {
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
}
}