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="lib" path="lib/bcel-5.2.jar"/>
<classpathentry kind="output" path="bin"/> <classpathentry kind="output" path="bin"/>
</classpath> </classpath>

View File

@ -1,35 +1,35 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/'> <log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/'>
<appender name="CONSOLE" class="de.dhbwstuttgart.logger.ConsoleAppender"> <appender name="CONSOLE" class="de.dhbwstuttgart.logger.ConsoleAppender">
<param name="Target" value="System.out"/> <param name="Target" value="System.out"/>
<layout class="de.dhbwstuttgart.logger.PatternLayout"> <layout class="de.dhbwstuttgart.logger.PatternLayout">
<param name="ConversionPattern" value="%-15C{1} %-5p [%-9c] %m%n"/> <param name="ConversionPattern" value="%-15C{1} %-5p [%-9c] %m%n"/>
</layout> </layout>
</appender> </appender>
<logger name="codegen"> <logger name="codegen">
<level value="INFO"/> <level value="INFO"/>
<appender-ref ref="CONSOLE"/> <appender-ref ref="CONSOLE"/>
</logger> </logger>
<logger name="parser"> <logger name="parser">
<level value="OFF"/> <level value="OFF"/>
<appender-ref ref="CONSOLE"/> <appender-ref ref="CONSOLE"/>
</logger> </logger>
<logger name="inference"> <logger name="inference">
<level value="WARN"/> <level value="WARN"/>
<appender-ref ref="CONSOLE"/> <appender-ref ref="CONSOLE"/>
</logger> </logger>
<logger name="bytecode"> <logger name="bytecode">
<level value="INFO"/> <level value="INFO"/>
<appender-ref ref="CONSOLE"/> <appender-ref ref="CONSOLE"/>
</logger> </logger>
</log4j:configuration> </log4j:configuration>

View File

@ -1,24 +1,24 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/'> <log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/'>
<appender name="CONSOLE" class="de.dhbwstuttgart.logger.ConsoleAppender"> <appender name="CONSOLE" class="de.dhbwstuttgart.logger.ConsoleAppender">
<param name="Target" value="System.out"/> <param name="Target" value="System.out"/>
<layout class="de.dhbwstuttgart.logger.PatternLayout"> <layout class="de.dhbwstuttgart.logger.PatternLayout">
<param name="ConversionPattern" value="%-15C{1} %-5p [%-9c] %m%n"/> <param name="ConversionPattern" value="%-15C{1} %-5p [%-9c] %m%n"/>
</layout> </layout>
</appender> </appender>
<logger name="trtest"> <logger name="trtest">
<level value="DEBUG"/> <level value="DEBUG"/>
<appender-ref ref="CONSOLE"/> <appender-ref ref="CONSOLE"/>
</logger> </logger>
<logger name="funcTest"> <logger name="funcTest">
<level value="DEBUG"/> <level value="DEBUG"/>
<appender-ref ref="CONSOLE"/> <appender-ref ref="CONSOLE"/>
</logger> </logger>
</log4j:configuration> </log4j:configuration>

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 * - wird der Rückgabetyp von generateBytecode in MyCompiler geändert, so muss auch der Rückgabetyp im Interface MyCompilerAPI geändert werden
*/ */
try { 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) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
return null; return null;

View File

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

View File

