This commit is contained in:
JanUlrich 2015-06-16 15:04:38 +02:00
commit 4191c8d8b2
47 changed files with 1157 additions and 777 deletions

View File

@ -9,3 +9,4 @@
<classpathentry kind="lib" path="lib/bcel-5.2.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@ -864,7 +864,9 @@ public class MyCompiler implements MyCompilerAPI
* - wird der Rückgabetyp von generateBytecode in MyCompiler geändert, so muss auch der Rückgabetyp im Interface MyCompilerAPI geändert werden
*/
try {
return this.m_AbstractSyntaxTree.firstElement().KlassenVektor.firstElement().genByteCode();
SourceFile parsedFile = this.m_AbstractSyntaxTree.firstElement();
Class parsedClass = parsedFile.KlassenVektor.firstElement();
return parsedClass.genByteCode();
} catch (IOException e) {
e.printStackTrace();
return null;

View File

@ -16,9 +16,9 @@ import org.apache.bcel.generic.InstructionList;
import org.apache.bcel.generic.MethodGen;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.logger.Logger;
import de.dhbwstuttgart.logger.Section;
import de.dhbwstuttgart.logger.SectionLogger;
import de.dhbwstuttgart.core.AClassOrInterface;
import de.dhbwstuttgart.core.IItemWithOffset;
import de.dhbwstuttgart.parser.JavaClassName;
@ -37,13 +37,16 @@ import de.dhbwstuttgart.typeinference.*;
import de.dhbwstuttgart.typeinference.assumptions.ClassAssumption;
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
import de.dhbwstuttgart.typeinference.exceptions.DebugException;
import de.dhbwstuttgart.typeinference.exceptions.NotImplementedException;
import de.dhbwstuttgart.typeinference.exceptions.TypeinferenceException;
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertPoint;
import de.dhbwstuttgart.typeinference.unify.FC_TTO;
import de.dhbwstuttgart.typeinference.unify.Unify;
import org.apache.bcel.generic.*;
import org.apache.bcel.classfile.*;
import org.apache.bcel.*;
import java.io.*;
@ -57,8 +60,8 @@ public class Class extends GTVDeclarationContext implements AClassOrInterface, I
* Log4j - Loggerinstanzen
*/
protected static Logger inferencelog = Logger.getLogger("inference");
//protected static Logger codegenlog = Logger.getLogger("codegen");
//protected static Logger parserlog = Logger.getLogger("parser");
protected static Logger codegenlog = Logger.getLogger("codegen");
protected static Logger parserlog = Logger.getLogger("parser");
protected UsedId pkgName;
protected Modifiers modifiers;
protected String name;
@ -70,33 +73,26 @@ public class Class extends GTVDeclarationContext implements AClassOrInterface, I
//Method created with BCEL to generate ByteCode
public ByteCodeResult genByteCode() throws IOException {
ByteCodeResult code = new ByteCodeResult();
SectionLogger logger = Logger.getSectionLogger(this.getClass().getName(), Section.CODEGEN);
logger.debug("Test");
_cg = new ClassGen(pkgName.get_Name() + "/" + name, superClass.get_Name(), name + ".java", Constants.ACC_PUBLIC , new String[] { }); //new String necessary?
if(pkgName != null)throw new NotImplementedException();
_cg = new ClassGen(name, superClass.get_Name(), name + ".java", Constants.ACC_PUBLIC , new String[] { }); //new String necessary?
_cp = _cg.getConstantPool();
_factory = new InstructionFactory(_cg, _cp);
ByteArrayOutputStream out = new ByteArrayOutputStream();
InstructionList il = new InstructionList();
MethodGen method = new MethodGen(Constants.ACC_PUBLIC, org.apache.bcel.generic.Type.VOID, org.apache.bcel.generic.Type.NO_ARGS, new String[] { }, "<init>", pkgName.get_Name() + "." + name, il, _cp);
InstructionHandle ih_0 = il.append(_factory.createLoad(org.apache.bcel.generic.Type.OBJECT, 0)); //creates Constructor
il.append(_factory.createInvoke("java.lang.Object", "<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)); //creates Constructor
method.setMaxStack();
method.setMaxLocals();
_cg.addMethod(method.getMethod());
il.dispose();
_cg.getJavaClass().dump(out);
code.attach(out.toString());
for(Field field : this.fielddecl){
field.genByteCode(_cg);
}
ByteCodeResult code = new ByteCodeResult(_cg);
return code;
/*ByteCodeResult bc = new ByteCodeResult();
_cg = new ClassGen(pkgName.get_Name() + "/" + name, superClass.get_Name(), name + ".java", Constants.ACC_PUBLIC , new String[] { });
//ByteCodeResult bc = new ByteCodeResult();
//_cg = new ClassGen(pkgName.get_Name() + "/" + name, superClass.get_Name(), name + ".java", Constants.ACC_PUBLIC , new String[] { });
//_cg zurückgeben
bc.append(BCELByteCodeOutput);
return _cg;*/
//bc.append(BCELByteCodeOutput);
//return _cg;
}
private Menge<Type> superif = new Menge<Type>();

View File

@ -1,7 +1,15 @@
package de.dhbwstuttgart.syntaxtree;
import de.dhbwstuttgart.typeinference.Menge;
import org.apache.bcel.Constants;
import org.apache.bcel.classfile.ConstantPool;
import org.apache.bcel.generic.ClassGen;
import org.apache.bcel.generic.ConstantPoolGen;
import org.apache.bcel.generic.InstructionFactory;
import org.apache.bcel.generic.InstructionHandle;
import org.apache.bcel.generic.InstructionList;
import org.apache.bcel.generic.MethodGen;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.myexception.JVMCodeException;
import de.dhbwstuttgart.parser.JavaClassName;
import de.dhbwstuttgart.syntaxtree.misc.DeclId;
@ -42,7 +50,30 @@ public class Constructor extends Method {
ret.addAssumption(new ConstructorAssumption(this, parentClass));
return ret;
}
/*
@Override
public void genByteCode(ClassGen cg) {
ConstantPoolGen _cp = cg.getConstantPool();
//InstructionFactory _factory = new InstructionFactory(cg, _cp);
InstructionList il = new InstructionList(); //sollte nicht new sein sondern aus Block kommen
Class parentClass = this.getParentClass();
//Hier müsste drin stehen: Kreiere einen Block, welcher ein Statement enthält, welches ein Super Statement ist.
//TODO: Alles dynamisch gestalten
//init darf nur drin stehen, wenn Konstruktor;
methode.method = new MethodGen(Constants.ACC_PUBLIC, org.apache.bcel.generic.Type.getReturnType(methode.getType().get_Name()), org.apache.bcel.generic.Type.NO_ARGS , new String[] { }, "<init>", parentClass.name, il, _cp);
methode.genByteCode(cg); //Aufrufen um Iteration über Block zu starten
}
// super statement muss drin sein
// stmt genByteCode + im block genByteCode implementieren & dann Hierarchie ausprobieren
// de.dhbw.systanxtree.stmts supercall
// Aufrufhierarchie: Class->Felder->Konstruktor->Methode innerhalb Konstruktor->Block->Statements (in diesem Fall nur super())->hier wird bytecode für superaufruf generiert
@Override
public void parserPostProcessing(SyntaxTreeNode parent){
if(this.parameterlist != null){
@ -54,7 +85,7 @@ public class Constructor extends Method {
gtv.parserPostProcessing(this);
}
}
*/
@Override
public ConstraintsSet TYPE(TypeAssumptions ass) {
//super.setType(this.getParentClass().getType());
@ -67,13 +98,13 @@ public class Constructor extends Method {
//throw new TypeinferenceException("Einem Konstruktor kann kein Typ zugewiesen werden", this);
//this.methode.setType(t);
}
/*
public Constructor(Method methode){
/*public Constructor(Method methode){
super(methode.getOffset());
this.methode = methode;
this.setDeclIdMenge(methode.getDeclIdMenge());
this.methode.setType(this.methode.getParentClass().getType());
}
}*/
@Override
public Menge<GenericTypeVar> getGenericParameter() {
@ -198,11 +229,11 @@ public class Constructor extends Method {
this.methode.setOverloadedID(overloadedID);
}
@Override
/*@Override
public String get_codegen_Param_Type(Menge paralist) {
return this.methode.get_codegen_Param_Type(paralist);
}
}*/
@Override
public String get_Method_Name() {
@ -216,12 +247,12 @@ public class Constructor extends Method {
return this.methode.get_Type_Paralist();
}
@Override
/*@Override
public void codegen(ClassFile classfile, Menge paralist)
throws JVMCodeException {
this.methode.codegen(classfile, paralist);
}
}*/
@Override
public int getLineNumber() {
@ -289,11 +320,11 @@ public class Constructor extends Method {
this.methode.set_Method_Name(string);
}
public ConstraintsSet TYPE(TypeAssumptions ass) {
/*public ConstraintsSet TYPE(TypeAssumptions ass) {
ConstraintsSet ret = new ConstraintsSet();
ret.add(this.methode.get_Block().TYPEStmt(ass));
return ret;
}
}*/
@Override
public String getTypeInformation() {
@ -307,24 +338,24 @@ public class Constructor extends Method {
return this.methode.printJavaCode(resultSet);
}
@Override
/*@Override
public TypeAssumptions createTypeAssumptions(Class classmember) {
Class parentClass = this.getParentClass();
TypeAssumptions ret = new TypeAssumptions();
ret.addAssumption(new ConstructorAssumption(this, parentClass));
return ret;
}
}*/
@Override
public SyntaxTreeNode getParent(){
return this.methode.getParent();
}
@Override
/*@Override
public void parserPostProcessing(SyntaxTreeNode parent) {
this.methode.parserPostProcessing(parent);
}
}*/
@Override
public Menge<SyntaxTreeNode> getChildren() {
@ -332,11 +363,11 @@ public class Constructor extends Method {
return this.methode.getChildren();
}
@Override
/*@Override
public void setType(Type t) {
throw new TypeinferenceException("Einem Konstruktor kann kein Typ zugewiesen werden", this);
//this.methode.setType(t);
}
}*/
@Override
public Type getType() {
@ -390,7 +421,7 @@ public class Constructor extends Method {
public Class getParentClass() {
return this.methode.getParentClass();
}
*/
}

View File

@ -1,7 +1,8 @@
package de.dhbwstuttgart.syntaxtree;
import de.dhbwstuttgart.typeinference.Menge;
import org.apache.bcel.generic.ClassGen;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.myexception.JVMCodeException;
import de.dhbwstuttgart.syntaxtree.misc.DeclId;
import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar;
@ -171,4 +172,11 @@ public abstract class Field extends GTVDeclarationContext implements TypeInserta
public boolean isClass() {
return false;
}
/**
* Fügt das das Feld zu ClassGen hinzu
* @param cg
*/
public abstract void genByteCode(ClassGen cg);
}

View File

@ -1,7 +1,8 @@
package de.dhbwstuttgart.syntaxtree;
import de.dhbwstuttgart.typeinference.Menge;
import org.apache.bcel.generic.ClassGen;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.myexception.JVMCodeException;
import de.dhbwstuttgart.syntaxtree.misc.DeclId;
import de.dhbwstuttgart.syntaxtree.statement.Expr;
@ -157,4 +158,16 @@ public class FieldDeclaration extends Field{
if(this.getWert()!=null)this.getWert().wandleRefTypeAttributes2GenericAttributes(paralist, new Menge<GenericTypeVar>()); //FieldDeclaration hat keine Generischen Variablen, daher leere Liste übergeben
}
@Override
public void genByteCode(ClassGen cg) {
// TODO Auto-generated method stub
}
/*@Override
public void genByteCode(ClassGen cg) {
// TODO Auto-generated method stub
}*/
}

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,8 @@
package de.dhbwstuttgart.syntaxtree;
import de.dhbwstuttgart.typeinference.Menge;
import org.apache.bcel.generic.ClassGen;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.core.IItemWithOffset;
import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar;
import de.dhbwstuttgart.syntaxtree.type.Type;
@ -126,4 +127,6 @@ public abstract class SyntaxTreeNode implements IItemWithOffset{
return this.getParent().getGTVDeclarationContext();
}
}

View File

@ -5,10 +5,11 @@ package de.dhbwstuttgart.syntaxtree.statement;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Iterator;
import org.apache.bcel.generic.ClassGen;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.logger.Logger;
import de.dhbwstuttgart.myexception.CTypeReconstructionException;
import de.dhbwstuttgart.myexception.JVMCodeException;
import de.dhbwstuttgart.myexception.SCExcept;
@ -166,5 +167,15 @@ public class Assign extends Expr
return ret;
}
@Override
public void genByteCode(ClassGen _cg) {
// TODO Auto-generated method stub
}
}
// ino.end

View File

@ -5,10 +5,11 @@ package de.dhbwstuttgart.syntaxtree.statement;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Hashtable;
import org.apache.bcel.generic.ClassGen;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.logger.Logger;
import de.dhbwstuttgart.myexception.CTypeReconstructionException;
import de.dhbwstuttgart.myexception.JVMCodeException;
import de.dhbwstuttgart.myexception.SCExcept;
@ -212,5 +213,13 @@ public JavaCodeResult printJavaCode(ResultSet resultSet) {
}
@Override
public void genByteCode(ClassGen _cg) {
// TODO Auto-generated method stub
}
}
// ino.end

View File

@ -5,8 +5,16 @@ package de.dhbwstuttgart.syntaxtree.statement;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Iterator;
import de.dhbwstuttgart.typeinference.Menge;
import org.apache.bcel.Constants;
import org.apache.bcel.generic.ClassGen;
import org.apache.bcel.generic.ConstantPoolGen;
import org.apache.bcel.generic.InstructionFactory;
import org.apache.bcel.generic.InstructionHandle;
import org.apache.bcel.generic.InstructionList;
import org.apache.bcel.generic.MethodGen;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.logger.Logger;
import de.dhbwstuttgart.logger.Section;
import de.dhbwstuttgart.myexception.CTypeReconstructionException;
@ -14,6 +22,7 @@ import de.dhbwstuttgart.myexception.JVMCodeException;
import de.dhbwstuttgart.myexception.SCExcept;
import de.dhbwstuttgart.myexception.SCStatementException;
import de.dhbwstuttgart.syntaxtree.Class;
import de.dhbwstuttgart.syntaxtree.Field;
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar;
import de.dhbwstuttgart.syntaxtree.type.Type;
@ -37,6 +46,9 @@ public class Block extends Statement
// ino.end
// ino.class.Block.25037.body
{
private InstructionFactory _factory;
private ConstantPoolGen _cp;
private ClassGen _cg;
// ino.method.Block.25041.definition
public Block()
@ -81,6 +93,7 @@ public class Block extends Statement
// ino.method.set_Statement.25068.definition
public void set_Statement(Statement s)
// ino.end
@ -224,6 +237,7 @@ public class Block extends Statement
ret.attach(stmt.printJavaCode(resultSet));
ret.attach((stmt instanceof ExprStmt ? ";" : "") + "\n");
}
return ret.attach("}");
}
@ -241,5 +255,24 @@ public class Block extends Statement
public String getDescription(){
return "Block";
}
@Override
public void genByteCode(ClassGen cg) {
//ConstantPoolGen _cp = cg.getConstantPool();
InstructionFactory _factory = new InstructionFactory(cg, _cp);
InstructionList il = new InstructionList();
//Frage: Wenn Block von Statements erbt, und Block selbst keinen BCEL Code besitzt, ist das hier dann nicht eine Sackgasse?
//Instructionhandle dynamisch
InstructionHandle ih_0 = il.append(_factory.createLoad(org.apache.bcel.generic.Type.OBJECT, 0));
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();
}
}
// ino.end

View File

@ -3,8 +3,10 @@ package de.dhbwstuttgart.syntaxtree.statement;
// ino.end
// ino.module.BoolLiteral.8626.import
import java.util.Hashtable;
import de.dhbwstuttgart.typeinference.Menge;
import org.apache.bcel.generic.ClassGen;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.logger.Logger;
import de.dhbwstuttgart.myexception.CTypeReconstructionException;
import de.dhbwstuttgart.myexception.JVMCodeException;
@ -28,7 +30,15 @@ public class BoolLiteral extends Literal
// ino.end
// ino.class.BoolLiteral.25089.body
{
// ino.attribute.Bool.25093.declaration
@Override
public void genByteCode(ClassGen _cg) {
// TODO Auto-generated method stub
}
// ino.attribute.Bool.25093.declaration
private boolean Bool;
// ino.end
// ino.attribute.parserlog.25096.declaration

View File

@ -4,8 +4,10 @@ package de.dhbwstuttgart.syntaxtree.statement;
// ino.module.CastExpr.8627.import
import java.util.Hashtable;
import java.util.Iterator;
import de.dhbwstuttgart.typeinference.Menge;
import org.apache.bcel.generic.ClassGen;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.logger.Logger;
import de.dhbwstuttgart.myexception.CTypeReconstructionException;
import de.dhbwstuttgart.myexception.JVMCodeException;
@ -118,5 +120,13 @@ public class CastExpr extends UnaryExpr
}
@Override
public void genByteCode(ClassGen _cg) {
// TODO Auto-generated method stub
}
}
// ino.end

View File

@ -3,6 +3,9 @@ package de.dhbwstuttgart.syntaxtree.statement;
// ino.end
// ino.module.CharLiteral.8628.import
import java.util.Hashtable;
import org.apache.bcel.generic.ClassGen;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.logger.Logger;
import de.dhbwstuttgart.myexception.CTypeReconstructionException;
@ -107,5 +110,12 @@ public class CharLiteral extends Literal
Menge<Type> paralist,
Menge<GenericTypeVar> genericMethodParameters) {
}
@Override
public void genByteCode(ClassGen _cg) {
// TODO Auto-generated method stub
}
}
// ino.end

