diff --git a/.classpath b/.classpath
index cf0244b5..a66c92d7 100755
--- a/.classpath
+++ b/.classpath
@@ -6,7 +6,7 @@
-
+
diff --git a/lib/bcel-6.0-SNAPSHOT.jar b/lib/bcel-6.0-SNAPSHOT.jar
new file mode 100644
index 00000000..a3753dee
Binary files /dev/null and b/lib/bcel-6.0-SNAPSHOT.jar differ
diff --git a/src/de/dhbwstuttgart/syntaxtree/Class.java b/src/de/dhbwstuttgart/syntaxtree/Class.java
index 972adb7f..d00cca51 100755
--- a/src/de/dhbwstuttgart/syntaxtree/Class.java
+++ b/src/de/dhbwstuttgart/syntaxtree/Class.java
@@ -721,7 +721,7 @@ public class Class extends GTVDeclarationContext implements AClassOrInterface, I
assumptions.add(globalAssumptions);
ConstraintsSet oderConstraints = new ConstraintsSet();
-
+
for(Type gparam : this.get_ParaList()){
if(gparam instanceof GenericTypeVar)assumptions.add(((GenericTypeVar)gparam).createAssumptions()); //Constraints für die Generischen Variablen erstellen und diese dem AssumptionsSet hinzufügen
}
@@ -744,7 +744,8 @@ public class Class extends GTVDeclarationContext implements AClassOrInterface, I
//ConstraintsSet oderConstraints = this.TYPE(this.getMethodList(), fieldInitializers, assumptions);
-
+ this.superClass = this.superClass.TYPE(assumptions, this);
+
for(Field f:this.getFields()){
oderConstraints.add(f.TYPE(assumptions));
}
@@ -1250,8 +1251,8 @@ public class Class extends GTVDeclarationContext implements AClassOrInterface, I
if(!constructorVorhanden){//Falls kein Konstruktor vorhanden ist, muss noch der Standardkonstruktor angefügt werden:
Block konstruktorBlock = new Block();
konstruktorBlock.statements.add(new SuperCall(konstruktorBlock));
- //Constructor standardKonstruktor = new Constructor(Method.createEmptyMethod(konstruktorBlock,this.getName().toString(), this));
- Constructor standardKonstruktor = new Constructor(Method.createEmptyMethod(this.getName().toString(), this));
+ Constructor standardKonstruktor = new Constructor(Method.createEmptyMethod(konstruktorBlock,this.getName().toString(), this));
+ //Constructor standardKonstruktor = new Constructor(Method.createEmptyMethod(this.getName().toString(), this));
this.addField(standardKonstruktor);
}
diff --git a/src/de/dhbwstuttgart/syntaxtree/Constructor.java b/src/de/dhbwstuttgart/syntaxtree/Constructor.java
index cb5914ad..e8f651b8 100644
--- a/src/de/dhbwstuttgart/syntaxtree/Constructor.java
+++ b/src/de/dhbwstuttgart/syntaxtree/Constructor.java
@@ -15,6 +15,7 @@ import de.dhbwstuttgart.parser.JavaClassName;
import de.dhbwstuttgart.syntaxtree.misc.DeclId;
import de.dhbwstuttgart.syntaxtree.modifier.Modifiers;
import de.dhbwstuttgart.syntaxtree.statement.Block;
+import de.dhbwstuttgart.syntaxtree.statement.SuperCall;
import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar;
import de.dhbwstuttgart.syntaxtree.type.RefType;
import de.dhbwstuttgart.syntaxtree.type.Type;
@@ -39,6 +40,10 @@ public class Constructor extends Method {
*/
public Constructor(Method methode){
super(methode.get_Method_Name(), methode.getType(), methode.getParameterList(),methode.get_Block(), methode.getGenericDeclarationList(), methode.getOffset());
+ //Sicherstellen, dass das erste Statement in der Methode ein SuperCall ist:
+ if(this.get_Block().get_Statement().size() <1 || ! (this.get_Block().get_Statement().firstElement() instanceof SuperCall)){
+ this.get_Block().statements.add(0, new SuperCall(this.get_Block()));
+ }
}
@Override
public TypeAssumptions createTypeAssumptions(Class classmember) {
@@ -52,18 +57,22 @@ public class Constructor extends Method {
@Override
public void genByteCode(ClassGen cg) {
ConstantPoolGen _cp = cg.getConstantPool();
- //InstructionFactory _factory = new InstructionFactory(cg, _cp);
InstructionList il = new InstructionList(); //sollte nicht new sein sondern aus Block kommen
Class parentClass = this.getParentClass();
- //Hier m�sste drin stehen: Kreiere einen Block, welcher ein Statement enth�lt, welches ein Super Statement ist.
-
//TODO: Alles dynamisch gestalten
//init darf nur drin stehen, wenn Konstruktor;
- this.method = new MethodGen(Constants.ACC_PUBLIC, org.apache.bcel.generic.Type.getReturnType(this.getType().get_Name()), org.apache.bcel.generic.Type.NO_ARGS , new String[] { }, "", parentClass.name, il, _cp);
+ this.method = new MethodGen(Constants.ACC_PUBLIC, this.getType().getBytecodeType(), org.apache.bcel.generic.Type.NO_ARGS , new String[] { }, "", parentClass.name, il, _cp);
- super.genByteCode(cg); //Aufrufen um Iteration �ber Block zu starten
-
+ //Iteration �ber Block starten
+ Block block = this.get_Block();
+ InstructionList blockInstructions = block.genByteCode(cg);
+
+ il.append(blockInstructions);//Die vom Block generierten Instructions an die InstructionList der Methode anfügen
+
+ this.method.setMaxStack(); //Die Stack Größe automatisch berechnen lassen (erst nach dem alle Instructions angehängt wurden)
+
+ cg.addMethod(this.method.getMethod());
}
// super statement muss drin sein
// stmt genByteCode + im block genByteCode implementieren & dann Hierarchie ausprobieren
diff --git a/src/de/dhbwstuttgart/syntaxtree/Method.java b/src/de/dhbwstuttgart/syntaxtree/Method.java
index dd27c698..c5547f23 100755
--- a/src/de/dhbwstuttgart/syntaxtree/Method.java
+++ b/src/de/dhbwstuttgart/syntaxtree/Method.java
@@ -741,19 +741,27 @@ public class Method extends Field implements IItemWithOffset, TypeInsertable
@Override
public void genByteCode(ClassGen cg) {
- /*ConstantPoolGen _cp = cg.getConstantPool();
- * InstructionFactory _factory = new InstructionFactory(cg, _cp);
- * InstructionList il = new InstructionList();
- * Class parentClass = this.getParentClass();
- */
+ ConstantPoolGen _cp = cg.getConstantPool();
+ InstructionFactory _factory = new InstructionFactory(cg, _cp);
+ InstructionList il = new InstructionList();
+ Class parentClass = this.getParentClass();
+
+ MethodGen method = new MethodGen(Constants.ACC_PUBLIC, this.getType().getBytecodeType(), org.apache.bcel.generic.Type.NO_ARGS , new String[] { }, this.get_Method_Name(), parentClass.name, il, _cp);
- //oben steht MethodGen method als Variable (Z. 71)
+ Block block = this.get_Block();
+ InstructionList blockInstructions = block.genByteCode(cg);
- // �ber Statements iterieren um Block abzurufen
- for (Statement statements : block.get_Statement()) {
- statements.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)); }
+ else {
+ if (!(block.get_Statement().lastElement() instanceof Return)) { il.append(_factory.createReturn(org.apache.bcel.generic.Type.VOID)); }
}
+ method.setMaxStack(); //Die Stack Größe automatisch berechnen lassen (erst nach dem alle Instructions angehängt wurden)
+
+ cg.addMethod(method.getMethod());
+
}
}
diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/Assign.java b/src/de/dhbwstuttgart/syntaxtree/statement/Assign.java
index 2bfab538..2b38bc8b 100755
--- a/src/de/dhbwstuttgart/syntaxtree/statement/Assign.java
+++ b/src/de/dhbwstuttgart/syntaxtree/statement/Assign.java
@@ -6,7 +6,14 @@ 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 de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.logger.Logger;
@@ -168,13 +175,40 @@ public class Assign extends Expr
}
-
-
+ public static int counterAssign = 0; //Zaehlvariable für ISTORE
@Override
- public void genByteCode(ClassGen _cg) {
+ public InstructionList genByteCode(ClassGen cg) {
// TODO Auto-generated method stub
-
+ InstructionFactory _factory = new InstructionFactory(cg, cg.getConstantPool());
+ InstructionList il = expr2.genByteCode(cg);//expr2 rechte expr
+ counterAssign++; //macht STORE für meherere Variable nutzbar (nicht nur ISTORE_1, ISTORE_2, etc.)
+
+
+ String expr2Type = expr2.getType().get_Name().toString();
+ switch(expr2Type){
+ case "java.lang.Integer":
+ il.append(new ISTORE(counterAssign));
+ break;
+
+ case "java.lang.String":
+ il.append(new ASTORE(counterAssign));
+ break;
+
+ case "java.lang.Double":
+ il.append(new DSTORE(counterAssign));
+ break;
+
+ case "java.lang.Float":
+ il.append(new FSTORE(counterAssign));
+ break;
+
+ case "java.lang.Long":
+ il.append(new LSTORE(counterAssign));
+ break;
+ }
+
+ return il;
}
}
diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/Block.java b/src/de/dhbwstuttgart/syntaxtree/statement/Block.java
index ab311454..fc744563 100755
--- a/src/de/dhbwstuttgart/syntaxtree/statement/Block.java
+++ b/src/de/dhbwstuttgart/syntaxtree/statement/Block.java
@@ -255,20 +255,16 @@ public class Block extends Statement
}
@Override
- public void genByteCode(ClassGen cg) {
+ public InstructionList genByteCode(ClassGen cg) {
//ConstantPoolGen _cp = cg.getConstantPool();
- InstructionFactory _factory = new InstructionFactory(cg, _cp);
InstructionList il = new InstructionList();
- //Frage: Wenn Block von Statements erbt, und Block selbst keinen BCEL Code besitzt, ist das hier dann nicht eine Sackgasse?
-
- //Instructionhandle dynamisch
- InstructionHandle ih_0 = il.append(_factory.createLoad(org.apache.bcel.generic.Type.OBJECT, 0));
- il.append(_factory.createInvoke(this.getParentClass().superclassid.toString(), "", 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));
+ for(Statement stmt : this.get_Statement()){
+ il.append(stmt.genByteCode(cg));
+ }
+ //il.dispose();
- il.dispose();
-
+ return il;
}
}
// ino.end
diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/BoolLiteral.java b/src/de/dhbwstuttgart/syntaxtree/statement/BoolLiteral.java
index f86d0e7e..fe740ae9 100755
--- a/src/de/dhbwstuttgart/syntaxtree/statement/BoolLiteral.java
+++ b/src/de/dhbwstuttgart/syntaxtree/statement/BoolLiteral.java
@@ -1,134 +1,146 @@
-// ino.module.BoolLiteral.8626.package
-package de.dhbwstuttgart.syntaxtree.statement;
-// ino.end
-// ino.module.BoolLiteral.8626.import
-import java.util.Hashtable;
-
-import org.apache.bcel.generic.ClassGen;
-
-import de.dhbwstuttgart.typeinference.Menge;
-import de.dhbwstuttgart.logger.Logger;
-import de.dhbwstuttgart.myexception.CTypeReconstructionException;
-import de.dhbwstuttgart.myexception.JVMCodeException;
-import de.dhbwstuttgart.syntaxtree.Class;
-import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
-import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar;
-import de.dhbwstuttgart.syntaxtree.type.RefType;
-import de.dhbwstuttgart.syntaxtree.type.Type;
-import de.dhbwstuttgart.typeinference.ConstraintsSet;
-import de.dhbwstuttgart.typeinference.JavaCodeResult;
-import de.dhbwstuttgart.typeinference.ResultSet;
-import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
-import de.dhbwstuttgart.typeinference.unify.CSubstitutionSet;
-
-
-
-
-// ino.class.BoolLiteral.25089.declaration
-public class BoolLiteral extends Literal
-// ino.end
-// ino.class.BoolLiteral.25089.body
-{
- @Override
- public void genByteCode(ClassGen _cg) {
- // TODO Auto-generated method stub
-
- }
-
-
-
- // ino.attribute.Bool.25093.declaration
- private boolean Bool;
- // ino.end
- // ino.attribute.parserlog.25096.declaration
- protected static Logger parserlog = Logger.getLogger("parser");
- // ino.end
-
-
- // ino.method.BoolLiteral.25099.definition
- public BoolLiteral()
- // ino.end
- // ino.method.BoolLiteral.25099.body
- {
- super(-1,-1);
- // #JB# 20.04.2005
- // ###########################################################
- this.setType(new RefType("Boolean",this,this.getOffset()));
- //this.setType(new Type("boolean"));
- // ###########################################################
- }
- // ino.end
-
-
- /*
- // ino.method.sc_check.25102.definition
- public void sc_check(Menge classname, Hashtable ch, Hashtable bh, boolean ext, Hashtable parach,Hashtable parabh)
- // ino.end
- // ino.method.sc_check.25102.body
- {
- if(ext)
- {
- parserlog.debug(" ---BoolLiteral---");
- }
- }
- // ino.end
- */
-
-
- // ino.method.set_Bool.25105.definition
- public void set_Bool(boolean b)
- // ino.end
- // ino.method.set_Bool.25105.body
- {
- this.Bool = b;
- }
- // ino.end
-
-
-
- // ino.method.get_Name.25108.definition
- public String get_Name()
- // ino.end
- // ino.method.get_Name.25108.body
- {
- return null;
- }
- // ino.end
-
-
-
-
-
- @Override
- public ConstraintsSet TYPEExpr(TypeAssumptions assumptions) {
- this.type = assumptions.checkType(new RefType("java.lang.Boolean",this,-1), this);
- return new ConstraintsSet();
- }
-
- @Override
- public JavaCodeResult printJavaCode(ResultSet resultSet) {
- if(Bool)return new JavaCodeResult("true");
- return new JavaCodeResult("false");
- }
-
-
-
- @Override
- public Menge getChildren() {
- Menge ret = new Menge();
- return ret;
- }
-
-
-
- @Override
- public void wandleRefTypeAttributes2GenericAttributes(
- Menge paralist,
- Menge genericMethodParameters) {
- // TODO Auto-generated method stub
-
- }
-
-
-}
-// ino.end
+// ino.module.BoolLiteral.8626.package
+package de.dhbwstuttgart.syntaxtree.statement;
+// ino.end
+// 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 de.dhbwstuttgart.typeinference.Menge;
+import de.dhbwstuttgart.logger.Logger;
+import de.dhbwstuttgart.myexception.CTypeReconstructionException;
+import de.dhbwstuttgart.myexception.JVMCodeException;
+import de.dhbwstuttgart.syntaxtree.Class;
+import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
+import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar;
+import de.dhbwstuttgart.syntaxtree.type.RefType;
+import de.dhbwstuttgart.syntaxtree.type.Type;
+import de.dhbwstuttgart.typeinference.ConstraintsSet;
+import de.dhbwstuttgart.typeinference.JavaCodeResult;
+import de.dhbwstuttgart.typeinference.ResultSet;
+import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
+import de.dhbwstuttgart.typeinference.unify.CSubstitutionSet;
+
+
+
+
+// ino.class.BoolLiteral.25089.declaration
+public class BoolLiteral extends Literal
+// ino.end
+// ino.class.BoolLiteral.25089.body
+{
+
+
+
+
+ // ino.attribute.Bool.25093.declaration
+ private boolean Bool;
+ // ino.end
+ // ino.attribute.parserlog.25096.declaration
+ protected static Logger parserlog = Logger.getLogger("parser");
+ // ino.end
+
+
+ // ino.method.BoolLiteral.25099.definition
+ public BoolLiteral()
+ // ino.end
+ // ino.method.BoolLiteral.25099.body
+ {
+ super(-1,-1);
+ // #JB# 20.04.2005
+ // ###########################################################
+ this.setType(new RefType("Boolean",this,this.getOffset()));
+ //this.setType(new Type("boolean"));
+ // ###########################################################
+ }
+ // ino.end
+
+
+ /*
+ // ino.method.sc_check.25102.definition
+ public void sc_check(Menge classname, Hashtable ch, Hashtable bh, boolean ext, Hashtable parach,Hashtable parabh)
+ // ino.end
+ // ino.method.sc_check.25102.body
+ {
+ if(ext)
+ {
+ parserlog.debug(" ---BoolLiteral---");
+ }
+ }
+ // ino.end
+ */
+
+
+ // ino.method.set_Bool.25105.definition
+ public void set_Bool(boolean b)
+ // ino.end
+ // ino.method.set_Bool.25105.body
+ {
+ this.Bool = b;
+ }
+ // ino.end
+
+
+
+ // ino.method.get_Name.25108.definition
+ public String get_Name()
+ // ino.end
+ // ino.method.get_Name.25108.body
+ {
+ return null;
+ }
+ // ino.end
+
+
+
+
+
+ @Override
+ public ConstraintsSet TYPEExpr(TypeAssumptions assumptions) {
+ this.type = assumptions.checkType(new RefType("java.lang.Boolean",this,-1), this);
+ return new ConstraintsSet();
+ }
+
+ @Override
+ public JavaCodeResult printJavaCode(ResultSet resultSet) {
+ if(Bool)return new JavaCodeResult("true");
+ return new JavaCodeResult("false");
+ }
+
+
+
+ @Override
+ public Menge getChildren() {
+ Menge ret = new Menge();
+ return ret;
+ }
+
+
+
+ @Override
+ public void wandleRefTypeAttributes2GenericAttributes(
+ Menge paralist,
+ Menge genericMethodParameters) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public InstructionList genByteCode(ClassGen cg) {
+ InstructionFactory _factory = new InstructionFactory(cg, cg.getConstantPool());
+ InstructionList il = new InstructionList();
+
+ if (Bool == true){
+ il.append(_factory.ICONST_1);
+ }else {
+ il.append(_factory.ICONST_0);
+ }
+
+
+ return il;
+ }
+
+}
+// ino.end
diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/CharLiteral.java b/src/de/dhbwstuttgart/syntaxtree/statement/CharLiteral.java
index a47853f2..33871d6f 100755
--- a/src/de/dhbwstuttgart/syntaxtree/statement/CharLiteral.java
+++ b/src/de/dhbwstuttgart/syntaxtree/statement/CharLiteral.java
@@ -4,7 +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 de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.logger.Logger;
@@ -111,10 +114,19 @@ public class CharLiteral extends Literal
}
+ //Char-Getter fuer genByteCode
+ public char get_Char()
+ // ino.end
+ // ino.method.get_Int.25463.body
+ {
+ return Char;
+ }
@Override
- public void genByteCode(ClassGen _cg) {
- // TODO Auto-generated method stub
-
+ public InstructionList genByteCode(ClassGen cg) {
+ InstructionFactory _factory = new InstructionFactory(cg, cg.getConstantPool());
+ InstructionList il = new InstructionList();
+ il.append(new BIPUSH((byte) get_Char()));
+ return il;
}
}
// ino.end
diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/DoubleLiteral.java b/src/de/dhbwstuttgart/syntaxtree/statement/DoubleLiteral.java
index 71bbad6c..3c8f8ee7 100755
--- a/src/de/dhbwstuttgart/syntaxtree/statement/DoubleLiteral.java
+++ b/src/de/dhbwstuttgart/syntaxtree/statement/DoubleLiteral.java
@@ -4,7 +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 de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.logger.Logger;
@@ -128,10 +134,26 @@ public JavaCodeResult printJavaCode(ResultSet resultSet) {
return ret;
}
+ //alter Double-Versuch vermutlich inkorrekt
+ /*@Override
+ public InstructionList genByteCode(ClassGen cg) {
+ InstructionFactory _factory = new InstructionFactory(cg, cg.getConstantPool());
+ InstructionList il = new InstructionList();
+ il.append(new BIPUSH(new Double(get_Double()).byteValue()));
+ return il;
+ }*/
+
@Override
- public void genByteCode(ClassGen _cg) {
- // TODO Auto-generated method stub
+ public InstructionList genByteCode(ClassGen cg) {
+ ConstantPoolGen cp = cg.getConstantPool();
+ //InstructionFactory _factory = new InstructionFactory(cg, cp);
+ InstructionList il = new InstructionList();
+ cp.addDouble(get_Double());
+ il.append(new LDC2_W(cp.getSize()-1));
+ return il;
+
}
+
}
// ino.end
diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/Expr.java b/src/de/dhbwstuttgart/syntaxtree/statement/Expr.java
index e62b9c53..f625c9ed 100755
--- a/src/de/dhbwstuttgart/syntaxtree/statement/Expr.java
+++ b/src/de/dhbwstuttgart/syntaxtree/statement/Expr.java
@@ -4,8 +4,11 @@ package de.dhbwstuttgart.syntaxtree.statement;
// ino.module.Expr.8630.import
import java.util.Hashtable;
import java.util.Iterator;
-import de.dhbwstuttgart.typeinference.Menge;
+import org.apache.bcel.generic.ClassGen;
+import org.apache.bcel.generic.InstructionList;
+
+import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.myexception.CTypeReconstructionException;
import de.dhbwstuttgart.myexception.SCStatementException;
import de.dhbwstuttgart.syntaxtree.Class;
@@ -109,5 +112,7 @@ public abstract class Expr extends ExprStmt
public ConstraintsSet TYPEStmt(TypeAssumptions assumptions){
throw new NotImplementedException(); //wird die TYPEStmt-Methode innerhalb einer Expr aufgerufen, dann ist etwas schief gelaufen.
}
+
+ public abstract InstructionList genByteCode(ClassGen _cg);
}
// ino.end
diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/FloatLiteral.java b/src/de/dhbwstuttgart/syntaxtree/statement/FloatLiteral.java
index bcd087b7..bdfd0149 100755
--- a/src/de/dhbwstuttgart/syntaxtree/statement/FloatLiteral.java
+++ b/src/de/dhbwstuttgart/syntaxtree/statement/FloatLiteral.java
@@ -5,6 +5,10 @@ package de.dhbwstuttgart.syntaxtree.statement;
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 de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.logger.Logger;
@@ -128,9 +132,14 @@ public JavaCodeResult printJavaCode(ResultSet resultSet) {
}
@Override
- public void genByteCode(ClassGen _cg) {
- // TODO Auto-generated method stub
+ public InstructionList genByteCode(ClassGen cg) {
+ ConstantPoolGen cp = cg.getConstantPool();
+ InstructionList il = new InstructionList();
+ cp.addFloat(get_Float());
+ il.append(new LDC(cp.getSize()-1));
+ return il;
+
}
}
// ino.end
diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/IntLiteral.java b/src/de/dhbwstuttgart/syntaxtree/statement/IntLiteral.java
index b56d253f..9c37c19a 100755
--- a/src/de/dhbwstuttgart/syntaxtree/statement/IntLiteral.java
+++ b/src/de/dhbwstuttgart/syntaxtree/statement/IntLiteral.java
@@ -4,7 +4,10 @@ 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.InstructionFactory;
+import org.apache.bcel.generic.InstructionList;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.logger.Logger;
@@ -131,9 +134,11 @@ public class IntLiteral extends Literal
}
@Override
- public void genByteCode(ClassGen _cg) {
- // TODO Auto-generated method stub
-
+ public InstructionList genByteCode(ClassGen cg) {
+ InstructionFactory _factory = new InstructionFactory(cg, cg.getConstantPool());
+ InstructionList il = new InstructionList();
+ il.append(new BIPUSH(new Integer(get_Int()).byteValue()));
+ return il;
}
}
// ino.end
diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/LambdaExpression.java b/src/de/dhbwstuttgart/syntaxtree/statement/LambdaExpression.java
index fddcbed8..62c3c761 100755
--- a/src/de/dhbwstuttgart/syntaxtree/statement/LambdaExpression.java
+++ b/src/de/dhbwstuttgart/syntaxtree/statement/LambdaExpression.java
@@ -2,7 +2,13 @@ package de.dhbwstuttgart.syntaxtree.statement;
import java.util.Hashtable;
+import org.apache.bcel.classfile.ConstantPool;
+import org.apache.bcel.generic.BIPUSH;
import org.apache.bcel.generic.ClassGen;
+import org.apache.bcel.generic.ConstantPoolGen;
+import org.apache.bcel.generic.InstructionFactory;
+import org.apache.bcel.generic.InstructionList;
+import org.apache.bcel.generic.INVOKEDYNAMIC;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.myexception.CTypeReconstructionException;
@@ -208,9 +214,24 @@ public class LambdaExpression extends Expr{
}
@Override
- public void genByteCode(ClassGen _cg) {
- // TODO Auto-generated method stub
+ public InstructionList genByteCode(ClassGen cg) {
+ ConstantPoolGen cp = cg.getConstantPool();
+ InstructionList il = new InstructionList();
+ /*
+ * Bytecode:
+ * 0: invokedynamic #2, 0 //#2 führt zu einem InvokeDynamic im KP - wildes Referenzieren
+ * 5: astore_1 //Speichert wahrscheinlich den String meiner TestEXPR
+ * 6: return
+ */
+ //---Variante 1 mit opcode----
+ short opcode = 186;//opcode - was genau ist das?
+ il.append(new INVOKEDYNAMIC(opcode, 0));//Invokedynamic lässt sich bei mir weder automatisch noch manuell importieren
+
+ //---Variante 2 mit Konstantenpool-Referenz---
+ //int cpSize = cp.getSize()-1;//Vermutlich ist die benötigte Referenz das aktuellste Element?
+ //il.append(new INVOKEDYNAMIC((short) cpSize, 0));
+ return il;
}
}
diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/LocalVarDecl.java b/src/de/dhbwstuttgart/syntaxtree/statement/LocalVarDecl.java
index 494bffd5..eddc29cf 100755
--- a/src/de/dhbwstuttgart/syntaxtree/statement/LocalVarDecl.java
+++ b/src/de/dhbwstuttgart/syntaxtree/statement/LocalVarDecl.java
@@ -6,6 +6,7 @@ import java.util.Enumeration;
import java.util.Hashtable;
import org.apache.bcel.generic.ClassGen;
+import org.apache.bcel.generic.InstructionList;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.logger.Logger;
@@ -427,9 +428,9 @@ public class LocalVarDecl extends Statement implements TypeInsertable
}
@Override
- public void genByteCode(ClassGen _cg) {
+ public InstructionList genByteCode(ClassGen _cg) {
// TODO Auto-generated method stub
-
+ return new InstructionList();
}
}
// ino.end
diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/LongLiteral.java b/src/de/dhbwstuttgart/syntaxtree/statement/LongLiteral.java
index 818f5b0e..e41d494f 100755
--- a/src/de/dhbwstuttgart/syntaxtree/statement/LongLiteral.java
+++ b/src/de/dhbwstuttgart/syntaxtree/statement/LongLiteral.java
@@ -5,6 +5,9 @@ package de.dhbwstuttgart.syntaxtree.statement;
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 de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.logger.Logger;
@@ -125,9 +128,15 @@ public JavaCodeResult printJavaCode(ResultSet resultSet) {
}
@Override
- public void genByteCode(ClassGen _cg) {
- // TODO Auto-generated method stub
+ public InstructionList genByteCode(ClassGen cg) {
+ ConstantPoolGen cp = cg.getConstantPool();
+ //InstructionFactory _factory = new InstructionFactory(cg, cp);
+ InstructionList il = new InstructionList();
+ cp.addLong(get_Long());
+ il.append(new LDC2_W(cp.getSize()-1));
+ return il;
+
}
}
// ino.end
diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/MethodCall.java b/src/de/dhbwstuttgart/syntaxtree/statement/MethodCall.java
index e1b03479..45f2716b 100755
--- a/src/de/dhbwstuttgart/syntaxtree/statement/MethodCall.java
+++ b/src/de/dhbwstuttgart/syntaxtree/statement/MethodCall.java
@@ -5,6 +5,7 @@ package de.dhbwstuttgart.syntaxtree.statement;
import java.util.Hashtable;
import org.apache.bcel.generic.ClassGen;
+import org.apache.bcel.generic.InstructionList;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.logger.Logger;
@@ -304,7 +305,7 @@ public class MethodCall extends Expr
}
@Override
- public void genByteCode(ClassGen _cg) {
+ public InstructionList genByteCode(ClassGen _cg) {
// TODO Auto-generated method stub
}
diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/NewArray.java b/src/de/dhbwstuttgart/syntaxtree/statement/NewArray.java
index 6c60bc9c..1461c248 100755
--- a/src/de/dhbwstuttgart/syntaxtree/statement/NewArray.java
+++ b/src/de/dhbwstuttgart/syntaxtree/statement/NewArray.java
@@ -1,153 +1,162 @@
-// ino.module.NewArray.8641.package
-package de.dhbwstuttgart.syntaxtree.statement;
-// ino.end
-// ino.module.NewArray.8641.import
-import java.util.Hashtable;
-
-import org.apache.bcel.generic.ClassGen;
-
-import de.dhbwstuttgart.typeinference.Menge;
-import de.dhbwstuttgart.logger.Logger;
-import de.dhbwstuttgart.myexception.CTypeReconstructionException;
-import de.dhbwstuttgart.myexception.JVMCodeException;
-import de.dhbwstuttgart.syntaxtree.Class;
-import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
-import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar;
-import de.dhbwstuttgart.syntaxtree.type.Type;
-import de.dhbwstuttgart.typeinference.ConstraintsSet;
-import de.dhbwstuttgart.typeinference.JavaCodeResult;
-import de.dhbwstuttgart.typeinference.ResultSet;
-import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
-import de.dhbwstuttgart.typeinference.unify.CSubstitutionSet;
-
-
-
-
-// ino.class.NewArray.25787.declaration
-public class NewArray extends Expr
-// ino.end
-// ino.class.NewArray.25787.body
-{
- // ino.method.NewArray.25791.definition
- public NewArray(int offset,int variableLength)
- // ino.end
- // ino.method.NewArray.25791.body
- {
- super(offset,variableLength);
- }
- // ino.end
- // ino.attribute.type.25794.declaration
- private Type type;
- // ino.end
- // ino.attribute.expr.25797.declaration
- public Menge expr = new Menge();
- // ino.end
- // ino.attribute.parserlog.25800.declaration
- protected static Logger parserlog = Logger.getLogger("parser");
- // ino.end
-
-
- // ino.method.getType.25803.defdescription type=javadoc
- /**
- * Author: J�rg B�uerle
- * @return Returns the type.
- */
- // ino.end
- // ino.method.getType.25803.definition
- public Type getType()
- // ino.end
- // ino.method.getType.25803.body
- {
- return type;
- }
- // ino.end
-
- // ino.method.setType.25806.defdescription type=javadoc
- /**
- * Author: J�rg B�uerle
- * @param type The type to set.
- */
- // ino.end
- // ino.method.setType.25806.definition
- public void setType(Type type)
- // ino.end
- // ino.method.setType.25806.body
- {
- this.type = type;
- }
- // ino.end
-
- // ino.method.get_Name.25809.definition
- public String get_Name()
- // ino.end
- // ino.method.get_Name.25809.body
- {
- return null;
- }
- // ino.end
-
- /*
- // ino.method.sc_check.25812.definition
- public void sc_check(Menge classname, Hashtable bh, Hashtable ch,boolean ext, Hashtable parach, Hashtable parabh)
- // ino.end
- // ino.method.sc_check.25812.body
- {
- if(ext)
- parserlog.debug(" ---NewArray---");
- }
- // ino.end
- */
-
- // ino.method.get_codegen_Array_Type.25815.definition
- public int get_codegen_Array_Type()
- throws JVMCodeException
- // ino.end
- // ino.method.get_codegen_Array_Type.25815.body
- {
- if(this.getType().equals("boolean")) return 4;
- else if(this.getType().equals("char")) return 5;
- else if(this.getType().equals("float")) return 6;
- else if(this.getType().equals("double")) return 7;
- else if(this.getType().equals("byte")) return 8;
- else if(this.getType().equals("short")) return 9;
- else if(this.getType().equals("int")) return 10;
- else if(this.getType().equals("long")) return 11;
- else throw new JVMCodeException("JVMCodeException: NewArray: int get_codegen_Array_Type()");
- }
- // ino.end
-
- // ino.method.wandleRefTypeAttributes2GenericAttributes.25827.definition
- public void wandleRefTypeAttributes2GenericAttributes(Menge paralist, Menge genericMethodParameters)
- // ino.end
- // ino.method.wandleRefTypeAttributes2GenericAttributes.25827.body
- {
- }
- // ino.end
-
- @Override
- public ConstraintsSet TYPEExpr(TypeAssumptions assumptions) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
-public JavaCodeResult printJavaCode(ResultSet resultSet) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public Menge getChildren() {
- Menge ret = new Menge();
- ret.addAll(this.expr);
- return ret;
- }
-
- @Override
- public void genByteCode(ClassGen _cg) {
- // TODO Auto-generated method stub
-
- }
-
-}
-// ino.end
+// ino.module.NewArray.8641.package
+package de.dhbwstuttgart.syntaxtree.statement;
+// ino.end
+// 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 de.dhbwstuttgart.typeinference.Menge;
+import de.dhbwstuttgart.logger.Logger;
+import de.dhbwstuttgart.myexception.CTypeReconstructionException;
+import de.dhbwstuttgart.myexception.JVMCodeException;
+import de.dhbwstuttgart.syntaxtree.Class;
+import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
+import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar;
+import de.dhbwstuttgart.syntaxtree.type.Type;
+import de.dhbwstuttgart.typeinference.ConstraintsSet;
+import de.dhbwstuttgart.typeinference.JavaCodeResult;
+import de.dhbwstuttgart.typeinference.ResultSet;
+import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
+import de.dhbwstuttgart.typeinference.unify.CSubstitutionSet;
+
+
+
+
+// ino.class.NewArray.25787.declaration
+public class NewArray extends Expr
+// ino.end
+// ino.class.NewArray.25787.body
+{
+ // ino.method.NewArray.25791.definition
+ public NewArray(int offset,int variableLength)
+ // ino.end
+ // ino.method.NewArray.25791.body
+ {
+ super(offset,variableLength);
+ }
+ // ino.end
+ // ino.attribute.type.25794.declaration
+ private Type type;
+ // ino.end
+ // ino.attribute.expr.25797.declaration
+ public Menge expr = new Menge();
+ // ino.end
+ // ino.attribute.parserlog.25800.declaration
+ protected static Logger parserlog = Logger.getLogger("parser");
+ // ino.end
+
+
+ // ino.method.getType.25803.defdescription type=javadoc
+ /**
+ * Author: J�rg B�uerle
+ * @return Returns the type.
+ */
+ // ino.end
+ // ino.method.getType.25803.definition
+ public Type getType()
+ // ino.end
+ // ino.method.getType.25803.body
+ {
+ return type;
+ }
+ // ino.end
+
+ // ino.method.setType.25806.defdescription type=javadoc
+ /**
+ * Author: J�rg B�uerle
+ * @param type The type to set.
+ */
+ // ino.end
+ // ino.method.setType.25806.definition
+ public void setType(Type type)
+ // ino.end
+ // ino.method.setType.25806.body
+ {
+ this.type = type;
+ }
+ // ino.end
+
+ // ino.method.get_Name.25809.definition
+ public String get_Name()
+ // ino.end
+ // ino.method.get_Name.25809.body
+ {
+ return null;
+ }
+ // ino.end
+
+ /*
+ // ino.method.sc_check.25812.definition
+ public void sc_check(Menge classname, Hashtable bh, Hashtable ch,boolean ext, Hashtable parach, Hashtable parabh)
+ // ino.end
+ // ino.method.sc_check.25812.body
+ {
+ if(ext)
+ parserlog.debug(" ---NewArray---");
+ }
+ // ino.end
+ */
+
+ // ino.method.get_codegen_Array_Type.25815.definition
+ public int get_codegen_Array_Type()
+ throws JVMCodeException
+ // ino.end
+ // ino.method.get_codegen_Array_Type.25815.body
+ {
+ if(this.getType().equals("boolean")) return 4;
+ else if(this.getType().equals("char")) return 5;
+ else if(this.getType().equals("float")) return 6;
+ else if(this.getType().equals("double")) return 7;
+ else if(this.getType().equals("byte")) return 8;
+ else if(this.getType().equals("short")) return 9;
+ else if(this.getType().equals("int")) return 10;
+ else if(this.getType().equals("long")) return 11;
+ else throw new JVMCodeException("JVMCodeException: NewArray: int get_codegen_Array_Type()");
+ }
+ // ino.end
+
+ // ino.method.wandleRefTypeAttributes2GenericAttributes.25827.definition
+ public void wandleRefTypeAttributes2GenericAttributes(Menge paralist, Menge genericMethodParameters)
+ // ino.end
+ // ino.method.wandleRefTypeAttributes2GenericAttributes.25827.body
+ {
+ }
+ // ino.end
+
+ @Override
+ public ConstraintsSet TYPEExpr(TypeAssumptions assumptions) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+public JavaCodeResult printJavaCode(ResultSet resultSet) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Menge getChildren() {
+ Menge ret = new Menge();
+ ret.addAll(this.expr);
+ return ret;
+ }
+
+ @Override
+ public InstructionList genByteCode(ClassGen cg) {
+
+ InstructionFactory _factory = new InstructionFactory(cg, cg.getConstantPool());
+ InstructionList il = new InstructionList();
+
+ il.append(expr.elementAt(0).genByteCode(cg));
+ il.append(_factory.createNewArray(org.apache.bcel.generic.Type.getType(getTypeName()), (short)1));
+
+
+ return il;
+ }
+
+}
+// ino.end
diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/Null.java b/src/de/dhbwstuttgart/syntaxtree/statement/Null.java
index 5cac43a3..8eee26ed 100755
--- a/src/de/dhbwstuttgart/syntaxtree/statement/Null.java
+++ b/src/de/dhbwstuttgart/syntaxtree/statement/Null.java
@@ -5,6 +5,8 @@ package de.dhbwstuttgart.syntaxtree.statement;
import java.util.Hashtable;
import org.apache.bcel.generic.ClassGen;
+import org.apache.bcel.generic.InstructionFactory;
+import org.apache.bcel.generic.InstructionList;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.logger.Logger;
@@ -91,10 +93,15 @@ public class Null extends Literal
}
@Override
- public void genByteCode(ClassGen _cg) {
- // TODO Auto-generated method stub
+ public InstructionList genByteCode(ClassGen cg) {
+ InstructionFactory _factory = new InstructionFactory(cg, cg.getConstantPool());
+ InstructionList il = new InstructionList();
+ il.append(_factory.ACONST_NULL);
+
+
+ return il;
}
-
+
}
// ino.end
diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/PostIncExpr.java b/src/de/dhbwstuttgart/syntaxtree/statement/PostIncExpr.java
index ac16826f..6659a526 100755
--- a/src/de/dhbwstuttgart/syntaxtree/statement/PostIncExpr.java
+++ b/src/de/dhbwstuttgart/syntaxtree/statement/PostIncExpr.java
@@ -5,7 +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 de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.logger.Logger;
@@ -95,10 +99,17 @@ public JavaCodeResult printJavaCode(ResultSet resultSet) {
return ret;
}
+ public static int counterPostInc = 0;
@Override
- public void genByteCode(ClassGen _cg) {
- // TODO Auto-generated method stub
-
+ public InstructionList genByteCode(ClassGen cg) {
+ InstructionFactory _factory = new InstructionFactory(cg, cg.getConstantPool());
+ InstructionList il = new InstructionList();
+ counterPostInc++;
+ il.append(new IINC(counterPostInc,1));
+ //Tests aufgrund fehlener TypInferenz-Funktionalität nicht möglich
+ //Vermutlich muss der Counter noch angepasst werden, da nicht incrementierende Variablen nicht mitgezählt werden, und zu falschen aufrufen führen
+ //Gibt es einen Compiler-internen Variablenindex, der den Counter effektiver ersetzen könnte
+ return il;
}
}
diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/Return.java b/src/de/dhbwstuttgart/syntaxtree/statement/Return.java
index 2246614a..ad3907e0 100755
--- a/src/de/dhbwstuttgart/syntaxtree/statement/Return.java
+++ b/src/de/dhbwstuttgart/syntaxtree/statement/Return.java
@@ -4,6 +4,9 @@ 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 de.dhbwstuttgart.typeinference.Menge;
@@ -130,9 +133,17 @@ public class Return extends Statement
}
@Override
- public void genByteCode(ClassGen _cg) {
- // TODO Auto-generated method stub
+ public InstructionList genByteCode(ClassGen cg) {
+ InstructionList il = retexpr.genByteCode(cg);
+ InstructionFactory _factory = new InstructionFactory(cg, cg.getConstantPool());
+
+ //Stimmt das VOID hier eigentlich? --> Wie wäre es mit getReturnType o.ä.? + evtl. von Type zu bcelType casten?
+ il.append(_factory.createReturn(org.apache.bcel.generic.Type.VOID));
+
+
+
+ return il;
}
}
// ino.end
diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/Statement.java b/src/de/dhbwstuttgart/syntaxtree/statement/Statement.java
index 70d3e540..eb4431b2 100755
--- a/src/de/dhbwstuttgart/syntaxtree/statement/Statement.java
+++ b/src/de/dhbwstuttgart/syntaxtree/statement/Statement.java
@@ -129,7 +129,7 @@ public abstract class Statement extends SyntaxTreeNode implements IItemWithOffse
}
- public abstract void genByteCode(ClassGen _cg);
+ public abstract InstructionList genByteCode(ClassGen _cg);
}
diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/StringLiteral.java b/src/de/dhbwstuttgart/syntaxtree/statement/StringLiteral.java
index f1a87e3b..e398d088 100755
--- a/src/de/dhbwstuttgart/syntaxtree/statement/StringLiteral.java
+++ b/src/de/dhbwstuttgart/syntaxtree/statement/StringLiteral.java
@@ -1,11 +1,21 @@
package de.dhbwstuttgart.syntaxtree.statement;
import de.dhbwstuttgart.typeinference.Menge;
+
+
+
+
+
// ino.end
// ino.module.StringLiteral.8653.import
import java.util.Hashtable;
+import org.apache.bcel.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 de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.logger.Logger;
@@ -102,11 +112,29 @@ public class StringLiteral extends Literal
return "\""+this.string+"\"";
}
+
+ public String get_String()
+ // ino.end
+ // ino.method.get_Name.26246.body
+ {
+ return string;
+ }
+ //public static int counterString = 0;
@Override
- public void genByteCode(ClassGen _cg) {
- // TODO Auto-generated method stub
-
+ public InstructionList genByteCode(ClassGen cg) {
+ ConstantPoolGen cp = cg.getConstantPool();
+ InstructionFactory _factory = new InstructionFactory(cg, cp);
+ InstructionList il = new InstructionList();
+ //counterString++;
+ //il.append(_factory.ASTORE_1, _factory.createNew(string));
+ cp.addString(get_String());
+ il.append(new LDC(cp.getSize()-1));
+ return il;
+
}
+
+
+
}
// ino.end
diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/SuperCall.java b/src/de/dhbwstuttgart/syntaxtree/statement/SuperCall.java
index a66c2042..eea3f491 100644
--- a/src/de/dhbwstuttgart/syntaxtree/statement/SuperCall.java
+++ b/src/de/dhbwstuttgart/syntaxtree/statement/SuperCall.java
@@ -3,8 +3,14 @@ package de.dhbwstuttgart.syntaxtree.statement;
// ino.end
// ino.module.This.8654.import
import java.util.Hashtable;
-import de.dhbwstuttgart.typeinference.Menge;
+import org.apache.bcel.Constants;
+import org.apache.bcel.generic.ClassGen;
+import org.apache.bcel.generic.InstructionFactory;
+import org.apache.bcel.generic.InstructionHandle;
+import org.apache.bcel.generic.InstructionList;
+
+import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.logger.Logger;
import de.dhbwstuttgart.myexception.CTypeReconstructionException;
import de.dhbwstuttgart.myexception.JVMCodeException;
@@ -76,7 +82,22 @@ public class SuperCall extends ThisCall
@Override
public JavaCodeResult printJavaCode(ResultSet resultSet) {
- return new JavaCodeResult("super("+this.getArgumentList().printJavaCode(resultSet)+")");
+ String argList = "";
+ if(this.getArgumentList() != null)argList = this.getArgumentList().printJavaCode(resultSet).getJavaCode();
+ return new JavaCodeResult("super("+argList+")");
+ }
+
+ @Override
+ public InstructionList genByteCode(ClassGen cg) {
+ InstructionFactory _factory = new InstructionFactory(cg, cg.getConstantPool());
+ InstructionList il = new InstructionList();
+ Type superClass = this.getParentClass().getSuperClass();
+ //Instructionhandle dynamisch
+ InstructionHandle ih_0 = il.append(_factory.createLoad(org.apache.bcel.generic.Type.OBJECT, 0));
+ il.append(_factory.createInvoke(superClass.getName().toString(), "", org.apache.bcel.generic.Type.VOID, org.apache.bcel.generic.Type.NO_ARGS, Constants.INVOKESPECIAL));
+ InstructionHandle ih_4 = il.append(_factory.createReturn(org.apache.bcel.generic.Type.VOID));
+
+ return il;
}
}
diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/UnaryExpr.java b/src/de/dhbwstuttgart/syntaxtree/statement/UnaryExpr.java
index 53903512..30bd4375 100755
--- a/src/de/dhbwstuttgart/syntaxtree/statement/UnaryExpr.java
+++ b/src/de/dhbwstuttgart/syntaxtree/statement/UnaryExpr.java
@@ -37,6 +37,7 @@ public abstract class UnaryExpr extends Expr
ret.add(new RefType("Integer",this,-1));
ret.add(new RefType("Long",this,-1));
ret.add(new RefType("Double",this,-1));
+ ret.add(new RefType("Float",this,-1));
return ret ;
}
@@ -59,7 +60,9 @@ public abstract class UnaryExpr extends Expr
@Override
public ConstraintsSet TYPEStmt(TypeAssumptions assumptions) {
- return this.TYPEExpr(assumptions);
+ ConstraintsSet ret = this.TYPEExpr(assumptions);
+ this.setType(new de.dhbwstuttgart.syntaxtree.type.Void(this, -1).TYPE(assumptions, this));
+ return ret;
}
diff --git a/src/de/dhbwstuttgart/syntaxtree/type/RefType.java b/src/de/dhbwstuttgart/syntaxtree/type/RefType.java
index a4ce2738..c0875303 100755
--- a/src/de/dhbwstuttgart/syntaxtree/type/RefType.java
+++ b/src/de/dhbwstuttgart/syntaxtree/type/RefType.java
@@ -810,6 +810,10 @@ public class RefType extends ObjectType implements IMatchable
param.parserPostProcessing(this);
}
}
+
+ public org.apache.bcel.generic.Type getBytecodeType() {
+ return new org.apache.bcel.generic.ObjectType(this.getTypeName());
+ }
}
// ino.end
diff --git a/src/de/dhbwstuttgart/syntaxtree/type/Type.java b/src/de/dhbwstuttgart/syntaxtree/type/Type.java
index 7b577602..20a9b07e 100755
--- a/src/de/dhbwstuttgart/syntaxtree/type/Type.java
+++ b/src/de/dhbwstuttgart/syntaxtree/type/Type.java
@@ -304,5 +304,7 @@ public abstract class Type extends SyntaxTreeNode implements IItemWithOffset
return this;
}
+ public abstract org.apache.bcel.generic.Type getBytecodeType();
+
}
// ino.end
diff --git a/src/de/dhbwstuttgart/syntaxtree/type/Void.java b/src/de/dhbwstuttgart/syntaxtree/type/Void.java
index 773a5fe8..42c63af3 100755
--- a/src/de/dhbwstuttgart/syntaxtree/type/Void.java
+++ b/src/de/dhbwstuttgart/syntaxtree/type/Void.java
@@ -78,6 +78,11 @@ public class Void extends RefType
public Type checkTYPE(TypeAssumptions ass, SyntaxTreeNode method) {
return this;//VOID ist immer korrekt, das wird vom Parser geprüft
}
+
+ @Override
+ public org.apache.bcel.generic.Type getBytecodeType() {
+ return org.apache.bcel.generic.Type.VOID;
+ }
}
// ino.end
diff --git a/src/de/dhbwstuttgart/typeinference/assumptions/TypeAssumptions.java b/src/de/dhbwstuttgart/typeinference/assumptions/TypeAssumptions.java
index 2fea0a02..5b342445 100755
--- a/src/de/dhbwstuttgart/typeinference/assumptions/TypeAssumptions.java
+++ b/src/de/dhbwstuttgart/typeinference/assumptions/TypeAssumptions.java
@@ -424,5 +424,6 @@ public class TypeAssumptions {
return null;
}
*/
+
}
diff --git a/test/KomplexeMenge/KeineDoppeltenVerweise.java b/test/KomplexeMenge/KeineDoppeltenVerweise.java
index d7c3f431..43eea37c 100644
--- a/test/KomplexeMenge/KeineDoppeltenVerweise.java
+++ b/test/KomplexeMenge/KeineDoppeltenVerweise.java
@@ -6,6 +6,8 @@ import java.util.Vector;
import org.junit.Test;
+import de.dhbwstuttgart.typeinference.EinzelElement;
+import de.dhbwstuttgart.typeinference.KomplexeMenge;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.typeinference.OderMenge;
import de.dhbwstuttgart.typeinference.UndMenge;
@@ -25,11 +27,45 @@ class TestKlasse {
}
}
+class TestKlasseOderMenge extends OderMenge{
+ Menge set = new Menge<>();
+
+ @Override
+ public Menge extends KomplexeMenge> getSet() {
+ return set;
+ }
+
+ public void addItem(TestKlasse string) {
+ TestUndMenge toAdd = new TestKlasseUndMenge();
+ toAdd.addItem(string);
+ set.add(toAdd);
+ }
+ public void addItems(TestKlasseUndMenge undMenge) {
+ set.add(undMenge);
+ }
+}
+
+class TestKlasseUndMenge extends UndMenge{
+ Menge> set = new Menge<>();
+
+ @Override
+ public Menge extends KomplexeMenge> getSet() {
+ return set;
+ }
+ public void addItem(TestKlasse string) {
+ set.add(new EinzelElement(string));
+ }
+
+ public void addItems(KomplexeMenge oderMenge) {
+ set.add(oderMenge);
+ }
+}
+
public class KeineDoppeltenVerweise {
@Test
public void test() {
- OderMenge oM1 = new OderMenge<>();
+ OderMenge oM1 = new TestOderMenge();
OderMenge oM2 = new OderMenge<>();
UndMenge oM3 = new UndMenge<>();
oM1.addItem(new TestKlasse("Menge 1, Item 1"));
diff --git a/test/bytecode/Assign.jav b/test/bytecode/Assign.jav
new file mode 100644
index 00000000..b238192f
--- /dev/null
+++ b/test/bytecode/Assign.jav
@@ -0,0 +1,6 @@
+class Assign{
+
+void method() {a; a = 20;b; b=59;}
+
+
+}
\ No newline at end of file
diff --git a/test/bytecode/Assign.java b/test/bytecode/Assign.java
new file mode 100644
index 00000000..c027e25b
--- /dev/null
+++ b/test/bytecode/Assign.java
@@ -0,0 +1,45 @@
+package bytecode;
+
+import static org.junit.Assert.*;
+
+import java.io.File;
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.junit.Test;
+
+import plugindevelopment.TypeInsertTester;
+import de.dhbwstuttgart.core.MyCompiler;
+import de.dhbwstuttgart.core.MyCompilerAPI;
+import de.dhbwstuttgart.logger.LoggerConfiguration;
+import de.dhbwstuttgart.logger.Section;
+import de.dhbwstuttgart.parser.JavaParser.yyException;
+import de.dhbwstuttgart.typeinference.ByteCodeResult;
+import de.dhbwstuttgart.typeinference.Menge;
+import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
+import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
+
+public class Assign {
+
+ public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
+ public final static String testFile = "Assign.jav";
+ public final static String outputFile = "Assign.class";
+
+ @Test
+ public void test() {
+ LoggerConfiguration logConfig = new LoggerConfiguration().setOutput(Section.PARSER, System.out);
+ MyCompilerAPI compiler = MyCompiler.getAPI(logConfig);
+ try {
+ compiler.parse(new File(rootDirectory + testFile));
+ compiler.typeReconstruction();
+ ByteCodeResult bytecode = compiler.generateBytecode();
+ System.out.println(bytecode);
+ bytecode.getByteCode().getJavaClass().dump(new File(rootDirectory + outputFile));
+ } catch (IOException | yyException e) {
+ e.printStackTrace();
+ TestCase.fail();
+ }
+ }
+
+}
diff --git a/test/bytecode/BoolLit.jav b/test/bytecode/BoolLit.jav
new file mode 100644
index 00000000..1fa4ac31
--- /dev/null
+++ b/test/bytecode/BoolLit.jav
@@ -0,0 +1,7 @@
+class BoolLit{
+
+void method() { b; b = false; }
+
+
+
+}
\ No newline at end of file
diff --git a/test/bytecode/BoolLitTest.java b/test/bytecode/BoolLitTest.java
new file mode 100644
index 00000000..ef7b0fc3
--- /dev/null
+++ b/test/bytecode/BoolLitTest.java
@@ -0,0 +1,45 @@
+package bytecode;
+
+import static org.junit.Assert.*;
+
+import java.io.File;
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.junit.Test;
+
+import plugindevelopment.TypeInsertTester;
+import de.dhbwstuttgart.core.MyCompiler;
+import de.dhbwstuttgart.core.MyCompilerAPI;
+import de.dhbwstuttgart.logger.LoggerConfiguration;
+import de.dhbwstuttgart.logger.Section;
+import de.dhbwstuttgart.parser.JavaParser.yyException;
+import de.dhbwstuttgart.typeinference.ByteCodeResult;
+import de.dhbwstuttgart.typeinference.Menge;
+import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
+import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
+
+public class BoolLitTest {
+
+ public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
+ public final static String testFile = "BoolLit.jav";
+ public final static String outputFile = "BoolLit.class";
+
+ @Test
+ public void test() {
+ LoggerConfiguration logConfig = new LoggerConfiguration().setOutput(Section.PARSER, System.out);
+ MyCompilerAPI compiler = MyCompiler.getAPI(logConfig);
+ try {
+ compiler.parse(new File(rootDirectory + testFile));
+ compiler.typeReconstruction();
+ ByteCodeResult bytecode = compiler.generateBytecode();
+ System.out.println(bytecode);
+ bytecode.getByteCode().getJavaClass().dump(new File(rootDirectory + outputFile));
+ } catch (IOException | yyException e) {
+ e.printStackTrace();
+ TestCase.fail();
+ }
+ }
+
+}
diff --git a/test/bytecode/CharLitTest.jav b/test/bytecode/CharLitTest.jav
new file mode 100644
index 00000000..1cf78415
--- /dev/null
+++ b/test/bytecode/CharLitTest.jav
@@ -0,0 +1,7 @@
+class CharLitTest{
+
+
+void method() { c; c = 'A'; }
+
+
+}
\ No newline at end of file
diff --git a/test/bytecode/CharLitTest.java b/test/bytecode/CharLitTest.java
new file mode 100644
index 00000000..add8b515
--- /dev/null
+++ b/test/bytecode/CharLitTest.java
@@ -0,0 +1,45 @@
+package bytecode;
+
+import static org.junit.Assert.*;
+
+import java.io.File;
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.junit.Test;
+
+import plugindevelopment.TypeInsertTester;
+import de.dhbwstuttgart.core.MyCompiler;
+import de.dhbwstuttgart.core.MyCompilerAPI;
+import de.dhbwstuttgart.logger.LoggerConfiguration;
+import de.dhbwstuttgart.logger.Section;
+import de.dhbwstuttgart.parser.JavaParser.yyException;
+import de.dhbwstuttgart.typeinference.ByteCodeResult;
+import de.dhbwstuttgart.typeinference.Menge;
+import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
+import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
+
+public class CharLitTest {
+
+ public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
+ public final static String testFile = "CharLitTest.jav";
+ public final static String outputFile = "CharLitTest.class";
+
+ @Test
+ public void test() {
+ LoggerConfiguration logConfig = new LoggerConfiguration().setOutput(Section.PARSER, System.out);
+ MyCompilerAPI compiler = MyCompiler.getAPI(logConfig);
+ try {
+ compiler.parse(new File(rootDirectory + testFile));
+ compiler.typeReconstruction();
+ ByteCodeResult bytecode = compiler.generateBytecode();
+ System.out.println(bytecode);
+ bytecode.getByteCode().getJavaClass().dump(new File(rootDirectory + outputFile));
+ } catch (IOException | yyException e) {
+ e.printStackTrace();
+ TestCase.fail();
+ }
+ }
+
+}
diff --git a/test/bytecode/DoubleLiteral.jav b/test/bytecode/DoubleLiteral.jav
new file mode 100644
index 00000000..7813d262
--- /dev/null
+++ b/test/bytecode/DoubleLiteral.jav
@@ -0,0 +1,6 @@
+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
new file mode 100644
index 00000000..e9470c5f
--- /dev/null
+++ b/test/bytecode/DoubleLiteral.java
@@ -0,0 +1,45 @@
+package bytecode;
+
+import static org.junit.Assert.*;
+
+import java.io.File;
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.junit.Test;
+
+import plugindevelopment.TypeInsertTester;
+import de.dhbwstuttgart.core.MyCompiler;
+import de.dhbwstuttgart.core.MyCompilerAPI;
+import de.dhbwstuttgart.logger.LoggerConfiguration;
+import de.dhbwstuttgart.logger.Section;
+import de.dhbwstuttgart.parser.JavaParser.yyException;
+import de.dhbwstuttgart.typeinference.ByteCodeResult;
+import de.dhbwstuttgart.typeinference.Menge;
+import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
+import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
+
+public class DoubleLiteral {
+
+ public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
+ public final static String testFile = "DoubleLiteral.jav";
+ public final static String outputFile = "DoubleLiteral.class";
+
+ @Test
+ public void test() {
+ LoggerConfiguration logConfig = new LoggerConfiguration().setOutput(Section.PARSER, System.out);
+ MyCompilerAPI compiler = MyCompiler.getAPI(logConfig);
+ try {
+ compiler.parse(new File(rootDirectory + testFile));
+ compiler.typeReconstruction();
+ ByteCodeResult bytecode = compiler.generateBytecode();
+ System.out.println(bytecode);
+ bytecode.getByteCode().getJavaClass().dump(new File(rootDirectory + outputFile));
+ } catch (IOException | yyException e) {
+ e.printStackTrace();
+ TestCase.fail();
+ }
+ }
+
+}
diff --git a/test/bytecode/EmptyClass.jav b/test/bytecode/EmptyClass.jav
index 44dfecf2..381162fa 100644
--- a/test/bytecode/EmptyClass.jav
+++ b/test/bytecode/EmptyClass.jav
@@ -1,7 +1,7 @@
class EmptyClass{
-public EmptyClass(){}
-public void leckMichAmArsch(){}
+
+
}
\ No newline at end of file
diff --git a/test/bytecode/EmptyClass.java b/test/bytecode/EmptyClassTest.java
similarity index 93%
rename from test/bytecode/EmptyClass.java
rename to test/bytecode/EmptyClassTest.java
index 5ce92d79..20aa3349 100644
--- a/test/bytecode/EmptyClass.java
+++ b/test/bytecode/EmptyClassTest.java
@@ -20,11 +20,11 @@ import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
-public class EmptyClass {
+public class EmptyClassTest {
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
public final static String testFile = "EmptyClass.jav";
- public final static String outputFile = "EmptyClassTest.class";
+ public final static String outputFile = "EmptyClass.class";
@Test
public void test() {
diff --git a/test/bytecode/FloatLiteral.jav b/test/bytecode/FloatLiteral.jav
new file mode 100644
index 00000000..c0531da4
--- /dev/null
+++ b/test/bytecode/FloatLiteral.jav
@@ -0,0 +1,6 @@
+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
new file mode 100644
index 00000000..ba789535
--- /dev/null
+++ b/test/bytecode/FloatLiteral.java
@@ -0,0 +1,45 @@
+package bytecode;
+
+import static org.junit.Assert.*;
+
+import java.io.File;
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.junit.Test;
+
+import plugindevelopment.TypeInsertTester;
+import de.dhbwstuttgart.core.MyCompiler;
+import de.dhbwstuttgart.core.MyCompilerAPI;
+import de.dhbwstuttgart.logger.LoggerConfiguration;
+import de.dhbwstuttgart.logger.Section;
+import de.dhbwstuttgart.parser.JavaParser.yyException;
+import de.dhbwstuttgart.typeinference.ByteCodeResult;
+import de.dhbwstuttgart.typeinference.Menge;
+import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
+import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
+
+public class FloatLiteral {
+
+ public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
+ public final static String testFile = "FloatLiteral.jav";
+ public final static String outputFile = "FloatLiteral.class";
+
+ @Test
+ public void test() {
+ LoggerConfiguration logConfig = new LoggerConfiguration().setOutput(Section.PARSER, System.out);
+ MyCompilerAPI compiler = MyCompiler.getAPI(logConfig);
+ try {
+ compiler.parse(new File(rootDirectory + testFile));
+ compiler.typeReconstruction();
+ ByteCodeResult bytecode = compiler.generateBytecode();
+ System.out.println(bytecode);
+ bytecode.getByteCode().getJavaClass().dump(new File(rootDirectory + outputFile));
+ } catch (IOException | yyException e) {
+ e.printStackTrace();
+ TestCase.fail();
+ }
+ }
+
+}
diff --git a/test/bytecode/LambdaExpr.jav b/test/bytecode/LambdaExpr.jav
new file mode 100644
index 00000000..e5b1a122
--- /dev/null
+++ b/test/bytecode/LambdaExpr.jav
@@ -0,0 +1,8 @@
+class LambdaExpr {
+
+ void method() {
+
+ lambda; lambda = ()-> 1;
+
+ }
+}
\ No newline at end of file
diff --git a/test/bytecode/LambdaExpr.java b/test/bytecode/LambdaExpr.java
new file mode 100644
index 00000000..e0d40b6b
--- /dev/null
+++ b/test/bytecode/LambdaExpr.java
@@ -0,0 +1,45 @@
+package bytecode;
+
+import static org.junit.Assert.*;
+
+import java.io.File;
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.junit.Test;
+
+import plugindevelopment.TypeInsertTester;
+import de.dhbwstuttgart.core.MyCompiler;
+import de.dhbwstuttgart.core.MyCompilerAPI;
+import de.dhbwstuttgart.logger.LoggerConfiguration;
+import de.dhbwstuttgart.logger.Section;
+import de.dhbwstuttgart.parser.JavaParser.yyException;
+import de.dhbwstuttgart.typeinference.ByteCodeResult;
+import de.dhbwstuttgart.typeinference.Menge;
+import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
+import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
+
+public class LambdaExpr {
+
+ public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
+ public final static String testFile = "LambdaExpr.jav";
+ public final static String outputFile = "LambdaExpr.class";
+
+ @Test
+ public void test() {
+ LoggerConfiguration logConfig = new LoggerConfiguration().setOutput(Section.PARSER, System.out);
+ MyCompilerAPI compiler = MyCompiler.getAPI(logConfig);
+ try {
+ compiler.parse(new File(rootDirectory + testFile));
+ compiler.typeReconstruction();
+ ByteCodeResult bytecode = compiler.generateBytecode();
+ System.out.println(bytecode);
+ bytecode.getByteCode().getJavaClass().dump(new File(rootDirectory + outputFile));
+ } catch (IOException | yyException e) {
+ e.printStackTrace();
+ TestCase.fail();
+ }
+ }
+
+}
diff --git a/test/bytecode/LongLiteral.jav b/test/bytecode/LongLiteral.jav
new file mode 100644
index 00000000..70d57aa7
--- /dev/null
+++ b/test/bytecode/LongLiteral.jav
@@ -0,0 +1,6 @@
+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
new file mode 100644
index 00000000..5e6ca9cb
--- /dev/null
+++ b/test/bytecode/LongLiteral.java
@@ -0,0 +1,45 @@
+package bytecode;
+
+import static org.junit.Assert.*;
+
+import java.io.File;
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.junit.Test;
+
+import plugindevelopment.TypeInsertTester;
+import de.dhbwstuttgart.core.MyCompiler;
+import de.dhbwstuttgart.core.MyCompilerAPI;
+import de.dhbwstuttgart.logger.LoggerConfiguration;
+import de.dhbwstuttgart.logger.Section;
+import de.dhbwstuttgart.parser.JavaParser.yyException;
+import de.dhbwstuttgart.typeinference.ByteCodeResult;
+import de.dhbwstuttgart.typeinference.Menge;
+import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
+import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
+
+public class LongLiteral {
+
+ public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
+ public final static String testFile = "LongLiteral.jav";
+ public final static String outputFile = "LongLiteral.class";
+
+ @Test
+ public void test() {
+ LoggerConfiguration logConfig = new LoggerConfiguration().setOutput(Section.PARSER, System.out);
+ MyCompilerAPI compiler = MyCompiler.getAPI(logConfig);
+ try {
+ compiler.parse(new File(rootDirectory + testFile));
+ compiler.typeReconstruction();
+ ByteCodeResult bytecode = compiler.generateBytecode();
+ System.out.println(bytecode);
+ bytecode.getByteCode().getJavaClass().dump(new File(rootDirectory + outputFile));
+ } catch (IOException | yyException e) {
+ e.printStackTrace();
+ TestCase.fail();
+ }
+ }
+
+}
diff --git a/test/bytecode/MethodEmpty.jav b/test/bytecode/MethodEmpty.jav
new file mode 100644
index 00000000..e2c5d97a
--- /dev/null
+++ b/test/bytecode/MethodEmpty.jav
@@ -0,0 +1,7 @@
+class MethodEmpty{
+
+
+void method() { }
+
+
+}
\ No newline at end of file
diff --git a/test/bytecode/MethodEmpty.java b/test/bytecode/MethodEmpty.java
new file mode 100644
index 00000000..dbeea0a5
--- /dev/null
+++ b/test/bytecode/MethodEmpty.java
@@ -0,0 +1,45 @@
+package bytecode;
+
+import static org.junit.Assert.*;
+
+import java.io.File;
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.junit.Test;
+
+import plugindevelopment.TypeInsertTester;
+import de.dhbwstuttgart.core.MyCompiler;
+import de.dhbwstuttgart.core.MyCompilerAPI;
+import de.dhbwstuttgart.logger.LoggerConfiguration;
+import de.dhbwstuttgart.logger.Section;
+import de.dhbwstuttgart.parser.JavaParser.yyException;
+import de.dhbwstuttgart.typeinference.ByteCodeResult;
+import de.dhbwstuttgart.typeinference.Menge;
+import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
+import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
+
+public class MethodEmpty {
+
+ public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
+ public final static String testFile = "MethodEmpty.jav";
+ public final static String outputFile = "MethodEmpty.class";
+
+ @Test
+ public void test() {
+ LoggerConfiguration logConfig = new LoggerConfiguration().setOutput(Section.PARSER, System.out);
+ MyCompilerAPI compiler = MyCompiler.getAPI(logConfig);
+ try {
+ compiler.parse(new File(rootDirectory + testFile));
+ compiler.typeReconstruction();
+ ByteCodeResult bytecode = compiler.generateBytecode();
+ System.out.println(bytecode);
+ bytecode.getByteCode().getJavaClass().dump(new File(rootDirectory + outputFile));
+ } catch (IOException | yyException e) {
+ e.printStackTrace();
+ TestCase.fail();
+ }
+ }
+
+}
diff --git a/test/bytecode/MethodEmptyRetType.jav b/test/bytecode/MethodEmptyRetType.jav
new file mode 100644
index 00000000..84dbc709
--- /dev/null
+++ b/test/bytecode/MethodEmptyRetType.jav
@@ -0,0 +1,7 @@
+class MethodEmptyRetType{
+
+
+Object method() { return null; }
+
+
+}
\ No newline at end of file
diff --git a/test/bytecode/MethodEmptyRetType.java b/test/bytecode/MethodEmptyRetType.java
new file mode 100644
index 00000000..7eecbe0e
--- /dev/null
+++ b/test/bytecode/MethodEmptyRetType.java
@@ -0,0 +1,45 @@
+package bytecode;
+
+import static org.junit.Assert.*;
+
+import java.io.File;
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.junit.Test;
+
+import plugindevelopment.TypeInsertTester;
+import de.dhbwstuttgart.core.MyCompiler;
+import de.dhbwstuttgart.core.MyCompilerAPI;
+import de.dhbwstuttgart.logger.LoggerConfiguration;
+import de.dhbwstuttgart.logger.Section;
+import de.dhbwstuttgart.parser.JavaParser.yyException;
+import de.dhbwstuttgart.typeinference.ByteCodeResult;
+import de.dhbwstuttgart.typeinference.Menge;
+import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
+import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
+
+public class MethodEmptyRetType {
+
+ public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
+ public final static String testFile = "MethodEmptyRetType.jav";
+ public final static String outputFile = "MethodEmptyRetType.class";
+
+ @Test
+ public void test() {
+ LoggerConfiguration logConfig = new LoggerConfiguration().setOutput(Section.PARSER, System.out);
+ MyCompilerAPI compiler = MyCompiler.getAPI(logConfig);
+ try {
+ compiler.parse(new File(rootDirectory + testFile));
+ compiler.typeReconstruction();
+ ByteCodeResult bytecode = compiler.generateBytecode();
+ System.out.println(bytecode);
+ bytecode.getByteCode().getJavaClass().dump(new File(rootDirectory + outputFile));
+ } catch (IOException | yyException e) {
+ e.printStackTrace();
+ TestCase.fail();
+ }
+ }
+
+}
diff --git a/test/bytecode/NewArray.jav b/test/bytecode/NewArray.jav
new file mode 100644
index 00000000..ff311c25
--- /dev/null
+++ b/test/bytecode/NewArray.jav
@@ -0,0 +1,11 @@
+class NewArray{
+
+void method() {
+a;
+a = new Integer[2];
+a = {1,2};
+}
+
+
+
+}
\ No newline at end of file
diff --git a/test/bytecode/NewArrayTest.java b/test/bytecode/NewArrayTest.java
new file mode 100644
index 00000000..6a9c3853
--- /dev/null
+++ b/test/bytecode/NewArrayTest.java
@@ -0,0 +1,45 @@
+package bytecode;
+
+import static org.junit.Assert.*;
+
+import java.io.File;
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.junit.Test;
+
+import plugindevelopment.TypeInsertTester;
+import de.dhbwstuttgart.core.MyCompiler;
+import de.dhbwstuttgart.core.MyCompilerAPI;
+import de.dhbwstuttgart.logger.LoggerConfiguration;
+import de.dhbwstuttgart.logger.Section;
+import de.dhbwstuttgart.parser.JavaParser.yyException;
+import de.dhbwstuttgart.typeinference.ByteCodeResult;
+import de.dhbwstuttgart.typeinference.Menge;
+import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
+import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
+
+public class NewArrayTest {
+
+ public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
+ public final static String testFile = "NewArray.jav";
+ public final static String outputFile = "NewArray.class";
+
+ @Test
+ public void test() {
+ LoggerConfiguration logConfig = new LoggerConfiguration().setOutput(Section.PARSER, System.out);
+ MyCompilerAPI compiler = MyCompiler.getAPI(logConfig);
+ try {
+ compiler.parse(new File(rootDirectory + testFile));
+ compiler.typeReconstruction();
+ ByteCodeResult bytecode = compiler.generateBytecode();
+ System.out.println(bytecode);
+ bytecode.getByteCode().getJavaClass().dump(new File(rootDirectory + outputFile));
+ } catch (IOException | yyException e) {
+ e.printStackTrace();
+ TestCase.fail();
+ }
+ }
+
+}
diff --git a/test/bytecode/PostIncrement.jav b/test/bytecode/PostIncrement.jav
new file mode 100644
index 00000000..463546c4
--- /dev/null
+++ b/test/bytecode/PostIncrement.jav
@@ -0,0 +1,6 @@
+class PostIncrement{
+
+void method() {a; a = 20; a++;}
+
+
+}
\ No newline at end of file
diff --git a/test/bytecode/PostIncrement.java b/test/bytecode/PostIncrement.java
new file mode 100644
index 00000000..e24ee34a
--- /dev/null
+++ b/test/bytecode/PostIncrement.java
@@ -0,0 +1,45 @@
+package bytecode;
+
+import static org.junit.Assert.*;
+
+import java.io.File;
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.junit.Test;
+
+import plugindevelopment.TypeInsertTester;
+import de.dhbwstuttgart.core.MyCompiler;
+import de.dhbwstuttgart.core.MyCompilerAPI;
+import de.dhbwstuttgart.logger.LoggerConfiguration;
+import de.dhbwstuttgart.logger.Section;
+import de.dhbwstuttgart.parser.JavaParser.yyException;
+import de.dhbwstuttgart.typeinference.ByteCodeResult;
+import de.dhbwstuttgart.typeinference.Menge;
+import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
+import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
+
+public class PostIncrement {
+
+ public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
+ public final static String testFile = "PostIncrement.jav";
+ public final static String outputFile = "PostIncrement.class";
+
+ @Test
+ public void test() {
+ LoggerConfiguration logConfig = new LoggerConfiguration().setOutput(Section.PARSER, System.out);
+ MyCompilerAPI compiler = MyCompiler.getAPI(logConfig);
+ try {
+ compiler.parse(new File(rootDirectory + testFile));
+ compiler.typeReconstruction();
+ ByteCodeResult bytecode = compiler.generateBytecode();
+ System.out.println(bytecode);
+ bytecode.getByteCode().getJavaClass().dump(new File(rootDirectory + outputFile));
+ } catch (IOException | yyException e) {
+ e.printStackTrace();
+ TestCase.fail();
+ }
+ }
+
+}
diff --git a/test/bytecode/StringLitTest.jav b/test/bytecode/StringLitTest.jav
new file mode 100644
index 00000000..a063d123
--- /dev/null
+++ b/test/bytecode/StringLitTest.jav
@@ -0,0 +1,7 @@
+class StringLitTest{
+
+
+void method() { s; s = "abcdefg"; t; t ="jfowehfowh"; }
+
+
+}
\ No newline at end of file
diff --git a/test/bytecode/StringLitTest.java b/test/bytecode/StringLitTest.java
new file mode 100644
index 00000000..6032c6a1
--- /dev/null
+++ b/test/bytecode/StringLitTest.java
@@ -0,0 +1,45 @@
+package bytecode;
+
+import static org.junit.Assert.*;
+
+import java.io.File;
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.junit.Test;
+
+import plugindevelopment.TypeInsertTester;
+import de.dhbwstuttgart.core.MyCompiler;
+import de.dhbwstuttgart.core.MyCompilerAPI;
+import de.dhbwstuttgart.logger.LoggerConfiguration;
+import de.dhbwstuttgart.logger.Section;
+import de.dhbwstuttgart.parser.JavaParser.yyException;
+import de.dhbwstuttgart.typeinference.ByteCodeResult;
+import de.dhbwstuttgart.typeinference.Menge;
+import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
+import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
+
+public class StringLitTest {
+
+ public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
+ public final static String testFile = "StringLitTest.jav";
+ public final static String outputFile = "StringLitTest.class";
+
+ @Test
+ public void test() {
+ LoggerConfiguration logConfig = new LoggerConfiguration().setOutput(Section.PARSER, System.out);
+ MyCompilerAPI compiler = MyCompiler.getAPI(logConfig);
+ try {
+ compiler.parse(new File(rootDirectory + testFile));
+ compiler.typeReconstruction();
+ ByteCodeResult bytecode = compiler.generateBytecode();
+ System.out.println(bytecode);
+ bytecode.getByteCode().getJavaClass().dump(new File(rootDirectory + outputFile));
+ } catch (IOException | yyException e) {
+ e.printStackTrace();
+ TestCase.fail();
+ }
+ }
+
+}