@ -1,7 +1,15 @@
package de.dhbwstuttgart.syntaxtree; 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.myexception.JVMCodeException;
import de.dhbwstuttgart.parser.JavaClassName; import de.dhbwstuttgart.parser.JavaClassName;
import de.dhbwstuttgart.syntaxtree.misc.DeclId; import de.dhbwstuttgart.syntaxtree.misc.DeclId;
@ -42,7 +50,30 @@ public class Constructor extends Method {
ret.addAssumption(new ConstructorAssumption(this, parentClass)); ret.addAssumption(new ConstructorAssumption(this, parentClass));
return ret; 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 @Override
public void parserPostProcessing(SyntaxTreeNode parent){ public void parserPostProcessing(SyntaxTreeNode parent){
if(this.parameterlist != null){ if(this.parameterlist != null){
@ -54,7 +85,7 @@ public class Constructor extends Method {
gtv.parserPostProcessing(this); gtv.parserPostProcessing(this);
} }
} }
*/
@Override @Override
public ConstraintsSet TYPE(TypeAssumptions ass) { public ConstraintsSet TYPE(TypeAssumptions ass) {
//super.setType(this.getParentClass().getType()); //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); //throw new TypeinferenceException("Einem Konstruktor kann kein Typ zugewiesen werden", this);
//this.methode.setType(t); //this.methode.setType(t);
} }
/*
public Constructor(Method methode){ /*public Constructor(Method methode){
super(methode.getOffset()); super(methode.getOffset());
this.methode = methode; this.methode = methode;
this.setDeclIdMenge(methode.getDeclIdMenge()); this.setDeclIdMenge(methode.getDeclIdMenge());
this.methode.setType(this.methode.getParentClass().getType()); this.methode.setType(this.methode.getParentClass().getType());
} }*/
@Override @Override
public Menge<GenericTypeVar> getGenericParameter() { public Menge<GenericTypeVar> getGenericParameter() {
@ -198,11 +229,11 @@ public class Constructor extends Method {
this.methode.setOverloadedID(overloadedID); this.methode.setOverloadedID(overloadedID);
} }
@Override /*@Override
public String get_codegen_Param_Type(Menge paralist) { public String get_codegen_Param_Type(Menge paralist) {
return this.methode.get_codegen_Param_Type(paralist); return this.methode.get_codegen_Param_Type(paralist);
} }*/
@Override @Override
public String get_Method_Name() { public String get_Method_Name() {
@ -216,12 +247,12 @@ public class Constructor extends Method {
return this.methode.get_Type_Paralist(); return this.methode.get_Type_Paralist();
} }
@Override /*@Override
public void codegen(ClassFile classfile, Menge paralist) public void codegen(ClassFile classfile, Menge paralist)
throws JVMCodeException { throws JVMCodeException {
this.methode.codegen(classfile, paralist); this.methode.codegen(classfile, paralist);
} }*/
@Override @Override
public int getLineNumber() { public int getLineNumber() {
@ -289,11 +320,11 @@ public class Constructor extends Method {
this.methode.set_Method_Name(string); this.methode.set_Method_Name(string);
} }
public ConstraintsSet TYPE(TypeAssumptions ass) { /*public ConstraintsSet TYPE(TypeAssumptions ass) {
ConstraintsSet ret = new ConstraintsSet(); ConstraintsSet ret = new ConstraintsSet();
ret.add(this.methode.get_Block().TYPEStmt(ass)); ret.add(this.methode.get_Block().TYPEStmt(ass));
return ret; return ret;
} }*/
@Override @Override
public String getTypeInformation() { public String getTypeInformation() {
@ -307,24 +338,24 @@ public class Constructor extends Method {
return this.methode.printJavaCode(resultSet); return this.methode.printJavaCode(resultSet);
} }
@Override /*@Override
public TypeAssumptions createTypeAssumptions(Class classmember) { public TypeAssumptions createTypeAssumptions(Class classmember) {
Class parentClass = this.getParentClass(); Class parentClass = this.getParentClass();
TypeAssumptions ret = new TypeAssumptions(); TypeAssumptions ret = new TypeAssumptions();
ret.addAssumption(new ConstructorAssumption(this, parentClass)); ret.addAssumption(new ConstructorAssumption(this, parentClass));
return ret; return ret;
} }*/
@Override @Override
public SyntaxTreeNode getParent(){ public SyntaxTreeNode getParent(){
return this.methode.getParent(); return this.methode.getParent();
} }
@Override /*@Override
public void parserPostProcessing(SyntaxTreeNode parent) { public void parserPostProcessing(SyntaxTreeNode parent) {
this.methode.parserPostProcessing(parent); this.methode.parserPostProcessing(parent);
} }*/
@Override @Override
public Menge<SyntaxTreeNode> getChildren() { public Menge<SyntaxTreeNode> getChildren() {
@ -332,11 +363,11 @@ public class Constructor extends Method {
return this.methode.getChildren(); return this.methode.getChildren();
} }
@Override /*@Override
public void setType(Type t) { public void setType(Type t) {
throw new TypeinferenceException("Einem Konstruktor kann kein Typ zugewiesen werden", this); throw new TypeinferenceException("Einem Konstruktor kann kein Typ zugewiesen werden", this);
//this.methode.setType(t); //this.methode.setType(t);
} }*/
@Override @Override
public Type getType() { public Type getType() {
@ -390,7 +421,7 @@ public class Constructor extends Method {
public Class getParentClass() { public Class getParentClass() {
return this.methode.getParentClass(); return this.methode.getParentClass();
} }
*/
} }

View File

@ -1,7 +1,8 @@
package de.dhbwstuttgart.syntaxtree; 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.myexception.JVMCodeException;
import de.dhbwstuttgart.syntaxtree.misc.DeclId; import de.dhbwstuttgart.syntaxtree.misc.DeclId;
import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar; import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar;
@ -171,4 +172,11 @@ public abstract class Field extends GTVDeclarationContext implements TypeInserta
public boolean isClass() { public boolean isClass() {
return false; 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; 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.myexception.JVMCodeException;
import de.dhbwstuttgart.syntaxtree.misc.DeclId; import de.dhbwstuttgart.syntaxtree.misc.DeclId;
import de.dhbwstuttgart.syntaxtree.statement.Expr; 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 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; 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.core.IItemWithOffset;
import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar; import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar;
import de.dhbwstuttgart.syntaxtree.type.Type; import de.dhbwstuttgart.syntaxtree.type.Type;
@ -126,4 +127,6 @@ public abstract class SyntaxTreeNode implements IItemWithOffset{
return this.getParent().getGTVDeclarationContext(); return this.getParent().getGTVDeclarationContext();
} }
} }

View File

@ -5,10 +5,11 @@ package de.dhbwstuttgart.syntaxtree.statement;
import java.util.Enumeration; 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.ClassGen;
import de.dhbwstuttgart.typeinference.Menge; 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;
import de.dhbwstuttgart.myexception.SCExcept; import de.dhbwstuttgart.myexception.SCExcept;
@ -166,5 +167,15 @@ public class Assign extends Expr
return ret; return ret;
} }
@Override
public void genByteCode(ClassGen _cg) {
// TODO Auto-generated method stub
}
} }
// ino.end // ino.end

View File

@ -5,10 +5,11 @@ package de.dhbwstuttgart.syntaxtree.statement;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.HashMap; import java.util.HashMap;
import java.util.Hashtable; import java.util.Hashtable;
import org.apache.bcel.generic.ClassGen;
import de.dhbwstuttgart.typeinference.Menge; 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;
import de.dhbwstuttgart.myexception.SCExcept; import de.dhbwstuttgart.myexception.SCExcept;
@ -210,6 +211,14 @@ public JavaCodeResult printJavaCode(ResultSet resultSet) {
ret.add(this.expr2); ret.add(this.expr2);
return ret; return ret;
} }
@Override
public void genByteCode(ClassGen _cg) {
// TODO Auto-generated method stub
}
} }

View File

@ -5,8 +5,16 @@ package de.dhbwstuttgart.syntaxtree.statement;
import java.util.Enumeration; import java.util.Enumeration;
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.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.Logger;
import de.dhbwstuttgart.logger.Section; import de.dhbwstuttgart.logger.Section;
import de.dhbwstuttgart.myexception.CTypeReconstructionException; import de.dhbwstuttgart.myexception.CTypeReconstructionException;
@ -14,6 +22,7 @@ import de.dhbwstuttgart.myexception.JVMCodeException;
import de.dhbwstuttgart.myexception.SCExcept; import de.dhbwstuttgart.myexception.SCExcept;
import de.dhbwstuttgart.myexception.SCStatementException; import de.dhbwstuttgart.myexception.SCStatementException;
import de.dhbwstuttgart.syntaxtree.Class; import de.dhbwstuttgart.syntaxtree.Class;
import de.dhbwstuttgart.syntaxtree.Field;
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode; import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar; import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar;
import de.dhbwstuttgart.syntaxtree.type.Type; import de.dhbwstuttgart.syntaxtree.type.Type;
@ -37,6 +46,9 @@ public class Block extends Statement
// ino.end // ino.end
// ino.class.Block.25037.body // ino.class.Block.25037.body
{ {
private InstructionFactory _factory;
private ConstantPoolGen _cp;
private ClassGen _cg;
// ino.method.Block.25041.definition // ino.method.Block.25041.definition
public Block() public Block()
@ -79,6 +91,7 @@ public class Block extends Statement
} }
// ino.end // ino.end
// ino.method.set_Statement.25068.definition // ino.method.set_Statement.25068.definition
@ -224,6 +237,7 @@ public class Block extends Statement
ret.attach(stmt.printJavaCode(resultSet)); ret.attach(stmt.printJavaCode(resultSet));
ret.attach((stmt instanceof ExprStmt ? ";" : "") + "\n"); ret.attach((stmt instanceof ExprStmt ? ";" : "") + "\n");
} }
return ret.attach("}"); return ret.attach("}");
} }
@ -241,5 +255,24 @@ public class Block extends Statement
public String getDescription(){ public String getDescription(){
return "Block"; 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 // ino.end

View File

@ -3,8 +3,10 @@ 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 de.dhbwstuttgart.typeinference.Menge;
import org.apache.bcel.generic.ClassGen;
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;
@ -28,7 +30,15 @@ public class BoolLiteral extends Literal
// ino.end // ino.end
// ino.class.BoolLiteral.25089.body // 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; private boolean Bool;
// ino.end // ino.end
// ino.attribute.parserlog.25096.declaration // ino.attribute.parserlog.25096.declaration

View File

@ -4,8 +4,10 @@ package de.dhbwstuttgart.syntaxtree.statement;
// ino.module.CastExpr.8627.import // ino.module.CastExpr.8627.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 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;
@ -117,6 +119,14 @@ public class CastExpr extends UnaryExpr
return ret; return ret;
} }
@Override
public void genByteCode(ClassGen _cg) {
// TODO Auto-generated method stub
}
} }
// ino.end // ino.end

