Merge mit bytecode

This commit is contained in:
JanUlrich 2015-07-14 14:51:15 +02:00
commit e891551b4e
56 changed files with 1266 additions and 359 deletions

View File

@ -6,7 +6,7 @@
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="lib" path="lib/junit-4.0.jar" sourcepath="/home/janulrich/.m2/repository/junit/junit/4.0/junit-4.0-sources.jar"/> <classpathentry kind="lib" path="lib/junit-4.0.jar" sourcepath="/home/janulrich/.m2/repository/junit/junit/4.0/junit-4.0-sources.jar"/>
<classpathentry kind="lib" path="lib/cloning.jar"/> <classpathentry kind="lib" path="lib/cloning.jar"/>
<classpathentry kind="lib" path="lib/bcel-5.2.jar"/>
<classpathentry kind="lib" path="lib/guava-10.0.1.jar"/> <classpathentry kind="lib" path="lib/guava-10.0.1.jar"/>
<classpathentry kind="lib" path="lib/bcel-6.0-SNAPSHOT.jar"/>
<classpathentry kind="output" path="bin"/> <classpathentry kind="output" path="bin"/>
</classpath> </classpath>

BIN
lib/bcel-6.0-SNAPSHOT.jar Normal file

Binary file not shown.

View File

@ -721,7 +721,7 @@ public class Class extends GTVDeclarationContext implements AClassOrInterface, I
assumptions.add(globalAssumptions); assumptions.add(globalAssumptions);
ConstraintsSet oderConstraints = new ConstraintsSet(); ConstraintsSet oderConstraints = new ConstraintsSet();
for(Type gparam : this.get_ParaList()){ for(Type gparam : this.get_ParaList()){
if(gparam instanceof GenericTypeVar)assumptions.add(((GenericTypeVar)gparam).createAssumptions()); //Constraints ¼r die Generischen Variablen erstellen und diese dem AssumptionsSet hinzufügen if(gparam instanceof GenericTypeVar)assumptions.add(((GenericTypeVar)gparam).createAssumptions()); //Constraints ¼r die Generischen Variablen erstellen und diese dem AssumptionsSet hinzufügen
} }
@ -744,7 +744,8 @@ public class Class extends GTVDeclarationContext implements AClassOrInterface, I
//ConstraintsSet oderConstraints = this.TYPE(this.getMethodList(), fieldInitializers, assumptions); //ConstraintsSet oderConstraints = this.TYPE(this.getMethodList(), fieldInitializers, assumptions);
this.superClass = this.superClass.TYPE(assumptions, this);
for(Field f:this.getFields()){ for(Field f:this.getFields()){
oderConstraints.add(f.TYPE(assumptions)); oderConstraints.add(f.TYPE(assumptions));
} }
@ -1250,8 +1251,8 @@ public class Class extends GTVDeclarationContext implements AClassOrInterface, I
if(!constructorVorhanden){//Falls kein Konstruktor vorhanden ist, muss noch der Standardkonstruktor angefügt werden: if(!constructorVorhanden){//Falls kein Konstruktor vorhanden ist, muss noch der Standardkonstruktor angefügt werden:
Block konstruktorBlock = new Block(); Block konstruktorBlock = new Block();
konstruktorBlock.statements.add(new SuperCall(konstruktorBlock)); konstruktorBlock.statements.add(new SuperCall(konstruktorBlock));
//Constructor standardKonstruktor = new Constructor(Method.createEmptyMethod(konstruktorBlock,this.getName().toString(), this)); Constructor standardKonstruktor = new Constructor(Method.createEmptyMethod(konstruktorBlock,this.getName().toString(), this));
Constructor standardKonstruktor = new Constructor(Method.createEmptyMethod(this.getName().toString(), this)); //Constructor standardKonstruktor = new Constructor(Method.createEmptyMethod(this.getName().toString(), this));
this.addField(standardKonstruktor); this.addField(standardKonstruktor);
} }

View File

@ -15,6 +15,7 @@ import de.dhbwstuttgart.parser.JavaClassName;
import de.dhbwstuttgart.syntaxtree.misc.DeclId; import de.dhbwstuttgart.syntaxtree.misc.DeclId;
import de.dhbwstuttgart.syntaxtree.modifier.Modifiers; import de.dhbwstuttgart.syntaxtree.modifier.Modifiers;
import de.dhbwstuttgart.syntaxtree.statement.Block; import de.dhbwstuttgart.syntaxtree.statement.Block;
import de.dhbwstuttgart.syntaxtree.statement.SuperCall;
import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar; import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar;
import de.dhbwstuttgart.syntaxtree.type.RefType; import de.dhbwstuttgart.syntaxtree.type.RefType;
import de.dhbwstuttgart.syntaxtree.type.Type; import de.dhbwstuttgart.syntaxtree.type.Type;
@ -39,6 +40,10 @@ public class Constructor extends Method {
*/ */
public Constructor(Method methode){ public Constructor(Method methode){
super(methode.get_Method_Name(), methode.getType(), methode.getParameterList(),methode.get_Block(), methode.getGenericDeclarationList(), methode.getOffset()); super(methode.get_Method_Name(), methode.getType(), methode.getParameterList(),methode.get_Block(), methode.getGenericDeclarationList(), methode.getOffset());
//Sicherstellen, dass das erste Statement in der Methode ein SuperCall ist:
if(this.get_Block().get_Statement().size() <1 || ! (this.get_Block().get_Statement().firstElement() instanceof SuperCall)){
this.get_Block().statements.add(0, new SuperCall(this.get_Block()));
}
} }
@Override @Override
public TypeAssumptions createTypeAssumptions(Class classmember) { public TypeAssumptions createTypeAssumptions(Class classmember) {
@ -52,18 +57,22 @@ public class Constructor extends Method {
@Override @Override
public void genByteCode(ClassGen cg) { public void genByteCode(ClassGen cg) {
ConstantPoolGen _cp = cg.getConstantPool(); ConstantPoolGen _cp = cg.getConstantPool();
//InstructionFactory _factory = new InstructionFactory(cg, _cp);
InstructionList il = new InstructionList(); //sollte nicht new sein sondern aus Block kommen InstructionList il = new InstructionList(); //sollte nicht new sein sondern aus Block kommen
Class parentClass = this.getParentClass(); Class parentClass = this.getParentClass();
//Hier m<EFBFBD>sste drin stehen: Kreiere einen Block, welcher ein Statement enth<EFBFBD>lt, welches ein Super Statement ist.
//TODO: Alles dynamisch gestalten //TODO: Alles dynamisch gestalten
//init darf nur drin stehen, wenn Konstruktor; //init darf nur drin stehen, wenn Konstruktor;
this.method = new MethodGen(Constants.ACC_PUBLIC, org.apache.bcel.generic.Type.getReturnType(this.getType().get_Name()), org.apache.bcel.generic.Type.NO_ARGS , new String[] { }, "<init>", parentClass.name, il, _cp); this.method = new MethodGen(Constants.ACC_PUBLIC, this.getType().getBytecodeType(), org.apache.bcel.generic.Type.NO_ARGS , new String[] { }, "<init>", parentClass.name, il, _cp);
super.genByteCode(cg); //Aufrufen um Iteration <EFBFBD>ber Block zu starten //Iteration <EFBFBD>ber Block starten
Block block = this.get_Block();
InstructionList blockInstructions = block.genByteCode(cg);
il.append(blockInstructions);//Die vom Block generierten Instructions an die InstructionList der Methode anfügen
this.method.setMaxStack(); //Die Stack Größe automatisch berechnen lassen (erst nach dem alle Instructions angehängt wurden)
cg.addMethod(this.method.getMethod());
} }
// super statement muss drin sein // super statement muss drin sein
// stmt genByteCode + im block genByteCode implementieren & dann Hierarchie ausprobieren // stmt genByteCode + im block genByteCode implementieren & dann Hierarchie ausprobieren

View File

@ -741,19 +741,27 @@ public class Method extends Field implements IItemWithOffset, TypeInsertable
@Override @Override
public void genByteCode(ClassGen cg) { public void genByteCode(ClassGen 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();
* Class parentClass = this.getParentClass(); Class parentClass = this.getParentClass();
*/
MethodGen method = new MethodGen(Constants.ACC_PUBLIC, this.getType().getBytecodeType(), org.apache.bcel.generic.Type.NO_ARGS , new String[] { }, this.get_Method_Name(), parentClass.name, il, _cp);
//oben steht MethodGen method als Variable (Z. 71) Block block = this.get_Block();
InstructionList blockInstructions = block.genByteCode(cg);
// <EFBFBD>ber Statements iterieren um Block abzurufen il.append(blockInstructions);//Die vom Block generierten Instructions an die InstructionList der Methode anfügen
for (Statement statements : block.get_Statement()) {
statements.genByteCode(cg); if (block.get_Statement().size() == 0) { il.append(_factory.createReturn(org.apache.bcel.generic.Type.VOID)); }
else {
if (!(block.get_Statement().lastElement() instanceof Return)) { il.append(_factory.createReturn(org.apache.bcel.generic.Type.VOID)); }
} }
method.setMaxStack(); //Die Stack Größe automatisch berechnen lassen (erst nach dem alle Instructions angehängt wurden)
cg.addMethod(method.getMethod());
} }
} }

View File

@ -6,7 +6,14 @@ import java.util.Enumeration;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.Iterator; import java.util.Iterator;
import org.apache.bcel.generic.ASTORE;
import org.apache.bcel.generic.ClassGen; import org.apache.bcel.generic.ClassGen;
import org.apache.bcel.generic.DSTORE;
import org.apache.bcel.generic.FSTORE;
import org.apache.bcel.generic.ISTORE;
import org.apache.bcel.generic.InstructionFactory;
import org.apache.bcel.generic.InstructionList;
import org.apache.bcel.generic.LSTORE;
import de.dhbwstuttgart.typeinference.Menge; import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.logger.Logger; import de.dhbwstuttgart.logger.Logger;
@ -168,13 +175,40 @@ public class Assign extends Expr
} }
public static int counterAssign = 0; //Zaehlvariable für ISTORE
@Override @Override
public void genByteCode(ClassGen _cg) { public InstructionList genByteCode(ClassGen cg) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
InstructionFactory _factory = new InstructionFactory(cg, cg.getConstantPool());
InstructionList il = expr2.genByteCode(cg);//expr2 rechte expr
counterAssign++; //macht STORE für meherere Variable nutzbar (nicht nur ISTORE_1, ISTORE_2, etc.)
String expr2Type = expr2.getType().get_Name().toString();
switch(expr2Type){
case "java.lang.Integer":
il.append(new ISTORE(counterAssign));
break;
case "java.lang.String":
il.append(new ASTORE(counterAssign));
break;
case "java.lang.Double":
il.append(new DSTORE(counterAssign));
break;
case "java.lang.Float":
il.append(new FSTORE(counterAssign));
break;
case "java.lang.Long":
il.append(new LSTORE(counterAssign));
break;
}
return il;
} }
} }