View File

@ -3,11 +3,11 @@ package de.dhbwstuttgart.syntaxtree.statement;
// ino.end
// ino.module.IntLiteral.8635.import
import java.util.Hashtable;
import org.apache.bcel.generic.ClassGen;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.logger.Logger;
import de.dhbwstuttgart.myexception.CTypeReconstructionException;
import de.dhbwstuttgart.myexception.JVMCodeException;
import de.dhbwstuttgart.syntaxtree.Class;
@ -130,5 +130,11 @@ public JavaCodeResult printJavaCode(ResultSet resultSet) {
Menge<SyntaxTreeNode> ret = new Menge<SyntaxTreeNode>();
return ret;
}
@Override
public void genByteCode(ClassGen _cg) {
// TODO Auto-generated method stub
}
}
// ino.end

View File

@ -3,10 +3,11 @@ package de.dhbwstuttgart.syntaxtree.statement;
// ino.end
// ino.module.EmptyStmt.8629.import
import java.util.Hashtable;
import org.apache.bcel.generic.ClassGen;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.logger.Logger;
import de.dhbwstuttgart.myexception.CTypeReconstructionException;
import de.dhbwstuttgart.myexception.JVMCodeException;
import de.dhbwstuttgart.syntaxtree.Class;
@ -85,5 +86,12 @@ public class EmptyStmt extends Statement
return new Menge<SyntaxTreeNode>();
}
@Override
public void genByteCode(ClassGen _cg) {
// TODO Auto-generated method stub
}
}
// ino.end