View File

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

View File

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

View File

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

View File

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

View File

@ -3,10 +3,11 @@ package de.dhbwstuttgart.syntaxtree.statement;
import java.util.Enumeration; 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.ClassGen;
import de.dhbwstuttgart.typeinference.Menge; 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;
import de.dhbwstuttgart.myexception.SCExcept; import de.dhbwstuttgart.myexception.SCExcept;
@ -115,4 +116,10 @@ public JavaCodeResult printJavaCode(ResultSet resultSet) {
//throw new NotImplementedException(); //throw new NotImplementedException();
return ret; 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.Enumeration;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.Iterator; import java.util.Iterator;
import org.apache.bcel.generic.ClassGen;
import de.dhbwstuttgart.typeinference.Menge; 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;
import de.dhbwstuttgart.myexception.SCExcept; import de.dhbwstuttgart.myexception.SCExcept;
@ -160,5 +161,13 @@ public class IfStmt extends Statement
if(this.then_block!=null)ret.add(this.then_block); if(this.then_block!=null)ret.add(this.then_block);
return ret; return ret;
} }
@Override
public void genByteCode(ClassGen _cg) {
// TODO Auto-generated method stub
}
} }
// ino.end // ino.end

View File

@ -5,10 +5,11 @@ package de.dhbwstuttgart.syntaxtree.statement;
import java.util.Enumeration; 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.ClassGen;
import de.dhbwstuttgart.typeinference.Menge; 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;
import de.dhbwstuttgart.syntaxtree.Class; import de.dhbwstuttgart.syntaxtree.Class;
@ -214,5 +215,11 @@ public class InstVar extends Expr
ret.add(this.expr); ret.add(this.expr);
return ret; return ret;
} }
@Override
public void genByteCode(ClassGen _cg) {
// TODO Auto-generated method stub
}
} }
// ino.end // ino.end