View File

@ -255,20 +255,16 @@ public class Block extends Statement
} }
@Override @Override
public void genByteCode(ClassGen cg) { public InstructionList genByteCode(ClassGen cg) {
//ConstantPoolGen _cp = cg.getConstantPool(); //ConstantPoolGen _cp = cg.getConstantPool();
InstructionFactory _factory = new InstructionFactory(cg, _cp);
InstructionList il = new InstructionList(); InstructionList il = new InstructionList();
//Frage: Wenn Block von Statements erbt, und Block selbst keinen BCEL Code besitzt, ist das hier dann nicht eine Sackgasse? for(Statement stmt : this.get_Statement()){
il.append(stmt.genByteCode(cg));
//Instructionhandle dynamisch }
InstructionHandle ih_0 = il.append(_factory.createLoad(org.apache.bcel.generic.Type.OBJECT, 0)); //il.dispose();
il.append(_factory.createInvoke(this.getParentClass().superclassid.toString(), "<init>", org.apache.bcel.generic.Type.VOID, org.apache.bcel.generic.Type.NO_ARGS, Constants.INVOKESPECIAL));
InstructionHandle ih_4 = il.append(_factory.createReturn(org.apache.bcel.generic.Type.VOID));
il.dispose(); return il;
} }
} }
// ino.end // ino.end

View File