View File

@ -3,10 +3,11 @@ package de.dhbwstuttgart.syntaxtree.statement;
// ino.end
// ino.module.IntLiteral.8635.import
import java.util.Hashtable;
import org.apache.bcel.generic.ClassGen;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.logger.Logger;
import de.dhbwstuttgart.myexception.CTypeReconstructionException;
import de.dhbwstuttgart.myexception.JVMCodeException;
import de.dhbwstuttgart.syntaxtree.Class;
@ -126,5 +127,11 @@ public JavaCodeResult printJavaCode(ResultSet resultSet) {
Menge<SyntaxTreeNode> ret = new Menge<SyntaxTreeNode>();
return ret;
}
@Override
public void genByteCode(ClassGen _cg) {
// TODO Auto-generated method stub
}
}
// ino.end

View File

@ -3,10 +3,11 @@ package de.dhbwstuttgart.syntaxtree.statement;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Iterator;
import org.apache.bcel.generic.ClassGen;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.logger.Logger;
import de.dhbwstuttgart.myexception.CTypeReconstructionException;
import de.dhbwstuttgart.myexception.JVMCodeException;
import de.dhbwstuttgart.myexception.SCExcept;
@ -115,4 +116,10 @@ public JavaCodeResult printJavaCode(ResultSet resultSet) {
//throw new NotImplementedException();
return ret;
}
@Override
public void genByteCode(ClassGen _cg) {
// TODO Auto-generated method stub
}
}