View File

@ -4,10 +4,11 @@ package de.dhbwstuttgart.syntaxtree.statement;
// ino.module.InstanceOf.8633.import // ino.module.InstanceOf.8633.import
import java.util.Enumeration; import java.util.Enumeration;
import java.util.Hashtable; import java.util.Hashtable;
import org.apache.bcel.generic.ClassGen;
import de.dhbwstuttgart.typeinference.Menge; 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;
import de.dhbwstuttgart.myexception.SCStatementException; import de.dhbwstuttgart.myexception.SCStatementException;
@ -114,6 +115,12 @@ public JavaCodeResult printJavaCode(ResultSet resultSet) {
ret.add(this.expr); ret.add(this.expr);
return ret; return ret;
} }
@Override
public void genByteCode(ClassGen _cg) {
// TODO Auto-generated method stub
}
} }

View File

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

View File

@ -1,8 +1,10 @@
package de.dhbwstuttgart.syntaxtree.statement; package de.dhbwstuttgart.syntaxtree.statement;
import java.util.Hashtable; 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.CTypeReconstructionException;
import de.dhbwstuttgart.myexception.JVMCodeException; import de.dhbwstuttgart.myexception.JVMCodeException;
import de.dhbwstuttgart.myexception.SCStatementException; import de.dhbwstuttgart.myexception.SCStatementException;
@ -206,4 +208,10 @@ public class LambdaExpression extends Expr{
return ret; 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 // ino.module.LocalOrFieldVar.8637.import
import java.util.Enumeration; import java.util.Enumeration;
import java.util.Hashtable; 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.logger.Logger;
import de.dhbwstuttgart.myexception.CTypeReconstructionException; import de.dhbwstuttgart.myexception.CTypeReconstructionException;
import de.dhbwstuttgart.myexception.JVMCodeException; import de.dhbwstuttgart.myexception.JVMCodeException;
@ -133,5 +135,11 @@ public class LocalOrFieldVar extends Expr
return ret; return ret;
} }
@Override
public void genByteCode(ClassGen _cg) {
// TODO Auto-generated method stub
}
} }
// ino.end // ino.end