@ -1,134 +1,146 @@
// ino.module.BoolLiteral.8626.package // ino.module.BoolLiteral.8626.package
package de.dhbwstuttgart.syntaxtree.statement; package de.dhbwstuttgart.syntaxtree.statement;
// ino.end // ino.end
// ino.module.BoolLiteral.8626.import // ino.module.BoolLiteral.8626.import
import java.util.Hashtable; import java.util.Hashtable;
import org.apache.bcel.generic.ClassGen; import org.apache.bcel.generic.ClassGen;
import org.apache.bcel.generic.InstructionFactory;
import de.dhbwstuttgart.typeinference.Menge; import org.apache.bcel.generic.InstructionList;
import de.dhbwstuttgart.logger.Logger;
import de.dhbwstuttgart.myexception.CTypeReconstructionException; import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.myexception.JVMCodeException; import de.dhbwstuttgart.logger.Logger;
import de.dhbwstuttgart.syntaxtree.Class; import de.dhbwstuttgart.myexception.CTypeReconstructionException;
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode; import de.dhbwstuttgart.myexception.JVMCodeException;
import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar; import de.dhbwstuttgart.syntaxtree.Class;
import de.dhbwstuttgart.syntaxtree.type.RefType; import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
import de.dhbwstuttgart.syntaxtree.type.Type; import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar;
import de.dhbwstuttgart.typeinference.ConstraintsSet; import de.dhbwstuttgart.syntaxtree.type.RefType;
import de.dhbwstuttgart.typeinference.JavaCodeResult; import de.dhbwstuttgart.syntaxtree.type.Type;
import de.dhbwstuttgart.typeinference.ResultSet; import de.dhbwstuttgart.typeinference.ConstraintsSet;
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions; import de.dhbwstuttgart.typeinference.JavaCodeResult;
import de.dhbwstuttgart.typeinference.unify.CSubstitutionSet; import de.dhbwstuttgart.typeinference.ResultSet;
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
import de.dhbwstuttgart.typeinference.unify.CSubstitutionSet;
// ino.class.BoolLiteral.25089.declaration
public class BoolLiteral extends Literal
// ino.end // ino.class.BoolLiteral.25089.declaration
// ino.class.BoolLiteral.25089.body public class BoolLiteral extends Literal
{ // ino.end
@Override // ino.class.BoolLiteral.25089.body
public void genByteCode(ClassGen _cg) { {
// TODO Auto-generated method stub
}
// ino.attribute.Bool.25093.declaration
private boolean Bool;
// ino.attribute.Bool.25093.declaration // ino.end
private boolean Bool; // ino.attribute.parserlog.25096.declaration
// ino.end protected static Logger parserlog = Logger.getLogger("parser");
// ino.attribute.parserlog.25096.declaration // ino.end
protected static Logger parserlog = Logger.getLogger("parser");
// ino.end
// ino.method.BoolLiteral.25099.definition
public BoolLiteral()
// ino.method.BoolLiteral.25099.definition // ino.end
public BoolLiteral() // ino.method.BoolLiteral.25099.body
// ino.end {
// ino.method.BoolLiteral.25099.body super(-1,-1);
{ // #JB# 20.04.2005
super(-1,-1); // ###########################################################
// #JB# 20.04.2005 this.setType(new RefType("Boolean",this,this.getOffset()));
// ########################################################### //this.setType(new Type("boolean"));
this.setType(new RefType("Boolean",this,this.getOffset())); // ###########################################################
//this.setType(new Type("boolean")); }
// ########################################################### // ino.end
}
// ino.end
/*
// ino.method.sc_check.25102.definition
/* public void sc_check(Menge<Class> classname, Hashtable ch, Hashtable<String, String> bh, boolean ext, Hashtable parach,Hashtable<String, Hashtable> parabh)
// ino.method.sc_check.25102.definition // ino.end
public void sc_check(Menge<Class> classname, Hashtable ch, Hashtable<String, String> bh, boolean ext, Hashtable parach,Hashtable<String, Hashtable> parabh) // ino.method.sc_check.25102.body
// ino.end {
// ino.method.sc_check.25102.body if(ext)
{ {
if(ext) parserlog.debug(" ---BoolLiteral---");
{ }
parserlog.debug(" ---BoolLiteral---"); }
} // ino.end
} */
// ino.end
*/
// ino.method.set_Bool.25105.definition
public void set_Bool(boolean b)
// ino.method.set_Bool.25105.definition // ino.end
public void set_Bool(boolean b) // ino.method.set_Bool.25105.body
// ino.end {
// ino.method.set_Bool.25105.body this.Bool = b;
{ }
this.Bool = b; // ino.end
}
// ino.end
// ino.method.get_Name.25108.definition
public String get_Name()
// ino.method.get_Name.25108.definition // ino.end
public String get_Name() // ino.method.get_Name.25108.body
// ino.end {
// ino.method.get_Name.25108.body return null;
{ }
return null; // ino.end
}
// ino.end
@Override
public ConstraintsSet TYPEExpr(TypeAssumptions assumptions) {
@Override this.type = assumptions.checkType(new RefType("java.lang.Boolean",this,-1), this);
public ConstraintsSet TYPEExpr(TypeAssumptions assumptions) { return new ConstraintsSet();
this.type = assumptions.checkType(new RefType("java.lang.Boolean",this,-1), this); }
return new ConstraintsSet();
} @Override
public JavaCodeResult printJavaCode(ResultSet resultSet) {
@Override if(Bool)return new JavaCodeResult("true");
public JavaCodeResult printJavaCode(ResultSet resultSet) { return new JavaCodeResult("false");
if(Bool)return new JavaCodeResult("true"); }
return new JavaCodeResult("false");
}
@Override
public Menge<SyntaxTreeNode> getChildren() {
@Override Menge<SyntaxTreeNode> ret = new Menge<SyntaxTreeNode>();
public Menge<SyntaxTreeNode> getChildren() { return ret;
Menge<SyntaxTreeNode> ret = new Menge<SyntaxTreeNode>(); }
return ret;
}
@Override
public void wandleRefTypeAttributes2GenericAttributes(
@Override Menge<Type> paralist,
public void wandleRefTypeAttributes2GenericAttributes( Menge<GenericTypeVar> genericMethodParameters) {
Menge<Type> paralist, // TODO Auto-generated method stub
Menge<GenericTypeVar> genericMethodParameters) {
// TODO Auto-generated method stub }
} @Override
public InstructionList genByteCode(ClassGen cg) {
InstructionFactory _factory = new InstructionFactory(cg, cg.getConstantPool());
} InstructionList il = new InstructionList();
// ino.end
if (Bool == true){
il.append(_factory.ICONST_1);
}else {
il.append(_factory.ICONST_0);
}
return il;
}
}
// ino.end

View File

@ -4,7 +4,10 @@ package de.dhbwstuttgart.syntaxtree.statement;
// ino.module.CharLiteral.8628.import // ino.module.CharLiteral.8628.import
import java.util.Hashtable; import java.util.Hashtable;
import org.apache.bcel.generic.BIPUSH;
import org.apache.bcel.generic.ClassGen; import org.apache.bcel.generic.ClassGen;
import org.apache.bcel.generic.InstructionFactory;
import org.apache.bcel.generic.InstructionList;
import de.dhbwstuttgart.typeinference.Menge; import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.logger.Logger; import de.dhbwstuttgart.logger.Logger;
@ -111,10 +114,19 @@ public class CharLiteral extends Literal
} }
//Char-Getter fuer genByteCode
public char get_Char()
// ino.end
// ino.method.get_Int.25463.body
{
return Char;
}
@Override @Override
public void genByteCode(ClassGen _cg) { public InstructionList genByteCode(ClassGen cg) {
// TODO Auto-generated method stub InstructionFactory _factory = new InstructionFactory(cg, cg.getConstantPool());
InstructionList il = new InstructionList();
il.append(new BIPUSH((byte) get_Char()));
return il;
} }
} }
// ino.end // ino.end

View File

@ -4,7 +4,13 @@ package de.dhbwstuttgart.syntaxtree.statement;
// ino.module.IntLiteral.8635.import // ino.module.IntLiteral.8635.import
import java.util.Hashtable; import java.util.Hashtable;
import org.apache.bcel.generic.BIPUSH;
import org.apache.bcel.generic.ClassGen; import org.apache.bcel.generic.ClassGen;
import org.apache.bcel.generic.ConstantPoolGen;
import org.apache.bcel.generic.InstructionFactory;
import org.apache.bcel.generic.InstructionList;
import org.apache.bcel.generic.LDC;
import org.apache.bcel.generic.LDC2_W;
import de.dhbwstuttgart.typeinference.Menge; import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.logger.Logger; import de.dhbwstuttgart.logger.Logger;
@ -128,10 +134,26 @@ public JavaCodeResult printJavaCode(ResultSet resultSet) {
return ret; return ret;
} }
//alter Double-Versuch vermutlich inkorrekt
/*@Override
public InstructionList genByteCode(ClassGen cg) {
InstructionFactory _factory = new InstructionFactory(cg, cg.getConstantPool());
InstructionList il = new InstructionList();
il.append(new BIPUSH(new Double(get_Double()).byteValue()));
return il;
}*/
@Override @Override
public void genByteCode(ClassGen _cg) { public InstructionList genByteCode(ClassGen cg) {
// TODO Auto-generated method stub ConstantPoolGen cp = cg.getConstantPool();
//InstructionFactory _factory = new InstructionFactory(cg, cp);
InstructionList il = new InstructionList();
cp.addDouble(get_Double());
il.append(new LDC2_W(cp.getSize()-1));
return il;
} }
} }
// ino.end // ino.end

View File

@ -4,8 +4,11 @@ package de.dhbwstuttgart.syntaxtree.statement;
// ino.module.Expr.8630.import // ino.module.Expr.8630.import
import java.util.Hashtable; import java.util.Hashtable;
import java.util.Iterator; import java.util.Iterator;
import de.dhbwstuttgart.typeinference.Menge;
import org.apache.bcel.generic.ClassGen;
import org.apache.bcel.generic.InstructionList;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.myexception.CTypeReconstructionException; import de.dhbwstuttgart.myexception.CTypeReconstructionException;
import de.dhbwstuttgart.myexception.SCStatementException; import de.dhbwstuttgart.myexception.SCStatementException;
import de.dhbwstuttgart.syntaxtree.Class; import de.dhbwstuttgart.syntaxtree.Class;
@ -109,5 +112,7 @@ public abstract class Expr extends ExprStmt
public ConstraintsSet TYPEStmt(TypeAssumptions assumptions){ public ConstraintsSet TYPEStmt(TypeAssumptions assumptions){
throw new NotImplementedException(); //wird die TYPEStmt-Methode innerhalb einer Expr aufgerufen, dann ist etwas schief gelaufen. throw new NotImplementedException(); //wird die TYPEStmt-Methode innerhalb einer Expr aufgerufen, dann ist etwas schief gelaufen.
} }
public abstract InstructionList genByteCode(ClassGen _cg);
} }
// ino.end // ino.end