View File

@ -5,10 +5,11 @@ package de.dhbwstuttgart.syntaxtree.statement;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Iterator;
import org.apache.bcel.generic.ClassGen;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.logger.Logger;
import de.dhbwstuttgart.myexception.CTypeReconstructionException;
import de.dhbwstuttgart.myexception.JVMCodeException;
import de.dhbwstuttgart.myexception.SCExcept;
@ -160,5 +161,13 @@ public class IfStmt extends Statement
if(this.then_block!=null)ret.add(this.then_block);
return ret;
}
@Override
public void genByteCode(ClassGen _cg) {
// TODO Auto-generated method stub
}
}
// ino.end

View File

@ -5,10 +5,11 @@ package de.dhbwstuttgart.syntaxtree.statement;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Iterator;
import org.apache.bcel.generic.ClassGen;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.logger.Logger;
import de.dhbwstuttgart.myexception.CTypeReconstructionException;
import de.dhbwstuttgart.myexception.JVMCodeException;
import de.dhbwstuttgart.syntaxtree.Class;
@ -214,5 +215,11 @@ public class InstVar extends Expr
ret.add(this.expr);
return ret;
}
@Override
public void genByteCode(ClassGen _cg) {
// TODO Auto-generated method stub
}
}
// ino.end

View File

