diff --git a/.classpath b/.classpath
index 3c2e81f4..6af9d44f 100755
--- a/.classpath
+++ b/.classpath
@@ -8,6 +8,7 @@
-
+
+
diff --git a/BCEL/bcelifier/FieldDeclaration.java b/BCEL/bcelifier/FieldDeclaration.java
new file mode 100644
index 00000000..00fb467d
--- /dev/null
+++ b/BCEL/bcelifier/FieldDeclaration.java
@@ -0,0 +1,11 @@
+package bcelifier;
+
+public class FieldDeclaration {
+
+ Integer field = methode();
+
+ Integer methode()
+ {
+ return field;
+ }
+}
diff --git a/BCEL/bcelifier/FieldDeclarationCreator.java b/BCEL/bcelifier/FieldDeclarationCreator.java
new file mode 100644
index 00000000..21553f53
--- /dev/null
+++ b/BCEL/bcelifier/FieldDeclarationCreator.java
@@ -0,0 +1,68 @@
+package bcelifier;
+
+import org.apache.commons.bcel6.generic.*;
+import org.apache.commons.bcel6.classfile.*;
+import org.apache.commons.bcel6.*;
+import java.io.*;
+
+public class FieldDeclarationCreator implements Constants {
+ private InstructionFactory _factory;
+ private ConstantPoolGen _cp;
+ private ClassGen _cg;
+
+ public FieldDeclarationCreator() {
+ _cg = new ClassGen("bcelifier.FieldDeclaration", "java.lang.Object", "FieldDeclaration.java", ACC_PUBLIC | ACC_SUPER, new String[] { });
+
+ _cp = _cg.getConstantPool();
+ _factory = new InstructionFactory(_cg, _cp);
+ }
+
+ public void create(OutputStream out) throws IOException {
+ createFields();
+ createMethod_0();
+ createMethod_1();
+ _cg.getJavaClass().dump(out);
+ }
+
+ private void createFields() {
+ FieldGen field;
+
+ field = new FieldGen(0, new ObjectType("java.lang.Integer"), "field", _cp);
+ _cg.addField(field.getField());
+ }
+
+ private void createMethod_0() {
+ InstructionList il = new InstructionList();
+ MethodGen method = new MethodGen(ACC_PUBLIC, Type.VOID, Type.NO_ARGS, new String[] { }, "", "bcelifier.FieldDeclaration", il, _cp);
+
+ InstructionHandle ih_0 = il.append(_factory.createLoad(Type.OBJECT, 0));
+ il.append(_factory.createInvoke("java.lang.Object", "", Type.VOID, Type.NO_ARGS, Constants.INVOKESPECIAL));
+ InstructionHandle ih_4 = il.append(_factory.createLoad(Type.OBJECT, 0));
+ il.append(_factory.createLoad(Type.OBJECT, 0));
+ il.append(_factory.createInvoke("bcelifier.FieldDeclaration", "methode", new ObjectType("java.lang.Integer"), Type.NO_ARGS, Constants.INVOKEVIRTUAL));
+ il.append(_factory.createFieldAccess("bcelifier.FieldDeclaration", "field", new ObjectType("java.lang.Integer"), Constants.PUTFIELD));
+ InstructionHandle ih_12 = il.append(_factory.createReturn(Type.VOID));
+ method.setMaxStack();
+ method.setMaxLocals();
+ _cg.addMethod(method.getMethod());
+ il.dispose();
+ }
+
+ private void createMethod_1() {
+ InstructionList il = new InstructionList();
+ MethodGen method = new MethodGen(0, new ObjectType("java.lang.Integer"), Type.NO_ARGS, new String[] { }, "methode", "bcelifier.FieldDeclaration", il, _cp);
+
+ InstructionHandle ih_0 = il.append(_factory.createLoad(Type.OBJECT, 0));
+ il.append(_factory.createFieldAccess("bcelifier.FieldDeclaration", "field", new ObjectType("java.lang.Integer"), Constants.GETFIELD));
+ InstructionHandle ih_4 = il.append(_factory.createReturn(Type.OBJECT));
+ method.setMaxStack();
+ method.setMaxLocals();
+ _cg.addMethod(method.getMethod());
+ il.dispose();
+ }
+
+ public static void main(String[] args) throws Exception {
+ bcelifier.FieldDeclarationCreator creator = new bcelifier.FieldDeclarationCreator();
+ creator.create(new FileOutputStream("bcelifier.FieldDeclaration.class"));
+ }
+}
diff --git a/BCEL/bcelifier/IntLiteralCreator.java b/BCEL/bcelifier/IntLiteralCreator.java
index eed6f137..00ed284b 100644
--- a/BCEL/bcelifier/IntLiteralCreator.java
+++ b/BCEL/bcelifier/IntLiteralCreator.java
@@ -1,8 +1,8 @@
package bcelifier;
-import org.apache.bcel.generic.*;
-import org.apache.bcel.classfile.*;
-import org.apache.bcel.*;
+import org.apache.commons.bcel6.generic.*;
+import org.apache.commons.bcel6.classfile.*;
+import org.apache.commons.bcel6.*;
import java.io.*;
public class IntLiteralCreator implements Constants {
diff --git a/BCEL/bcelifier/JavaToBCEL.java b/BCEL/bcelifier/JavaToBCEL.java
index 574f6b7c..bcd9524d 100644
--- a/BCEL/bcelifier/JavaToBCEL.java
+++ b/BCEL/bcelifier/JavaToBCEL.java
@@ -8,10 +8,10 @@ import java.nio.file.Files;
import java.nio.file.OpenOption;
import java.nio.file.Path;
-import org.apache.bcel.classfile.ClassFormatException;
-import org.apache.bcel.classfile.ClassParser;
-import org.apache.bcel.classfile.JavaClass;
-import org.apache.bcel.util.BCELifier;
+import org.apache.commons.bcel6.classfile.ClassFormatException;
+import org.apache.commons.bcel6.classfile.ClassParser;
+import org.apache.commons.bcel6.classfile.JavaClass;
+import org.apache.commons.bcel6.util.BCELifier;
public class JavaToBCEL {
@@ -27,6 +27,8 @@ public class JavaToBCEL {
new BCELifier(new ClassParser(rootDirectory+"This.class").parse(), new FileOutputStream(new File(rootDirectory+"ThisCreator.java"))).start();
new BCELifier(new ClassParser(rootDirectory+"IntLiteral.class").parse(), new FileOutputStream(new File(rootDirectory+"IntLiteralCreator.java"))).start();
new BCELifier(new ClassParser(rootDirectory+"MethodCall.class").parse(), new FileOutputStream(new File(rootDirectory+"MethodCallCreator.java"))).start();
+ new BCELifier(new ClassParser(rootDirectory+"FieldDeclaration.class").parse(), new FileOutputStream(new File(rootDirectory+"FieldDeclarationCreator.java"))).start();
+ new BCELifier(new ClassParser(rootDirectory+"Null.class").parse(), new FileOutputStream(new File(rootDirectory+"NullCreator.java"))).start();
} catch (ClassFormatException | IOException e) {
e.printStackTrace();
diff --git a/BCEL/bcelifier/Lambda1Creator.java b/BCEL/bcelifier/Lambda1Creator.java
index f7f6f8a5..7a0d7c38 100644
--- a/BCEL/bcelifier/Lambda1Creator.java
+++ b/BCEL/bcelifier/Lambda1Creator.java
@@ -1,8 +1,8 @@
package bcelifier;
-import org.apache.bcel.generic.*;
-import org.apache.bcel.classfile.*;
-import org.apache.bcel.*;
+import org.apache.commons.bcel6.generic.*;
+import org.apache.commons.bcel6.classfile.*;
+import org.apache.commons.bcel6.*;
import java.io.*;
public class Lambda1Creator implements Constants {
diff --git a/BCEL/bcelifier/MethodCallCreator.java b/BCEL/bcelifier/MethodCallCreator.java
index 303fb699..341b0357 100644
--- a/BCEL/bcelifier/MethodCallCreator.java
+++ b/BCEL/bcelifier/MethodCallCreator.java
@@ -1,8 +1,8 @@
package bcelifier;
-import org.apache.bcel.generic.*;
-import org.apache.bcel.classfile.*;
-import org.apache.bcel.*;
+import org.apache.commons.bcel6.generic.*;
+import org.apache.commons.bcel6.classfile.*;
+import org.apache.commons.bcel6.*;
import java.io.*;
public class MethodCallCreator implements Constants {
diff --git a/BCEL/bcelifier/Null.java b/BCEL/bcelifier/Null.java
new file mode 100644
index 00000000..d7329b7c
--- /dev/null
+++ b/BCEL/bcelifier/Null.java
@@ -0,0 +1,7 @@
+package bcelifier;
+
+public class Null {
+
+ Integer i = null;
+
+}
diff --git a/BCEL/bcelifier/NullCreator.java b/BCEL/bcelifier/NullCreator.java
new file mode 100644
index 00000000..d7960def
--- /dev/null
+++ b/BCEL/bcelifier/NullCreator.java
@@ -0,0 +1,53 @@
+package bcelifier;
+
+import org.apache.commons.bcel6.generic.*;
+import org.apache.commons.bcel6.classfile.*;
+import org.apache.commons.bcel6.*;
+import java.io.*;
+
+public class NullCreator implements Constants {
+ private InstructionFactory _factory;
+ private ConstantPoolGen _cp;
+ private ClassGen _cg;
+
+ public NullCreator() {
+ _cg = new ClassGen("bcelifier.Null", "java.lang.Object", "Null.java", ACC_PUBLIC | ACC_SUPER, new String[] { });
+
+ _cp = _cg.getConstantPool();
+ _factory = new InstructionFactory(_cg, _cp);
+ }
+
+ public void create(OutputStream out) throws IOException {
+ createFields();
+ createMethod_0();
+ _cg.getJavaClass().dump(out);
+ }
+
+ private void createFields() {
+ FieldGen field;
+
+ field = new FieldGen(0, new ObjectType("java.lang.Integer"), "i", _cp);
+ _cg.addField(field.getField());
+ }
+
+ private void createMethod_0() {
+ InstructionList il = new InstructionList();
+ MethodGen method = new MethodGen(ACC_PUBLIC, Type.VOID, Type.NO_ARGS, new String[] { }, "", "bcelifier.Null", il, _cp);
+
+ InstructionHandle ih_0 = il.append(_factory.createLoad(Type.OBJECT, 0));
+ il.append(_factory.createInvoke("java.lang.Object", "", Type.VOID, Type.NO_ARGS, Constants.INVOKESPECIAL));
+ InstructionHandle ih_4 = il.append(_factory.createLoad(Type.OBJECT, 0));
+ il.append(InstructionConstants.ACONST_NULL);
+ il.append(_factory.createFieldAccess("bcelifier.Null", "i", new ObjectType("java.lang.Integer"), Constants.PUTFIELD));
+ InstructionHandle ih_9 = il.append(_factory.createReturn(Type.VOID));
+ method.setMaxStack();
+ method.setMaxLocals();
+ _cg.addMethod(method.getMethod());
+ il.dispose();
+ }
+
+ public static void main(String[] args) throws Exception {
+ bcelifier.NullCreator creator = new bcelifier.NullCreator();
+ creator.create(new FileOutputStream("bcelifier.Null.class"));
+ }
+}
diff --git a/BCEL/bcelifier/ThisCreator.java b/BCEL/bcelifier/ThisCreator.java
index 329d0d5d..573b162e 100644
--- a/BCEL/bcelifier/ThisCreator.java
+++ b/BCEL/bcelifier/ThisCreator.java
@@ -1,8 +1,8 @@
package bcelifier;
-import org.apache.bcel.generic.*;
-import org.apache.bcel.classfile.*;
-import org.apache.bcel.*;
+import org.apache.commons.bcel6.generic.*;
+import org.apache.commons.bcel6.classfile.*;
+import org.apache.commons.bcel6.*;
import java.io.*;
public class ThisCreator implements Constants {
diff --git a/lib/commons-bcel6-6.0-SNAPSHOT.jar b/lib/commons-bcel6-6.0-SNAPSHOT.jar
new file mode 100644
index 00000000..463f5801
Binary files /dev/null and b/lib/commons-bcel6-6.0-SNAPSHOT.jar differ
diff --git a/src/de/dhbwstuttgart/bytecode/ClassGenerator.java b/src/de/dhbwstuttgart/bytecode/ClassGenerator.java
new file mode 100644
index 00000000..f5d0017c
--- /dev/null
+++ b/src/de/dhbwstuttgart/bytecode/ClassGenerator.java
@@ -0,0 +1,30 @@
+package de.dhbwstuttgart.bytecode;
+
+import org.apache.commons.bcel6.generic.ClassGen;
+import org.apache.commons.bcel6.generic.ConstantPoolGen;
+
+import de.dhbwstuttgart.syntaxtree.type.Type;
+import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
+import de.dhbwstuttgart.typeinference.ResultSet;
+import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
+
+public class ClassGenerator extends ClassGen{
+
+ private DHBWInstructionFactory factory = new DHBWInstructionFactory(this, this.getConstantPool());
+ private TypeinferenceResultSet tiResult;
+
+ public ClassGenerator(String name, String get_Name, String string,
+ short accPublic, String[] strings, TypeinferenceResultSet resultSet) {
+ super(name,get_Name,string,accPublic,strings);
+ this.tiResult = resultSet;
+ }
+
+ public DHBWInstructionFactory getInstructionFactory() {
+ return factory ;
+ }
+
+ public Type resolveTPH(TypePlaceholder typePlaceholder) {
+ return tiResult.getTypeOfPlaceholder(typePlaceholder);
+ }
+
+}
diff --git a/src/de/dhbwstuttgart/bytecode/DHBWInstructionFactory.java b/src/de/dhbwstuttgart/bytecode/DHBWInstructionFactory.java
index bec3f076..6d0c8e2a 100644
--- a/src/de/dhbwstuttgart/bytecode/DHBWInstructionFactory.java
+++ b/src/de/dhbwstuttgart/bytecode/DHBWInstructionFactory.java
@@ -3,15 +3,17 @@ package de.dhbwstuttgart.bytecode;
import java.awt.List;
import java.util.ArrayList;
-import org.apache.bcel.classfile.BootstrapMethod;
-import org.apache.bcel.classfile.ConstantInvokeDynamic;
-import org.apache.bcel.classfile.Method;
-import org.apache.bcel.generic.ClassGen;
-import org.apache.bcel.generic.ConstantPoolGen;
-import org.apache.bcel.generic.INVOKEDYNAMIC;
-import org.apache.bcel.generic.InstructionFactory;
-import org.apache.bcel.generic.MethodGen;
-import org.apache.bcel.generic.Type;
+import org.apache.commons.bcel6.Constants;
+import org.apache.commons.bcel6.classfile.BootstrapMethod;
+import org.apache.commons.bcel6.classfile.ConstantInvokeDynamic;
+import org.apache.commons.bcel6.classfile.InnerClass;
+import org.apache.commons.bcel6.classfile.Method;
+import org.apache.commons.bcel6.generic.ClassGen;
+import org.apache.commons.bcel6.generic.ConstantPoolGen;
+import org.apache.commons.bcel6.generic.INVOKEDYNAMIC;
+import org.apache.commons.bcel6.generic.InstructionFactory;
+import org.apache.commons.bcel6.generic.MethodGen;
+import org.apache.commons.bcel6.generic.Type;
public class DHBWInstructionFactory extends InstructionFactory{
@@ -26,11 +28,39 @@ public class DHBWInstructionFactory extends InstructionFactory{
public INVOKEDYNAMIC createInvokeDynamic( MethodGen lambdaMethod ) {
//Zuerst die Bootstrap-Methode erstellen: Diese müssen dann in ein BootstrapMethods-Attribut zusammengefasst und dem Classfile hinzugefügt werden
- int lambdaMethodIndex = this.cp.addMethodref(lambdaMethod);
+ //this.cp.addMethodref(lambdaMethod);
- ArrayList arguments = new ArrayList();
+ ArrayList arguments = new ArrayList();
+ /*
+ * Die Argumente für die Bootstrap-Methode. Im Decompilierten Beispiel sind das:
+ * #19 ()V
+ * #20 invokespecial Lambda3.lambda$methode$0:()V
+ * #19 ()V
+ *
+ * #20 ist ein MethodHandle_info Structure
+ * TODO: Rausfinden, was es mit den Argumenten auf sich hat:
+ * -> Das sind Informationen die die Lambda Funktion zum Ausführen benötigt. (This-Referenz, Variablen, welche vom Lambda Ausdruck benutzt werden)
+ * Anmerkung: Bei der momentanen Implementierung der Lambda Ausdrücke wird nur this übergeben.
+ */
- BootstrapMethod bMethod = new BootstrapMethod(lambdaMethodIndex, arguments.size(), (int[])arguments.toArray());
+
+ int innerClassIndex = cp.addClass("java.lang.invoke.MethodHandles$Lookup");
+ int innerClassName = cp.addUtf8("Lookup");
+ int outerClassIndex = cp.addClass("java.lang.invoke.MethodHandles");
+
+ int accessFlags = Constants.ACC_FINAL + Constants.ACC_STATIC + Constants.ACC_PUBLIC;
+ InnerClass innerClassAttribute = new InnerClass(innerClassIndex, outerClassIndex, innerClassName,accessFlags);
+ //Diese InnereKlasse muss später im ClassFile vorkommen, da sie von der Bootstrap Methode benutzt wird.
+ //TODO: Dies kann man möglicherweise auslagern. Die ClassGen Klasse erweiter, welche sich dann die InnerenKlassen mertk, welche gebraucht werden
+
+ String bootstrapSignature = "(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite;";
+ int lambdaMethodIndex = cp.addMethodref("java.lang.invoke.LambdaMetafactory", "metafactory", bootstrapSignature);
+
+ int[] argumentsArray = new int[arguments.size()];
+ for(int i = 0; i generateBytecode() {
+ public Menge generateBytecode(TypeinferenceResultSet typeinferenceResult) {
//SourceFile parsedFile = this.m_AbstractSyntaxTree.firstElement();
//Class parsedClass = parsedFile.KlassenVektor.firstElement();
Menge ret = new Menge<>();
for(SourceFile sf : this.m_AbstractSyntaxTree){
- ret.addAll(sf.generateBytecode());
+ ret.addAll(sf.generateBytecode(typeinferenceResult));
}
return ret;
}
diff --git a/src/de/dhbwstuttgart/core/MyCompilerAPI.java b/src/de/dhbwstuttgart/core/MyCompilerAPI.java
index f1c8880e..9c5d2a57 100755
--- a/src/de/dhbwstuttgart/core/MyCompilerAPI.java
+++ b/src/de/dhbwstuttgart/core/MyCompilerAPI.java
@@ -127,6 +127,6 @@ public interface MyCompilerAPI
* Dafür müssen die Schritte Parsen und typeReconstruction ausgeführt werden.
* @return
*/
- public Menge generateBytecode();
+ public Menge generateBytecode(TypeinferenceResultSet rs);
}
// ino.end
diff --git a/src/de/dhbwstuttgart/syntaxtree/Class.java b/src/de/dhbwstuttgart/syntaxtree/Class.java
index e694a1a5..804a7af7 100755
--- a/src/de/dhbwstuttgart/syntaxtree/Class.java
+++ b/src/de/dhbwstuttgart/syntaxtree/Class.java
@@ -8,17 +8,18 @@ import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Iterator;
-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 org.apache.commons.bcel6.generic.ClassGen;
+import org.apache.commons.bcel6.generic.ConstantPoolGen;
+import org.apache.commons.bcel6.generic.InstructionFactory;
+import org.apache.commons.bcel6.generic.InstructionHandle;
+import org.apache.commons.bcel6.generic.InstructionList;
+import org.apache.commons.bcel6.generic.MethodGen;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.logger.Logger;
import de.dhbwstuttgart.logger.Section;
import de.dhbwstuttgart.logger.SectionLogger;
+import de.dhbwstuttgart.bytecode.ClassGenerator;
import de.dhbwstuttgart.core.AClassOrInterface;
import de.dhbwstuttgart.core.IItemWithOffset;
import de.dhbwstuttgart.parser.JavaClassName;
@@ -44,9 +45,9 @@ 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 org.apache.commons.bcel6.generic.*;
+import org.apache.commons.bcel6.classfile.*;
+import org.apache.commons.bcel6.*;
import java.io.*;
@@ -66,25 +67,47 @@ public class Class extends GTVDeclarationContext implements AClassOrInterface, I
protected UsedId pkgName;
protected Modifiers modifiers;
protected String name;
- //For ByteCode Construction
- private InstructionFactory _factory;
- private ConstantPoolGen _cp;
- private ClassGen _cg;
- //Method created with BCEL to generate ByteCode
- public ByteCodeResult genByteCode() {
-
+ /**
+ *
+ * @param resultSet - Fehlende Typen im Syntaxbaum werden nach diesem ResultSet aufgelöst
+ * @return
+ */
+ public ByteCodeResult genByteCode(TypeinferenceResultSet resultSet) {
+ InstructionFactory _factory;
+ ConstantPoolGen _cp;
+ ClassGenerator _cg;
+
SectionLogger logger = Logger.getSectionLogger(this.getClass().getName(), Section.CODEGEN);
logger.debug("Test");
if(pkgName != null)throw new NotImplementedException();
- _cg = new ClassGen(name, superClass.get_Name(), name + ".java", Constants.ACC_PUBLIC , new String[] { }); //letzter Parameter sind implementierte Interfaces
+ _cg = new ClassGenerator(name, superClass.get_Name(), name + ".java", Constants.ACC_PUBLIC , new String[] { }, resultSet); //letzter Parameter sind implementierte Interfaces
_cp = _cg.getConstantPool();
_factory = new InstructionFactory(_cg, _cp);
-
+
+ //Die Felder in Methoden Felder und Konstruktoren aufteilen:
+ Menge fieldDeclarations = new Menge<>();
+ Menge constructors = new Menge<>();
+ Menge methods = new Menge<>();
for(Field field : this.fielddecl){
- field.genByteCode(_cg);
+ if(field instanceof Constructor)constructors.add((Constructor)field);
+ if(field instanceof Method && ! (field instanceof Constructor))methods.add((Method)field);
+ if(field instanceof FieldDeclaration)fieldDeclarations.add((FieldDeclaration)field);
+ //field.genByteCode(_cg);
}
+ //Zuerst die Methoden und Felder abarbeiten:
+ for(Method m : methods){
+ m.genByteCode(_cg);
+ }
+ InstructionList fieldInitializations = new InstructionList();
+ for(FieldDeclaration f : fieldDeclarations){
+ fieldInitializations.append(f.genByteCode(_cg));
+ }
+ //Die Konstruktoren müssen die Feld initialisierungswerte beinhalten:
+ for(Constructor c : constructors){
+ c.genByteCode(_cg, fieldInitializations);
+ }
ByteCodeResult code = new ByteCodeResult(_cg);
return code;
diff --git a/src/de/dhbwstuttgart/syntaxtree/Constructor.java b/src/de/dhbwstuttgart/syntaxtree/Constructor.java
index cf592857..3482d2ef 100644
--- a/src/de/dhbwstuttgart/syntaxtree/Constructor.java
+++ b/src/de/dhbwstuttgart/syntaxtree/Constructor.java
@@ -1,15 +1,16 @@
package de.dhbwstuttgart.syntaxtree;
-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 org.apache.commons.bcel6.Constants;
+import org.apache.commons.bcel6.classfile.ConstantPool;
+import org.apache.commons.bcel6.generic.ClassGen;
+import org.apache.commons.bcel6.generic.ConstantPoolGen;
+import org.apache.commons.bcel6.generic.InstructionFactory;
+import org.apache.commons.bcel6.generic.InstructionHandle;
+import org.apache.commons.bcel6.generic.InstructionList;
+import org.apache.commons.bcel6.generic.MethodGen;
import de.dhbwstuttgart.typeinference.Menge;
+import de.dhbwstuttgart.bytecode.ClassGenerator;
import de.dhbwstuttgart.myexception.JVMCodeException;
import de.dhbwstuttgart.parser.JavaClassName;
import de.dhbwstuttgart.syntaxtree.misc.DeclId;
@@ -55,18 +56,20 @@ public class Constructor extends Method {
return ret;
}
- @Override
- public void genByteCode(ClassGen cg) {
+ public void genByteCode(ClassGenerator cg, InstructionList fieldInitializations){
ConstantPoolGen _cp = cg.getConstantPool();
InstructionList il = new InstructionList(); //sollte nicht new sein sondern aus Block kommen
Class parentClass = this.getParentClass();
//TODO: Alles dynamisch gestalten
//init darf nur drin stehen, wenn Konstruktor;
- this.method = new MethodGen(Constants.ACC_PUBLIC, this.getType().getBytecodeType(), org.apache.bcel.generic.Type.NO_ARGS , new String[] { }, "", parentClass.name, il, _cp);
+ this.method = new MethodGen(Constants.ACC_PUBLIC, this.getType().getBytecodeType(cg), org.apache.commons.bcel6.generic.Type.NO_ARGS , new String[] { }, "", parentClass.name, il, _cp);
//Iteration �ber Block starten
Block block = this.get_Block();
+ if(block.statements.firstElement() instanceof SuperCall){
+ block.statements.insertElementAt(new BytecodeInstructionBlock(fieldInitializations), 1);
+ }
InstructionList blockInstructions = block.genByteCode(cg);
il.append(blockInstructions);//Die vom Block generierten Instructions an die InstructionList der Methode anfügen
@@ -75,6 +78,26 @@ public class Constructor extends Method {
cg.addMethod(this.method.getMethod());
}
+
+ /**
+ * Mit dieser Hilfsklasse kann eine beliebige InstructionList in eine vorhandenen Block als Statement eingefügt werden.
+ * Wird für Bytecodegenerierung benötigt.
+ */
+ private class BytecodeInstructionBlock extends Block{
+ InstructionList il;
+ BytecodeInstructionBlock(InstructionList toInsert){
+ il = toInsert;
+ }
+ @Override
+ public InstructionList genByteCode(ClassGenerator cg){
+ return il;
+ }
+ }
+
+ @Override
+ public void genByteCode(ClassGenerator cg) {
+ this.genByteCode(cg, new InstructionList());
+ }
// super statement muss drin sein
// stmt genByteCode + im block genByteCode implementieren & dann Hierarchie ausprobieren
// de.dhbw.systanxtree.stmts supercall
diff --git a/src/de/dhbwstuttgart/syntaxtree/Field.java b/src/de/dhbwstuttgart/syntaxtree/Field.java
index 77011a5f..fabc1328 100644
--- a/src/de/dhbwstuttgart/syntaxtree/Field.java
+++ b/src/de/dhbwstuttgart/syntaxtree/Field.java
@@ -1,8 +1,9 @@
package de.dhbwstuttgart.syntaxtree;
-import org.apache.bcel.generic.ClassGen;
+import org.apache.commons.bcel6.generic.ClassGen;
import de.dhbwstuttgart.typeinference.Menge;
+import de.dhbwstuttgart.bytecode.ClassGenerator;
import de.dhbwstuttgart.myexception.JVMCodeException;
import de.dhbwstuttgart.syntaxtree.misc.DeclId;
import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar;
@@ -173,10 +174,5 @@ public abstract class Field extends GTVDeclarationContext implements TypeInserta
return false;
}
- /**
- * F�gt das das Feld zu ClassGen hinzu
- * @param cg
- */
- public abstract void genByteCode(ClassGen cg);
}
diff --git a/src/de/dhbwstuttgart/syntaxtree/FieldDeclaration.java b/src/de/dhbwstuttgart/syntaxtree/FieldDeclaration.java
index 99f00a94..68914f9f 100644
--- a/src/de/dhbwstuttgart/syntaxtree/FieldDeclaration.java
+++ b/src/de/dhbwstuttgart/syntaxtree/FieldDeclaration.java
@@ -1,11 +1,18 @@
package de.dhbwstuttgart.syntaxtree;
-import org.apache.bcel.generic.ClassGen;
+import org.apache.bcel.Constants;
+import org.apache.commons.bcel6.generic.FieldGen;
+import org.apache.commons.bcel6.generic.FieldInstruction;
+import org.apache.commons.bcel6.generic.InstructionList;
+import org.apache.commons.bcel6.generic.ObjectType;
+import org.apache.commons.bcel6.generic.ClassGen;
import de.dhbwstuttgart.typeinference.Menge;
+import de.dhbwstuttgart.bytecode.ClassGenerator;
import de.dhbwstuttgart.myexception.JVMCodeException;
import de.dhbwstuttgart.syntaxtree.misc.DeclId;
import de.dhbwstuttgart.syntaxtree.statement.Expr;
+import de.dhbwstuttgart.syntaxtree.statement.This;
import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar;
import de.dhbwstuttgart.syntaxtree.type.RefType;
import de.dhbwstuttgart.syntaxtree.type.Type;
@@ -157,10 +164,26 @@ public class FieldDeclaration extends Field{
if(this.getWert()!=null)this.getWert().wandleRefTypeAttributes2GenericAttributes(paralist, new Menge()); //FieldDeclaration hat keine Generischen Variablen, daher leere Liste übergeben
}
- @Override
- public void genByteCode(ClassGen cg) {
- // TODO Auto-generated method stub
+ /**
+ * Das besondere bei genByteCode einer FieldDeclaration ist, dass ein InstructionList zurückgegeben wird.
+ * Dieser muss in jeden Konstruktor eingefügt werden um das Feld zu initialisieren.
+ * @param cg
+ * @return - Die InstructionList, welche das Feld initialisiert
+ */
+ public InstructionList genByteCode(ClassGenerator cg) {
+ //Das Feld an die Klasse anfügen:
+ FieldGen field = new FieldGen(0, this.getType().getBytecodeType(cg), this.getDescription(), cg.getConstantPool());
+ cg.addField(field.getField());
+ //Die Felddekleration an den Konstruktor anhängen:
+ InstructionList il = new InstructionList();
+ il.append(new This(this).genByteCode(cg));
+ il.append(this.wert.genByteCode(cg));
+ FieldInstruction putFieldInstruction =
+ cg.getInstructionFactory().createFieldAccess(this.getParentClass().getName().toString(),
+ this.getDescription(), this.getType().getBytecodeType(cg), Constants.PUTFIELD);
+ il.append(putFieldInstruction );
+ return il;
}
/*@Override
diff --git a/src/de/dhbwstuttgart/syntaxtree/Method.java b/src/de/dhbwstuttgart/syntaxtree/Method.java
index feb39437..6029462e 100755
--- a/src/de/dhbwstuttgart/syntaxtree/Method.java
+++ b/src/de/dhbwstuttgart/syntaxtree/Method.java
@@ -7,16 +7,17 @@ import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Iterator;
-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 org.apache.commons.bcel6.Constants;
+import org.apache.commons.bcel6.generic.ClassGen;
+import org.apache.commons.bcel6.generic.ConstantPoolGen;
+import org.apache.commons.bcel6.generic.InstructionFactory;
+import org.apache.commons.bcel6.generic.InstructionHandle;
+import org.apache.commons.bcel6.generic.InstructionList;
+import org.apache.commons.bcel6.generic.MethodGen;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.logger.Logger;
+import de.dhbwstuttgart.bytecode.ClassGenerator;
import de.dhbwstuttgart.core.IItemWithOffset;
import de.dhbwstuttgart.core.MyCompiler;
import de.dhbwstuttgart.myexception.JVMCodeException;
@@ -739,39 +740,38 @@ public class Method extends Field implements IItemWithOffset, TypeInsertable
return super.equals(obj);
}
- @Override
- public void genByteCode(ClassGen cg) {
+ public void genByteCode(ClassGenerator cg) {
ConstantPoolGen _cp = cg.getConstantPool();
InstructionFactory _factory = new InstructionFactory(cg, _cp);
InstructionList il = new InstructionList();
Class parentClass = this.getParentClass();
//Die Argumentliste generieren:
- org.apache.bcel.generic.Type[] argumentTypes = org.apache.bcel.generic.Type.NO_ARGS;
+ org.apache.commons.bcel6.generic.Type[] argumentTypes = org.apache.commons.bcel6.generic.Type.NO_ARGS;
String[] argumentNames = new String[]{};
if(this.parameterlist != null &&
this.parameterlist.size() > 0){
- argumentTypes = new org.apache.bcel.generic.Type[this.parameterlist.size()];
+ argumentTypes = new org.apache.commons.bcel6.generic.Type[this.parameterlist.size()];
argumentNames = new String[this.parameterlist.size()];
int i = 0;
for(FormalParameter parameter : this.parameterlist){
- argumentTypes[i] = parameter.getType().getBytecodeType();
+ argumentTypes[i] = parameter.getType().getBytecodeType(cg);
argumentNames[i] = parameter.getIdentifier();
i++;
}
}
//Methode generieren:
- MethodGen method = new MethodGen(Constants.ACC_PUBLIC, this.getType().getBytecodeType(), argumentTypes , argumentNames, this.get_Method_Name(), parentClass.name, il, _cp);
+ MethodGen method = new MethodGen(Constants.ACC_PUBLIC, this.getType().getBytecodeType(cg), argumentTypes , argumentNames, this.get_Method_Name(), parentClass.name, il, _cp);
Block block = this.get_Block();
InstructionList blockInstructions = block.genByteCode(cg);
il.append(blockInstructions);//Die vom Block generierten Instructions an die InstructionList der Methode anfügen
- if (block.get_Statement().size() == 0) { il.append(_factory.createReturn(org.apache.bcel.generic.Type.VOID)); }
+ if (block.get_Statement().size() == 0) { il.append(_factory.createReturn( org.apache.commons.bcel6.generic.Type.VOID)); }
else {
- if (!(block.get_Statement().lastElement() instanceof Return)) { il.append(_factory.createReturn(org.apache.bcel.generic.Type.VOID)); }
+ if (!(block.get_Statement().lastElement() instanceof Return)) { il.append(_factory.createReturn( org.apache.commons.bcel6.generic.Type.VOID)); }
}
method.setMaxStack(); //Die Stack Größe automatisch berechnen lassen (erst nach dem alle Instructions angehängt wurden)
diff --git a/src/de/dhbwstuttgart/syntaxtree/SourceFile.java b/src/de/dhbwstuttgart/syntaxtree/SourceFile.java
index 0adcb710..f919d44c 100755
--- a/src/de/dhbwstuttgart/syntaxtree/SourceFile.java
+++ b/src/de/dhbwstuttgart/syntaxtree/SourceFile.java
@@ -1834,10 +1834,10 @@ public class SourceFile
* Bisher wird nur der Bytecode der Klassen generiert. Nicht der Interfaces.
* @return
*/
- public Collection extends ByteCodeResult> generateBytecode() {
+ public Collection extends ByteCodeResult> generateBytecode(TypeinferenceResultSet rs) {
Menge ret = new Menge<>();
for(Class cl : this.KlassenVektor){
- ret.add(cl.genByteCode());
+ ret.add(cl.genByteCode(rs));
}
return ret;
}
diff --git a/src/de/dhbwstuttgart/syntaxtree/SyntaxTreeNode.java b/src/de/dhbwstuttgart/syntaxtree/SyntaxTreeNode.java
index 0d234b61..f76249ba 100644
--- a/src/de/dhbwstuttgart/syntaxtree/SyntaxTreeNode.java
+++ b/src/de/dhbwstuttgart/syntaxtree/SyntaxTreeNode.java
@@ -1,6 +1,6 @@
package de.dhbwstuttgart.syntaxtree;
-import org.apache.bcel.generic.ClassGen;
+import org.apache.commons.bcel6.generic.ClassGen;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.core.IItemWithOffset;
diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/Assign.java b/src/de/dhbwstuttgart/syntaxtree/statement/Assign.java
index 5aa376b8..a0ed7d72 100755
--- a/src/de/dhbwstuttgart/syntaxtree/statement/Assign.java
+++ b/src/de/dhbwstuttgart/syntaxtree/statement/Assign.java
@@ -6,16 +6,17 @@ import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Iterator;
-import org.apache.bcel.generic.ASTORE;
-import org.apache.bcel.generic.ClassGen;
-import org.apache.bcel.generic.DSTORE;
-import org.apache.bcel.generic.FSTORE;
-import org.apache.bcel.generic.ISTORE;
-import org.apache.bcel.generic.InstructionFactory;
-import org.apache.bcel.generic.InstructionList;
-import org.apache.bcel.generic.LSTORE;
+import org.apache.commons.bcel6.generic.ASTORE;
+import org.apache.commons.bcel6.generic.ClassGen;
+import org.apache.commons.bcel6.generic.DSTORE;
+import org.apache.commons.bcel6.generic.FSTORE;
+import org.apache.commons.bcel6.generic.ISTORE;
+import org.apache.commons.bcel6.generic.InstructionFactory;
+import org.apache.commons.bcel6.generic.InstructionList;
+import org.apache.commons.bcel6.generic.LSTORE;
import de.dhbwstuttgart.typeinference.Menge;
+import de.dhbwstuttgart.bytecode.ClassGenerator;
import de.dhbwstuttgart.logger.Logger;
import de.dhbwstuttgart.myexception.CTypeReconstructionException;
import de.dhbwstuttgart.myexception.JVMCodeException;
@@ -178,13 +179,15 @@ public class Assign extends Expr
public static int counterAssign = 0; //Zaehlvariable f�r ISTORE
@Override
- public InstructionList genByteCode(ClassGen cg, TypeAssumptions ass) {
+ public InstructionList genByteCode(ClassGenerator cg) {
// TODO Auto-generated method stub
InstructionFactory _factory = new InstructionFactory(cg, cg.getConstantPool());
- InstructionList il = expr2.genByteCode(cg, ass);//expr2 rechte expr
+ InstructionList il = expr2.genByteCode(cg);//expr2 rechte expr
+
+ //TODO: ^^
counterAssign++; //macht STORE f�r meherere Variable nutzbar (nicht nur ISTORE_1, ISTORE_2, etc.)
-
+ /*
String expr2Type = expr2.getType().get_Name().toString();
switch(expr2Type){
case "java.lang.Integer":
@@ -207,6 +210,9 @@ public class Assign extends Expr
il.append(new LSTORE(counterAssign));
break;
}
+ */
+ //Es wird momentan immer von RefType ausgegangen:
+ il.append(new ASTORE(counterAssign));
return il;
}
diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/Binary.java b/src/de/dhbwstuttgart/syntaxtree/statement/Binary.java
index 2f0b3b7d..af54441d 100755
--- a/src/de/dhbwstuttgart/syntaxtree/statement/Binary.java
+++ b/src/de/dhbwstuttgart/syntaxtree/statement/Binary.java
@@ -6,8 +6,8 @@ import java.util.Enumeration;
import java.util.HashMap;
import java.util.Hashtable;
-import org.apache.bcel.generic.ClassGen;
-import org.apache.bcel.generic.InstructionList;
+import org.apache.commons.bcel6.generic.ClassGen;
+import org.apache.commons.bcel6.generic.InstructionList;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.logger.Logger;
diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/Block.java b/src/de/dhbwstuttgart/syntaxtree/statement/Block.java
index fc744563..9a9cd5fc 100755
--- a/src/de/dhbwstuttgart/syntaxtree/statement/Block.java
+++ b/src/de/dhbwstuttgart/syntaxtree/statement/Block.java
@@ -6,15 +6,16 @@ import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Iterator;
-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 org.apache.commons.bcel6.Constants;
+import org.apache.commons.bcel6.generic.ClassGen;
+import org.apache.commons.bcel6.generic.ConstantPoolGen;
+import org.apache.commons.bcel6.generic.InstructionFactory;
+import org.apache.commons.bcel6.generic.InstructionHandle;
+import org.apache.commons.bcel6.generic.InstructionList;
+import org.apache.commons.bcel6.generic.MethodGen;
import de.dhbwstuttgart.typeinference.Menge;
+import de.dhbwstuttgart.bytecode.ClassGenerator;
import de.dhbwstuttgart.logger.Logger;
import de.dhbwstuttgart.logger.Section;
import de.dhbwstuttgart.myexception.CTypeReconstructionException;
@@ -255,7 +256,7 @@ public class Block extends Statement
}
@Override
- public InstructionList genByteCode(ClassGen cg) {
+ public InstructionList genByteCode(ClassGenerator cg) {
//ConstantPoolGen _cp = cg.getConstantPool();
InstructionList il = new InstructionList();
diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/BoolLiteral.java b/src/de/dhbwstuttgart/syntaxtree/statement/BoolLiteral.java
index fe740ae9..806bd1ac 100755
--- a/src/de/dhbwstuttgart/syntaxtree/statement/BoolLiteral.java
+++ b/src/de/dhbwstuttgart/syntaxtree/statement/BoolLiteral.java
@@ -4,9 +4,9 @@ package de.dhbwstuttgart.syntaxtree.statement;
// ino.module.BoolLiteral.8626.import
import java.util.Hashtable;
-import org.apache.bcel.generic.ClassGen;
-import org.apache.bcel.generic.InstructionFactory;
-import org.apache.bcel.generic.InstructionList;
+import org.apache.commons.bcel6.generic.ClassGen;
+import org.apache.commons.bcel6.generic.InstructionFactory;
+import org.apache.commons.bcel6.generic.InstructionList;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.logger.Logger;
diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/CastExpr.java b/src/de/dhbwstuttgart/syntaxtree/statement/CastExpr.java
index 71002127..13d9c714 100755
--- a/src/de/dhbwstuttgart/syntaxtree/statement/CastExpr.java
+++ b/src/de/dhbwstuttgart/syntaxtree/statement/CastExpr.java
@@ -5,7 +5,7 @@ package de.dhbwstuttgart.syntaxtree.statement;
import java.util.Hashtable;
import java.util.Iterator;
-import org.apache.bcel.generic.ClassGen;
+import org.apache.commons.bcel6.generic.ClassGen;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.logger.Logger;
diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/CharLiteral.java b/src/de/dhbwstuttgart/syntaxtree/statement/CharLiteral.java
index 33871d6f..c4c87e8e 100755
--- a/src/de/dhbwstuttgart/syntaxtree/statement/CharLiteral.java
+++ b/src/de/dhbwstuttgart/syntaxtree/statement/CharLiteral.java
@@ -4,10 +4,10 @@ package de.dhbwstuttgart.syntaxtree.statement;
// ino.module.CharLiteral.8628.import
import java.util.Hashtable;
-import org.apache.bcel.generic.BIPUSH;
-import org.apache.bcel.generic.ClassGen;
-import org.apache.bcel.generic.InstructionFactory;
-import org.apache.bcel.generic.InstructionList;
+import org.apache.commons.bcel6.generic.BIPUSH;
+import org.apache.commons.bcel6.generic.ClassGen;
+import org.apache.commons.bcel6.generic.InstructionFactory;
+import org.apache.commons.bcel6.generic.InstructionList;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.logger.Logger;
diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/DoubleLiteral.java b/src/de/dhbwstuttgart/syntaxtree/statement/DoubleLiteral.java
index 3c8f8ee7..1ac8ee43 100755
--- a/src/de/dhbwstuttgart/syntaxtree/statement/DoubleLiteral.java
+++ b/src/de/dhbwstuttgart/syntaxtree/statement/DoubleLiteral.java
@@ -4,13 +4,13 @@ package de.dhbwstuttgart.syntaxtree.statement;
// ino.module.IntLiteral.8635.import
import java.util.Hashtable;
-import org.apache.bcel.generic.BIPUSH;
-import org.apache.bcel.generic.ClassGen;
-import org.apache.bcel.generic.ConstantPoolGen;
-import org.apache.bcel.generic.InstructionFactory;
-import org.apache.bcel.generic.InstructionList;
-import org.apache.bcel.generic.LDC;
-import org.apache.bcel.generic.LDC2_W;
+import org.apache.commons.bcel6.generic.BIPUSH;
+import org.apache.commons.bcel6.generic.ClassGen;
+import org.apache.commons.bcel6.generic.ConstantPoolGen;
+import org.apache.commons.bcel6.generic.InstructionFactory;
+import org.apache.commons.bcel6.generic.InstructionList;
+import org.apache.commons.bcel6.generic.LDC;
+import org.apache.commons.bcel6.generic.LDC2_W;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.logger.Logger;
diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/EmptyStmt.java b/src/de/dhbwstuttgart/syntaxtree/statement/EmptyStmt.java
index a6dc7bbc..4eb7c37d 100755
--- a/src/de/dhbwstuttgart/syntaxtree/statement/EmptyStmt.java
+++ b/src/de/dhbwstuttgart/syntaxtree/statement/EmptyStmt.java
@@ -4,7 +4,7 @@ package de.dhbwstuttgart.syntaxtree.statement;
// ino.module.EmptyStmt.8629.import
import java.util.Hashtable;
-import org.apache.bcel.generic.ClassGen;
+import org.apache.commons.bcel6.generic.ClassGen;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.logger.Logger;
diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/Expr.java b/src/de/dhbwstuttgart/syntaxtree/statement/Expr.java
index 6feade6f..8bfb7a51 100755
--- a/src/de/dhbwstuttgart/syntaxtree/statement/Expr.java
+++ b/src/de/dhbwstuttgart/syntaxtree/statement/Expr.java
@@ -5,8 +5,8 @@ package de.dhbwstuttgart.syntaxtree.statement;
import java.util.Hashtable;
import java.util.Iterator;
-import org.apache.bcel.generic.ClassGen;
-import org.apache.bcel.generic.InstructionList;
+import org.apache.commons.bcel6.generic.ClassGen;
+import org.apache.commons.bcel6.generic.InstructionList;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.myexception.CTypeReconstructionException;
diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/FloatLiteral.java b/src/de/dhbwstuttgart/syntaxtree/statement/FloatLiteral.java
index bdfd0149..be8d12a8 100755
--- a/src/de/dhbwstuttgart/syntaxtree/statement/FloatLiteral.java
+++ b/src/de/dhbwstuttgart/syntaxtree/statement/FloatLiteral.java
@@ -4,11 +4,11 @@ package de.dhbwstuttgart.syntaxtree.statement;
// ino.module.IntLiteral.8635.import
import java.util.Hashtable;
-import org.apache.bcel.generic.ClassGen;
-import org.apache.bcel.generic.ConstantPoolGen;
-import org.apache.bcel.generic.InstructionList;
-import org.apache.bcel.generic.LDC;
-import org.apache.bcel.generic.LDC2_W;
+import org.apache.commons.bcel6.generic.ClassGen;
+import org.apache.commons.bcel6.generic.ConstantPoolGen;
+import org.apache.commons.bcel6.generic.InstructionList;
+import org.apache.commons.bcel6.generic.LDC;
+import org.apache.commons.bcel6.generic.LDC2_W;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.logger.Logger;
diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/ForStmt.java b/src/de/dhbwstuttgart/syntaxtree/statement/ForStmt.java
index 723295c3..72da14d6 100755
--- a/src/de/dhbwstuttgart/syntaxtree/statement/ForStmt.java
+++ b/src/de/dhbwstuttgart/syntaxtree/statement/ForStmt.java
@@ -4,7 +4,7 @@ import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Iterator;
-import org.apache.bcel.generic.ClassGen;
+import org.apache.commons.bcel6.generic.ClassGen;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.logger.Logger;
diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/IfStmt.java b/src/de/dhbwstuttgart/syntaxtree/statement/IfStmt.java
index 3621dff0..b897ce02 100755
--- a/src/de/dhbwstuttgart/syntaxtree/statement/IfStmt.java
+++ b/src/de/dhbwstuttgart/syntaxtree/statement/IfStmt.java
@@ -6,7 +6,7 @@ import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Iterator;
-import org.apache.bcel.generic.ClassGen;
+import org.apache.commons.bcel6.generic.ClassGen;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.logger.Logger;
diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/InstVar.java b/src/de/dhbwstuttgart/syntaxtree/statement/InstVar.java
index 94e49231..c2e09b72 100755
--- a/src/de/dhbwstuttgart/syntaxtree/statement/InstVar.java
+++ b/src/de/dhbwstuttgart/syntaxtree/statement/InstVar.java
@@ -6,7 +6,7 @@ import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Iterator;
-import org.apache.bcel.generic.ClassGen;
+import org.apache.commons.bcel6.generic.ClassGen;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.logger.Logger;
diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/InstanceOf.java b/src/de/dhbwstuttgart/syntaxtree/statement/InstanceOf.java
index ef1a88ac..c541a2ef 100755
--- a/src/de/dhbwstuttgart/syntaxtree/statement/InstanceOf.java
+++ b/src/de/dhbwstuttgart/syntaxtree/statement/InstanceOf.java
@@ -5,7 +5,7 @@ package de.dhbwstuttgart.syntaxtree.statement;
import java.util.Enumeration;
import java.util.Hashtable;
-import org.apache.bcel.generic.ClassGen;
+import org.apache.commons.bcel6.generic.ClassGen;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.logger.Logger;
diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/IntLiteral.java b/src/de/dhbwstuttgart/syntaxtree/statement/IntLiteral.java
index 7d672ca4..d649089c 100755
--- a/src/de/dhbwstuttgart/syntaxtree/statement/IntLiteral.java
+++ b/src/de/dhbwstuttgart/syntaxtree/statement/IntLiteral.java
@@ -4,16 +4,17 @@ package de.dhbwstuttgart.syntaxtree.statement;
// ino.module.IntLiteral.8635.import
import java.util.Hashtable;
-import org.apache.bcel.Constants;
-import org.apache.bcel.generic.BIPUSH;
-import org.apache.bcel.generic.ClassGen;
-import org.apache.bcel.generic.InstructionFactory;
-import org.apache.bcel.generic.InstructionHandle;
-import org.apache.bcel.generic.InstructionList;
-import org.apache.bcel.generic.ObjectType;
-import org.apache.bcel.generic.PUSH;
+import org.apache.commons.bcel6.Constants;
+import org.apache.commons.bcel6.generic.BIPUSH;
+import org.apache.commons.bcel6.generic.ClassGen;
+import org.apache.commons.bcel6.generic.InstructionFactory;
+import org.apache.commons.bcel6.generic.InstructionHandle;
+import org.apache.commons.bcel6.generic.InstructionList;
+import org.apache.commons.bcel6.generic.ObjectType;
+import org.apache.commons.bcel6.generic.PUSH;
import de.dhbwstuttgart.typeinference.Menge;
+import de.dhbwstuttgart.bytecode.ClassGenerator;
import de.dhbwstuttgart.logger.Logger;
import de.dhbwstuttgart.myexception.CTypeReconstructionException;
import de.dhbwstuttgart.myexception.JVMCodeException;
@@ -138,7 +139,7 @@ public class IntLiteral extends Literal
}
@Override
- public InstructionList genByteCode(ClassGen cg) {
+ public InstructionList genByteCode(ClassGenerator cg) {
InstructionFactory _factory = new InstructionFactory(cg, cg.getConstantPool());
InstructionList il = new InstructionList();
@@ -146,7 +147,7 @@ public class IntLiteral extends Literal
* Der jetzige Compiler kann keine primitiven Typen. Ein int-Literal ist daher eine Instanz von java.lang.Integer
*/
il.append(new PUSH(cg.getConstantPool(), this.get_Int()));
- il.append(_factory.createInvoke("java.lang.Integer", "valueOf", new ObjectType("java.lang.Integer"), new org.apache.bcel.generic.Type[] { org.apache.bcel.generic.Type.INT }, Constants.INVOKESTATIC));
+ il.append(_factory.createInvoke("java.lang.Integer", "valueOf", new ObjectType("java.lang.Integer"), new org.apache.commons.bcel6.generic.Type[] { org.apache.commons.bcel6.generic.Type.INT }, Constants.INVOKESTATIC));
return il;
}
diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/LambdaExpression.java b/src/de/dhbwstuttgart/syntaxtree/statement/LambdaExpression.java
index 08ca6291..3c12ac59 100755
--- a/src/de/dhbwstuttgart/syntaxtree/statement/LambdaExpression.java
+++ b/src/de/dhbwstuttgart/syntaxtree/statement/LambdaExpression.java
@@ -2,16 +2,17 @@ package de.dhbwstuttgart.syntaxtree.statement;
import java.util.Hashtable;
-import org.apache.bcel.classfile.BootstrapMethod;
-import org.apache.bcel.classfile.ConstantPool;
-import org.apache.bcel.generic.BIPUSH;
-import org.apache.bcel.generic.ClassGen;
-import org.apache.bcel.generic.ConstantPoolGen;
-import org.apache.bcel.generic.InstructionFactory;
-import org.apache.bcel.generic.InstructionList;
-import org.apache.bcel.generic.INVOKEDYNAMIC;
+import org.apache.commons.bcel6.classfile.BootstrapMethod;
+import org.apache.commons.bcel6.classfile.ConstantPool;
+import org.apache.commons.bcel6.generic.BIPUSH;
+import org.apache.commons.bcel6.generic.ClassGen;
+import org.apache.commons.bcel6.generic.ConstantPoolGen;
+import org.apache.commons.bcel6.generic.InstructionFactory;
+import org.apache.commons.bcel6.generic.InstructionList;
+import org.apache.commons.bcel6.generic.INVOKEDYNAMIC;
import de.dhbwstuttgart.typeinference.Menge;
+import de.dhbwstuttgart.bytecode.ClassGenerator;
import de.dhbwstuttgart.myexception.CTypeReconstructionException;
import de.dhbwstuttgart.myexception.JVMCodeException;
import de.dhbwstuttgart.myexception.SCStatementException;
@@ -225,7 +226,7 @@ public class LambdaExpression extends Expr{
}
@Override
- public InstructionList genByteCode(ClassGen cg) {
+ public InstructionList genByteCode(ClassGenerator cg) {
ConstantPoolGen cp = cg.getConstantPool();
InstructionList il = new InstructionList();
diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/LocalOrFieldVar.java b/src/de/dhbwstuttgart/syntaxtree/statement/LocalOrFieldVar.java
index 107c5a3c..46bb0b1e 100755
--- a/src/de/dhbwstuttgart/syntaxtree/statement/LocalOrFieldVar.java
+++ b/src/de/dhbwstuttgart/syntaxtree/statement/LocalOrFieldVar.java
@@ -5,7 +5,7 @@ package de.dhbwstuttgart.syntaxtree.statement;
import java.util.Enumeration;
import java.util.Hashtable;
-import org.apache.bcel.generic.ClassGen;
+import org.apache.commons.bcel6.generic.ClassGen;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.logger.Logger;
diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/LocalVarDecl.java b/src/de/dhbwstuttgart/syntaxtree/statement/LocalVarDecl.java
index eddc29cf..1add7b35 100755
--- a/src/de/dhbwstuttgart/syntaxtree/statement/LocalVarDecl.java
+++ b/src/de/dhbwstuttgart/syntaxtree/statement/LocalVarDecl.java
@@ -5,11 +5,12 @@ package de.dhbwstuttgart.syntaxtree.statement;
import java.util.Enumeration;
import java.util.Hashtable;
-import org.apache.bcel.generic.ClassGen;
-import org.apache.bcel.generic.InstructionList;
+import org.apache.commons.bcel6.generic.ClassGen;
+import org.apache.commons.bcel6.generic.InstructionList;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.logger.Logger;
+import de.dhbwstuttgart.bytecode.ClassGenerator;
import de.dhbwstuttgart.core.MyCompiler;
import de.dhbwstuttgart.myexception.JVMCodeException;
import de.dhbwstuttgart.myexception.SCExcept;
@@ -428,7 +429,7 @@ public class LocalVarDecl extends Statement implements TypeInsertable
}
@Override
- public InstructionList genByteCode(ClassGen _cg) {
+ public InstructionList genByteCode(ClassGenerator _cg) {
// TODO Auto-generated method stub
return new InstructionList();
}
diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/LongLiteral.java b/src/de/dhbwstuttgart/syntaxtree/statement/LongLiteral.java
index e41d494f..8aac0961 100755
--- a/src/de/dhbwstuttgart/syntaxtree/statement/LongLiteral.java
+++ b/src/de/dhbwstuttgart/syntaxtree/statement/LongLiteral.java
@@ -4,10 +4,10 @@ package de.dhbwstuttgart.syntaxtree.statement;
// ino.module.IntLiteral.8635.import
import java.util.Hashtable;
-import org.apache.bcel.generic.ClassGen;
-import org.apache.bcel.generic.ConstantPoolGen;
-import org.apache.bcel.generic.InstructionList;
-import org.apache.bcel.generic.LDC2_W;
+import org.apache.commons.bcel6.generic.ClassGen;
+import org.apache.commons.bcel6.generic.ConstantPoolGen;
+import org.apache.commons.bcel6.generic.InstructionList;
+import org.apache.commons.bcel6.generic.LDC2_W;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.logger.Logger;
diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/MethodCall.java b/src/de/dhbwstuttgart/syntaxtree/statement/MethodCall.java
index 370107c8..4ab7c857 100755
--- a/src/de/dhbwstuttgart/syntaxtree/statement/MethodCall.java
+++ b/src/de/dhbwstuttgart/syntaxtree/statement/MethodCall.java
@@ -4,13 +4,14 @@ package de.dhbwstuttgart.syntaxtree.statement;
// ino.module.MethodCall.8639.import
import java.util.Hashtable;
-import org.apache.bcel.Constants;
-import org.apache.bcel.generic.ClassGen;
-import org.apache.bcel.generic.InstructionFactory;
-import org.apache.bcel.generic.InstructionHandle;
-import org.apache.bcel.generic.InstructionList;
+import org.apache.commons.bcel6.Constants;
+import org.apache.commons.bcel6.generic.ClassGen;
+import org.apache.commons.bcel6.generic.InstructionFactory;
+import org.apache.commons.bcel6.generic.InstructionHandle;
+import org.apache.commons.bcel6.generic.InstructionList;
import de.dhbwstuttgart.typeinference.Menge;
+import de.dhbwstuttgart.bytecode.ClassGenerator;
import de.dhbwstuttgart.logger.Logger;
import de.dhbwstuttgart.myexception.JVMCodeException;
import de.dhbwstuttgart.syntaxtree.Method;
@@ -313,11 +314,11 @@ public class MethodCall extends Expr
*/
@Override
- public InstructionList genByteCode(ClassGen _cg) {
+ public InstructionList genByteCode(ClassGenerator cg) {
InstructionList il = new InstructionList();
- InstructionFactory _factory = new InstructionFactory(_cg, _cg.getConstantPool());
+ InstructionFactory _factory = new InstructionFactory(cg, cg.getConstantPool());
- il.append(receiver.get_Expr().genByteCode(_cg));
+ il.append(receiver.get_Expr().genByteCode(cg));
//Herausfinden, ob eine Methode oder ein Interface aufgerufen wird:
Type receiverType = this.receiver.get_Expr().getType();
@@ -329,19 +330,19 @@ public class MethodCall extends Expr
kind = Constants.INVOKEVIRTUAL;
}
- org.apache.bcel.generic.Type[] argumentTypen = org.apache.bcel.generic.Type.NO_ARGS;
+ org.apache.commons.bcel6.generic.Type[] argumentTypen = org.apache.commons.bcel6.generic.Type.NO_ARGS;
if(this.getArgumentList() != null && this.getArgumentList().size()>0){
- argumentTypen = new org.apache.bcel.generic.Type[this.getArgumentList().size()];
+ argumentTypen = new org.apache.commons.bcel6.generic.Type[this.getArgumentList().size()];
int i = 0;
for(Expr argument : this.arglist.expr){
- argumentTypen[i] = argument.getType().getBytecodeType();
+ argumentTypen[i] = argument.getType().getBytecodeType(cg);
//Das Argument auf den Stack legen:
- il.append(argument.genByteCode(_cg));
+ il.append(argument.genByteCode(cg));
i++;
}
}
- org.apache.bcel.generic.Type returnType = this.getType().getBytecodeType();
+ org.apache.commons.bcel6.generic.Type returnType = this.getType().getBytecodeType(cg);
il.append(_factory.createInvoke(receiver.getReceiverClass().getName().toString(), this.get_Name(), returnType , argumentTypen, kind));
return il;
}
diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/NegativeExpr.java b/src/de/dhbwstuttgart/syntaxtree/statement/NegativeExpr.java
index 2562c862..2f19b975 100755
--- a/src/de/dhbwstuttgart/syntaxtree/statement/NegativeExpr.java
+++ b/src/de/dhbwstuttgart/syntaxtree/statement/NegativeExpr.java
@@ -5,7 +5,7 @@ package de.dhbwstuttgart.syntaxtree.statement;
import java.util.Hashtable;
import java.util.Iterator;
-import org.apache.bcel.generic.ClassGen;
+import org.apache.commons.bcel6.generic.ClassGen;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.logger.Logger;
diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/NewArray.java b/src/de/dhbwstuttgart/syntaxtree/statement/NewArray.java
index 1461c248..630ca25f 100755
--- a/src/de/dhbwstuttgart/syntaxtree/statement/NewArray.java
+++ b/src/de/dhbwstuttgart/syntaxtree/statement/NewArray.java
@@ -4,9 +4,9 @@ package de.dhbwstuttgart.syntaxtree.statement;
// ino.module.NewArray.8641.import
import java.util.Hashtable;
-import org.apache.bcel.generic.ClassGen;
-import org.apache.bcel.generic.InstructionFactory;
-import org.apache.bcel.generic.InstructionList;
+import org.apache.commons.bcel6.generic.ClassGen;
+import org.apache.commons.bcel6.generic.InstructionFactory;
+import org.apache.commons.bcel6.generic.InstructionList;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.logger.Logger;
@@ -152,7 +152,7 @@ public JavaCodeResult printJavaCode(ResultSet resultSet) {
InstructionList il = new InstructionList();
il.append(expr.elementAt(0).genByteCode(cg));
- il.append(_factory.createNewArray(org.apache.bcel.generic.Type.getType(getTypeName()), (short)1));
+ il.append(_factory.createNewArray( org.apache.commons.bcel6.generic.Type.getType(getTypeName()), (short)1));
return il;
diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/NewClass.java b/src/de/dhbwstuttgart/syntaxtree/statement/NewClass.java
index cb2c6935..8d0cb176 100755
--- a/src/de/dhbwstuttgart/syntaxtree/statement/NewClass.java
+++ b/src/de/dhbwstuttgart/syntaxtree/statement/NewClass.java
@@ -6,7 +6,7 @@ import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Iterator;
-import org.apache.bcel.generic.ClassGen;
+import org.apache.commons.bcel6.generic.ClassGen;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.logger.Logger;
diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/NotExpr.java b/src/de/dhbwstuttgart/syntaxtree/statement/NotExpr.java
index 17b7e352..ca22f922 100755
--- a/src/de/dhbwstuttgart/syntaxtree/statement/NotExpr.java
+++ b/src/de/dhbwstuttgart/syntaxtree/statement/NotExpr.java
@@ -5,7 +5,7 @@ package de.dhbwstuttgart.syntaxtree.statement;
import java.util.Hashtable;
import java.util.Iterator;
-import org.apache.bcel.generic.ClassGen;
+import org.apache.commons.bcel6.generic.ClassGen;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.logger.Logger;
diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/Null.java b/src/de/dhbwstuttgart/syntaxtree/statement/Null.java
index 8eee26ed..7a9e2c47 100755
--- a/src/de/dhbwstuttgart/syntaxtree/statement/Null.java
+++ b/src/de/dhbwstuttgart/syntaxtree/statement/Null.java
@@ -4,11 +4,13 @@ package de.dhbwstuttgart.syntaxtree.statement;
// ino.module.Null.8644.import
import java.util.Hashtable;
-import org.apache.bcel.generic.ClassGen;
-import org.apache.bcel.generic.InstructionFactory;
-import org.apache.bcel.generic.InstructionList;
+import org.apache.commons.bcel6.generic.ClassGen;
+import org.apache.commons.bcel6.generic.InstructionConstants;
+import org.apache.commons.bcel6.generic.InstructionFactory;
+import org.apache.commons.bcel6.generic.InstructionList;
import de.dhbwstuttgart.typeinference.Menge;
+import de.dhbwstuttgart.bytecode.ClassGenerator;
import de.dhbwstuttgart.logger.Logger;
import de.dhbwstuttgart.myexception.CTypeReconstructionException;
import de.dhbwstuttgart.myexception.JVMCodeException;
@@ -93,11 +95,11 @@ public class Null extends Literal
}
@Override
- public InstructionList genByteCode(ClassGen cg) {
+ public InstructionList genByteCode(ClassGenerator cg) {
InstructionFactory _factory = new InstructionFactory(cg, cg.getConstantPool());
InstructionList il = new InstructionList();
- il.append(_factory.ACONST_NULL);
+ il.append(InstructionConstants.ACONST_NULL);
return il;
diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/PositivExpr.java b/src/de/dhbwstuttgart/syntaxtree/statement/PositivExpr.java
index deb5ccfe..0ff9198f 100755
--- a/src/de/dhbwstuttgart/syntaxtree/statement/PositivExpr.java
+++ b/src/de/dhbwstuttgart/syntaxtree/statement/PositivExpr.java
@@ -4,7 +4,7 @@ package de.dhbwstuttgart.syntaxtree.statement;
// ino.module.PositivExpr.8645.import
import java.util.Hashtable;
-import org.apache.bcel.generic.ClassGen;
+import org.apache.commons.bcel6.generic.ClassGen;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.logger.Logger;
diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/PostDecExpr.java b/src/de/dhbwstuttgart/syntaxtree/statement/PostDecExpr.java
index 8996932f..c5fb39d8 100755
--- a/src/de/dhbwstuttgart/syntaxtree/statement/PostDecExpr.java
+++ b/src/de/dhbwstuttgart/syntaxtree/statement/PostDecExpr.java
@@ -5,7 +5,7 @@ package de.dhbwstuttgart.syntaxtree.statement;
import java.util.Hashtable;
import java.util.Iterator;
-import org.apache.bcel.generic.ClassGen;
+import org.apache.commons.bcel6.generic.ClassGen;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.logger.Logger;
diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/PostIncExpr.java b/src/de/dhbwstuttgart/syntaxtree/statement/PostIncExpr.java
index 6659a526..e8226319 100755
--- a/src/de/dhbwstuttgart/syntaxtree/statement/PostIncExpr.java
+++ b/src/de/dhbwstuttgart/syntaxtree/statement/PostIncExpr.java
@@ -5,11 +5,11 @@ package de.dhbwstuttgart.syntaxtree.statement;
import java.util.Hashtable;
import java.util.Iterator;
-import org.apache.bcel.generic.BIPUSH;
-import org.apache.bcel.generic.ClassGen;
-import org.apache.bcel.generic.IINC;
-import org.apache.bcel.generic.InstructionFactory;
-import org.apache.bcel.generic.InstructionList;
+import org.apache.commons.bcel6.generic.BIPUSH;
+import org.apache.commons.bcel6.generic.ClassGen;
+import org.apache.commons.bcel6.generic.IINC;
+import org.apache.commons.bcel6.generic.InstructionFactory;
+import org.apache.commons.bcel6.generic.InstructionList;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.logger.Logger;
@@ -106,9 +106,9 @@ public JavaCodeResult printJavaCode(ResultSet resultSet) {
InstructionList il = new InstructionList();
counterPostInc++;
il.append(new IINC(counterPostInc,1));
- //Tests aufgrund fehlener TypInferenz-Funktionalität nicht möglich
- //Vermutlich muss der Counter noch angepasst werden, da nicht incrementierende Variablen nicht mitgezählt werden, und zu falschen aufrufen führen
- //Gibt es einen Compiler-internen Variablenindex, der den Counter effektiver ersetzen könnte
+ //Tests aufgrund fehlener TypInferenz-Funktionalit�t nicht m�glich
+ //Vermutlich muss der Counter noch angepasst werden, da nicht incrementierende Variablen nicht mitgez�hlt werden, und zu falschen aufrufen f�hren
+ //Gibt es einen Compiler-internen Variablenindex, der den Counter effektiver ersetzen k�nnte
return il;
}
diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/PreDecExpr.java b/src/de/dhbwstuttgart/syntaxtree/statement/PreDecExpr.java
index 78f6647b..54d7abc9 100755
--- a/src/de/dhbwstuttgart/syntaxtree/statement/PreDecExpr.java
+++ b/src/de/dhbwstuttgart/syntaxtree/statement/PreDecExpr.java
@@ -5,7 +5,7 @@ package de.dhbwstuttgart.syntaxtree.statement;
import java.util.Hashtable;
import java.util.Iterator;
-import org.apache.bcel.generic.ClassGen;
+import org.apache.commons.bcel6.generic.ClassGen;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.logger.Logger;
diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/PreIncExpr.java b/src/de/dhbwstuttgart/syntaxtree/statement/PreIncExpr.java
index 6b66c5af..49824e5a 100755
--- a/src/de/dhbwstuttgart/syntaxtree/statement/PreIncExpr.java
+++ b/src/de/dhbwstuttgart/syntaxtree/statement/PreIncExpr.java
@@ -5,7 +5,7 @@ package de.dhbwstuttgart.syntaxtree.statement;
import java.util.Hashtable;
import java.util.Iterator;
-import org.apache.bcel.generic.ClassGen;
+import org.apache.commons.bcel6.generic.ClassGen;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.logger.Logger;
diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/Return.java b/src/de/dhbwstuttgart/syntaxtree/statement/Return.java
index 21aca178..170345ef 100755
--- a/src/de/dhbwstuttgart/syntaxtree/statement/Return.java
+++ b/src/de/dhbwstuttgart/syntaxtree/statement/Return.java
@@ -4,12 +4,13 @@ package de.dhbwstuttgart.syntaxtree.statement;
// ino.module.Return.8651.import
import java.util.Hashtable;
-import org.apache.bcel.generic.ConstantPoolGen;
-import org.apache.bcel.generic.InstructionFactory;
-import org.apache.bcel.generic.InstructionList;
-import org.apache.bcel.generic.ClassGen;
+import org.apache.commons.bcel6.generic.ConstantPoolGen;
+import org.apache.commons.bcel6.generic.InstructionFactory;
+import org.apache.commons.bcel6.generic.InstructionList;
+import org.apache.commons.bcel6.generic.ClassGen;
import de.dhbwstuttgart.typeinference.Menge;
+import de.dhbwstuttgart.bytecode.ClassGenerator;
import de.dhbwstuttgart.logger.Logger;
import de.dhbwstuttgart.myexception.CTypeReconstructionException;
import de.dhbwstuttgart.myexception.JVMCodeException;
@@ -133,12 +134,13 @@ public class Return extends Statement
}
@Override
- public InstructionList genByteCode(ClassGen cg) {
+ public InstructionList genByteCode(ClassGenerator cg) {
InstructionList il = retexpr.genByteCode(cg);
InstructionFactory _factory = new InstructionFactory(cg, cg.getConstantPool());
- il.append(_factory.createReturn(retexpr.getType().getBytecodeType()));
+ org.apache.commons.bcel6.generic.Type retType = this.getReturnType().getBytecodeType(cg);//retexpr.getType().getBytecodeType();
+ il.append(_factory.createReturn(retType ));
return il;
}
diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/Statement.java b/src/de/dhbwstuttgart/syntaxtree/statement/Statement.java
index eb4431b2..c8d4d7ba 100755
--- a/src/de/dhbwstuttgart/syntaxtree/statement/Statement.java
+++ b/src/de/dhbwstuttgart/syntaxtree/statement/Statement.java
@@ -5,12 +5,13 @@ package de.dhbwstuttgart.syntaxtree.statement;
import java.util.Enumeration;
import java.util.Hashtable;
-import org.apache.bcel.generic.ClassGen;
-import org.apache.bcel.generic.ConstantPoolGen;
-import org.apache.bcel.generic.InstructionFactory;
-import org.apache.bcel.generic.InstructionList;
+import org.apache.commons.bcel6.generic.ClassGen;
+import org.apache.commons.bcel6.generic.ConstantPoolGen;
+import org.apache.commons.bcel6.generic.InstructionFactory;
+import org.apache.commons.bcel6.generic.InstructionList;
import de.dhbwstuttgart.typeinference.Menge;
+import de.dhbwstuttgart.bytecode.ClassGenerator;
import de.dhbwstuttgart.core.IItemWithOffset;
import de.dhbwstuttgart.myexception.CTypeReconstructionException;
import de.dhbwstuttgart.myexception.JVMCodeException;
@@ -129,7 +130,7 @@ public abstract class Statement extends SyntaxTreeNode implements IItemWithOffse
}
- public abstract InstructionList genByteCode(ClassGen _cg);
+ public abstract InstructionList genByteCode(ClassGenerator _cg);
}
diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/StringLiteral.java b/src/de/dhbwstuttgart/syntaxtree/statement/StringLiteral.java
index e398d088..0323d603 100755
--- a/src/de/dhbwstuttgart/syntaxtree/statement/StringLiteral.java
+++ b/src/de/dhbwstuttgart/syntaxtree/statement/StringLiteral.java
@@ -6,18 +6,20 @@ import de.dhbwstuttgart.typeinference.Menge;
+
// ino.end
// ino.module.StringLiteral.8653.import
import java.util.Hashtable;
-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.InstructionList;
-import org.apache.bcel.generic.LDC;
+import org.apache.commons.bcel6.classfile.ConstantPool;
+import org.apache.commons.bcel6.generic.ClassGen;
+import org.apache.commons.bcel6.generic.ConstantPoolGen;
+import org.apache.commons.bcel6.generic.InstructionFactory;
+import org.apache.commons.bcel6.generic.InstructionList;
+import org.apache.commons.bcel6.generic.LDC;
import de.dhbwstuttgart.typeinference.Menge;
+import de.dhbwstuttgart.bytecode.ClassGenerator;
import de.dhbwstuttgart.logger.Logger;
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar;
@@ -121,7 +123,7 @@ public class StringLiteral extends Literal
}
//public static int counterString = 0;
@Override
- public InstructionList genByteCode(ClassGen cg) {
+ public InstructionList genByteCode(ClassGenerator cg) {
ConstantPoolGen cp = cg.getConstantPool();
InstructionFactory _factory = new InstructionFactory(cg, cp);
InstructionList il = new InstructionList();
diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/SuperCall.java b/src/de/dhbwstuttgart/syntaxtree/statement/SuperCall.java
index 6b354f2a..378a52c3 100644
--- a/src/de/dhbwstuttgart/syntaxtree/statement/SuperCall.java
+++ b/src/de/dhbwstuttgart/syntaxtree/statement/SuperCall.java
@@ -4,13 +4,14 @@ package de.dhbwstuttgart.syntaxtree.statement;
// ino.module.This.8654.import
import java.util.Hashtable;
-import org.apache.bcel.Constants;
-import org.apache.bcel.generic.ClassGen;
-import org.apache.bcel.generic.InstructionFactory;
-import org.apache.bcel.generic.InstructionHandle;
-import org.apache.bcel.generic.InstructionList;
+import org.apache.commons.bcel6.Constants;
+import org.apache.commons.bcel6.generic.ClassGen;
+import org.apache.commons.bcel6.generic.InstructionFactory;
+import org.apache.commons.bcel6.generic.InstructionHandle;
+import org.apache.commons.bcel6.generic.InstructionList;
import de.dhbwstuttgart.typeinference.Menge;
+import de.dhbwstuttgart.bytecode.ClassGenerator;
import de.dhbwstuttgart.logger.Logger;
import de.dhbwstuttgart.myexception.CTypeReconstructionException;
import de.dhbwstuttgart.myexception.JVMCodeException;
@@ -91,14 +92,14 @@ public class SuperCall extends ThisCall
}
@Override
- public InstructionList genByteCode(ClassGen cg) {
+ public InstructionList genByteCode(ClassGenerator cg) {
InstructionFactory _factory = new InstructionFactory(cg, cg.getConstantPool());
InstructionList il = new InstructionList();
Type superClass = this.getParentClass().getSuperClass();
//Instructionhandle dynamisch
- InstructionHandle ih_0 = il.append(_factory.createLoad(org.apache.bcel.generic.Type.OBJECT, 0));
- il.append(_factory.createInvoke(superClass.getName().toString(), "", 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));
+ InstructionHandle ih_0 = il.append(_factory.createLoad( org.apache.commons.bcel6.generic.Type.OBJECT, 0));
+ il.append(_factory.createInvoke(superClass.getName().toString(), "", org.apache.commons.bcel6.generic.Type.VOID, org.apache.commons.bcel6.generic.Type.NO_ARGS, Constants.INVOKESPECIAL));
+ InstructionHandle ih_4 = il.append(_factory.createReturn( org.apache.commons.bcel6.generic.Type.VOID));
return il;
}
diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/This.java b/src/de/dhbwstuttgart/syntaxtree/statement/This.java
index 09ea299a..ead9f40b 100755
--- a/src/de/dhbwstuttgart/syntaxtree/statement/This.java
+++ b/src/de/dhbwstuttgart/syntaxtree/statement/This.java
@@ -4,14 +4,15 @@ package de.dhbwstuttgart.syntaxtree.statement;
// ino.module.This.8654.import
import java.util.Hashtable;
-import org.apache.bcel.generic.ClassGen;
-import org.apache.bcel.generic.InstructionFactory;
-import org.apache.bcel.generic.InstructionHandle;
-import org.apache.bcel.generic.InstructionList;
-import org.apache.bcel.generic.MethodGen;
-import org.apache.bcel.generic.ObjectType;
+import org.apache.commons.bcel6.generic.ClassGen;
+import org.apache.commons.bcel6.generic.InstructionFactory;
+import org.apache.commons.bcel6.generic.InstructionHandle;
+import org.apache.commons.bcel6.generic.InstructionList;
+import org.apache.commons.bcel6.generic.MethodGen;
+import org.apache.commons.bcel6.generic.ObjectType;
import de.dhbwstuttgart.typeinference.Menge;
+import de.dhbwstuttgart.bytecode.ClassGenerator;
import de.dhbwstuttgart.logger.Logger;
import de.dhbwstuttgart.myexception.CTypeReconstructionException;
import de.dhbwstuttgart.myexception.JVMCodeException;
@@ -148,9 +149,9 @@ public class This extends Expr
}
@Override
- public InstructionList genByteCode(ClassGen _cg) {
+ public InstructionList genByteCode(ClassGenerator _cg) {
InstructionList il = new InstructionList();
- InstructionHandle ih_0 = il.append(InstructionFactory.createLoad(org.apache.bcel.generic.Type.OBJECT, 0));
+ il.append(InstructionFactory.createLoad( org.apache.commons.bcel6.generic.Type.OBJECT, 0));
return il;
}
diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/WhileStmt.java b/src/de/dhbwstuttgart/syntaxtree/statement/WhileStmt.java
index 32d98dc6..29496d9d 100755
--- a/src/de/dhbwstuttgart/syntaxtree/statement/WhileStmt.java
+++ b/src/de/dhbwstuttgart/syntaxtree/statement/WhileStmt.java
@@ -6,7 +6,7 @@ import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Iterator;
-import org.apache.bcel.generic.ClassGen;
+import org.apache.commons.bcel6.generic.ClassGen;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.logger.Logger;
diff --git a/src/de/dhbwstuttgart/syntaxtree/type/RefType.java b/src/de/dhbwstuttgart/syntaxtree/type/RefType.java
index 29637635..e8451faa 100755
--- a/src/de/dhbwstuttgart/syntaxtree/type/RefType.java
+++ b/src/de/dhbwstuttgart/syntaxtree/type/RefType.java
@@ -9,6 +9,7 @@ import java.util.Iterator;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.logger.Logger;
+import de.dhbwstuttgart.bytecode.ClassGenerator;
import de.dhbwstuttgart.core.IItemWithOffset;
import de.dhbwstuttgart.myexception.SCException;
import de.dhbwstuttgart.parser.JavaClassName;
@@ -812,8 +813,8 @@ public class RefType extends ObjectType implements IMatchable
}
}
- public org.apache.bcel.generic.Type getBytecodeType() {
- return new org.apache.bcel.generic.ObjectType(this.getTypeName());
+ public org.apache.commons.bcel6.generic.Type getBytecodeType(ClassGenerator cg) {
+ return new org.apache.commons.bcel6.generic.ObjectType(this.getTypeName());
}
}
diff --git a/src/de/dhbwstuttgart/syntaxtree/type/Type.java b/src/de/dhbwstuttgart/syntaxtree/type/Type.java
index 20a9b07e..c365723d 100755
--- a/src/de/dhbwstuttgart/syntaxtree/type/Type.java
+++ b/src/de/dhbwstuttgart/syntaxtree/type/Type.java
@@ -3,8 +3,9 @@ package de.dhbwstuttgart.syntaxtree.type;
// ino.end
// ino.module.Type.8677.import
import java.util.ArrayList;
-import de.dhbwstuttgart.typeinference.Menge;
+import de.dhbwstuttgart.typeinference.Menge;
+import de.dhbwstuttgart.bytecode.ClassGenerator;
import de.dhbwstuttgart.core.IItemWithOffset;
import de.dhbwstuttgart.parser.JavaClassName;
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
@@ -304,7 +305,7 @@ public abstract class Type extends SyntaxTreeNode implements IItemWithOffset
return this;
}
- public abstract org.apache.bcel.generic.Type getBytecodeType();
+ public abstract org.apache.commons.bcel6.generic.Type getBytecodeType(ClassGenerator cg);
}
// ino.end
diff --git a/src/de/dhbwstuttgart/syntaxtree/type/TypePlaceholder.java b/src/de/dhbwstuttgart/syntaxtree/type/TypePlaceholder.java
index d93160b9..755be5fd 100755
--- a/src/de/dhbwstuttgart/syntaxtree/type/TypePlaceholder.java
+++ b/src/de/dhbwstuttgart/syntaxtree/type/TypePlaceholder.java
@@ -5,9 +5,10 @@ package de.dhbwstuttgart.syntaxtree.type;
// ino.module.TypePlaceholder.8678.import
import java.util.Hashtable;
import java.util.Iterator;
-import de.dhbwstuttgart.typeinference.Menge;
+import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.logger.*;
+import de.dhbwstuttgart.bytecode.ClassGenerator;
import de.dhbwstuttgart.core.MyCompiler;
import de.dhbwstuttgart.parser.JavaClassName;
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
@@ -15,6 +16,8 @@ import de.dhbwstuttgart.typeinference.JavaCodeResult;
import de.dhbwstuttgart.typeinference.ResultSet;
import de.dhbwstuttgart.typeinference.TypeInsertable;
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
+import de.dhbwstuttgart.typeinference.exceptions.DebugException;
+import de.dhbwstuttgart.typeinference.exceptions.TypeinferenceException;
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertPoint;
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
// ino.class.TypePlaceholder.26780.description type=javadoc
@@ -425,6 +428,14 @@ public class TypePlaceholder extends ObjectType
}
return ret;
}
+
+ @Override
+ public org.apache.commons.bcel6.generic.Type getBytecodeType(ClassGenerator cg) {
+ //throw new TypeinferenceException("Zuerst alle Typen einsetzen vor dem Kompiliervorgang",this);
+ Type resolvedType = cg.resolveTPH(this);
+ if(resolvedType instanceof TypePlaceholder)throw new DebugException("Kann TypePlaceholder nicht auflösen");
+ return resolvedType.getBytecodeType(cg);
+ }
}
// ino.end
diff --git a/src/de/dhbwstuttgart/syntaxtree/type/Void.java b/src/de/dhbwstuttgart/syntaxtree/type/Void.java
index 42c63af3..8e575dff 100755
--- a/src/de/dhbwstuttgart/syntaxtree/type/Void.java
+++ b/src/de/dhbwstuttgart/syntaxtree/type/Void.java
@@ -1,6 +1,7 @@
// ino.module.Void.8679.package
package de.dhbwstuttgart.syntaxtree.type;
+import de.dhbwstuttgart.bytecode.ClassGenerator;
import de.dhbwstuttgart.core.IItemWithOffset;
import de.dhbwstuttgart.syntaxtree.Method;
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
@@ -80,8 +81,8 @@ public class Void extends RefType
}
@Override
- public org.apache.bcel.generic.Type getBytecodeType() {
- return org.apache.bcel.generic.Type.VOID;
+ public org.apache.commons.bcel6.generic.Type getBytecodeType(ClassGenerator cg) {
+ return org.apache.commons.bcel6.generic.Type.VOID;
}
}
diff --git a/src/de/dhbwstuttgart/typeinference/ByteCodeResult.java b/src/de/dhbwstuttgart/typeinference/ByteCodeResult.java
index b83a5d65..ec127bec 100644
--- a/src/de/dhbwstuttgart/typeinference/ByteCodeResult.java
+++ b/src/de/dhbwstuttgart/typeinference/ByteCodeResult.java
@@ -1,6 +1,6 @@
package de.dhbwstuttgart.typeinference;
-import org.apache.bcel.generic.ClassGen;
+import org.apache.commons.bcel6.generic.ClassGen;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
diff --git a/test/bytecode/CharLitTest.jav b/test/bytecode/CharLitTest.jav
deleted file mode 100644
index 1cf78415..00000000
--- a/test/bytecode/CharLitTest.jav
+++ /dev/null
@@ -1,7 +0,0 @@
-class CharLitTest{
-
-
-void method() { c; c = 'A'; }
-
-
-}
\ No newline at end of file
diff --git a/test/bytecode/DoubleLiteral.jav b/test/bytecode/DoubleLiteral.jav
deleted file mode 100644
index 7813d262..00000000
--- a/test/bytecode/DoubleLiteral.jav
+++ /dev/null
@@ -1,6 +0,0 @@
-class DoubleLiteral{
-
-void method() {a; a = 20.0d;}
-
-
-}
\ No newline at end of file
diff --git a/test/bytecode/DoubleLiteral.java b/test/bytecode/DoubleLiteral.java
deleted file mode 100644
index e9470c5f..00000000
--- a/test/bytecode/DoubleLiteral.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package bytecode;
-
-import static org.junit.Assert.*;
-
-import java.io.File;
-import java.io.IOException;
-
-import junit.framework.TestCase;
-
-import org.junit.Test;
-
-import plugindevelopment.TypeInsertTester;
-import de.dhbwstuttgart.core.MyCompiler;
-import de.dhbwstuttgart.core.MyCompilerAPI;
-import de.dhbwstuttgart.logger.LoggerConfiguration;
-import de.dhbwstuttgart.logger.Section;
-import de.dhbwstuttgart.parser.JavaParser.yyException;
-import de.dhbwstuttgart.typeinference.ByteCodeResult;
-import de.dhbwstuttgart.typeinference.Menge;
-import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
-import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
-
-public class DoubleLiteral {
-
- public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
- public final static String testFile = "DoubleLiteral.jav";
- public final static String outputFile = "DoubleLiteral.class";
-
- @Test
- public void test() {
- LoggerConfiguration logConfig = new LoggerConfiguration().setOutput(Section.PARSER, System.out);
- MyCompilerAPI compiler = MyCompiler.getAPI(logConfig);
- try {
- compiler.parse(new File(rootDirectory + testFile));
- compiler.typeReconstruction();
- ByteCodeResult bytecode = compiler.generateBytecode();
- System.out.println(bytecode);
- bytecode.getByteCode().getJavaClass().dump(new File(rootDirectory + outputFile));
- } catch (IOException | yyException e) {
- e.printStackTrace();
- TestCase.fail();
- }
- }
-
-}
diff --git a/test/bytecode/FieldDeclaration.jav b/test/bytecode/FieldDeclaration.jav
new file mode 100644
index 00000000..14d4f9bd
--- /dev/null
+++ b/test/bytecode/FieldDeclaration.jav
@@ -0,0 +1,8 @@
+class FieldDeclaration{
+ Integer integer = 20;
+ FieldDeclaration field = methode();
+
+ FieldDeclaration methode(){
+ return this;
+ }
+}
\ No newline at end of file
diff --git a/test/bytecode/FieldDeclarationTest.java b/test/bytecode/FieldDeclarationTest.java
new file mode 100644
index 00000000..7724c0e8
--- /dev/null
+++ b/test/bytecode/FieldDeclarationTest.java
@@ -0,0 +1,14 @@
+package bytecode;
+
+import org.junit.Test;
+
+public class FieldDeclarationTest {
+ public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
+ public final static String testFile = "FieldDeclaration.jav";
+ public final static String outputFile = "FieldDeclaration.class";
+
+ @Test
+ public void test() {
+ SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
+ }
+}
diff --git a/test/bytecode/FloatLiteral.jav b/test/bytecode/FloatLiteral.jav
deleted file mode 100644
index c0531da4..00000000
--- a/test/bytecode/FloatLiteral.jav
+++ /dev/null
@@ -1,6 +0,0 @@
-class FloatLiteral{
-
-void method() {f; f = 20.0f;}
-
-
-}
\ No newline at end of file
diff --git a/test/bytecode/FloatLiteral.java b/test/bytecode/FloatLiteral.java
deleted file mode 100644
index ba789535..00000000
--- a/test/bytecode/FloatLiteral.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package bytecode;
-
-import static org.junit.Assert.*;
-
-import java.io.File;
-import java.io.IOException;
-
-import junit.framework.TestCase;
-
-import org.junit.Test;
-
-import plugindevelopment.TypeInsertTester;
-import de.dhbwstuttgart.core.MyCompiler;
-import de.dhbwstuttgart.core.MyCompilerAPI;
-import de.dhbwstuttgart.logger.LoggerConfiguration;
-import de.dhbwstuttgart.logger.Section;
-import de.dhbwstuttgart.parser.JavaParser.yyException;
-import de.dhbwstuttgart.typeinference.ByteCodeResult;
-import de.dhbwstuttgart.typeinference.Menge;
-import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
-import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
-
-public class FloatLiteral {
-
- public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
- public final static String testFile = "FloatLiteral.jav";
- public final static String outputFile = "FloatLiteral.class";
-
- @Test
- public void test() {
- LoggerConfiguration logConfig = new LoggerConfiguration().setOutput(Section.PARSER, System.out);
- MyCompilerAPI compiler = MyCompiler.getAPI(logConfig);
- try {
- compiler.parse(new File(rootDirectory + testFile));
- compiler.typeReconstruction();
- ByteCodeResult bytecode = compiler.generateBytecode();
- System.out.println(bytecode);
- bytecode.getByteCode().getJavaClass().dump(new File(rootDirectory + outputFile));
- } catch (IOException | yyException e) {
- e.printStackTrace();
- TestCase.fail();
- }
- }
-
-}
diff --git a/test/bytecode/LambdaExpr.java b/test/bytecode/LambdaExpr.java
index e0d40b6b..c28dad56 100644
--- a/test/bytecode/LambdaExpr.java
+++ b/test/bytecode/LambdaExpr.java
@@ -28,18 +28,7 @@ public class LambdaExpr {
@Test
public void test() {
- LoggerConfiguration logConfig = new LoggerConfiguration().setOutput(Section.PARSER, System.out);
- MyCompilerAPI compiler = MyCompiler.getAPI(logConfig);
- try {
- compiler.parse(new File(rootDirectory + testFile));
- compiler.typeReconstruction();
- ByteCodeResult bytecode = compiler.generateBytecode();
- System.out.println(bytecode);
- bytecode.getByteCode().getJavaClass().dump(new File(rootDirectory + outputFile));
- } catch (IOException | yyException e) {
- e.printStackTrace();
- TestCase.fail();
- }
+ SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
}
}
diff --git a/test/bytecode/LongLiteral.jav b/test/bytecode/LongLiteral.jav
deleted file mode 100644
index 70d57aa7..00000000
--- a/test/bytecode/LongLiteral.jav
+++ /dev/null
@@ -1,6 +0,0 @@
-class LongLiteral{
-
-void method() {l; l = 20L;}
-
-
-}
\ No newline at end of file
diff --git a/test/bytecode/LongLiteral.java b/test/bytecode/LongLiteral.java
deleted file mode 100644
index 5e6ca9cb..00000000
--- a/test/bytecode/LongLiteral.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package bytecode;
-
-import static org.junit.Assert.*;
-
-import java.io.File;
-import java.io.IOException;
-
-import junit.framework.TestCase;
-
-import org.junit.Test;
-
-import plugindevelopment.TypeInsertTester;
-import de.dhbwstuttgart.core.MyCompiler;
-import de.dhbwstuttgart.core.MyCompilerAPI;
-import de.dhbwstuttgart.logger.LoggerConfiguration;
-import de.dhbwstuttgart.logger.Section;
-import de.dhbwstuttgart.parser.JavaParser.yyException;
-import de.dhbwstuttgart.typeinference.ByteCodeResult;
-import de.dhbwstuttgart.typeinference.Menge;
-import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
-import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
-
-public class LongLiteral {
-
- public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
- public final static String testFile = "LongLiteral.jav";
- public final static String outputFile = "LongLiteral.class";
-
- @Test
- public void test() {
- LoggerConfiguration logConfig = new LoggerConfiguration().setOutput(Section.PARSER, System.out);
- MyCompilerAPI compiler = MyCompiler.getAPI(logConfig);
- try {
- compiler.parse(new File(rootDirectory + testFile));
- compiler.typeReconstruction();
- ByteCodeResult bytecode = compiler.generateBytecode();
- System.out.println(bytecode);
- bytecode.getByteCode().getJavaClass().dump(new File(rootDirectory + outputFile));
- } catch (IOException | yyException e) {
- e.printStackTrace();
- TestCase.fail();
- }
- }
-
-}
diff --git a/test/bytecode/MethodEmpty.java b/test/bytecode/MethodEmpty.java
index dbeea0a5..1f6af8be 100644
--- a/test/bytecode/MethodEmpty.java
+++ b/test/bytecode/MethodEmpty.java
@@ -28,18 +28,7 @@ public class MethodEmpty {
@Test
public void test() {
- LoggerConfiguration logConfig = new LoggerConfiguration().setOutput(Section.PARSER, System.out);
- MyCompilerAPI compiler = MyCompiler.getAPI(logConfig);
- try {
- compiler.parse(new File(rootDirectory + testFile));
- compiler.typeReconstruction();
- ByteCodeResult bytecode = compiler.generateBytecode();
- System.out.println(bytecode);
- bytecode.getByteCode().getJavaClass().dump(new File(rootDirectory + outputFile));
- } catch (IOException | yyException e) {
- e.printStackTrace();
- TestCase.fail();
- }
+ SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
}
}
diff --git a/test/bytecode/MethodEmptyRetType.java b/test/bytecode/MethodEmptyRetType.java
index 7eecbe0e..272e3998 100644
--- a/test/bytecode/MethodEmptyRetType.java
+++ b/test/bytecode/MethodEmptyRetType.java
@@ -28,18 +28,7 @@ public class MethodEmptyRetType {
@Test
public void test() {
- LoggerConfiguration logConfig = new LoggerConfiguration().setOutput(Section.PARSER, System.out);
- MyCompilerAPI compiler = MyCompiler.getAPI(logConfig);
- try {
- compiler.parse(new File(rootDirectory + testFile));
- compiler.typeReconstruction();
- ByteCodeResult bytecode = compiler.generateBytecode();
- System.out.println(bytecode);
- bytecode.getByteCode().getJavaClass().dump(new File(rootDirectory + outputFile));
- } catch (IOException | yyException e) {
- e.printStackTrace();
- TestCase.fail();
- }
+ SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
}
}
diff --git a/test/bytecode/NewArrayTest.java b/test/bytecode/NewArrayTest.java
deleted file mode 100644
index 6a9c3853..00000000
--- a/test/bytecode/NewArrayTest.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package bytecode;
-
-import static org.junit.Assert.*;
-
-import java.io.File;
-import java.io.IOException;
-
-import junit.framework.TestCase;
-
-import org.junit.Test;
-
-import plugindevelopment.TypeInsertTester;
-import de.dhbwstuttgart.core.MyCompiler;
-import de.dhbwstuttgart.core.MyCompilerAPI;
-import de.dhbwstuttgart.logger.LoggerConfiguration;
-import de.dhbwstuttgart.logger.Section;
-import de.dhbwstuttgart.parser.JavaParser.yyException;
-import de.dhbwstuttgart.typeinference.ByteCodeResult;
-import de.dhbwstuttgart.typeinference.Menge;
-import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
-import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
-
-public class NewArrayTest {
-
- public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
- public final static String testFile = "NewArray.jav";
- public final static String outputFile = "NewArray.class";
-
- @Test
- public void test() {
- LoggerConfiguration logConfig = new LoggerConfiguration().setOutput(Section.PARSER, System.out);
- MyCompilerAPI compiler = MyCompiler.getAPI(logConfig);
- try {
- compiler.parse(new File(rootDirectory + testFile));
- compiler.typeReconstruction();
- ByteCodeResult bytecode = compiler.generateBytecode();
- System.out.println(bytecode);
- bytecode.getByteCode().getJavaClass().dump(new File(rootDirectory + outputFile));
- } catch (IOException | yyException e) {
- e.printStackTrace();
- TestCase.fail();
- }
- }
-
-}
diff --git a/test/bytecode/PostIncrement.java b/test/bytecode/PostIncrement.java
index e24ee34a..8c0b3930 100644
--- a/test/bytecode/PostIncrement.java
+++ b/test/bytecode/PostIncrement.java
@@ -28,18 +28,7 @@ public class PostIncrement {
@Test
public void test() {
- LoggerConfiguration logConfig = new LoggerConfiguration().setOutput(Section.PARSER, System.out);
- MyCompilerAPI compiler = MyCompiler.getAPI(logConfig);
- try {
- compiler.parse(new File(rootDirectory + testFile));
- compiler.typeReconstruction();
- ByteCodeResult bytecode = compiler.generateBytecode();
- System.out.println(bytecode);
- bytecode.getByteCode().getJavaClass().dump(new File(rootDirectory + outputFile));
- } catch (IOException | yyException e) {
- e.printStackTrace();
- TestCase.fail();
- }
+ SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
}
}
diff --git a/test/bytecode/SingleClassTester.java b/test/bytecode/SingleClassTester.java
index f8a85463..d769fe98 100644
--- a/test/bytecode/SingleClassTester.java
+++ b/test/bytecode/SingleClassTester.java
@@ -19,8 +19,7 @@ public class SingleClassTester {
MyCompilerAPI compiler = MyCompiler.getAPI(logConfig);
try {
compiler.parse(new File(inputFile));
- compiler.typeReconstruction();
- Menge bytecode = compiler.generateBytecode();
+ Menge bytecode = compiler.generateBytecode(compiler.typeReconstruction().firstElement());
System.out.println(bytecode);
bytecode.firstElement().getByteCode().getJavaClass().dump(new File(outputFile));
} catch (IOException | yyException e) {
diff --git a/test/bytecode/StringLitTest.java b/test/bytecode/StringLitTest.java
index 6032c6a1..d4d93f19 100644
--- a/test/bytecode/StringLitTest.java
+++ b/test/bytecode/StringLitTest.java
@@ -28,18 +28,7 @@ public class StringLitTest {
@Test
public void test() {
- LoggerConfiguration logConfig = new LoggerConfiguration().setOutput(Section.PARSER, System.out);
- MyCompilerAPI compiler = MyCompiler.getAPI(logConfig);
- try {
- compiler.parse(new File(rootDirectory + testFile));
- compiler.typeReconstruction();
- ByteCodeResult bytecode = compiler.generateBytecode();
- System.out.println(bytecode);
- bytecode.getByteCode().getJavaClass().dump(new File(rootDirectory + outputFile));
- } catch (IOException | yyException e) {
- e.printStackTrace();
- TestCase.fail();
- }
+ SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
}
}
diff --git a/test/bytecode/Test.java b/test/bytecode/Test.java
index 2c625925..ed9c705d 100644
--- a/test/bytecode/Test.java
+++ b/test/bytecode/Test.java
@@ -7,5 +7,6 @@ public static void main(String[] args){
new Assign();
System.out.println(new Return().method());
new MethodCall().method();
+ System.out.println(new FieldDeclaration().field);
}
}
diff --git a/test/plugindevelopment/TypeInsertTests/Analysis.txt b/test/plugindevelopment/TypeInsertTests/Analysis.txt
new file mode 100644
index 00000000..c6c27a75
--- /dev/null
+++ b/test/plugindevelopment/TypeInsertTests/Analysis.txt
@@ -0,0 +1,3 @@
+LambdaTest5:
+* Zeit ohne Unify-Filterung: 729601
+* Zeit mit Unify-Filterung: 95235
diff --git a/test/plugindevelopment/TypeInsertTests/UnifyPaper.jav b/test/plugindevelopment/TypeInsertTests/UnifyPaper.jav
new file mode 100644
index 00000000..02305377
--- /dev/null
+++ b/test/plugindevelopment/TypeInsertTests/UnifyPaper.jav
@@ -0,0 +1,13 @@
+
+
+class Klasse1 {
+ void methode(){
+ var;
+ var = this;
+ var = new Klasse2();
+ }
+}
+
+class Klasse2 extends Klasse1{
+
+}
\ No newline at end of file
diff --git a/test/plugindevelopment/TypeInsertTests/UnifyPaper.java b/test/plugindevelopment/TypeInsertTests/UnifyPaper.java
new file mode 100644
index 00000000..9f963c5f
--- /dev/null
+++ b/test/plugindevelopment/TypeInsertTests/UnifyPaper.java
@@ -0,0 +1,19 @@
+package plugindevelopment.TypeInsertTests;
+
+import java.util.ArrayList;
+import java.util.List;
+import de.dhbwstuttgart.typeinference.Menge;
+
+import org.junit.Test;
+
+public class UnifyPaper {
+ private static final String TEST_FILE = "UnifyPaper.jav";
+
+ @Test
+ public void run(){
+ Menge mustContain = new Menge();
+ //mustContain.add("TestIfStmt var");
+ MultipleTypesInsertTester.testSingleInsert(this.TEST_FILE, mustContain);
+ ArrayList l = new ArrayList();
+ }
+}
diff --git a/test/plugindevelopment/TypeInsertTests/UnifyPaper2.jav b/test/plugindevelopment/TypeInsertTests/UnifyPaper2.jav
new file mode 100644
index 00000000..ced65a23
--- /dev/null
+++ b/test/plugindevelopment/TypeInsertTests/UnifyPaper2.jav
@@ -0,0 +1,13 @@
+import java.util.Vector;
+
+class Klasse1 {
+ void methode(){
+ var;
+ var = new Vector();
+ var = new Vector();
+ }
+}
+
+class Klasse2 extends Klasse1{
+
+}
diff --git a/test/plugindevelopment/TypeInsertTests/UnifyPaper2.java b/test/plugindevelopment/TypeInsertTests/UnifyPaper2.java
new file mode 100644
index 00000000..0c1f1338
--- /dev/null
+++ b/test/plugindevelopment/TypeInsertTests/UnifyPaper2.java
@@ -0,0 +1,19 @@
+package plugindevelopment.TypeInsertTests;
+
+import java.util.ArrayList;
+import java.util.List;
+import de.dhbwstuttgart.typeinference.Menge;
+
+import org.junit.Test;
+
+public class UnifyPaper2 {
+ private static final String TEST_FILE = "UnifyPaper2.jav";
+
+ @Test
+ public void run(){
+ Menge mustContain = new Menge();
+ //mustContain.add("TestIfStmt var");
+ MultipleTypesInsertTester.testSingleInsert(this.TEST_FILE, mustContain);
+ ArrayList l = new ArrayList();
+ }
+}