View File

@ -5,6 +5,10 @@ package de.dhbwstuttgart.syntaxtree.statement;
import java.util.Hashtable; import java.util.Hashtable;
import org.apache.bcel.generic.ClassGen; import org.apache.bcel.generic.ClassGen;
import org.apache.bcel.generic.ConstantPoolGen;
import org.apache.bcel.generic.InstructionList;
import org.apache.bcel.generic.LDC;
import org.apache.bcel.generic.LDC2_W;
import de.dhbwstuttgart.typeinference.Menge; import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.logger.Logger; import de.dhbwstuttgart.logger.Logger;
@ -128,9 +132,14 @@ public JavaCodeResult printJavaCode(ResultSet resultSet) {
} }
@Override @Override
public void genByteCode(ClassGen _cg) { public InstructionList genByteCode(ClassGen cg) {
// TODO Auto-generated method stub ConstantPoolGen cp = cg.getConstantPool();
InstructionList il = new InstructionList();
cp.addFloat(get_Float());
il.append(new LDC(cp.getSize()-1));
return il;
} }
} }
// ino.end // ino.end

View File

@ -4,7 +4,10 @@ package de.dhbwstuttgart.syntaxtree.statement;
// ino.module.IntLiteral.8635.import // ino.module.IntLiteral.8635.import
import java.util.Hashtable; import java.util.Hashtable;
import org.apache.bcel.generic.BIPUSH;
import org.apache.bcel.generic.ClassGen; import org.apache.bcel.generic.ClassGen;
import org.apache.bcel.generic.InstructionFactory;
import org.apache.bcel.generic.InstructionList;
import de.dhbwstuttgart.typeinference.Menge; import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.logger.Logger; import de.dhbwstuttgart.logger.Logger;
@ -131,9 +134,11 @@ public class IntLiteral extends Literal
} }
@Override @Override
public void genByteCode(ClassGen _cg) { public InstructionList genByteCode(ClassGen cg) {
// TODO Auto-generated method stub InstructionFactory _factory = new InstructionFactory(cg, cg.getConstantPool());
InstructionList il = new InstructionList();
il.append(new BIPUSH(new Integer(get_Int()).byteValue()));
return il;
} }
} }
// ino.end // ino.end

View File

@ -2,7 +2,13 @@ package de.dhbwstuttgart.syntaxtree.statement;
import java.util.Hashtable; import java.util.Hashtable;
import org.apache.bcel.classfile.ConstantPool;
import org.apache.bcel.generic.BIPUSH;
import org.apache.bcel.generic.ClassGen; import org.apache.bcel.generic.ClassGen;
import org.apache.bcel.generic.ConstantPoolGen;
import org.apache.bcel.generic.InstructionFactory;
import org.apache.bcel.generic.InstructionList;
import org.apache.bcel.generic.INVOKEDYNAMIC;
import de.dhbwstuttgart.typeinference.Menge; import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.myexception.CTypeReconstructionException; import de.dhbwstuttgart.myexception.CTypeReconstructionException;
@ -208,9 +214,24 @@ public class LambdaExpression extends Expr{
} }
@Override @Override
public void genByteCode(ClassGen _cg) { public InstructionList genByteCode(ClassGen cg) {
// TODO Auto-generated method stub ConstantPoolGen cp = cg.getConstantPool();
InstructionList il = new InstructionList();
/*
* Bytecode:
* 0: invokedynamic #2, 0 //#2 führt zu einem InvokeDynamic im KP - wildes Referenzieren
* 5: astore_1 //Speichert wahrscheinlich den String meiner TestEXPR
* 6: return
*/
//---Variante 1 mit opcode----
short opcode = 186;//opcode - was genau ist das?
il.append(new INVOKEDYNAMIC(opcode, 0));//Invokedynamic lässt sich bei mir weder automatisch noch manuell importieren
//---Variante 2 mit Konstantenpool-Referenz---
//int cpSize = cp.getSize()-1;//Vermutlich ist die benötigte Referenz das aktuellste Element?
//il.append(new INVOKEDYNAMIC((short) cpSize, 0));
return il;
} }
} }

View File

@ -6,6 +6,7 @@ import java.util.Enumeration;
import java.util.Hashtable; import java.util.Hashtable;
import org.apache.bcel.generic.ClassGen; import org.apache.bcel.generic.ClassGen;
import org.apache.bcel.generic.InstructionList;
import de.dhbwstuttgart.typeinference.Menge; import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.logger.Logger; import de.dhbwstuttgart.logger.Logger;
@ -427,9 +428,9 @@ public class LocalVarDecl extends Statement implements TypeInsertable
} }
@Override @Override
public void genByteCode(ClassGen _cg) { public InstructionList genByteCode(ClassGen _cg) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return new InstructionList();
} }
} }
// ino.end // ino.end

View File

@ -5,6 +5,9 @@ package de.dhbwstuttgart.syntaxtree.statement;
import java.util.Hashtable; import java.util.Hashtable;
import org.apache.bcel.generic.ClassGen; import org.apache.bcel.generic.ClassGen;
import org.apache.bcel.generic.ConstantPoolGen;
import org.apache.bcel.generic.InstructionList;
import org.apache.bcel.generic.LDC2_W;
import de.dhbwstuttgart.typeinference.Menge; import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.logger.Logger; import de.dhbwstuttgart.logger.Logger;
@ -125,9 +128,15 @@ public JavaCodeResult printJavaCode(ResultSet resultSet) {
} }
@Override @Override
public void genByteCode(ClassGen _cg) { public InstructionList genByteCode(ClassGen cg) {
// TODO Auto-generated method stub ConstantPoolGen cp = cg.getConstantPool();
//InstructionFactory _factory = new InstructionFactory(cg, cp);
InstructionList il = new InstructionList();
cp.addLong(get_Long());
il.append(new LDC2_W(cp.getSize()-1));
return il;
} }
} }
// ino.end // ino.end

View File

@ -5,6 +5,7 @@ package de.dhbwstuttgart.syntaxtree.statement;
import java.util.Hashtable; import java.util.Hashtable;
import org.apache.bcel.generic.ClassGen; import org.apache.bcel.generic.ClassGen;
import org.apache.bcel.generic.InstructionList;
import de.dhbwstuttgart.typeinference.Menge; import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.logger.Logger; import de.dhbwstuttgart.logger.Logger;
@ -304,7 +305,7 @@ public class MethodCall extends Expr
} }
@Override @Override
public void genByteCode(ClassGen _cg) { public InstructionList genByteCode(ClassGen _cg) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
} }

View File