@ -4,10 +4,11 @@ package de.dhbwstuttgart.syntaxtree.statement;
// ino.module.InstanceOf.8633.import
import java.util.Enumeration;
import java.util.Hashtable;
import org.apache.bcel.generic.ClassGen;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.logger.Logger;
import de.dhbwstuttgart.myexception.CTypeReconstructionException;
import de.dhbwstuttgart.myexception.JVMCodeException;
import de.dhbwstuttgart.myexception.SCStatementException;
@ -115,6 +116,12 @@ public JavaCodeResult printJavaCode(ResultSet resultSet) {
return ret;
}
@Override
public void genByteCode(ClassGen _cg) {
// TODO Auto-generated method stub
}
}
// ino.end

View File

@ -3,8 +3,10 @@ package de.dhbwstuttgart.syntaxtree.statement;
// ino.end
// ino.module.IntLiteral.8635.import
import java.util.Hashtable;
import de.dhbwstuttgart.typeinference.Menge;
import org.apache.bcel.generic.ClassGen;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.logger.Logger;
import de.dhbwstuttgart.myexception.CTypeReconstructionException;
import de.dhbwstuttgart.myexception.JVMCodeException;
@ -128,5 +130,11 @@ public class IntLiteral extends Literal
Menge<SyntaxTreeNode> ret = new Menge<SyntaxTreeNode>();
return ret;
}
@Override
public void genByteCode(ClassGen _cg) {
// TODO Auto-generated method stub
}
}
// ino.end

View File

@ -1,8 +1,10 @@
package de.dhbwstuttgart.syntaxtree.statement;
import java.util.Hashtable;
import de.dhbwstuttgart.typeinference.Menge;
import org.apache.bcel.generic.ClassGen;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.myexception.CTypeReconstructionException;
import de.dhbwstuttgart.myexception.JVMCodeException;
import de.dhbwstuttgart.myexception.SCStatementException;
@ -206,4 +208,10 @@ public class LambdaExpression extends Expr{
return ret;
}
@Override
public void genByteCode(ClassGen _cg) {
// TODO Auto-generated method stub
}
}

View File