View File

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

View File

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

View File

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

View File

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

View File

@ -3,9 +3,10 @@ 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 de.dhbwstuttgart.typeinference.Menge; 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;
@ -142,5 +143,11 @@ public JavaCodeResult printJavaCode(ResultSet resultSet) {
return ret; return ret;
} }
@Override
public void genByteCode(ClassGen _cg) {
// TODO Auto-generated method stub
}
} }
// ino.end // ino.end

View File

@ -5,9 +5,10 @@ package de.dhbwstuttgart.syntaxtree.statement;
import java.util.Enumeration; 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.ClassGen;
import de.dhbwstuttgart.typeinference.Menge; 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;
@ -201,6 +202,12 @@ public class NewClass extends Expr
} }
return ret; return ret;
} }
@Override
public void genByteCode(ClassGen _cg) {
// TODO Auto-generated method stub
}
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,9 +1,13 @@
package de.dhbwstuttgart.syntaxtree.statement; 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.typeinference.Menge;
import de.dhbwstuttgart.logger.Logger; import de.dhbwstuttgart.logger.Logger;
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode; import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar; import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar;
@ -97,6 +101,12 @@ public class StringLiteral extends Literal
public String toString(){ public String toString(){
return "\""+this.string+"\""; return "\""+this.string+"\"";
} }
@Override
public void genByteCode(ClassGen _cg) {
// TODO Auto-generated method stub
}
} }
// ino.end // ino.end