@ -1,153 +1,162 @@
// ino.module.NewArray.8641.package // ino.module.NewArray.8641.package
package de.dhbwstuttgart.syntaxtree.statement; package de.dhbwstuttgart.syntaxtree.statement;
// ino.end // ino.end
// ino.module.NewArray.8641.import // ino.module.NewArray.8641.import
import java.util.Hashtable; import java.util.Hashtable;
import org.apache.bcel.generic.ClassGen; import org.apache.bcel.generic.ClassGen;
import org.apache.bcel.generic.InstructionFactory;
import de.dhbwstuttgart.typeinference.Menge; import org.apache.bcel.generic.InstructionList;
import de.dhbwstuttgart.logger.Logger;
import de.dhbwstuttgart.myexception.CTypeReconstructionException; import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.myexception.JVMCodeException; import de.dhbwstuttgart.logger.Logger;
import de.dhbwstuttgart.syntaxtree.Class; import de.dhbwstuttgart.myexception.CTypeReconstructionException;
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode; import de.dhbwstuttgart.myexception.JVMCodeException;
import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar; import de.dhbwstuttgart.syntaxtree.Class;
import de.dhbwstuttgart.syntaxtree.type.Type; import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
import de.dhbwstuttgart.typeinference.ConstraintsSet; import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar;
import de.dhbwstuttgart.typeinference.JavaCodeResult; import de.dhbwstuttgart.syntaxtree.type.Type;
import de.dhbwstuttgart.typeinference.ResultSet; import de.dhbwstuttgart.typeinference.ConstraintsSet;
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions; import de.dhbwstuttgart.typeinference.JavaCodeResult;
import de.dhbwstuttgart.typeinference.unify.CSubstitutionSet; import de.dhbwstuttgart.typeinference.ResultSet;
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
import de.dhbwstuttgart.typeinference.unify.CSubstitutionSet;
// ino.class.NewArray.25787.declaration
public class NewArray extends Expr
// ino.end // ino.class.NewArray.25787.declaration
// ino.class.NewArray.25787.body public class NewArray extends Expr
{ // ino.end
// ino.method.NewArray.25791.definition // ino.class.NewArray.25787.body
public NewArray(int offset,int variableLength) {
// ino.end // ino.method.NewArray.25791.definition
// ino.method.NewArray.25791.body public NewArray(int offset,int variableLength)
{ // ino.end
super(offset,variableLength); // ino.method.NewArray.25791.body
} {
// ino.end super(offset,variableLength);
// ino.attribute.type.25794.declaration }
private Type type; // ino.end
// ino.end // ino.attribute.type.25794.declaration
// ino.attribute.expr.25797.declaration private Type type;
public Menge<Expr> expr = new Menge<Expr>(); // ino.end
// ino.end // ino.attribute.expr.25797.declaration
// ino.attribute.parserlog.25800.declaration public Menge<Expr> expr = new Menge<Expr>();
protected static Logger parserlog = Logger.getLogger("parser"); // ino.end
// ino.end // ino.attribute.parserlog.25800.declaration
protected static Logger parserlog = Logger.getLogger("parser");
// ino.end
// ino.method.getType.25803.defdescription type=javadoc
/**
* Author: ¯Â¿Â½rg ¯Â¿Â½uerle<br/> // ino.method.getType.25803.defdescription type=javadoc
* @return Returns the type. /**
*/ * Author: ¯Â¿Â½rg ¯Â¿Â½uerle<br/>
// ino.end * @return Returns the type.
// ino.method.getType.25803.definition */
public Type getType() // ino.end
// ino.end // ino.method.getType.25803.definition
// ino.method.getType.25803.body public Type getType()
{ // ino.end
return type; // ino.method.getType.25803.body
} {
// ino.end return type;
}
// ino.method.setType.25806.defdescription type=javadoc // ino.end
/**
* Author: ¯Â¿Â½rg ¯Â¿Â½uerle<br/> // ino.method.setType.25806.defdescription type=javadoc
* @param type The type to set. /**
*/ * Author: ¯Â¿Â½rg ¯Â¿Â½uerle<br/>
// ino.end * @param type The type to set.
// ino.method.setType.25806.definition */
public void setType(Type type) // ino.end
// ino.end // ino.method.setType.25806.definition
// ino.method.setType.25806.body public void setType(Type type)
{ // ino.end
this.type = type; // ino.method.setType.25806.body
} {
// ino.end this.type = type;
}
// ino.method.get_Name.25809.definition // ino.end
public String get_Name()
// ino.end // ino.method.get_Name.25809.definition
// ino.method.get_Name.25809.body public String get_Name()
{ // ino.end
return null; // ino.method.get_Name.25809.body
} {
// ino.end return null;
}
/* // ino.end
// ino.method.sc_check.25812.definition
public void sc_check(Menge<Class> classname, Hashtable bh, Hashtable<String, String> ch,boolean ext, Hashtable parach, Hashtable<String, Hashtable> parabh) /*
// ino.end // ino.method.sc_check.25812.definition
// ino.method.sc_check.25812.body public void sc_check(Menge<Class> classname, Hashtable bh, Hashtable<String, String> ch,boolean ext, Hashtable parach, Hashtable<String, Hashtable> parabh)
{ // ino.end
if(ext) // ino.method.sc_check.25812.body
parserlog.debug(" ---NewArray---"); {
} if(ext)
// ino.end parserlog.debug(" ---NewArray---");
*/ }
// ino.end
// ino.method.get_codegen_Array_Type.25815.definition */
public int get_codegen_Array_Type()
throws JVMCodeException // ino.method.get_codegen_Array_Type.25815.definition
// ino.end public int get_codegen_Array_Type()
// ino.method.get_codegen_Array_Type.25815.body throws JVMCodeException
{ // ino.end
if(this.getType().equals("boolean")) return 4; // ino.method.get_codegen_Array_Type.25815.body
else if(this.getType().equals("char")) return 5; {
else if(this.getType().equals("float")) return 6; if(this.getType().equals("boolean")) return 4;
else if(this.getType().equals("double")) return 7; else if(this.getType().equals("char")) return 5;
else if(this.getType().equals("byte")) return 8; else if(this.getType().equals("float")) return 6;
else if(this.getType().equals("short")) return 9; else if(this.getType().equals("double")) return 7;
else if(this.getType().equals("int")) return 10; else if(this.getType().equals("byte")) return 8;
else if(this.getType().equals("long")) return 11; else if(this.getType().equals("short")) return 9;
else throw new JVMCodeException("JVMCodeException: NewArray: int get_codegen_Array_Type()"); else if(this.getType().equals("int")) return 10;
} else if(this.getType().equals("long")) return 11;
// ino.end else throw new JVMCodeException("JVMCodeException: NewArray: int get_codegen_Array_Type()");
}
// ino.method.wandleRefTypeAttributes2GenericAttributes.25827.definition // ino.end
public void wandleRefTypeAttributes2GenericAttributes(Menge<Type> paralist, Menge<GenericTypeVar> genericMethodParameters)
// ino.end // ino.method.wandleRefTypeAttributes2GenericAttributes.25827.definition
// ino.method.wandleRefTypeAttributes2GenericAttributes.25827.body public void wandleRefTypeAttributes2GenericAttributes(Menge<Type> paralist, Menge<GenericTypeVar> genericMethodParameters)
{ // ino.end
} // ino.method.wandleRefTypeAttributes2GenericAttributes.25827.body
// ino.end {
}
@Override // ino.end
public ConstraintsSet TYPEExpr(TypeAssumptions assumptions) {
// TODO Auto-generated method stub @Override
return null; public ConstraintsSet TYPEExpr(TypeAssumptions assumptions) {
} // TODO Auto-generated method stub
return null;
@Override }
public JavaCodeResult printJavaCode(ResultSet resultSet) {
// TODO Auto-generated method stub @Override
return null; public JavaCodeResult printJavaCode(ResultSet resultSet) {
} // TODO Auto-generated method stub
return null;
@Override }
public Menge<SyntaxTreeNode> getChildren() {
Menge<SyntaxTreeNode> ret = new Menge<SyntaxTreeNode>(); @Override
ret.addAll(this.expr); public Menge<SyntaxTreeNode> getChildren() {
return ret; Menge<SyntaxTreeNode> ret = new Menge<SyntaxTreeNode>();
} ret.addAll(this.expr);
return ret;
@Override }
public void genByteCode(ClassGen _cg) {
// TODO Auto-generated method stub @Override
public InstructionList genByteCode(ClassGen cg) {
}
InstructionFactory _factory = new InstructionFactory(cg, cg.getConstantPool());
} InstructionList il = new InstructionList();
// ino.end
il.append(expr.elementAt(0).genByteCode(cg));
il.append(_factory.createNewArray(org.apache.bcel.generic.Type.getType(getTypeName()), (short)1));
return il;
}
}
// ino.end