@ -4,8 +4,10 @@ package de.dhbwstuttgart.syntaxtree.statement;
// ino.module.LocalOrFieldVar.8637.import
import java.util.Enumeration;
import java.util.Hashtable;
import de.dhbwstuttgart.typeinference.Menge;
import org.apache.bcel.generic.ClassGen;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.logger.Logger;
import de.dhbwstuttgart.myexception.CTypeReconstructionException;
import de.dhbwstuttgart.myexception.JVMCodeException;
@ -133,5 +135,11 @@ public class LocalOrFieldVar extends Expr
return ret;
}
@Override
public void genByteCode(ClassGen _cg) {
// TODO Auto-generated method stub
}
}
// ino.end

View File

@ -4,10 +4,11 @@ package de.dhbwstuttgart.syntaxtree.statement;
// ino.module.LocalVarDecl.8638.import
import java.util.Enumeration;
import java.util.Hashtable;
import org.apache.bcel.generic.ClassGen;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.logger.Logger;
import de.dhbwstuttgart.core.MyCompiler;
import de.dhbwstuttgart.myexception.JVMCodeException;
import de.dhbwstuttgart.myexception.SCExcept;
@ -422,5 +423,11 @@ public class LocalVarDecl extends Statement implements TypeInsertable
ResultSet resultSet) {
return new TypeInsertPoint(this, this, resultSet.getTypeEqualTo(tph),resultSet);
}
@Override
public void genByteCode(ClassGen _cg) {
// TODO Auto-generated method stub
}
}
// ino.end

View File

@ -3,11 +3,11 @@ package de.dhbwstuttgart.syntaxtree.statement;
// ino.end
// ino.module.IntLiteral.8635.import
import java.util.Hashtable;
import org.apache.bcel.generic.ClassGen;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.logger.Logger;
import de.dhbwstuttgart.myexception.CTypeReconstructionException;
import de.dhbwstuttgart.myexception.JVMCodeException;
import de.dhbwstuttgart.syntaxtree.Class;
@ -125,5 +125,11 @@ public JavaCodeResult printJavaCode(ResultSet resultSet) {
Menge<SyntaxTreeNode> ret = new Menge<SyntaxTreeNode>();
return ret;
}
@Override
public void genByteCode(ClassGen _cg) {
// TODO Auto-generated method stub
}
}
// ino.end

View File