View File

@ -3,8 +3,10 @@ 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.generic.ClassGen;
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;
@ -139,5 +141,11 @@ public class This extends Expr
Menge<SyntaxTreeNode> ret = new Menge<SyntaxTreeNode>(); Menge<SyntaxTreeNode> ret = new Menge<SyntaxTreeNode>();
return ret; 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.Enumeration;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.Iterator; import java.util.Iterator;
import org.apache.bcel.generic.ClassGen;
import de.dhbwstuttgart.typeinference.Menge; 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;
import de.dhbwstuttgart.myexception.SCExcept; import de.dhbwstuttgart.myexception.SCExcept;
@ -133,5 +134,11 @@ public class WhileStmt extends Statement
ret.add(this.loop_block); ret.add(this.loop_block);
return ret; return ret;
} }
@Override
public void genByteCode(ClassGen _cg) {
// TODO Auto-generated method stub
}
} }
// ino.end // ino.end

View File

@ -1,38 +1,24 @@
package de.dhbwstuttgart.typeinference; 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; import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
public class ByteCodeResult{ public class ByteCodeResult{
private String byteCode = ""; private ClassGen byteCode;
//TODO: unresolvedTPHs entfernen. BROKEN! //TODO: unresolvedTPHs entfernen. BROKEN!
private Menge<TypePlaceholder> unresolvedTPHs = new Menge<TypePlaceholder>(); private Menge<TypePlaceholder> unresolvedTPHs = new Menge<TypePlaceholder>();
public ByteCodeResult(){ public ByteCodeResult(ClassGen byteCode){
this.byteCode = byteCode;
} }
public ByteCodeResult(String byteCode){ public ClassGen getByteCode(){
this.byteCode += byteCode;
}
public String getByteCode(){
return byteCode; 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) { public void addUnresolvedTPH(TypePlaceholder typePlaceholder) {
unresolvedTPHs.add(typePlaceholder); unresolvedTPHs.add(typePlaceholder);
@ -49,7 +35,7 @@ public class ByteCodeResult{
@Override @Override
public String toString(){ public String toString(){
return getByteCode(); return getByteCode().toString();
} }
@Override @Override

View File

@ -1,2 +1,7 @@
class EmptyClass{ 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.MyCompiler;
import de.dhbwstuttgart.core.MyCompilerAPI; import de.dhbwstuttgart.core.MyCompilerAPI;
import de.dhbwstuttgart.logger.LoggerConfiguration; import de.dhbwstuttgart.logger.LoggerConfiguration;
import de.dhbwstuttgart.logger.Section;
import de.dhbwstuttgart.parser.JavaParser.yyException; import de.dhbwstuttgart.parser.JavaParser.yyException;
import de.dhbwstuttgart.typeinference.ByteCodeResult; import de.dhbwstuttgart.typeinference.ByteCodeResult;
import de.dhbwstuttgart.typeinference.Menge; 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 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";
@Test @Test
public void test() { public void test() {
LoggerConfiguration logConfig = new LoggerConfiguration(); LoggerConfiguration logConfig = new LoggerConfiguration().setOutput(Section.PARSER, System.out);
MyCompilerAPI compiler = MyCompiler.getAPI(logConfig); MyCompilerAPI compiler = MyCompiler.getAPI(logConfig);
try { try {
compiler.parse(new File(rootDirectory + testFile)); compiler.parse(new File(rootDirectory + testFile));
compiler.typeReconstruction(); compiler.typeReconstruction();
ByteCodeResult bytecode = compiler.generateBytecode(); ByteCodeResult bytecode = compiler.generateBytecode();
System.out.println(bytecode); System.out.println(bytecode);
bytecode.getByteCode().getJavaClass().dump(new File(rootDirectory + outputFile));
} catch (IOException | yyException e) { } catch (IOException | yyException e) {
e.printStackTrace(); e.printStackTrace();
TestCase.fail(); TestCase.fail();