View File

@ -5,6 +5,8 @@ package de.dhbwstuttgart.syntaxtree.statement;
import java.util.Hashtable; import java.util.Hashtable;
import org.apache.bcel.generic.ClassGen; import org.apache.bcel.generic.ClassGen;
import org.apache.bcel.generic.InstructionFactory;
import org.apache.bcel.generic.InstructionList;
import de.dhbwstuttgart.typeinference.Menge; import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.logger.Logger; import de.dhbwstuttgart.logger.Logger;
@ -91,10 +93,15 @@ public class Null extends Literal
} }
@Override @Override
public void genByteCode(ClassGen _cg) { public InstructionList genByteCode(ClassGen cg) {
// TODO Auto-generated method stub InstructionFactory _factory = new InstructionFactory(cg, cg.getConstantPool());
InstructionList il = new InstructionList();
il.append(_factory.ACONST_NULL);
return il;
} }
} }
// ino.end // ino.end

View File

@ -5,7 +5,11 @@ package de.dhbwstuttgart.syntaxtree.statement;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.Iterator; import java.util.Iterator;
import org.apache.bcel.generic.BIPUSH;
import org.apache.bcel.generic.ClassGen; import org.apache.bcel.generic.ClassGen;
import org.apache.bcel.generic.IINC;
import org.apache.bcel.generic.InstructionFactory;
import org.apache.bcel.generic.InstructionList;
import de.dhbwstuttgart.typeinference.Menge; import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.logger.Logger; import de.dhbwstuttgart.logger.Logger;
@ -95,10 +99,17 @@ public JavaCodeResult printJavaCode(ResultSet resultSet) {
return ret; return ret;
} }
public static int counterPostInc = 0;
@Override @Override
public void genByteCode(ClassGen _cg) { public InstructionList genByteCode(ClassGen cg) {
// TODO Auto-generated method stub InstructionFactory _factory = new InstructionFactory(cg, cg.getConstantPool());
InstructionList il = new InstructionList();
counterPostInc++;
il.append(new IINC(counterPostInc,1));
//Tests aufgrund fehlener TypInferenz-Funktionalität nicht möglich
//Vermutlich muss der Counter noch angepasst werden, da nicht incrementierende Variablen nicht mitgezählt werden, und zu falschen aufrufen führen
//Gibt es einen Compiler-internen Variablenindex, der den Counter effektiver ersetzen könnte
return il;
} }
} }

View File

@ -4,6 +4,9 @@ package de.dhbwstuttgart.syntaxtree.statement;
// ino.module.Return.8651.import // ino.module.Return.8651.import
import java.util.Hashtable; import java.util.Hashtable;
import org.apache.bcel.generic.ConstantPoolGen;
import org.apache.bcel.generic.InstructionFactory;
import org.apache.bcel.generic.InstructionList;
import org.apache.bcel.generic.ClassGen; import org.apache.bcel.generic.ClassGen;
import de.dhbwstuttgart.typeinference.Menge; import de.dhbwstuttgart.typeinference.Menge;
@ -130,9 +133,17 @@ public class Return extends Statement
} }
@Override @Override
public void genByteCode(ClassGen _cg) { public InstructionList genByteCode(ClassGen cg) {
// TODO Auto-generated method stub InstructionList il = retexpr.genByteCode(cg);
InstructionFactory _factory = new InstructionFactory(cg, cg.getConstantPool());
//Stimmt das VOID hier eigentlich? --> Wie wäre es mit getReturnType o.ä.? + evtl. von Type zu bcelType casten?
il.append(_factory.createReturn(org.apache.bcel.generic.Type.VOID));
return il;
} }
} }
// ino.end // ino.end

View File

@ -129,7 +129,7 @@ public abstract class Statement extends SyntaxTreeNode implements IItemWithOffse
} }
public abstract void genByteCode(ClassGen _cg); public abstract InstructionList genByteCode(ClassGen _cg);
} }

View File

@ -1,11 +1,21 @@
package de.dhbwstuttgart.syntaxtree.statement; package de.dhbwstuttgart.syntaxtree.statement;
import de.dhbwstuttgart.typeinference.Menge; import de.dhbwstuttgart.typeinference.Menge;
// ino.end // ino.end
// ino.module.StringLiteral.8653.import // ino.module.StringLiteral.8653.import
import java.util.Hashtable; import java.util.Hashtable;
import org.apache.bcel.classfile.ConstantPool;
import org.apache.bcel.generic.ClassGen; import org.apache.bcel.generic.ClassGen;
import org.apache.bcel.generic.ConstantPoolGen;
import org.apache.bcel.generic.InstructionFactory;
import org.apache.bcel.generic.InstructionList;
import org.apache.bcel.generic.LDC;
import de.dhbwstuttgart.typeinference.Menge; import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.logger.Logger; import de.dhbwstuttgart.logger.Logger;
@ -102,11 +112,29 @@ public class StringLiteral extends Literal
return "\""+this.string+"\""; return "\""+this.string+"\"";
} }
public String get_String()
// ino.end
// ino.method.get_Name.26246.body
{
return string;
}
//public static int counterString = 0;
@Override @Override
public void genByteCode(ClassGen _cg) { public InstructionList genByteCode(ClassGen cg) {
// TODO Auto-generated method stub ConstantPoolGen cp = cg.getConstantPool();
InstructionFactory _factory = new InstructionFactory(cg, cp);
InstructionList il = new InstructionList();
//counterString++;
//il.append(_factory.ASTORE_1, _factory.createNew(string));
cp.addString(get_String());
il.append(new LDC(cp.getSize()-1));
return il;
} }
} }
// ino.end // ino.end

View File

@ -3,8 +3,14 @@ package de.dhbwstuttgart.syntaxtree.statement;
// ino.end // ino.end
// ino.module.This.8654.import // ino.module.This.8654.import
import java.util.Hashtable; import java.util.Hashtable;
import de.dhbwstuttgart.typeinference.Menge;
import org.apache.bcel.Constants;
import org.apache.bcel.generic.ClassGen;
import org.apache.bcel.generic.InstructionFactory;
import org.apache.bcel.generic.InstructionHandle;
import org.apache.bcel.generic.InstructionList;
import de.dhbwstuttgart.typeinference.Menge;
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;
@ -76,7 +82,22 @@ public class SuperCall extends ThisCall
@Override @Override
public JavaCodeResult printJavaCode(ResultSet resultSet) { public JavaCodeResult printJavaCode(ResultSet resultSet) {
return new JavaCodeResult("super("+this.getArgumentList().printJavaCode(resultSet)+")"); String argList = "";
if(this.getArgumentList() != null)argList = this.getArgumentList().printJavaCode(resultSet).getJavaCode();
return new JavaCodeResult("super("+argList+")");
}
@Override
public InstructionList genByteCode(ClassGen cg) {
InstructionFactory _factory = new InstructionFactory(cg, cg.getConstantPool());
InstructionList il = new InstructionList();
Type superClass = this.getParentClass().getSuperClass();
//Instructionhandle dynamisch
InstructionHandle ih_0 = il.append(_factory.createLoad(org.apache.bcel.generic.Type.OBJECT, 0));
il.append(_factory.createInvoke(superClass.getName().toString(), "<init>", org.apache.bcel.generic.Type.VOID, org.apache.bcel.generic.Type.NO_ARGS, Constants.INVOKESPECIAL));
InstructionHandle ih_4 = il.append(_factory.createReturn(org.apache.bcel.generic.Type.VOID));
return il;
} }
} }

View File