@ -3,8 +3,10 @@ package de.dhbwstuttgart.syntaxtree.statement;
// ino.end
// ino.module.MethodCall.8639.import
import java.util.Hashtable;
import de.dhbwstuttgart.typeinference.Menge;
import org.apache.bcel.generic.ClassGen;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.logger.Logger;
import de.dhbwstuttgart.myexception.JVMCodeException;
import de.dhbwstuttgart.syntaxtree.Method;
@ -48,7 +50,6 @@ public class MethodCall extends Expr
}
// ino.end
// ino.attribute.receiver.25639.declaration
/**
* Diese Variable speichert die Expression, welche die Klasse von welcher die Methode aufgerufen wird darstellt.
@ -303,5 +304,11 @@ public class MethodCall extends Expr
super.parserPostProcessing(parent);
}
@Override
public void genByteCode(ClassGen _cg) {
// TODO Auto-generated method stub
}
}
// ino.end

View File

@ -4,10 +4,11 @@ package de.dhbwstuttgart.syntaxtree.statement;
// ino.module.NegativeExpr.8640.import
import java.util.Hashtable;
import java.util.Iterator;
import org.apache.bcel.generic.ClassGen;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.logger.Logger;
import de.dhbwstuttgart.myexception.CTypeReconstructionException;
import de.dhbwstuttgart.myexception.JVMCodeException;
import de.dhbwstuttgart.myexception.SCExcept;
@ -107,5 +108,11 @@ public class NegativeExpr extends UnaryExpr
return ret;
}
@Override
public void genByteCode(ClassGen _cg) {
// TODO Auto-generated method stub
}
}
// ino.end

View File

@ -3,9 +3,10 @@ package de.dhbwstuttgart.syntaxtree.statement;
// ino.end
// ino.module.NewArray.8641.import
import java.util.Hashtable;
import org.apache.bcel.generic.ClassGen;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.logger.Logger;
import de.dhbwstuttgart.myexception.CTypeReconstructionException;
import de.dhbwstuttgart.myexception.JVMCodeException;
@ -142,5 +143,11 @@ public JavaCodeResult printJavaCode(ResultSet resultSet) {
return ret;
}
@Override
public void genByteCode(ClassGen _cg) {
// TODO Auto-generated method stub
}
}
// ino.end

View File

@ -5,9 +5,10 @@ package de.dhbwstuttgart.syntaxtree.statement;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Iterator;
import org.apache.bcel.generic.ClassGen;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.logger.Logger;
import de.dhbwstuttgart.myexception.CTypeReconstructionException;
import de.dhbwstuttgart.myexception.JVMCodeException;
@ -202,6 +203,12 @@ public class NewClass extends Expr
return ret;
}
@Override
public void genByteCode(ClassGen _cg) {
// TODO Auto-generated method stub
}
}
// ino.end

View File

@ -4,10 +4,11 @@ package de.dhbwstuttgart.syntaxtree.statement;
// ino.module.NotExpr.8643.import
import java.util.Hashtable;
import java.util.Iterator;
import org.apache.bcel.generic.ClassGen;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.logger.Logger;
import de.dhbwstuttgart.myexception.CTypeReconstructionException;
import de.dhbwstuttgart.myexception.JVMCodeException;
import de.dhbwstuttgart.myexception.SCStatementException;
@ -132,5 +133,11 @@ public JavaCodeResult printJavaCode(ResultSet resultSet) {
return ret;
}
@Override
public void genByteCode(ClassGen _cg) {
// TODO Auto-generated method stub
}
}
// ino.end

View File

@ -3,9 +3,10 @@ package de.dhbwstuttgart.syntaxtree.statement;
// ino.end
// ino.module.Null.8644.import
import java.util.Hashtable;
import org.apache.bcel.generic.ClassGen;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.logger.Logger;
import de.dhbwstuttgart.myexception.CTypeReconstructionException;
import de.dhbwstuttgart.myexception.JVMCodeException;
@ -89,5 +90,11 @@ public class Null extends Literal
return new Menge<SyntaxTreeNode>();
}
@Override
public void genByteCode(ClassGen _cg) {
// TODO Auto-generated method stub
}
}
// ino.end

View File

@ -3,9 +3,10 @@ package de.dhbwstuttgart.syntaxtree.statement;
// ino.end
// ino.module.PositivExpr.8645.import
import java.util.Hashtable;
import org.apache.bcel.generic.ClassGen;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.logger.Logger;
import de.dhbwstuttgart.myexception.CTypeReconstructionException;
import de.dhbwstuttgart.myexception.JVMCodeException;
@ -115,5 +116,11 @@ public JavaCodeResult printJavaCode(ResultSet resultSet) {
return ret;
}
@Override
public void genByteCode(ClassGen _cg) {
// TODO Auto-generated method stub
}
}
// ino.end

View File

@ -4,10 +4,11 @@ package de.dhbwstuttgart.syntaxtree.statement;
// ino.module.PostDecExpr.8646.import
import java.util.Hashtable;
import java.util.Iterator;
import org.apache.bcel.generic.ClassGen;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.logger.Logger;
import de.dhbwstuttgart.myexception.CTypeReconstructionException;
import de.dhbwstuttgart.myexception.JVMCodeException;
import de.dhbwstuttgart.myexception.SCExcept;
@ -88,5 +89,11 @@ public JavaCodeResult printJavaCode(ResultSet resultSet) {
return ret;
}
@Override
public void genByteCode(ClassGen _cg) {
// TODO Auto-generated method stub
}
}
// ino.end

View File

@ -4,10 +4,11 @@ package de.dhbwstuttgart.syntaxtree.statement;
// ino.module.PostIncExpr.8647.import
import java.util.Hashtable;
import java.util.Iterator;
import org.apache.bcel.generic.ClassGen;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.logger.Logger;
import de.dhbwstuttgart.myexception.CTypeReconstructionException;
import de.dhbwstuttgart.myexception.JVMCodeException;
import de.dhbwstuttgart.myexception.SCExcept;
@ -94,5 +95,11 @@ public JavaCodeResult printJavaCode(ResultSet resultSet) {
return ret;
}
@Override
public void genByteCode(ClassGen _cg) {
// TODO Auto-generated method stub
}
}
// ino.end

View File

@ -4,10 +4,11 @@ package de.dhbwstuttgart.syntaxtree.statement;
// ino.module.PreDecExpr.8648.import
import java.util.Hashtable;
import java.util.Iterator;
import org.apache.bcel.generic.ClassGen;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.logger.Logger;
import de.dhbwstuttgart.myexception.CTypeReconstructionException;
import de.dhbwstuttgart.myexception.JVMCodeException;
import de.dhbwstuttgart.myexception.SCExcept;
@ -86,6 +87,11 @@ public class PreDecExpr extends UnaryExpr
ret.add(this.expr);
return ret;
}
@Override
public void genByteCode(ClassGen _cg) {
// TODO Auto-generated method stub
}
}
// ino.end

View File

@ -4,10 +4,11 @@ package de.dhbwstuttgart.syntaxtree.statement;
// ino.module.PreIncExpr.8649.import
import java.util.Hashtable;
import java.util.Iterator;
import org.apache.bcel.generic.ClassGen;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.logger.Logger;
import de.dhbwstuttgart.myexception.CTypeReconstructionException;
import de.dhbwstuttgart.myexception.JVMCodeException;
import de.dhbwstuttgart.myexception.SCExcept;
@ -89,5 +90,11 @@ public JavaCodeResult printJavaCode(ResultSet resultSet) {
return ret;
}
@Override
public void genByteCode(ClassGen _cg) {
// TODO Auto-generated method stub
}
}
// ino.end

View File

@ -3,8 +3,10 @@ package de.dhbwstuttgart.syntaxtree.statement;
// ino.end
// ino.module.Return.8651.import
import java.util.Hashtable;
import de.dhbwstuttgart.typeinference.Menge;
import org.apache.bcel.generic.ClassGen;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.logger.Logger;
import de.dhbwstuttgart.myexception.CTypeReconstructionException;
import de.dhbwstuttgart.myexception.JVMCodeException;
@ -126,5 +128,11 @@ public class Return extends Statement
public Type getReturnType(){
return this.getType();
}
@Override
public void genByteCode(ClassGen _cg) {
// TODO Auto-generated method stub
}
}
// ino.end

View File

@ -4,8 +4,13 @@ package de.dhbwstuttgart.syntaxtree.statement;
// ino.module.Statement.8652.import
import java.util.Enumeration;
import java.util.Hashtable;
import de.dhbwstuttgart.typeinference.Menge;
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 de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.core.IItemWithOffset;
import de.dhbwstuttgart.myexception.CTypeReconstructionException;
import de.dhbwstuttgart.myexception.JVMCodeException;
@ -122,5 +127,12 @@ public abstract class Statement extends SyntaxTreeNode implements IItemWithOffse
public Type getReturnType(){
return new de.dhbwstuttgart.syntaxtree.type.Void(this,-1);
}
public abstract void genByteCode(ClassGen _cg);
}
// ino.end

View File

@ -1,9 +1,13 @@
package de.dhbwstuttgart.syntaxtree.statement;
import de.dhbwstuttgart.typeinference.Menge;
// ino.end
// ino.module.StringLiteral.8653.import
import java.util.Hashtable;
import org.apache.bcel.generic.ClassGen;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.logger.Logger;
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar;
@ -98,5 +102,11 @@ public class StringLiteral extends Literal
return "\""+this.string+"\"";
}
@Override
public void genByteCode(ClassGen _cg) {
// TODO Auto-generated method stub
}
}
// ino.end

View File

@ -3,8 +3,10 @@ package de.dhbwstuttgart.syntaxtree.statement;
// ino.end
// ino.module.This.8654.import
import java.util.Hashtable;
import de.dhbwstuttgart.typeinference.Menge;
import org.apache.bcel.generic.ClassGen;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.logger.Logger;
import de.dhbwstuttgart.myexception.CTypeReconstructionException;
import de.dhbwstuttgart.myexception.JVMCodeException;
@ -140,4 +142,10 @@ public class This extends Expr
return ret;
}
@Override
public void genByteCode(ClassGen _cg) {
// TODO Auto-generated method stub
}
}

View File

@ -5,10 +5,11 @@ package de.dhbwstuttgart.syntaxtree.statement;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Iterator;
import org.apache.bcel.generic.ClassGen;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.logger.Logger;
import de.dhbwstuttgart.myexception.CTypeReconstructionException;
import de.dhbwstuttgart.myexception.JVMCodeException;
import de.dhbwstuttgart.myexception.SCExcept;
@ -133,5 +134,11 @@ public class WhileStmt extends Statement
ret.add(this.loop_block);
return ret;
}
@Override
public void genByteCode(ClassGen _cg) {
// TODO Auto-generated method stub
}
}
// ino.end

View File

@ -1,38 +1,24 @@
package de.dhbwstuttgart.typeinference;
import de.dhbwstuttgart.typeinference.Menge;
import org.apache.bcel.generic.ClassGen;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
public class ByteCodeResult{
private String byteCode = "";
private ClassGen byteCode;
//TODO: unresolvedTPHs entfernen. BROKEN!
private Menge<TypePlaceholder> unresolvedTPHs = new Menge<TypePlaceholder>();
public ByteCodeResult(){
public ByteCodeResult(ClassGen byteCode){
this.byteCode = byteCode;
}
public ByteCodeResult(String byteCode){
this.byteCode += byteCode;
}
public String getByteCode(){
public ClassGen getByteCode(){
return byteCode;
}
public ByteCodeResult attach(ByteCodeResult byteCodeResult){
this.byteCode += byteCodeResult.getByteCode();
//Alle TPH anfügen:
for(TypePlaceholder tph : byteCodeResult.getUnresolvedTPH())this.addUnresolvedTPH(tph);
return this;
}
public ByteCodeResult attach(String javaCode){
this.byteCode += javaCode;
return this;
}
public void addUnresolvedTPH(TypePlaceholder typePlaceholder) {
unresolvedTPHs.add(typePlaceholder);
@ -49,7 +35,7 @@ public class ByteCodeResult{
@Override
public String toString(){
return getByteCode();
return getByteCode().toString();
}
@Override

View File

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

View File

@ -13,6 +13,7 @@ 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;
@ -23,16 +24,18 @@ public class EmptyClass {
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
public final static String testFile = "EmptyClass.jav";
public final static String outputFile = "EmptyClassTest.class";
@Test
public void test() {
LoggerConfiguration logConfig = new LoggerConfiguration();
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();