@ -37,6 +37,7 @@ public abstract class UnaryExpr extends Expr
ret.add(new RefType("Integer",this,-1)); ret.add(new RefType("Integer",this,-1));
ret.add(new RefType("Long",this,-1)); ret.add(new RefType("Long",this,-1));
ret.add(new RefType("Double",this,-1)); ret.add(new RefType("Double",this,-1));
ret.add(new RefType("Float",this,-1));
return ret ; return ret ;
} }
@ -59,7 +60,9 @@ public abstract class UnaryExpr extends Expr
@Override @Override
public ConstraintsSet TYPEStmt(TypeAssumptions assumptions) { public ConstraintsSet TYPEStmt(TypeAssumptions assumptions) {
return this.TYPEExpr(assumptions); ConstraintsSet ret = this.TYPEExpr(assumptions);
this.setType(new de.dhbwstuttgart.syntaxtree.type.Void(this, -1).TYPE(assumptions, this));
return ret;
} }

View File

@ -810,6 +810,10 @@ public class RefType extends ObjectType implements IMatchable
param.parserPostProcessing(this); param.parserPostProcessing(this);
} }
} }
public org.apache.bcel.generic.Type getBytecodeType() {
return new org.apache.bcel.generic.ObjectType(this.getTypeName());
}
} }
// ino.end // ino.end

View File

@ -304,5 +304,7 @@ public abstract class Type extends SyntaxTreeNode implements IItemWithOffset
return this; return this;
} }
public abstract org.apache.bcel.generic.Type getBytecodeType();
} }
// ino.end // ino.end

View File

@ -78,6 +78,11 @@ public class Void extends RefType
public Type checkTYPE(TypeAssumptions ass, SyntaxTreeNode method) { public Type checkTYPE(TypeAssumptions ass, SyntaxTreeNode method) {
return this;//VOID ist immer korrekt, das wird vom Parser geprüft return this;//VOID ist immer korrekt, das wird vom Parser geprüft
} }
@Override
public org.apache.bcel.generic.Type getBytecodeType() {
return org.apache.bcel.generic.Type.VOID;
}
} }
// ino.end // ino.end

View File

@ -424,5 +424,6 @@ public class TypeAssumptions {
return null; return null;
} }
*/ */
} }

View File

@ -6,6 +6,8 @@ import java.util.Vector;
import org.junit.Test; import org.junit.Test;
import de.dhbwstuttgart.typeinference.EinzelElement;
import de.dhbwstuttgart.typeinference.KomplexeMenge;
import de.dhbwstuttgart.typeinference.Menge; import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.typeinference.OderMenge; import de.dhbwstuttgart.typeinference.OderMenge;
import de.dhbwstuttgart.typeinference.UndMenge; import de.dhbwstuttgart.typeinference.UndMenge;
@ -25,11 +27,45 @@ class TestKlasse {
} }
} }
class TestKlasseOderMenge extends OderMenge<TestKlasse>{
Menge<TestKlasseUndMenge> set = new Menge<>();
@Override
public Menge<? extends KomplexeMenge<TestKlasse>> getSet() {
return set;
}
public void addItem(TestKlasse string) {
TestUndMenge toAdd = new TestKlasseUndMenge();
toAdd.addItem(string);
set.add(toAdd);
}
public void addItems(TestKlasseUndMenge undMenge) {
set.add(undMenge);
}
}
class TestKlasseUndMenge extends UndMenge<TestKlasse>{
Menge<KomplexeMenge<TestKlasse>> set = new Menge<>();
@Override
public Menge<? extends KomplexeMenge<TestKlasse>> getSet() {
return set;
}
public void addItem(TestKlasse string) {
set.add(new EinzelElement<TestKlasse>(string));
}
public void addItems(KomplexeMenge<TestKlasse> oderMenge) {
set.add(oderMenge);
}
}
public class KeineDoppeltenVerweise { public class KeineDoppeltenVerweise {
@Test @Test
public void test() { public void test() {
OderMenge<TestKlasse> oM1 = new OderMenge<>(); OderMenge<TestKlasse> oM1 = new TestOderMenge();
OderMenge<TestKlasse> oM2 = new OderMenge<>(); OderMenge<TestKlasse> oM2 = new OderMenge<>();
UndMenge<TestKlasse> oM3 = new UndMenge<>(); UndMenge<TestKlasse> oM3 = new UndMenge<>();
oM1.addItem(new TestKlasse("Menge 1, Item 1")); oM1.addItem(new TestKlasse("Menge 1, Item 1"));

6
test/bytecode/Assign.jav Normal file
View File

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

45
test/bytecode/Assign.java Normal file
View File

@ -0,0 +1,45 @@
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 Assign {
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
public final static String testFile = "Assign.jav";
public final static String outputFile = "Assign.class";
@Test
public void test() {
LoggerConfiguration logConfig = new LoggerConfiguration().setOutput(Section.PARSER, System.out);
MyCompilerAPI compiler = MyCompiler.getAPI(logConfig);
try {
compiler.parse(new File(rootDirectory + testFile));
compiler.typeReconstruction();
ByteCodeResult bytecode = compiler.generateBytecode();
System.out.println(bytecode);
bytecode.getByteCode().getJavaClass().dump(new File(rootDirectory + outputFile));
} catch (IOException | yyException e) {
e.printStackTrace();
TestCase.fail();
}
}
}

View File

@ -0,0 +1,7 @@
class BoolLit{
void method() { b; b = false; }
}

View File

@ -0,0 +1,45 @@
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 BoolLitTest {
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
public final static String testFile = "BoolLit.jav";
public final static String outputFile = "BoolLit.class";
@Test
public void test() {
LoggerConfiguration logConfig = new LoggerConfiguration().setOutput(Section.PARSER, System.out);
MyCompilerAPI compiler = MyCompiler.getAPI(logConfig);
try {
compiler.parse(new File(rootDirectory + testFile));
compiler.typeReconstruction();
ByteCodeResult bytecode = compiler.generateBytecode();
System.out.println(bytecode);
bytecode.getByteCode().getJavaClass().dump(new File(rootDirectory + outputFile));
} catch (IOException | yyException e) {
e.printStackTrace();
TestCase.fail();
}
}
}

View File

@ -0,0 +1,7 @@
class CharLitTest{
void method() { c; c = 'A'; }
}

View File

@ -0,0 +1,45 @@
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 CharLitTest {
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
public final static String testFile = "CharLitTest.jav";
public final static String outputFile = "CharLitTest.class";
@Test
public void test() {
LoggerConfiguration logConfig = new LoggerConfiguration().setOutput(Section.PARSER, System.out);
MyCompilerAPI compiler = MyCompiler.getAPI(logConfig);
try {
compiler.parse(new File(rootDirectory + testFile));
compiler.typeReconstruction();
ByteCodeResult bytecode = compiler.generateBytecode();
System.out.println(bytecode);
bytecode.getByteCode().getJavaClass().dump(new File(rootDirectory + outputFile));
} catch (IOException | yyException e) {
e.printStackTrace();
TestCase.fail();
}
}
}

View File

@ -0,0 +1,6 @@
class DoubleLiteral{
void method() {a; a = 20.0d;}
}

View File

@ -0,0 +1,45 @@
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 DoubleLiteral {
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
public final static String testFile = "DoubleLiteral.jav";
public final static String outputFile = "DoubleLiteral.class";
@Test
public void test() {
LoggerConfiguration logConfig = new LoggerConfiguration().setOutput(Section.PARSER, System.out);
MyCompilerAPI compiler = MyCompiler.getAPI(logConfig);
try {
compiler.parse(new File(rootDirectory + testFile));
compiler.typeReconstruction();
ByteCodeResult bytecode = compiler.generateBytecode();
System.out.println(bytecode);
bytecode.getByteCode().getJavaClass().dump(new File(rootDirectory + outputFile));
} catch (IOException | yyException e) {
e.printStackTrace();
TestCase.fail();
}
}
}

View File

@ -1,7 +1,7 @@
class EmptyClass{ class EmptyClass{
public EmptyClass(){}
public void leckMichAmArsch(){}
} }

View File

@ -20,11 +20,11 @@ import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet; import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet; import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
public class EmptyClass { public class EmptyClassTest {
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/"; public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
public final static String testFile = "EmptyClass.jav"; public final static String testFile = "EmptyClass.jav";
public final static String outputFile = "EmptyClassTest.class"; public final static String outputFile = "EmptyClass.class";
@Test @Test
public void test() { public void test() {

View File

@ -0,0 +1,6 @@
class FloatLiteral{
void method() {f; f = 20.0f;}
}

View File

@ -0,0 +1,45 @@
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 FloatLiteral {
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
public final static String testFile = "FloatLiteral.jav";
public final static String outputFile = "FloatLiteral.class";
@Test
public void test() {
LoggerConfiguration logConfig = new LoggerConfiguration().setOutput(Section.PARSER, System.out);
MyCompilerAPI compiler = MyCompiler.getAPI(logConfig);
try {
compiler.parse(new File(rootDirectory + testFile));
compiler.typeReconstruction();
ByteCodeResult bytecode = compiler.generateBytecode();
System.out.println(bytecode);
bytecode.getByteCode().getJavaClass().dump(new File(rootDirectory + outputFile));
} catch (IOException | yyException e) {
e.printStackTrace();
TestCase.fail();
}
}
}

View File

@ -0,0 +1,8 @@
class LambdaExpr {
void method() {
lambda; lambda = ()-> 1;
}
}

View File

@ -0,0 +1,45 @@
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 LambdaExpr {
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
public final static String testFile = "LambdaExpr.jav";
public final static String outputFile = "LambdaExpr.class";
@Test
public void test() {
LoggerConfiguration logConfig = new LoggerConfiguration().setOutput(Section.PARSER, System.out);
MyCompilerAPI compiler = MyCompiler.getAPI(logConfig);
try {
compiler.parse(new File(rootDirectory + testFile));
compiler.typeReconstruction();
ByteCodeResult bytecode = compiler.generateBytecode();
System.out.println(bytecode);
bytecode.getByteCode().getJavaClass().dump(new File(rootDirectory + outputFile));
} catch (IOException | yyException e) {
e.printStackTrace();
TestCase.fail();
}
}
}

View File

@ -0,0 +1,6 @@
class LongLiteral{
void method() {l; l = 20L;}
}

View File

@ -0,0 +1,45 @@
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 LongLiteral {
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
public final static String testFile = "LongLiteral.jav";
public final static String outputFile = "LongLiteral.class";
@Test
public void test() {
LoggerConfiguration logConfig = new LoggerConfiguration().setOutput(Section.PARSER, System.out);
MyCompilerAPI compiler = MyCompiler.getAPI(logConfig);
try {
compiler.parse(new File(rootDirectory + testFile));
compiler.typeReconstruction();
ByteCodeResult bytecode = compiler.generateBytecode();
System.out.println(bytecode);
bytecode.getByteCode().getJavaClass().dump(new File(rootDirectory + outputFile));
} catch (IOException | yyException e) {
e.printStackTrace();
TestCase.fail();
}
}
}

View File

@ -0,0 +1,7 @@
class MethodEmpty{
void method() { }
}

View File

@ -0,0 +1,45 @@
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 MethodEmpty {
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
public final static String testFile = "MethodEmpty.jav";
public final static String outputFile = "MethodEmpty.class";
@Test
public void test() {
LoggerConfiguration logConfig = new LoggerConfiguration().setOutput(Section.PARSER, System.out);
MyCompilerAPI compiler = MyCompiler.getAPI(logConfig);
try {
compiler.parse(new File(rootDirectory + testFile));
compiler.typeReconstruction();
ByteCodeResult bytecode = compiler.generateBytecode();
System.out.println(bytecode);
bytecode.getByteCode().getJavaClass().dump(new File(rootDirectory + outputFile));
} catch (IOException | yyException e) {
e.printStackTrace();
TestCase.fail();
}
}
}

View File

@ -0,0 +1,7 @@
class MethodEmptyRetType{
Object method() { return null; }
}

View File

@ -0,0 +1,45 @@
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 MethodEmptyRetType {
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
public final static String testFile = "MethodEmptyRetType.jav";
public final static String outputFile = "MethodEmptyRetType.class";
@Test
public void test() {
LoggerConfiguration logConfig = new LoggerConfiguration().setOutput(Section.PARSER, System.out);
MyCompilerAPI compiler = MyCompiler.getAPI(logConfig);
try {
compiler.parse(new File(rootDirectory + testFile));
compiler.typeReconstruction();
ByteCodeResult bytecode = compiler.generateBytecode();
System.out.println(bytecode);
bytecode.getByteCode().getJavaClass().dump(new File(rootDirectory + outputFile));
} catch (IOException | yyException e) {
e.printStackTrace();
TestCase.fail();
}
}
}

View File

@ -0,0 +1,11 @@
class NewArray{
void method() {
a;
a = new Integer[2];
a = {1,2};
}
}

View File

@ -0,0 +1,45 @@
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 NewArrayTest {
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
public final static String testFile = "NewArray.jav";
public final static String outputFile = "NewArray.class";
@Test
public void test() {
LoggerConfiguration logConfig = new LoggerConfiguration().setOutput(Section.PARSER, System.out);
MyCompilerAPI compiler = MyCompiler.getAPI(logConfig);
try {
compiler.parse(new File(rootDirectory + testFile));
compiler.typeReconstruction();
ByteCodeResult bytecode = compiler.generateBytecode();
System.out.println(bytecode);
bytecode.getByteCode().getJavaClass().dump(new File(rootDirectory + outputFile));
} catch (IOException | yyException e) {
e.printStackTrace();
TestCase.fail();
}
}
}

View File

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

View File

@ -0,0 +1,45 @@
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 PostIncrement {
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
public final static String testFile = "PostIncrement.jav";
public final static String outputFile = "PostIncrement.class";
@Test
public void test() {
LoggerConfiguration logConfig = new LoggerConfiguration().setOutput(Section.PARSER, System.out);
MyCompilerAPI compiler = MyCompiler.getAPI(logConfig);
try {
compiler.parse(new File(rootDirectory + testFile));
compiler.typeReconstruction();
ByteCodeResult bytecode = compiler.generateBytecode();
System.out.println(bytecode);
bytecode.getByteCode().getJavaClass().dump(new File(rootDirectory + outputFile));
} catch (IOException | yyException e) {
e.printStackTrace();
TestCase.fail();
}
}
}

View File

@ -0,0 +1,7 @@
class StringLitTest{
void method() { s; s = "abcdefg"; t; t ="jfowehfowh"; }
}

View File

@ -0,0 +1,45 @@
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 StringLitTest {
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
public final static String testFile = "StringLitTest.jav";
public final static String outputFile = "StringLitTest.class";
@Test
public void test() {
LoggerConfiguration logConfig = new LoggerConfiguration().setOutput(Section.PARSER, System.out);
MyCompilerAPI compiler = MyCompiler.getAPI(logConfig);
try {
compiler.parse(new File(rootDirectory + testFile));
compiler.typeReconstruction();
ByteCodeResult bytecode = compiler.generateBytecode();
System.out.println(bytecode);
bytecode.getByteCode().getJavaClass().dump(new File(rootDirectory + outputFile));
} catch (IOException | yyException e) {
e.printStackTrace();
TestCase.fail();
}
}
}