Merge mit Bytecode
This commit is contained in:
commit
d19414c513
12
BCEL/bcelifier/IfStatement.java
Normal file
12
BCEL/bcelifier/IfStatement.java
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
package bcelifier;
|
||||||
|
|
||||||
|
class IfStatement{
|
||||||
|
Integer methode(Boolean b){
|
||||||
|
if(b){
|
||||||
|
return 1;
|
||||||
|
}else{
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
71
BCEL/bcelifier/IfStatementCreator.java
Normal file
71
BCEL/bcelifier/IfStatementCreator.java
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
package bcelifier;
|
||||||
|
|
||||||
|
import org.apache.commons.bcel6.generic.*;
|
||||||
|
|
||||||
|
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
||||||
|
import de.dhbwstuttgart.bytecode.ClassGenerator;
|
||||||
|
import de.dhbwstuttgart.bytecode.MethodGenerator;
|
||||||
|
import de.dhbwstuttgart.typeinference.TypeinferenceResults;
|
||||||
|
|
||||||
|
import org.apache.commons.bcel6.*;
|
||||||
|
import java.io.*;
|
||||||
|
|
||||||
|
public class IfStatementCreator {
|
||||||
|
private InstructionFactory _factory;
|
||||||
|
private ConstantPoolGen _cp;
|
||||||
|
private ClassGenerator _cg;
|
||||||
|
|
||||||
|
public IfStatementCreator() {
|
||||||
|
|
||||||
|
TypeinferenceResults typeinferenceResults = null;
|
||||||
|
_cg = new ClassGenerator("bcelifier.IfStatement", new RefType("java.lang.Object", null, 0), "IfStatement.java", Const.ACC_SUPER, new String[] { }, typeinferenceResults);
|
||||||
|
|
||||||
|
_cp = _cg.getConstantPool();
|
||||||
|
_factory = new InstructionFactory(_cg, _cp);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void create(OutputStream out) throws IOException {
|
||||||
|
createMethod_0();
|
||||||
|
createMethod_1();
|
||||||
|
_cg.getJavaClass().dump(out);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createMethod_0() {
|
||||||
|
InstructionList il = new InstructionList();
|
||||||
|
MethodGen method = new MethodGenerator(0, Type.VOID, new Type[] { new ObjectType("java.lang.Boolean") }, new String[] { "arg0" }, "<init>", "bcelifier.IfStatement", il, _cp);
|
||||||
|
|
||||||
|
InstructionHandle ih_0 = il.append(_factory.createLoad(Type.OBJECT, 0));
|
||||||
|
il.append(_factory.createInvoke("java.lang.Object", "<init>", Type.VOID, Type.NO_ARGS, Const.INVOKESPECIAL));
|
||||||
|
InstructionHandle ih_4 = il.append(_factory.createReturn(Type.VOID));
|
||||||
|
method.setMaxStack();
|
||||||
|
method.setMaxLocals();
|
||||||
|
_cg.addMethod(method.getMethod());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createMethod_1() {
|
||||||
|
InstructionList il = new InstructionList();
|
||||||
|
MethodGen method = new MethodGenerator(0, new ObjectType("java.lang.Integer"), new Type[] { new ObjectType("java.lang.Boolean") }, new String[] { "arg0" }, "methode", "bcelifier.IfStatement", il, _cp);
|
||||||
|
|
||||||
|
il.append(InstructionFactory.createLoad(Type.OBJECT, 1));
|
||||||
|
il.append(_factory.createInvoke("java.lang.Boolean", "booleanValue", Type.BOOLEAN, Type.NO_ARGS, Const.INVOKEVIRTUAL));
|
||||||
|
BranchInstruction ifeq_4 = InstructionFactory.createBranchInstruction(Const.IFEQ, null);
|
||||||
|
il.append(ifeq_4);
|
||||||
|
il.append(new PUSH(_cp, 1));
|
||||||
|
il.append(_factory.createInvoke("java.lang.Integer", "valueOf", new ObjectType("java.lang.Integer"), new Type[] { Type.INT }, Const.INVOKESTATIC));
|
||||||
|
il.append(InstructionFactory.createReturn(Type.OBJECT));
|
||||||
|
InstructionHandle ih_12 = il.append(new PUSH(_cp, 2));
|
||||||
|
il.append(_factory.createInvoke("java.lang.Integer", "valueOf", new ObjectType("java.lang.Integer"), new Type[] { Type.INT }, Const.INVOKESTATIC));
|
||||||
|
il.append(InstructionFactory.createReturn(Type.OBJECT));
|
||||||
|
ifeq_4.setTarget(ih_12);
|
||||||
|
method.setMaxStack();
|
||||||
|
method.setMaxLocals();
|
||||||
|
_cg.addMethod(method.getMethod());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) throws Exception {
|
||||||
|
bcelifier.IfStatementCreator creator = new bcelifier.IfStatementCreator();
|
||||||
|
creator.create(new FileOutputStream("bcelifier.IfStatement.class"));
|
||||||
|
|
||||||
|
System.out.println("bcelifier.IfStatement.class");
|
||||||
|
}
|
||||||
|
}
|
@ -24,16 +24,16 @@ public class JavaToBCEL {
|
|||||||
public JavaToBCEL(){
|
public JavaToBCEL(){
|
||||||
try {
|
try {
|
||||||
//new BCELifier(new ClassParser(rootDirectory+"Lambda1.class").parse(), new FileOutputStream(new File(rootDirectory+"Lambda1Creator.java"))).start();
|
//new BCELifier(new ClassParser(rootDirectory+"Lambda1.class").parse(), new FileOutputStream(new File(rootDirectory+"Lambda1Creator.java"))).start();
|
||||||
new BCELifier(new ClassParser(rootDirectory+"This.class").parse(), new FileOutputStream(new File(rootDirectory+"ThisCreator.java"))).start();
|
//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+"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+"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+"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();
|
//new BCELifier(new ClassParser(rootDirectory+"Null.class").parse(), new FileOutputStream(new File(rootDirectory+"NullCreator.java"))).start();
|
||||||
new BCELifier(new ClassParser(rootDirectory+"LocalVarAccess.class").parse(), new FileOutputStream(new File(rootDirectory+"LocalVarAccessCreator.java"))).start();
|
//new BCELifier(new ClassParser(rootDirectory+"LocalVarAccess.class").parse(), new FileOutputStream(new File(rootDirectory+"LocalVarAccessCreator.java"))).start();
|
||||||
new BCELifier(new ClassParser(rootDirectory+"Wildcard.class").parse(), new FileOutputStream(new File(rootDirectory+"WildcardCreator.java"))).start();
|
//new BCELifier(new ClassParser(rootDirectory+"Wildcard.class").parse(), new FileOutputStream(new File(rootDirectory+"WildcardCreator.java"))).start();
|
||||||
new BCELifier(new ClassParser(rootDirectory+"BooleanValue.class").parse(), new FileOutputStream(new File(rootDirectory+"BooleanValueCreator.java"))).start();
|
//new BCELifier(new ClassParser(rootDirectory+"BooleanValue.class").parse(), new FileOutputStream(new File(rootDirectory+"BooleanValueCreator.java"))).start();
|
||||||
new BCELifier(new ClassParser(rootDirectory+"NewClass.class").parse(), new FileOutputStream(new File(rootDirectory+"NewClassCreator.java"))).start();
|
//new BCELifier(new ClassParser(rootDirectory+"NewClass.class").parse(), new FileOutputStream(new File(rootDirectory+"NewClassCreator.java"))).start();
|
||||||
|
new BCELifier(new ClassParser(rootDirectory+"IfStatement.class").parse(), new FileOutputStream(new File(rootDirectory+"IfStatementCreator.java"))).start();
|
||||||
} catch (ClassFormatException | IOException e) {
|
} catch (ClassFormatException | IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -139,7 +139,7 @@ public class DHBWInstructionFactory extends InstructionFactory{
|
|||||||
return new INVOKEDYNAMIC(index);
|
return new INVOKEDYNAMIC(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
public LocalVariableInstruction createLoad(org.apache.commons.bcel6.generic.Type bytecodeType, String variableName) {
|
public static LocalVariableInstruction createLoad(org.apache.commons.bcel6.generic.Type bytecodeType, String variableName) {
|
||||||
return InstructionFactory.createLoad(bytecodeType, getStoreIndex(variableName));
|
return InstructionFactory.createLoad(bytecodeType, getStoreIndex(variableName));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,7 +147,7 @@ public class DHBWInstructionFactory extends InstructionFactory{
|
|||||||
return InstructionFactory.createStore(bytecodeType, getStoreIndex(variableName));
|
return InstructionFactory.createStore(bytecodeType, getStoreIndex(variableName));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getStoreIndex(String variableName) {
|
public static Integer getStoreIndex(String variableName) {
|
||||||
if(storeIndexes.get(variableName) == null){
|
if(storeIndexes.get(variableName) == null){
|
||||||
Integer index = storeIndexes.size()+1;
|
Integer index = storeIndexes.size()+1;
|
||||||
storeIndexes.put(variableName, index);
|
storeIndexes.put(variableName, index);
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// ino.module.Method.8564.package
|
// ino.module.Method.8564.package
|
||||||
package de.dhbwstuttgart.syntaxtree;
|
package de.dhbwstuttgart.syntaxtree;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
import java.util.Hashtable;
|
import java.util.Hashtable;
|
||||||
@ -406,45 +407,37 @@ public class Method extends Field implements IItemWithOffset, TypeInsertable
|
|||||||
DHBWInstructionFactory _factory = cg.getInstructionFactory();
|
DHBWInstructionFactory _factory = cg.getInstructionFactory();
|
||||||
|
|
||||||
for(TypeinferenceResultSet t: typeInterferenceResults){
|
for(TypeinferenceResultSet t: typeInterferenceResults){
|
||||||
|
addMethodToClassGenerator(cg, _factory, t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addMethodToClassGenerator(ClassGenerator cg, DHBWInstructionFactory _factory, TypeinferenceResultSet t) {
|
||||||
DHBWConstantPoolGen _cp = cg.getConstantPool();
|
DHBWConstantPoolGen _cp = cg.getConstantPool();
|
||||||
InstructionList il = new InstructionList();
|
InstructionList il = new InstructionList();
|
||||||
Class parentClass = this.getParentClass();
|
|
||||||
|
|
||||||
//Die Argumentliste generieren:
|
ArrayList<org.apache.commons.bcel6.generic.Type> argumentTypes = new ArrayList<org.apache.commons.bcel6.generic.Type>();
|
||||||
org.apache.commons.bcel6.generic.Type[] argumentTypes = org.apache.commons.bcel6.generic.Type.NO_ARGS;
|
ArrayList<String> argumentNames = new ArrayList<String>();
|
||||||
String[] argumentNames = new String[]{};
|
|
||||||
if(this.parameterlist != null && this.parameterlist.size() > 0){
|
if(this.parameterlist != null && this.parameterlist.size() > 0){
|
||||||
argumentTypes = new org.apache.commons.bcel6.generic.Type[this.parameterlist.size()];
|
generateArgumentList(argumentTypes, argumentNames, cg, _factory, t);
|
||||||
argumentNames = new String[this.parameterlist.size()];
|
|
||||||
int i = 0;
|
|
||||||
for(FormalParameter parameter : this.parameterlist){
|
|
||||||
argumentTypes[i] = parameter.getType().getBytecodeType(cg, t);
|
|
||||||
argumentNames[i] = parameter.getIdentifier();
|
|
||||||
|
|
||||||
|
|
||||||
_factory.getStoreIndex(parameter.getIdentifier());
|
|
||||||
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String nameAndSignature = get_Method_Name()+Arrays.toString(argumentTypes);
|
short constants = Constants.ACC_PUBLIC;
|
||||||
|
|
||||||
Logger.getLogger("nameAndSignature").error(nameAndSignature, Section.CODEGEN);
|
|
||||||
|
|
||||||
|
|
||||||
short constants = Constants.ACC_PUBLIC; //Per Definition ist jede Methode public
|
|
||||||
if(this.modifiers != null && this.modifiers.includesModifier(new Static())) constants += Constants.ACC_STATIC;
|
if(this.modifiers != null && this.modifiers.includesModifier(new Static())) constants += Constants.ACC_STATIC;
|
||||||
|
|
||||||
Type returnType = this.getType();
|
Type returnType = this.getType();
|
||||||
|
|
||||||
//Methode generieren:
|
MethodGenerator method = new MethodGenerator(constants, returnType.getBytecodeType(cg, t), argumentTypes.toArray(new org.apache.commons.bcel6.generic.Type[parameterlist.size()]) , argumentNames.toArray(new String[parameterlist.size()]), this.get_Method_Name(), getParentClass().name, il, _cp);
|
||||||
MethodGenerator method = new MethodGenerator(constants, returnType.getBytecodeType(cg, t), argumentTypes , argumentNames, this.get_Method_Name(), parentClass.name, il, _cp);
|
|
||||||
|
|
||||||
//Methode generieren und anfügen:
|
|
||||||
cg.addMethod(method.createMethod(cg, getParameterList(), returnType, get_Block(), t));
|
cg.addMethod(method.createMethod(cg, getParameterList(), returnType, get_Block(), t));
|
||||||
|
}
|
||||||
|
|
||||||
Logger.getLogger("createMethod").debug(this.toString(), Section.CODEGEN);
|
private void generateArgumentList(ArrayList<org.apache.commons.bcel6.generic.Type> argumentTypes, ArrayList<String> argumentNames, ClassGenerator cg, DHBWInstructionFactory _factory, TypeinferenceResultSet t) {
|
||||||
|
for(FormalParameter parameter : this.parameterlist){
|
||||||
|
argumentTypes.add(parameter.getType().getBytecodeType(cg, t));
|
||||||
|
argumentNames.add(parameter.getIdentifier());
|
||||||
|
|
||||||
|
_factory.getStoreIndex(parameter.getIdentifier());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -170,7 +170,7 @@ public class UnifyTypeFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Type convert(ReferenceType t) {
|
public static Type convert(ReferenceType t) {
|
||||||
//TODO: Hier kann man vielleicht die GTVs extrahieren
|
//TODO: Hier kann man die GTVs extrahieren
|
||||||
RefType ret = new RefType(t.getName(),null,0);
|
RefType ret = new RefType(t.getName(),null,0);
|
||||||
ret.set_ParaList(convert(t.getTypeParams()));
|
ret.set_ParaList(convert(t.getTypeParams()));
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -5,8 +5,17 @@ package de.dhbwstuttgart.syntaxtree.operator;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Hashtable;
|
import java.util.Hashtable;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import de.dhbwstuttgart.typeinference.Menge;
|
|
||||||
|
|
||||||
|
import org.apache.commons.bcel6.Constants;
|
||||||
|
import org.apache.commons.bcel6.generic.ArithmeticInstruction;
|
||||||
|
import org.apache.commons.bcel6.generic.IADD;
|
||||||
|
import org.apache.commons.bcel6.generic.InstructionList;
|
||||||
|
import org.apache.commons.bcel6.generic.InvokeInstruction;
|
||||||
|
import org.apache.commons.bcel6.generic.ObjectType;
|
||||||
|
|
||||||
|
import de.dhbwstuttgart.typeinference.Menge;
|
||||||
|
import de.dhbwstuttgart.bytecode.ClassGenerator;
|
||||||
|
import de.dhbwstuttgart.bytecode.DHBWInstructionFactory;
|
||||||
import de.dhbwstuttgart.myexception.CTypeReconstructionException;
|
import de.dhbwstuttgart.myexception.CTypeReconstructionException;
|
||||||
import de.dhbwstuttgart.myexception.JVMCodeException;
|
import de.dhbwstuttgart.myexception.JVMCodeException;
|
||||||
import de.dhbwstuttgart.syntaxtree.statement.Binary;
|
import de.dhbwstuttgart.syntaxtree.statement.Binary;
|
||||||
@ -18,6 +27,10 @@ import de.dhbwstuttgart.typeinference.Pair;
|
|||||||
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
|
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
|
||||||
import de.dhbwstuttgart.typeinference.exceptions.DebugException;
|
import de.dhbwstuttgart.typeinference.exceptions.DebugException;
|
||||||
import de.dhbwstuttgart.typeinference.unify.TypeUnify;
|
import de.dhbwstuttgart.typeinference.unify.TypeUnify;
|
||||||
|
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
||||||
|
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
|
||||||
|
import de.dhbwstuttgart.typeinference.exceptions.DebugException;
|
||||||
|
import de.dhbwstuttgart.typeinference.exceptions.NotImplementedException;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -61,5 +74,44 @@ public abstract class AddOp extends Operator
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public InstructionList genByteCode(ClassGenerator _cg, TypeinferenceResultSet rs, Binary operator) {
|
||||||
|
// TODO Plus Operator ist bis jetzt nur für Integer implementiert
|
||||||
|
/*
|
||||||
|
0: aload_1
|
||||||
|
1: invokevirtual #2 // Method java/lang/Integer.intValue:()I
|
||||||
|
4: aload_1
|
||||||
|
5: invokevirtual #2 // Method java/lang/Integer.intValue:()I
|
||||||
|
8: iadd
|
||||||
|
9: invokestatic #3 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
|
||||||
|
12: areturn
|
||||||
|
*/
|
||||||
|
DHBWInstructionFactory _factory = _cg.getInstructionFactory();
|
||||||
|
|
||||||
|
String returnType = getReturnType(operator.get_Expr1(), operator.get_Expr2());
|
||||||
|
|
||||||
|
InstructionList il = getInstructionListForOperand(_cg, rs, operator.get_Expr1(), returnType);
|
||||||
|
|
||||||
|
il.append(getInstructionListForOperand(_cg, rs, operator.get_Expr2(), returnType));
|
||||||
|
|
||||||
|
il.append(getOperator(returnType));
|
||||||
|
|
||||||
|
il.append(convertValueToObject(_factory, returnType));
|
||||||
|
return il;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getReturnType(Expr expr1, Expr expr2) {
|
||||||
|
return "java.lang.Integer";
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract ArithmeticInstruction getOperator(String returnType);
|
||||||
|
|
||||||
|
private InvokeInstruction convertValueToObject(DHBWInstructionFactory _factory, String returnType) {
|
||||||
|
if(returnType.equals("java.lang.Integer")){
|
||||||
|
return _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);
|
||||||
|
}else{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// ino.end
|
// ino.end
|
||||||
|
@ -4,6 +4,9 @@ package de.dhbwstuttgart.syntaxtree.operator;
|
|||||||
// ino.module.DivideOp.8596.import
|
// ino.module.DivideOp.8596.import
|
||||||
import de.dhbwstuttgart.typeinference.Menge;
|
import de.dhbwstuttgart.typeinference.Menge;
|
||||||
|
|
||||||
|
import org.apache.commons.bcel6.generic.ArithmeticInstruction;
|
||||||
|
import org.apache.commons.bcel6.generic.IDIV;
|
||||||
|
|
||||||
import de.dhbwstuttgart.myexception.JVMCodeException;
|
import de.dhbwstuttgart.myexception.JVMCodeException;
|
||||||
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
|
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
|
||||||
import de.dhbwstuttgart.syntaxtree.statement.Binary;
|
import de.dhbwstuttgart.syntaxtree.statement.Binary;
|
||||||
@ -26,8 +29,9 @@ public class DivideOp extends MulOp
|
|||||||
}
|
}
|
||||||
// ino.end
|
// ino.end
|
||||||
|
|
||||||
|
@Override
|
||||||
|
ArithmeticInstruction getOperator(String returnType) {
|
||||||
|
return new IDIV();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// ino.end
|
// ino.end
|
||||||
|
@ -47,36 +47,8 @@ public class EqualOp extends RelOp
|
|||||||
// ino.end
|
// ino.end
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InstructionList genByteCode(ClassGenerator _cg, TypeinferenceResultSet rs, Binary operator) {
|
BranchInstruction getOperator() {
|
||||||
DHBWInstructionFactory _factory = _cg.getInstructionFactory();
|
return new IF_ICMPNE(null);
|
||||||
|
|
||||||
InstructionList linkeSeite = operator.expr1.genByteCode(_cg, rs);
|
|
||||||
linkeSeite.append(_factory.createInvoke("java.lang.Integer", "intValue", org.apache.commons.bcel6.generic.Type.INT, new org.apache.commons.bcel6.generic.Type[] {}, Constants.INVOKEVIRTUAL));
|
|
||||||
|
|
||||||
InstructionList rechteSeite = operator.expr2.genByteCode(_cg, rs);
|
|
||||||
rechteSeite.append(_factory.createInvoke("java.lang.Integer", "intValue", org.apache.commons.bcel6.generic.Type.INT, new org.apache.commons.bcel6.generic.Type[] {}, Constants.INVOKEVIRTUAL));
|
|
||||||
|
|
||||||
|
|
||||||
if(operator.getReturnType().getName().equals(new JavaClassName("String"))){
|
|
||||||
throw new TypeinferenceException("Zeichenketten zusammenfügen ist noch nicht unterstützt",this);
|
|
||||||
}
|
|
||||||
|
|
||||||
linkeSeite.append(rechteSeite);
|
|
||||||
|
|
||||||
//TODO: bytecode (Bis jetzt wird jeder Condition als EQUALS behandelt)
|
|
||||||
//TODO: bytecode autoboxing
|
|
||||||
|
|
||||||
BranchInstruction if_icmpneInstruction = new IF_ICMPNE(null);
|
|
||||||
linkeSeite.append(if_icmpneInstruction);
|
|
||||||
linkeSeite.append(InstructionConstants.ICONST_1);
|
|
||||||
|
|
||||||
BranchInstruction gotoInstruction = new GOTO(null);
|
|
||||||
|
|
||||||
linkeSeite.append(gotoInstruction);
|
|
||||||
if_icmpneInstruction.setTarget(linkeSeite.append(InstructionConstants.ICONST_0));
|
|
||||||
gotoInstruction.setTarget(linkeSeite.append(_factory.createInvoke("java.lang.Boolean", "valueOf", new ObjectType("java.lang.Boolean"), new org.apache.commons.bcel6.generic.Type[] {org.apache.commons.bcel6.generic.Type.BOOLEAN}, Constants.INVOKESTATIC)));
|
|
||||||
|
|
||||||
return linkeSeite;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,9 @@ package de.dhbwstuttgart.syntaxtree.operator;
|
|||||||
// ino.module.GreaterEquOp.8598.import
|
// ino.module.GreaterEquOp.8598.import
|
||||||
import de.dhbwstuttgart.typeinference.Menge;
|
import de.dhbwstuttgart.typeinference.Menge;
|
||||||
|
|
||||||
|
import org.apache.commons.bcel6.generic.BranchInstruction;
|
||||||
|
import org.apache.commons.bcel6.generic.IF_ICMPLT;
|
||||||
|
|
||||||
import de.dhbwstuttgart.myexception.JVMCodeException;
|
import de.dhbwstuttgart.myexception.JVMCodeException;
|
||||||
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
|
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
|
||||||
import de.dhbwstuttgart.syntaxtree.statement.Binary;
|
import de.dhbwstuttgart.syntaxtree.statement.Binary;
|
||||||
@ -26,5 +29,10 @@ public class GreaterEquOp extends RelOp
|
|||||||
}
|
}
|
||||||
// ino.end
|
// ino.end
|
||||||
|
|
||||||
|
@Override
|
||||||
|
BranchInstruction getOperator() {
|
||||||
|
return new IF_ICMPLT(null);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
// ino.end
|
// ino.end
|
||||||
|
@ -4,6 +4,9 @@ package de.dhbwstuttgart.syntaxtree.operator;
|
|||||||
// ino.module.GreaterOp.8599.import
|
// ino.module.GreaterOp.8599.import
|
||||||
import de.dhbwstuttgart.typeinference.Menge;
|
import de.dhbwstuttgart.typeinference.Menge;
|
||||||
|
|
||||||
|
import org.apache.commons.bcel6.generic.BranchInstruction;
|
||||||
|
import org.apache.commons.bcel6.generic.IF_ICMPLE;
|
||||||
|
|
||||||
import de.dhbwstuttgart.myexception.JVMCodeException;
|
import de.dhbwstuttgart.myexception.JVMCodeException;
|
||||||
import de.dhbwstuttgart.syntaxtree.statement.Binary;
|
import de.dhbwstuttgart.syntaxtree.statement.Binary;
|
||||||
import de.dhbwstuttgart.syntaxtree.statement.Expr;
|
import de.dhbwstuttgart.syntaxtree.statement.Expr;
|
||||||
@ -25,5 +28,10 @@ public class GreaterOp extends RelOp
|
|||||||
}
|
}
|
||||||
// ino.end
|
// ino.end
|
||||||
|
|
||||||
|
@Override
|
||||||
|
BranchInstruction getOperator() {
|
||||||
|
return new IF_ICMPLE(null);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
// ino.end
|
// ino.end
|
||||||
|
@ -4,6 +4,9 @@ package de.dhbwstuttgart.syntaxtree.operator;
|
|||||||
// ino.module.LessEquOp.8600.import
|
// ino.module.LessEquOp.8600.import
|
||||||
import de.dhbwstuttgart.typeinference.Menge;
|
import de.dhbwstuttgart.typeinference.Menge;
|
||||||
|
|
||||||
|
import org.apache.commons.bcel6.generic.BranchInstruction;
|
||||||
|
import org.apache.commons.bcel6.generic.IF_ICMPGT;
|
||||||
|
|
||||||
import de.dhbwstuttgart.myexception.JVMCodeException;
|
import de.dhbwstuttgart.myexception.JVMCodeException;
|
||||||
import de.dhbwstuttgart.syntaxtree.statement.Binary;
|
import de.dhbwstuttgart.syntaxtree.statement.Binary;
|
||||||
import de.dhbwstuttgart.syntaxtree.statement.Expr;
|
import de.dhbwstuttgart.syntaxtree.statement.Expr;
|
||||||
@ -25,5 +28,10 @@ public class LessEquOp extends RelOp
|
|||||||
}
|
}
|
||||||
// ino.end
|
// ino.end
|
||||||
|
|
||||||
|
@Override
|
||||||
|
BranchInstruction getOperator() {
|
||||||
|
return new IF_ICMPGT(null);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
// ino.end
|
// ino.end
|
||||||
|
@ -3,6 +3,8 @@ package de.dhbwstuttgart.syntaxtree.operator;
|
|||||||
// ino.end
|
// ino.end
|
||||||
// ino.module.LessOp.8601.import
|
// ino.module.LessOp.8601.import
|
||||||
import de.dhbwstuttgart.typeinference.Menge;
|
import de.dhbwstuttgart.typeinference.Menge;
|
||||||
|
import org.apache.commons.bcel6.generic.BranchInstruction;
|
||||||
|
import org.apache.commons.bcel6.generic.IF_ICMPGE;
|
||||||
|
|
||||||
import de.dhbwstuttgart.myexception.JVMCodeException;
|
import de.dhbwstuttgart.myexception.JVMCodeException;
|
||||||
import de.dhbwstuttgart.syntaxtree.statement.Binary;
|
import de.dhbwstuttgart.syntaxtree.statement.Binary;
|
||||||
@ -25,5 +27,10 @@ public class LessOp extends RelOp
|
|||||||
}
|
}
|
||||||
// ino.end
|
// ino.end
|
||||||
|
|
||||||
|
@Override
|
||||||
|
BranchInstruction getOperator() {
|
||||||
|
return new IF_ICMPGE(null);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
// ino.end
|
// ino.end
|
||||||
|
@ -4,6 +4,10 @@ package de.dhbwstuttgart.syntaxtree.operator;
|
|||||||
// ino.module.MinusOp.8603.import
|
// ino.module.MinusOp.8603.import
|
||||||
import de.dhbwstuttgart.typeinference.Menge;
|
import de.dhbwstuttgart.typeinference.Menge;
|
||||||
|
|
||||||
|
import org.apache.commons.bcel6.generic.ArithmeticInstruction;
|
||||||
|
import org.apache.commons.bcel6.generic.IADD;
|
||||||
|
import org.apache.commons.bcel6.generic.ISUB;
|
||||||
|
|
||||||
import de.dhbwstuttgart.myexception.JVMCodeException;
|
import de.dhbwstuttgart.myexception.JVMCodeException;
|
||||||
import de.dhbwstuttgart.syntaxtree.statement.Binary;
|
import de.dhbwstuttgart.syntaxtree.statement.Binary;
|
||||||
import de.dhbwstuttgart.syntaxtree.statement.Expr;
|
import de.dhbwstuttgart.syntaxtree.statement.Expr;
|
||||||
@ -25,6 +29,8 @@ public class MinusOp extends AddOp
|
|||||||
}
|
}
|
||||||
// ino.end
|
// ino.end
|
||||||
|
|
||||||
|
ArithmeticInstruction getOperator(String returnType) {
|
||||||
|
return new ISUB();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// ino.end
|
// ino.end
|
||||||
|
@ -4,6 +4,9 @@ package de.dhbwstuttgart.syntaxtree.operator;
|
|||||||
// ino.module.ModuloOp.8604.import
|
// ino.module.ModuloOp.8604.import
|
||||||
import de.dhbwstuttgart.typeinference.Menge;
|
import de.dhbwstuttgart.typeinference.Menge;
|
||||||
|
|
||||||
|
import org.apache.commons.bcel6.generic.ArithmeticInstruction;
|
||||||
|
import org.apache.commons.bcel6.generic.IREM;
|
||||||
|
|
||||||
import de.dhbwstuttgart.myexception.JVMCodeException;
|
import de.dhbwstuttgart.myexception.JVMCodeException;
|
||||||
import de.dhbwstuttgart.syntaxtree.statement.Binary;
|
import de.dhbwstuttgart.syntaxtree.statement.Binary;
|
||||||
import de.dhbwstuttgart.syntaxtree.statement.Expr;
|
import de.dhbwstuttgart.syntaxtree.statement.Expr;
|
||||||
@ -25,5 +28,10 @@ public class ModuloOp extends MulOp
|
|||||||
}
|
}
|
||||||
// ino.end
|
// ino.end
|
||||||
|
|
||||||
|
@Override
|
||||||
|
ArithmeticInstruction getOperator(String returnType) {
|
||||||
|
return new IREM();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
// ino.end
|
// ino.end
|
||||||
|
@ -6,16 +6,27 @@ package de.dhbwstuttgart.syntaxtree.operator;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Hashtable;
|
import java.util.Hashtable;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import de.dhbwstuttgart.typeinference.Menge;
|
|
||||||
|
|
||||||
|
import org.apache.commons.bcel6.Constants;
|
||||||
|
import org.apache.commons.bcel6.generic.ArithmeticInstruction;
|
||||||
|
import org.apache.commons.bcel6.generic.InstructionList;
|
||||||
|
import org.apache.commons.bcel6.generic.InvokeInstruction;
|
||||||
|
import org.apache.commons.bcel6.generic.ObjectType;
|
||||||
|
|
||||||
|
import de.dhbwstuttgart.typeinference.Menge;
|
||||||
|
import de.dhbwstuttgart.bytecode.ClassGenerator;
|
||||||
|
import de.dhbwstuttgart.bytecode.DHBWInstructionFactory;
|
||||||
import de.dhbwstuttgart.myexception.CTypeReconstructionException;
|
import de.dhbwstuttgart.myexception.CTypeReconstructionException;
|
||||||
import de.dhbwstuttgart.syntaxtree.statement.Binary;
|
import de.dhbwstuttgart.syntaxtree.statement.Binary;
|
||||||
|
import de.dhbwstuttgart.syntaxtree.statement.Expr;
|
||||||
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
||||||
import de.dhbwstuttgart.syntaxtree.type.Type;
|
import de.dhbwstuttgart.syntaxtree.type.Type;
|
||||||
import de.dhbwstuttgart.typeinference.Pair;
|
import de.dhbwstuttgart.typeinference.Pair;
|
||||||
|
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
||||||
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
|
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
|
||||||
import de.dhbwstuttgart.typeinference.exceptions.DebugException;
|
import de.dhbwstuttgart.typeinference.exceptions.DebugException;
|
||||||
import de.dhbwstuttgart.typeinference.unify.TypeUnify;
|
import de.dhbwstuttgart.typeinference.unify.TypeUnify;
|
||||||
|
import de.dhbwstuttgart.typeinference.exceptions.NotImplementedException;
|
||||||
|
|
||||||
// ino.class.MulOp.24231.declaration
|
// ino.class.MulOp.24231.declaration
|
||||||
public abstract class MulOp extends Operator
|
public abstract class MulOp extends Operator
|
||||||
@ -50,6 +61,44 @@ public abstract class MulOp extends Operator
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public InstructionList genByteCode(ClassGenerator _cg, TypeinferenceResultSet rs, Binary operator) {
|
||||||
|
// TODO Plus Operator ist bis jetzt nur für Integer implementiert
|
||||||
|
/*
|
||||||
|
0: aload_1
|
||||||
|
1: invokevirtual #2 // Method java/lang/Integer.intValue:()I
|
||||||
|
4: aload_1
|
||||||
|
5: invokevirtual #2 // Method java/lang/Integer.intValue:()I
|
||||||
|
8: imul
|
||||||
|
9: invokestatic #3 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
|
||||||
|
12: areturn
|
||||||
|
*/
|
||||||
|
DHBWInstructionFactory _factory = _cg.getInstructionFactory();
|
||||||
|
|
||||||
|
String returnType = getReturnType(operator.get_Expr1(), operator.get_Expr2());
|
||||||
|
|
||||||
|
InstructionList il = getInstructionListForOperand(_cg, rs, operator.get_Expr1(), returnType);
|
||||||
|
|
||||||
|
il.append(getInstructionListForOperand(_cg, rs, operator.get_Expr2(), returnType));
|
||||||
|
|
||||||
|
il.append(getOperator(returnType));
|
||||||
|
|
||||||
|
il.append(convertValueToObject(_factory, returnType));
|
||||||
|
return il;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getReturnType(Expr expr1, Expr expr2) {
|
||||||
|
return "java.lang.Integer";
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract ArithmeticInstruction getOperator(String returnType);
|
||||||
|
|
||||||
|
private InvokeInstruction convertValueToObject(DHBWInstructionFactory _factory, String returnType) {
|
||||||
|
if(returnType.equals("java.lang.Integer")){
|
||||||
|
return _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);
|
||||||
|
}else{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// ino.end
|
// ino.end
|
||||||
|
@ -3,7 +3,6 @@ package de.dhbwstuttgart.syntaxtree.operator;
|
|||||||
// ino.end
|
// ino.end
|
||||||
// ino.module.NotEqualOp.8606.import
|
// ino.module.NotEqualOp.8606.import
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import de.dhbwstuttgart.typeinference.Menge;
|
|
||||||
|
|
||||||
import de.dhbwstuttgart.myexception.CTypeReconstructionException;
|
import de.dhbwstuttgart.myexception.CTypeReconstructionException;
|
||||||
import de.dhbwstuttgart.myexception.JVMCodeException;
|
import de.dhbwstuttgart.myexception.JVMCodeException;
|
||||||
@ -13,6 +12,9 @@ import de.dhbwstuttgart.syntaxtree.statement.Null;
|
|||||||
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
||||||
import de.dhbwstuttgart.typeinference.Pair;
|
import de.dhbwstuttgart.typeinference.Pair;
|
||||||
import de.dhbwstuttgart.typeinference.unify.TypeUnify;
|
import de.dhbwstuttgart.typeinference.unify.TypeUnify;
|
||||||
|
import org.apache.commons.bcel6.generic.BranchInstruction;
|
||||||
|
import org.apache.commons.bcel6.generic.IF_ACMPEQ;
|
||||||
|
|
||||||
|
|
||||||
// ino.class.NotEqualOp.24241.declaration
|
// ino.class.NotEqualOp.24241.declaration
|
||||||
public class NotEqualOp extends RelOp
|
public class NotEqualOp extends RelOp
|
||||||
@ -28,5 +30,10 @@ public class NotEqualOp extends RelOp
|
|||||||
}
|
}
|
||||||
// ino.end
|
// ino.end
|
||||||
|
|
||||||
|
@Override
|
||||||
|
BranchInstruction getOperator() {
|
||||||
|
return new IF_ACMPEQ(null);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
// ino.end
|
// ino.end
|
||||||
|
@ -6,6 +6,7 @@ import java.util.HashMap;
|
|||||||
import java.util.Hashtable;
|
import java.util.Hashtable;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
|
import org.apache.commons.bcel6.Constants;
|
||||||
import org.apache.commons.bcel6.generic.InstructionList;
|
import org.apache.commons.bcel6.generic.InstructionList;
|
||||||
|
|
||||||
import de.dhbwstuttgart.typeinference.Menge;
|
import de.dhbwstuttgart.typeinference.Menge;
|
||||||
@ -75,5 +76,13 @@ public abstract class Operator extends SyntaxTreeNode
|
|||||||
public Menge<SyntaxTreeNode> getChildren() {
|
public Menge<SyntaxTreeNode> getChildren() {
|
||||||
return new Menge<>();
|
return new Menge<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected InstructionList getInstructionListForOperand(ClassGenerator _cg, TypeinferenceResultSet rs, Expr operand, String returnType){
|
||||||
|
InstructionList il = new InstructionList();
|
||||||
|
il.append(operand.genByteCode(_cg, rs));
|
||||||
|
il.append(_cg.getInstructionFactory().createInvoke("java.lang.Integer", "intValue", org.apache.commons.bcel6.generic.Type.INT, new org.apache.commons.bcel6.generic.Type[] {}, Constants.INVOKEVIRTUAL));
|
||||||
|
return il;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// ino.end
|
// ino.end
|
||||||
|
@ -42,53 +42,8 @@ public class PlusOp extends AddOp
|
|||||||
}
|
}
|
||||||
// ino.end
|
// ino.end
|
||||||
|
|
||||||
@Override
|
ArithmeticInstruction getOperator(String returnType) {
|
||||||
public InstructionList genByteCode(ClassGenerator _cg, TypeinferenceResultSet rs, Binary operator) {
|
|
||||||
// TODO Plus Operator ist bis jetzt nur für Integer implementiert
|
|
||||||
/*
|
|
||||||
0: aload_1
|
|
||||||
1: invokevirtual #2 // Method java/lang/Integer.intValue:()I
|
|
||||||
4: aload_1
|
|
||||||
5: invokevirtual #2 // Method java/lang/Integer.intValue:()I
|
|
||||||
8: iadd
|
|
||||||
9: invokestatic #3 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
|
|
||||||
12: areturn
|
|
||||||
*/
|
|
||||||
DHBWInstructionFactory _factory = _cg.getInstructionFactory();
|
|
||||||
|
|
||||||
String returnType = getReturnType(operator.get_Expr1(), operator.get_Expr2());
|
|
||||||
|
|
||||||
InstructionList il = getInstructionListForOperand(_cg, rs, operator.get_Expr1(), returnType);
|
|
||||||
|
|
||||||
il.append(getInstructionListForOperand(_cg, rs, operator.get_Expr2(), returnType));
|
|
||||||
|
|
||||||
il.append(getOperator(returnType));
|
|
||||||
|
|
||||||
il.append(convertValueToObject(_factory, returnType));
|
|
||||||
return il;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getReturnType(Expr expr1, Expr expr2) {
|
|
||||||
return "java.lang.Integer";
|
|
||||||
}
|
|
||||||
|
|
||||||
private ArithmeticInstruction getOperator(String returnType) {
|
|
||||||
return new IADD();
|
return new IADD();
|
||||||
}
|
}
|
||||||
private InvokeInstruction convertValueToObject(DHBWInstructionFactory _factory, String returnType) {
|
|
||||||
if(returnType.equals("java.lang.Integer")){
|
|
||||||
return _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);
|
|
||||||
}else{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private InstructionList getInstructionListForOperand(ClassGenerator _cg, TypeinferenceResultSet rs, Expr operand, String returnType){
|
|
||||||
InstructionList il = new InstructionList();
|
|
||||||
il.append(operand.genByteCode(_cg, rs));
|
|
||||||
il.append(_cg.getInstructionFactory().createInvoke("java.lang.Integer", "intValue", org.apache.commons.bcel6.generic.Type.INT, new org.apache.commons.bcel6.generic.Type[] {}, Constants.INVOKEVIRTUAL));
|
|
||||||
return il;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
// ino.end
|
// ino.end
|
||||||
|
@ -6,14 +6,24 @@ package de.dhbwstuttgart.syntaxtree.operator;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Hashtable;
|
import java.util.Hashtable;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import de.dhbwstuttgart.typeinference.Menge;
|
|
||||||
|
|
||||||
|
import org.apache.commons.bcel6.Constants;
|
||||||
|
import org.apache.commons.bcel6.generic.BranchInstruction;
|
||||||
|
import org.apache.commons.bcel6.generic.GOTO;
|
||||||
|
import org.apache.commons.bcel6.generic.InstructionConstants;
|
||||||
|
import org.apache.commons.bcel6.generic.InstructionList;
|
||||||
|
import org.apache.commons.bcel6.generic.ObjectType;
|
||||||
|
|
||||||
|
import de.dhbwstuttgart.typeinference.Menge;
|
||||||
|
import de.dhbwstuttgart.bytecode.ClassGenerator;
|
||||||
|
import de.dhbwstuttgart.bytecode.DHBWInstructionFactory;
|
||||||
import de.dhbwstuttgart.myexception.CTypeReconstructionException;
|
import de.dhbwstuttgart.myexception.CTypeReconstructionException;
|
||||||
import de.dhbwstuttgart.myexception.JVMCodeException;
|
import de.dhbwstuttgart.myexception.JVMCodeException;
|
||||||
import de.dhbwstuttgart.syntaxtree.statement.Binary;
|
import de.dhbwstuttgart.syntaxtree.statement.Binary;
|
||||||
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
||||||
import de.dhbwstuttgart.syntaxtree.type.Type;
|
import de.dhbwstuttgart.syntaxtree.type.Type;
|
||||||
import de.dhbwstuttgart.typeinference.Pair;
|
import de.dhbwstuttgart.typeinference.Pair;
|
||||||
|
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
||||||
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
|
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
|
||||||
import de.dhbwstuttgart.typeinference.exceptions.DebugException;
|
import de.dhbwstuttgart.typeinference.exceptions.DebugException;
|
||||||
import de.dhbwstuttgart.typeinference.unify.TypeUnify;
|
import de.dhbwstuttgart.typeinference.unify.TypeUnify;
|
||||||
@ -55,5 +65,44 @@ public abstract class RelOp extends Operator
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public InstructionList genByteCode(ClassGenerator _cg, TypeinferenceResultSet rs, Binary operator) {
|
||||||
|
/*
|
||||||
|
0: aload_1
|
||||||
|
1: invokevirtual #3 // Method java/lang/Integer.intValue:()I
|
||||||
|
4: aload_2
|
||||||
|
5: invokevirtual #3 // Method java/lang/Integer.intValue:()I
|
||||||
|
8: if_icmplt 15
|
||||||
|
11: iconst_1
|
||||||
|
12: goto 16
|
||||||
|
15: iconst_0
|
||||||
|
16: invokestatic #2 // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;
|
||||||
|
19: areturn
|
||||||
|
*/
|
||||||
|
|
||||||
|
DHBWInstructionFactory _factory = _cg.getInstructionFactory();
|
||||||
|
|
||||||
|
InstructionList il = getInstructionListForOperand(_cg, rs, operator.get_Expr1(), "java.lang.Boolean");
|
||||||
|
|
||||||
|
il.append(getInstructionListForOperand(_cg, rs, operator.get_Expr2(), "java.lang.Boolean"));
|
||||||
|
|
||||||
|
BranchInstruction operatorBranchInstruction = getOperator();
|
||||||
|
|
||||||
|
il.append(operatorBranchInstruction);
|
||||||
|
|
||||||
|
il.append(InstructionConstants.ICONST_1);
|
||||||
|
|
||||||
|
BranchInstruction gotoInstruction = new GOTO(null);
|
||||||
|
|
||||||
|
il.append(gotoInstruction);
|
||||||
|
|
||||||
|
operatorBranchInstruction.setTarget(il.append(InstructionConstants.ICONST_0));
|
||||||
|
gotoInstruction.setTarget(il.append(_factory.createInvoke("java.lang.Boolean", "valueOf", new ObjectType("java.lang.Boolean"), new org.apache.commons.bcel6.generic.Type[] {org.apache.commons.bcel6.generic.Type.BOOLEAN}, Constants.INVOKESTATIC)));
|
||||||
|
|
||||||
|
return il;
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract BranchInstruction getOperator();
|
||||||
|
|
||||||
}
|
}
|
||||||
// ino.end
|
// ino.end
|
||||||
|
@ -5,6 +5,9 @@ package de.dhbwstuttgart.syntaxtree.operator;
|
|||||||
// ino.module.TimesOp.8611.import
|
// ino.module.TimesOp.8611.import
|
||||||
import de.dhbwstuttgart.typeinference.Menge;
|
import de.dhbwstuttgart.typeinference.Menge;
|
||||||
|
|
||||||
|
import org.apache.commons.bcel6.generic.ArithmeticInstruction;
|
||||||
|
import org.apache.commons.bcel6.generic.IMUL;
|
||||||
|
|
||||||
import de.dhbwstuttgart.myexception.JVMCodeException;
|
import de.dhbwstuttgart.myexception.JVMCodeException;
|
||||||
import de.dhbwstuttgart.syntaxtree.statement.Binary;
|
import de.dhbwstuttgart.syntaxtree.statement.Binary;
|
||||||
import de.dhbwstuttgart.syntaxtree.statement.Expr;
|
import de.dhbwstuttgart.syntaxtree.statement.Expr;
|
||||||
@ -23,5 +26,10 @@ public class TimesOp extends MulOp
|
|||||||
}
|
}
|
||||||
// ino.end
|
// ino.end
|
||||||
|
|
||||||
|
@Override
|
||||||
|
ArithmeticInstruction getOperator(String returnType) {
|
||||||
|
return new IMUL();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
// ino.end
|
// ino.end
|
||||||
|
@ -38,10 +38,6 @@ import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
|
|||||||
import de.dhbwstuttgart.typeinference.exceptions.NotImplementedException;
|
import de.dhbwstuttgart.typeinference.exceptions.NotImplementedException;
|
||||||
import de.dhbwstuttgart.typeinference.unify.TypeUnify;
|
import de.dhbwstuttgart.typeinference.unify.TypeUnify;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public class ForStmt extends Statement
|
public class ForStmt extends Statement
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -6,7 +6,11 @@ import java.util.Enumeration;
|
|||||||
import java.util.Hashtable;
|
import java.util.Hashtable;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
|
import org.apache.commons.bcel6.generic.BranchInstruction;
|
||||||
import org.apache.commons.bcel6.generic.ClassGen;
|
import org.apache.commons.bcel6.generic.ClassGen;
|
||||||
|
import org.apache.commons.bcel6.generic.DUP;
|
||||||
|
import org.apache.commons.bcel6.generic.GOTO;
|
||||||
|
import org.apache.commons.bcel6.generic.IFEQ;
|
||||||
import org.apache.commons.bcel6.generic.InstructionList;
|
import org.apache.commons.bcel6.generic.InstructionList;
|
||||||
|
|
||||||
import de.dhbwstuttgart.typeinference.Menge;
|
import de.dhbwstuttgart.typeinference.Menge;
|
||||||
@ -138,8 +142,20 @@ public class WhileStmt extends Statement
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InstructionList genByteCode(ClassGenerator _cg, TypeinferenceResultSet rs) {
|
public InstructionList genByteCode(ClassGenerator _cg, TypeinferenceResultSet rs) {
|
||||||
// TODO Bytecode
|
//TOD: while Statement
|
||||||
throw new NotImplementedException();
|
InstructionList il = expr.genByteCode(_cg, rs);
|
||||||
|
|
||||||
|
BranchInstruction ifeq = new IFEQ(null);
|
||||||
|
il.append(ifeq);
|
||||||
|
|
||||||
|
il.append(loop_block.genByteCode(_cg, rs));
|
||||||
|
|
||||||
|
il.append(new GOTO(il.getStart()));
|
||||||
|
|
||||||
|
ifeq.setTarget(il.append(new DUP()));
|
||||||
|
|
||||||
|
|
||||||
|
return il;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// ino.end
|
// ino.end
|
||||||
|
@ -20,15 +20,20 @@ import de.dhbwstuttgart.typeinference.Menge;
|
|||||||
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
||||||
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
|
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
|
||||||
|
|
||||||
public class AssignTest {
|
public class AssignTest extends SourceFileBytecodeTest{
|
||||||
|
@Override
|
||||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
protected void init() {
|
||||||
public final static String testFile = "Assign.jav";
|
testName = "Assign";
|
||||||
public final static String outputFile = "Assign.class";
|
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||||
|
|
||||||
@Test
|
|
||||||
public void test() {
|
|
||||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testConstruct() throws Exception{
|
||||||
|
ClassLoader classLoader = getClassLoader();
|
||||||
|
|
||||||
|
Class cls = classLoader.loadClass(testName);
|
||||||
|
|
||||||
|
Object obj = cls.newInstance();
|
||||||
|
assertTrue(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,15 +20,20 @@ import de.dhbwstuttgart.typeinference.Menge;
|
|||||||
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
||||||
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
|
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
|
||||||
|
|
||||||
public class BinaryTest {
|
public class BinaryTest extends SourceFileBytecodeTest{
|
||||||
|
@Override
|
||||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
protected void init() {
|
||||||
public final static String testFile = "Binary.jav";
|
testName = "Binary";
|
||||||
public final static String outputFile = "Binary.class";
|
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||||
|
|
||||||
@Test
|
|
||||||
public void test() {
|
|
||||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testConstruct() throws Exception{
|
||||||
|
ClassLoader classLoader = getClassLoader();
|
||||||
|
|
||||||
|
Class cls = classLoader.loadClass(testName);
|
||||||
|
|
||||||
|
Object obj = cls.newInstance();
|
||||||
|
assertTrue(true);
|
||||||
|
}
|
||||||
}
|
}
|
@ -20,15 +20,20 @@ import de.dhbwstuttgart.typeinference.Menge;
|
|||||||
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
||||||
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
|
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
|
||||||
|
|
||||||
public class BinaryTest2 {
|
public class BinaryTest2 extends SourceFileBytecodeTest{
|
||||||
|
@Override
|
||||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
protected void init() {
|
||||||
public final static String testFile = "Binary2.jav";
|
testName = "Binary2";
|
||||||
public final static String outputFile = "Binary2.class";
|
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||||
|
|
||||||
@Test
|
|
||||||
public void test() {
|
|
||||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testConstruct() throws Exception{
|
||||||
|
ClassLoader classLoader = getClassLoader();
|
||||||
|
|
||||||
|
Class cls = classLoader.loadClass(testName);
|
||||||
|
|
||||||
|
Object obj = cls.newInstance();
|
||||||
|
assertTrue(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,15 +20,20 @@ import de.dhbwstuttgart.typeinference.Menge;
|
|||||||
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
||||||
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
|
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
|
||||||
|
|
||||||
public class BoolLitTest {
|
public class BoolLitTest extends SourceFileBytecodeTest{
|
||||||
|
@Override
|
||||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
protected void init() {
|
||||||
public final static String testFile = "BoolLit.jav";
|
testName = "BoolLit";
|
||||||
public final static String outputFile = "BoolLit.class";
|
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||||
|
|
||||||
@Test
|
|
||||||
public void test() {
|
|
||||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testConstruct() throws Exception{
|
||||||
|
ClassLoader classLoader = getClassLoader();
|
||||||
|
|
||||||
|
Class cls = classLoader.loadClass(testName);
|
||||||
|
|
||||||
|
Object obj = cls.newInstance();
|
||||||
|
assertTrue(true);
|
||||||
|
}
|
||||||
}
|
}
|
@ -20,15 +20,20 @@ import de.dhbwstuttgart.typeinference.Menge;
|
|||||||
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
||||||
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
|
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
|
||||||
|
|
||||||
public class CharLitTest {
|
public class CharLitTest extends SourceFileBytecodeTest{
|
||||||
|
@Override
|
||||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
protected void init() {
|
||||||
public final static String testFile = "CharLitTest.jav";
|
testName = "CharLit";
|
||||||
public final static String outputFile = "CharLitTest.class";
|
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||||
|
|
||||||
@Test
|
|
||||||
public void test() {
|
|
||||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testConstruct() throws Exception{
|
||||||
|
ClassLoader classLoader = getClassLoader();
|
||||||
|
|
||||||
|
Class cls = classLoader.loadClass(testName);
|
||||||
|
|
||||||
|
Object obj = cls.newInstance();
|
||||||
|
assertTrue(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,15 +20,20 @@ import de.dhbwstuttgart.typeinference.Menge;
|
|||||||
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
||||||
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
|
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
|
||||||
|
|
||||||
public class ConditionTest {
|
public class ConditionTest extends SourceFileBytecodeTest{
|
||||||
|
@Override
|
||||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
protected void init() {
|
||||||
public final static String testFile = "Condition.jav";
|
testName = "Condition";
|
||||||
public final static String outputFile = "Condition.class";
|
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||||
|
|
||||||
@Test
|
|
||||||
public void test() {
|
|
||||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testConstruct() throws Exception{
|
||||||
|
ClassLoader classLoader = getClassLoader();
|
||||||
|
|
||||||
|
Class cls = classLoader.loadClass(testName);
|
||||||
|
|
||||||
|
Object obj = cls.newInstance();
|
||||||
|
assertTrue(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,15 +20,20 @@ import de.dhbwstuttgart.typeinference.Menge;
|
|||||||
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
||||||
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
|
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
|
||||||
|
|
||||||
public class EmptyClassTest {
|
public class EmptyClassTest extends SourceFileBytecodeTest{
|
||||||
|
@Override
|
||||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
protected void init() {
|
||||||
public final static String testFile = "EmptyClass.jav";
|
testName = "EmptyClass";
|
||||||
public final static String outputFile = "EmptyClass.class";
|
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||||
|
|
||||||
@Test
|
|
||||||
public void test() {
|
|
||||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testConstruct() throws Exception{
|
||||||
|
ClassLoader classLoader = getClassLoader();
|
||||||
|
|
||||||
|
Class cls = classLoader.loadClass(testName);
|
||||||
|
|
||||||
|
Object obj = cls.newInstance();
|
||||||
|
assertTrue(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,13 +2,20 @@ package bytecode;
|
|||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class FieldDeclarationTest {
|
public class FieldDeclarationTest extends SourceFileBytecodeTest{
|
||||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
@Override
|
||||||
public final static String testFile = "FieldDeclaration.jav";
|
protected void init() {
|
||||||
public final static String outputFile = "FieldDeclaration.class";
|
testName = "FieldDeclaration";
|
||||||
|
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test() {
|
public void testConstruct() throws Exception{
|
||||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
|
ClassLoader classLoader = getClassLoader();
|
||||||
|
|
||||||
|
Class cls = classLoader.loadClass(testName);
|
||||||
|
|
||||||
|
Object obj = cls.newInstance();
|
||||||
|
assertTrue(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,6 +1,6 @@
|
|||||||
class IfElse{
|
class ForTest{
|
||||||
method(){
|
void method(){
|
||||||
for( i = 0; i < 10 ; i = i++){
|
for(Integer i = 0; i < 10 ; i = i + 1){
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,14 +3,20 @@ package bytecode;
|
|||||||
import org.junit.Ignore;
|
import org.junit.Ignore;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class ForTest {
|
public class ForTest extends SourceFileBytecodeTest{
|
||||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
@Override
|
||||||
public final static String testFile = "ForTest.jav";
|
protected void init() {
|
||||||
public final static String outputFile = "ForTest.class";
|
testName = "ForTest";
|
||||||
|
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Ignore
|
public void testConstruct() throws Exception{
|
||||||
public void test() {
|
ClassLoader classLoader = getClassLoader();
|
||||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
|
|
||||||
|
Class cls = classLoader.loadClass(testName);
|
||||||
|
|
||||||
|
Object obj = cls.newInstance();
|
||||||
|
assertTrue(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,13 +2,20 @@ package bytecode;
|
|||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class IdTest {
|
public class IdTest extends SourceFileBytecodeTest{
|
||||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
@Override
|
||||||
public final static String testFile = "Id.jav";
|
protected void init() {
|
||||||
public final static String outputFile = "Id.class";
|
testName = "Id";
|
||||||
|
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test() {
|
public void testConstruct() throws Exception{
|
||||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
|
ClassLoader classLoader = getClassLoader();
|
||||||
|
|
||||||
|
Class cls = classLoader.loadClass(testName);
|
||||||
|
|
||||||
|
Object obj = cls.newInstance();
|
||||||
|
assertTrue(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,3 +1,3 @@
|
|||||||
class Id {
|
class IdentityField {
|
||||||
<GPM, FNF extends GPM> Fun1<? extends GPM, ? super FNF> op = (x) -> x;
|
<GPM, FNF extends GPM> Fun1<? extends GPM, ? super FNF> op = (x) -> x;
|
||||||
}
|
}
|
@ -2,13 +2,20 @@ package bytecode;
|
|||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class IdentityFieldTest {
|
public class IdentityFieldTest extends SourceFileBytecodeTest{
|
||||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
@Override
|
||||||
public final static String testFile = "IdentityField.jav";
|
protected void init() {
|
||||||
public final static String outputFile = "IdentityField.class";
|
testName = "IdentityField";
|
||||||
|
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test() {
|
public void testConstruct() throws Exception{
|
||||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
|
ClassLoader classLoader = getClassLoader();
|
||||||
|
|
||||||
|
Class cls = classLoader.loadClass(testName);
|
||||||
|
|
||||||
|
Object obj = cls.newInstance();
|
||||||
|
assertTrue(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -2,13 +2,20 @@ package bytecode;
|
|||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class IdentityTest {
|
public class IdentityTest extends SourceFileBytecodeTest{
|
||||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
@Override
|
||||||
public final static String testFile = "Identity.jav";
|
protected void init() {
|
||||||
public final static String outputFile = "Identity.class";
|
testName = "Identity";
|
||||||
|
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test() {
|
public void testConstruct() throws Exception{
|
||||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
|
ClassLoader classLoader = getClassLoader();
|
||||||
|
|
||||||
|
Class cls = classLoader.loadClass(testName);
|
||||||
|
|
||||||
|
Object obj = cls.newInstance();
|
||||||
|
assertTrue(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -4,6 +4,8 @@ class IfElseIfStatement{
|
|||||||
return 0;
|
return 0;
|
||||||
}else if(flag){
|
}else if(flag){
|
||||||
return 1;
|
return 1;
|
||||||
|
}else{
|
||||||
|
return 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,13 +2,20 @@ package bytecode;
|
|||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class IfElseIfStatementTest {
|
public class IfElseIfStatementTest extends SourceFileBytecodeTest{
|
||||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
@Override
|
||||||
public final static String testFile = "IfElseIfStatement.jav";
|
protected void init() {
|
||||||
public final static String outputFile = "IfElseIfStatement.class";
|
testName = "IfElseIfStatement";
|
||||||
|
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test() {
|
public void testConstruct() throws Exception{
|
||||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory);
|
ClassLoader classLoader = getClassLoader();
|
||||||
|
|
||||||
|
Class cls = classLoader.loadClass(testName);
|
||||||
|
|
||||||
|
Object obj = cls.newInstance();
|
||||||
|
assertTrue(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,13 +2,20 @@ package bytecode;
|
|||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class IfElseStatementTest {
|
public class IfElseStatementTest extends SourceFileBytecodeTest{
|
||||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
@Override
|
||||||
public final static String testFile = "IfElseStatement.jav";
|
protected void init() {
|
||||||
public final static String outputFile = "IfElseStatement.class";
|
testName = "IfElseStatement";
|
||||||
|
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test() {
|
public void testConstruct() throws Exception{
|
||||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory);
|
ClassLoader classLoader = getClassLoader();
|
||||||
|
|
||||||
|
Class cls = classLoader.loadClass(testName);
|
||||||
|
|
||||||
|
Object obj = cls.newInstance();
|
||||||
|
assertTrue(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,13 +2,20 @@ package bytecode;
|
|||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class IfStatementTest {
|
public class IfStatementTest extends SourceFileBytecodeTest{
|
||||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
@Override
|
||||||
public final static String testFile = "IfStatement.jav";
|
protected void init() {
|
||||||
public final static String outputFile = "IfStatement.class";
|
testName = "IfStatement";
|
||||||
|
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test() {
|
public void testConstruct() throws Exception{
|
||||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory);
|
ClassLoader classLoader = getClassLoader();
|
||||||
|
|
||||||
|
Class cls = classLoader.loadClass(testName);
|
||||||
|
|
||||||
|
Object obj = cls.newInstance();
|
||||||
|
assertTrue(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,16 +21,20 @@ import de.dhbwstuttgart.typeinference.Menge;
|
|||||||
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
||||||
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
|
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
|
||||||
|
|
||||||
public class LambdaExpr2 {
|
public class LambdaExpr2Test extends SourceFileBytecodeTest{
|
||||||
|
@Override
|
||||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
protected void init() {
|
||||||
public final static String testFile = "LambdaExpr2.jav";
|
testName = "LambdaExpr";
|
||||||
public final static String outputFile = "LambdaExpr2.class";
|
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||||
|
|
||||||
@Test
|
|
||||||
@Ignore
|
|
||||||
public void test() {
|
|
||||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testConstruct() throws Exception{
|
||||||
|
ClassLoader classLoader = getClassLoader();
|
||||||
|
|
||||||
|
Class cls = classLoader.loadClass(testName);
|
||||||
|
|
||||||
|
Object obj = cls.newInstance();
|
||||||
|
assertTrue(true);
|
||||||
|
}
|
||||||
}
|
}
|
@ -20,15 +20,20 @@ import de.dhbwstuttgart.typeinference.Menge;
|
|||||||
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
||||||
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
|
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
|
||||||
|
|
||||||
public class LambdaExpr {
|
public class LambdaExprTest extends SourceFileBytecodeTest{
|
||||||
|
@Override
|
||||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
protected void init() {
|
||||||
public final static String testFile = "LambdaExpr.jav";
|
testName = "LambdaExpr";
|
||||||
public final static String outputFile = "LambdaExpr.class";
|
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||||
|
|
||||||
@Test
|
|
||||||
public void test() {
|
|
||||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testConstruct() throws Exception{
|
||||||
|
ClassLoader classLoader = getClassLoader();
|
||||||
|
|
||||||
|
Class cls = classLoader.loadClass(testName);
|
||||||
|
|
||||||
|
Object obj = cls.newInstance();
|
||||||
|
assertTrue(true);
|
||||||
|
}
|
||||||
}
|
}
|
@ -20,15 +20,20 @@ import de.dhbwstuttgart.typeinference.Menge;
|
|||||||
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
||||||
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
|
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
|
||||||
|
|
||||||
public class MainTest {
|
public class MainTest extends SourceFileBytecodeTest{
|
||||||
|
@Override
|
||||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
protected void init() {
|
||||||
public final static String testFile = "Main.jav";
|
testName = "Main";
|
||||||
public final static String outputFile = "Main.class";
|
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||||
|
|
||||||
@Test
|
|
||||||
public void test() {
|
|
||||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testConstruct() throws Exception{
|
||||||
|
ClassLoader classLoader = getClassLoader();
|
||||||
|
|
||||||
|
Class cls = classLoader.loadClass(testName);
|
||||||
|
|
||||||
|
Object obj = cls.newInstance();
|
||||||
|
assertTrue(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
|
||||||
class Matrix extends Vector<Vector<Integer>> {
|
class Matrix_lambda extends Vector<Vector<Integer>> {
|
||||||
op = (Matrix m) -> (f) -> f.apply(this, m);
|
op = (Matrix m) -> (f) -> f.apply(this, m);
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
|
|
||||||
class Matrix2 {
|
class Matrix_lambda2 {
|
||||||
op = (f) -> f.apply(2);
|
op = (f) -> f.apply(2);
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
|
|
||||||
class Matrix3 {
|
class Matrix_lambda3 {
|
||||||
op = (f) -> f.apply();
|
op = (f) -> f.apply();
|
||||||
}
|
}
|
@ -2,13 +2,20 @@ package bytecode;
|
|||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class Matrix_lambdaTest {
|
public class Matrix_lambdaTest extends SourceFileBytecodeTest{
|
||||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
@Override
|
||||||
public final static String testFile = "Matrix_lambda.jav";
|
protected void init() {
|
||||||
public final static String outputFile = "Matrix_lambda.class";
|
testName = "Matrix_lambda";
|
||||||
|
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test() {
|
public void testConstruct() throws Exception{
|
||||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
|
ClassLoader classLoader = getClassLoader();
|
||||||
|
|
||||||
|
Class cls = classLoader.loadClass(testName);
|
||||||
|
|
||||||
|
Object obj = cls.newInstance();
|
||||||
|
assertTrue(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -2,13 +2,20 @@ package bytecode;
|
|||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class Matrix_lambdaTest2 {
|
public class Matrix_lambdaTest2 extends SourceFileBytecodeTest{
|
||||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
@Override
|
||||||
public final static String testFile = "Matrix_lambda2.jav";
|
protected void init() {
|
||||||
public final static String outputFile = "Matrix2.class";
|
testName = "Matrix_lambda2";
|
||||||
|
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test() {
|
public void testConstruct() throws Exception{
|
||||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
|
ClassLoader classLoader = getClassLoader();
|
||||||
|
|
||||||
|
Class cls = classLoader.loadClass(testName);
|
||||||
|
|
||||||
|
Object obj = cls.newInstance();
|
||||||
|
assertTrue(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -2,13 +2,20 @@ package bytecode;
|
|||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class Matrix_lambdaTest3 {
|
public class Matrix_lambdaTest3 extends SourceFileBytecodeTest{
|
||||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
@Override
|
||||||
public final static String testFile = "Matrix_lambda3.jav";
|
protected void init() {
|
||||||
public final static String outputFile = "Matrix3.class";
|
testName = "Matrix_lambda3";
|
||||||
|
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test() {
|
public void testConstruct() throws Exception{
|
||||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
|
ClassLoader classLoader = getClassLoader();
|
||||||
|
|
||||||
|
Class cls = classLoader.loadClass(testName);
|
||||||
|
|
||||||
|
Object obj = cls.newInstance();
|
||||||
|
assertTrue(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -20,15 +20,20 @@ import de.dhbwstuttgart.typeinference.Menge;
|
|||||||
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
||||||
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
|
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
|
||||||
|
|
||||||
public class MethodCallTest {
|
public class MethodCallTest extends SourceFileBytecodeTest{
|
||||||
|
@Override
|
||||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
protected void init() {
|
||||||
public final static String testFile = "MethodCall.jav";
|
testName = "MethodCall";
|
||||||
public final static String outputFile = "MethodCall.class";
|
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||||
|
|
||||||
@Test
|
|
||||||
public void test() {
|
|
||||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testConstruct() throws Exception{
|
||||||
|
ClassLoader classLoader = getClassLoader();
|
||||||
|
|
||||||
|
Class cls = classLoader.loadClass(testName);
|
||||||
|
|
||||||
|
Object obj = cls.newInstance();
|
||||||
|
assertTrue(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,15 +20,20 @@ import de.dhbwstuttgart.typeinference.Menge;
|
|||||||
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
||||||
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
|
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
|
||||||
|
|
||||||
public class MethodEmpty {
|
public class MethodEmpty extends SourceFileBytecodeTest{
|
||||||
|
@Override
|
||||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
protected void init() {
|
||||||
public final static String testFile = "MethodEmpty.jav";
|
testName = "MethodEmpty";
|
||||||
public final static String outputFile = "MethodEmpty.class";
|
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||||
|
|
||||||
@Test
|
|
||||||
public void test() {
|
|
||||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testConstruct() throws Exception{
|
||||||
|
ClassLoader classLoader = getClassLoader();
|
||||||
|
|
||||||
|
Class cls = classLoader.loadClass(testName);
|
||||||
|
|
||||||
|
Object obj = cls.newInstance();
|
||||||
|
assertTrue(true);
|
||||||
|
}
|
||||||
}
|
}
|
@ -20,15 +20,20 @@ import de.dhbwstuttgart.typeinference.Menge;
|
|||||||
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
||||||
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
|
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
|
||||||
|
|
||||||
public class MethodEmptyRetType {
|
public class MethodEmptyRetType extends SourceFileBytecodeTest{
|
||||||
|
@Override
|
||||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
protected void init() {
|
||||||
public final static String testFile = "MethodEmptyRetType.jav";
|
testName = "MethodEmptyRetType";
|
||||||
public final static String outputFile = "MethodEmptyRetType.class";
|
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||||
|
|
||||||
@Test
|
|
||||||
public void test() {
|
|
||||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testConstruct() throws Exception{
|
||||||
|
ClassLoader classLoader = getClassLoader();
|
||||||
|
|
||||||
|
Class cls = classLoader.loadClass(testName);
|
||||||
|
|
||||||
|
Object obj = cls.newInstance();
|
||||||
|
assertTrue(true);
|
||||||
|
}
|
||||||
}
|
}
|
@ -23,35 +23,20 @@ import de.dhbwstuttgart.typeinference.Menge;
|
|||||||
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
||||||
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
|
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
|
||||||
|
|
||||||
public class NewStatementTest {
|
public class NewStatementTest extends SourceFileBytecodeTest{
|
||||||
|
@Override
|
||||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
protected void init() {
|
||||||
public final static String testFile = "NewStatement.jav";
|
testName = "NewStatement";
|
||||||
public final static String outputFile = "NewStatement.class";
|
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test() {
|
public void testConstruct() throws Exception{
|
||||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory);
|
ClassLoader classLoader = getClassLoader();
|
||||||
}
|
|
||||||
/*
|
|
||||||
@Test
|
|
||||||
public void testUntypedVectorDeclaredMethods() {
|
|
||||||
try{
|
|
||||||
File file = new File(System.getProperty("user.dir")+"/test/bytecode/types/");
|
|
||||||
URL url = file.toURL();
|
|
||||||
URL[] urls = new URL[]{url};
|
|
||||||
|
|
||||||
ClassLoader classLoader = new URLClassLoader(urls);
|
Class cls = classLoader.loadClass(testName);
|
||||||
|
|
||||||
Class untypedVectorTest = classLoader.loadClass("UntypedVector");
|
Object obj = cls.newInstance();
|
||||||
|
assertTrue(true);
|
||||||
for(Method method: untypedVectorTest.getDeclaredMethods()){
|
|
||||||
System.out.println(method.toGenericString());
|
|
||||||
}
|
}
|
||||||
}catch(Exception e){
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -20,15 +20,20 @@ import de.dhbwstuttgart.typeinference.Menge;
|
|||||||
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
||||||
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
|
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
|
||||||
|
|
||||||
public class ParameterTest {
|
public class ParameterTest extends SourceFileBytecodeTest{
|
||||||
|
@Override
|
||||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
protected void init() {
|
||||||
public final static String testFile = "Parameter.jav";
|
testName = "Parameter";
|
||||||
public final static String outputFile = "Parameter.class";
|
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||||
|
|
||||||
@Test
|
|
||||||
public void test() {
|
|
||||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testConstruct() throws Exception{
|
||||||
|
ClassLoader classLoader = getClassLoader();
|
||||||
|
|
||||||
|
Class cls = classLoader.loadClass(testName);
|
||||||
|
|
||||||
|
Object obj = cls.newInstance();
|
||||||
|
assertTrue(true);
|
||||||
|
}
|
||||||
}
|
}
|
@ -21,16 +21,20 @@ import de.dhbwstuttgart.typeinference.Menge;
|
|||||||
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
||||||
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
|
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
|
||||||
|
|
||||||
public class PostDecrement {
|
public class PostDecrement extends SourceFileBytecodeTest{
|
||||||
|
@Override
|
||||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
protected void init() {
|
||||||
public final static String testFile = "PostDecrement.jav";
|
testName = "PostDecrement";
|
||||||
public final static String outputFile = "PostDecrement.class";
|
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||||
|
|
||||||
@Test
|
|
||||||
@Ignore
|
|
||||||
public void test() {
|
|
||||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testConstruct() throws Exception{
|
||||||
|
ClassLoader classLoader = getClassLoader();
|
||||||
|
|
||||||
|
Class cls = classLoader.loadClass(testName);
|
||||||
|
|
||||||
|
Object obj = cls.newInstance();
|
||||||
|
assertTrue(true);
|
||||||
|
}
|
||||||
}
|
}
|
@ -21,16 +21,20 @@ import de.dhbwstuttgart.typeinference.Menge;
|
|||||||
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
||||||
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
|
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
|
||||||
|
|
||||||
public class PostIncrement {
|
public class PostIncrement extends SourceFileBytecodeTest{
|
||||||
|
@Override
|
||||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
protected void init() {
|
||||||
public final static String testFile = "PostIncrement.jav";
|
testName = "PostIncrement";
|
||||||
public final static String outputFile = "PostIncrement.class";
|
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||||
|
|
||||||
@Test
|
|
||||||
@Ignore
|
|
||||||
public void test() {
|
|
||||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testConstruct() throws Exception{
|
||||||
|
ClassLoader classLoader = getClassLoader();
|
||||||
|
|
||||||
|
Class cls = classLoader.loadClass(testName);
|
||||||
|
|
||||||
|
Object obj = cls.newInstance();
|
||||||
|
assertTrue(true);
|
||||||
|
}
|
||||||
}
|
}
|
@ -20,15 +20,20 @@ import de.dhbwstuttgart.typeinference.Menge;
|
|||||||
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
||||||
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
|
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
|
||||||
|
|
||||||
public class ReturnTest {
|
public class ReturnTest extends SourceFileBytecodeTest{
|
||||||
|
@Override
|
||||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
protected void init() {
|
||||||
public final static String testFile = "Return.jav";
|
testName = "Return";
|
||||||
public final static String outputFile = "Return.class";
|
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||||
|
|
||||||
@Test
|
|
||||||
public void test() {
|
|
||||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testConstruct() throws Exception{
|
||||||
|
ClassLoader classLoader = getClassLoader();
|
||||||
|
|
||||||
|
Class cls = classLoader.loadClass(testName);
|
||||||
|
|
||||||
|
Object obj = cls.newInstance();
|
||||||
|
assertTrue(true);
|
||||||
|
}
|
||||||
}
|
}
|
@ -2,13 +2,20 @@ package bytecode;
|
|||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class RunnableTest {
|
public class RunnableTest extends SourceFileBytecodeTest{
|
||||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
@Override
|
||||||
public final static String testFile = "Runnable.jav";
|
protected void init() {
|
||||||
public final static String outputFile = "Runnable.class";
|
testName = "Runnable";
|
||||||
|
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test() {
|
public void testConstruct() throws Exception{
|
||||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
|
ClassLoader classLoader = getClassLoader();
|
||||||
|
|
||||||
|
Class cls = classLoader.loadClass(testName);
|
||||||
|
|
||||||
|
Object obj = cls.newInstance();
|
||||||
|
assertTrue(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -20,15 +20,20 @@ import de.dhbwstuttgart.typeinference.Menge;
|
|||||||
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
||||||
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
|
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
|
||||||
|
|
||||||
public class StringLitTest {
|
public class StringLitTest extends SourceFileBytecodeTest{
|
||||||
|
@Override
|
||||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
protected void init() {
|
||||||
public final static String testFile = "StringLitTest.jav";
|
testName = "StringLitTest";
|
||||||
public final static String outputFile = "StringLitTest.class";
|
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||||
|
|
||||||
@Test
|
|
||||||
public void test() {
|
|
||||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testConstruct() throws Exception{
|
||||||
|
ClassLoader classLoader = getClassLoader();
|
||||||
|
|
||||||
|
Class cls = classLoader.loadClass(testName);
|
||||||
|
|
||||||
|
Object obj = cls.newInstance();
|
||||||
|
assertTrue(true);
|
||||||
|
}
|
||||||
}
|
}
|
@ -20,15 +20,20 @@ import de.dhbwstuttgart.typeinference.Menge;
|
|||||||
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
||||||
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
|
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
|
||||||
|
|
||||||
public class SystemOutPrintlnTest {
|
public class SystemOutPrintlnTest extends SourceFileBytecodeTest{
|
||||||
|
@Override
|
||||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
protected void init() {
|
||||||
public final static String testFile = "SystemOutPrintln.jav";
|
testName = "SystemOutPrintln";
|
||||||
public final static String outputFile = "SystemOutPrintln.class";
|
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||||
|
|
||||||
@Test
|
|
||||||
public void test() {
|
|
||||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testConstruct() throws Exception{
|
||||||
|
ClassLoader classLoader = getClassLoader();
|
||||||
|
|
||||||
|
Class cls = classLoader.loadClass(testName);
|
||||||
|
|
||||||
|
Object obj = cls.newInstance();
|
||||||
|
assertTrue(true);
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,6 +1,6 @@
|
|||||||
class Test3{
|
class Test3{
|
||||||
|
|
||||||
public static void main(String[] args){
|
public static void main(String[] args){
|
||||||
System.out.println(new LambdaExpr2().op.apply());
|
System.out.println(new LambdaExpr2Test().op.apply());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
class IfElse{
|
class WhileTest{
|
||||||
method(){
|
void method(){
|
||||||
while(true){
|
Integer i;
|
||||||
|
i = 1;
|
||||||
|
while(i < 10){
|
||||||
|
i = i + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -2,13 +2,20 @@ package bytecode;
|
|||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class WhileTest {
|
public class WhileTest extends SourceFileBytecodeTest{
|
||||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
@Override
|
||||||
public final static String testFile = "WhileTest.jav";
|
protected void init() {
|
||||||
public final static String outputFile = "WhileTest.class";
|
testName = "WhileTest";
|
||||||
|
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test() {
|
public void testConstruct() throws Exception{
|
||||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
|
ClassLoader classLoader = getClassLoader();
|
||||||
|
|
||||||
|
Class cls = classLoader.loadClass(testName);
|
||||||
|
|
||||||
|
Object obj = cls.newInstance();
|
||||||
|
assertTrue(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
5
test/bytecode/operators/DivOperator.jav
Normal file
5
test/bytecode/operators/DivOperator.jav
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
class DivOperator{
|
||||||
|
Integer method(Integer x, Integer y){
|
||||||
|
return x / y;
|
||||||
|
}
|
||||||
|
}
|
53
test/bytecode/operators/DivOperatorTest.java
Normal file
53
test/bytecode/operators/DivOperatorTest.java
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
package bytecode.operators;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.net.URLClassLoader;
|
||||||
|
import java.util.Vector;
|
||||||
|
|
||||||
|
import org.junit.Ignore;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import bytecode.SourceFileBytecodeTest;
|
||||||
|
|
||||||
|
public class DivOperatorTest extends SourceFileBytecodeTest{
|
||||||
|
@Override
|
||||||
|
protected void init() {
|
||||||
|
testName = "DivOperator";
|
||||||
|
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/operators/";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testConstruct() throws Exception{
|
||||||
|
ClassLoader classLoader = getClassLoader();
|
||||||
|
|
||||||
|
Class cls = classLoader.loadClass(testName);
|
||||||
|
|
||||||
|
Object obj = cls.newInstance();
|
||||||
|
assertTrue(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testTwoIntegers() throws Exception{
|
||||||
|
ClassLoader classLoader = getClassLoader();
|
||||||
|
|
||||||
|
Class cls = classLoader.loadClass(testName);
|
||||||
|
|
||||||
|
Object obj = cls.newInstance();
|
||||||
|
|
||||||
|
Integer x = new Integer(1);
|
||||||
|
Integer y = new Integer(2);
|
||||||
|
|
||||||
|
Class[] params = new Class[]{
|
||||||
|
x.getClass(),
|
||||||
|
y.getClass(),
|
||||||
|
};
|
||||||
|
|
||||||
|
Method method = cls.getDeclaredMethod("method", params);
|
||||||
|
Integer returnValue = (Integer) method.invoke(obj, x, y);
|
||||||
|
assertEquals(new Integer(0), returnValue);
|
||||||
|
}
|
||||||
|
}
|
@ -2,31 +2,29 @@ package bytecode.operators;
|
|||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.net.URL;
|
|
||||||
import java.net.URLClassLoader;
|
|
||||||
import java.util.Vector;
|
|
||||||
|
|
||||||
import org.junit.Ignore;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import bytecode.SourceFileBytecodeTest;
|
import bytecode.SourceFileBytecodeTest;
|
||||||
|
|
||||||
public class EqualOperatorTest extends SourceFileBytecodeTest{
|
public class EqualOperatorTest extends RelOperatorTest{
|
||||||
@Override
|
@Override
|
||||||
protected void init() {
|
protected void init() {
|
||||||
testName = "EqualOperator";
|
testName = "EqualOperator";
|
||||||
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/operators/";
|
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/operators/";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Override
|
||||||
public void testConstruct() throws Exception{
|
protected Boolean getTest1x2ReturnValue() {
|
||||||
ClassLoader classLoader = getClassLoader();
|
return new Boolean(false);
|
||||||
|
}
|
||||||
|
|
||||||
Class cls = classLoader.loadClass(testName);
|
@Override
|
||||||
|
protected Boolean getTest2x2ReturnValue() {
|
||||||
|
return new Boolean(true);
|
||||||
|
}
|
||||||
|
|
||||||
Object obj = cls.newInstance();
|
@Override
|
||||||
assertTrue(true);
|
protected Boolean getTest2x1ReturnValue() {
|
||||||
|
return new Boolean(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
5
test/bytecode/operators/GreaterEqualOperator.jav
Normal file
5
test/bytecode/operators/GreaterEqualOperator.jav
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
class GreaterEqualOperator{
|
||||||
|
Boolean method(Integer x, Integer y){
|
||||||
|
return x >= y;
|
||||||
|
}
|
||||||
|
}
|
30
test/bytecode/operators/GreaterEqualOperatorTest.java
Normal file
30
test/bytecode/operators/GreaterEqualOperatorTest.java
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
package bytecode.operators;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import org.junit.Test;
|
||||||
|
import bytecode.SourceFileBytecodeTest;
|
||||||
|
|
||||||
|
public class GreaterEqualOperatorTest extends RelOperatorTest{
|
||||||
|
@Override
|
||||||
|
protected void init() {
|
||||||
|
testName = "GreaterEqualOperator";
|
||||||
|
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/operators/";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Boolean getTest1x2ReturnValue() {
|
||||||
|
return new Boolean(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Boolean getTest2x2ReturnValue() {
|
||||||
|
return new Boolean(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Boolean getTest2x1ReturnValue() {
|
||||||
|
return new Boolean(true);
|
||||||
|
}
|
||||||
|
}
|
5
test/bytecode/operators/GreaterOperator.jav
Normal file
5
test/bytecode/operators/GreaterOperator.jav
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
class GreaterOperator{
|
||||||
|
Boolean method(Integer x, Integer y){
|
||||||
|
return x > y;
|
||||||
|
}
|
||||||
|
}
|
30
test/bytecode/operators/GreaterOperatorTest.java
Normal file
30
test/bytecode/operators/GreaterOperatorTest.java
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
package bytecode.operators;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import org.junit.Test;
|
||||||
|
import bytecode.SourceFileBytecodeTest;
|
||||||
|
|
||||||
|
public class GreaterOperatorTest extends RelOperatorTest{
|
||||||
|
@Override
|
||||||
|
protected void init() {
|
||||||
|
testName = "GreaterOperator";
|
||||||
|
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/operators/";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Boolean getTest1x2ReturnValue() {
|
||||||
|
return new Boolean(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Boolean getTest2x2ReturnValue() {
|
||||||
|
return new Boolean(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Boolean getTest2x1ReturnValue() {
|
||||||
|
return new Boolean(true);
|
||||||
|
}
|
||||||
|
}
|
5
test/bytecode/operators/ModuloOperator.jav
Normal file
5
test/bytecode/operators/ModuloOperator.jav
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
class ModuloOperator{
|
||||||
|
Integer method(Integer x, Integer y){
|
||||||
|
return x % y;
|
||||||
|
}
|
||||||
|
}
|
53
test/bytecode/operators/ModuloOperatorTest.java
Normal file
53
test/bytecode/operators/ModuloOperatorTest.java
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
package bytecode.operators;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.net.URLClassLoader;
|
||||||
|
import java.util.Vector;
|
||||||
|
|
||||||
|
import org.junit.Ignore;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import bytecode.SourceFileBytecodeTest;
|
||||||
|
|
||||||
|
public class ModuloOperatorTest extends SourceFileBytecodeTest{
|
||||||
|
@Override
|
||||||
|
protected void init() {
|
||||||
|
testName = "ModuloOperator";
|
||||||
|
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/operators/";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testConstruct() throws Exception{
|
||||||
|
ClassLoader classLoader = getClassLoader();
|
||||||
|
|
||||||
|
Class cls = classLoader.loadClass(testName);
|
||||||
|
|
||||||
|
Object obj = cls.newInstance();
|
||||||
|
assertTrue(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testTwoIntegers() throws Exception{
|
||||||
|
ClassLoader classLoader = getClassLoader();
|
||||||
|
|
||||||
|
Class cls = classLoader.loadClass(testName);
|
||||||
|
|
||||||
|
Object obj = cls.newInstance();
|
||||||
|
|
||||||
|
Integer x = new Integer(1);
|
||||||
|
Integer y = new Integer(2);
|
||||||
|
|
||||||
|
Class[] params = new Class[]{
|
||||||
|
x.getClass(),
|
||||||
|
y.getClass(),
|
||||||
|
};
|
||||||
|
|
||||||
|
Method method = cls.getDeclaredMethod("method", params);
|
||||||
|
Integer returnValue = (Integer) method.invoke(obj, x, y);
|
||||||
|
assertEquals(new Integer(1), returnValue);
|
||||||
|
}
|
||||||
|
}
|
5
test/bytecode/operators/MulOperator.jav
Normal file
5
test/bytecode/operators/MulOperator.jav
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
class MulOperator{
|
||||||
|
Integer method(Integer x, Integer y){
|
||||||
|
return x * y;
|
||||||
|
}
|
||||||
|
}
|
53
test/bytecode/operators/MulOperatorTest.java
Normal file
53
test/bytecode/operators/MulOperatorTest.java
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
package bytecode.operators;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.net.URLClassLoader;
|
||||||
|
import java.util.Vector;
|
||||||
|
|
||||||
|
import org.junit.Ignore;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import bytecode.SourceFileBytecodeTest;
|
||||||
|
|
||||||
|
public class MulOperatorTest extends SourceFileBytecodeTest{
|
||||||
|
@Override
|
||||||
|
protected void init() {
|
||||||
|
testName = "MulOperator";
|
||||||
|
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/operators/";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testConstruct() throws Exception{
|
||||||
|
ClassLoader classLoader = getClassLoader();
|
||||||
|
|
||||||
|
Class cls = classLoader.loadClass(testName);
|
||||||
|
|
||||||
|
Object obj = cls.newInstance();
|
||||||
|
assertTrue(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testTwoIntegers() throws Exception{
|
||||||
|
ClassLoader classLoader = getClassLoader();
|
||||||
|
|
||||||
|
Class cls = classLoader.loadClass(testName);
|
||||||
|
|
||||||
|
Object obj = cls.newInstance();
|
||||||
|
|
||||||
|
Integer x = new Integer(1);
|
||||||
|
Integer y = new Integer(2);
|
||||||
|
|
||||||
|
Class[] params = new Class[]{
|
||||||
|
x.getClass(),
|
||||||
|
y.getClass(),
|
||||||
|
};
|
||||||
|
|
||||||
|
Method method = cls.getDeclaredMethod("method", params);
|
||||||
|
Integer returnValue = (Integer) method.invoke(obj, x, y);
|
||||||
|
assertEquals(new Integer(2), returnValue);
|
||||||
|
}
|
||||||
|
}
|
5
test/bytecode/operators/NotEqualOperator.jav
Normal file
5
test/bytecode/operators/NotEqualOperator.jav
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
class NotEqualOperator{
|
||||||
|
Boolean method(Integer x, Integer y){
|
||||||
|
return x != y;
|
||||||
|
}
|
||||||
|
}
|
30
test/bytecode/operators/NotEqualOperatorTest.java
Normal file
30
test/bytecode/operators/NotEqualOperatorTest.java
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
package bytecode.operators;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import org.junit.Test;
|
||||||
|
import bytecode.SourceFileBytecodeTest;
|
||||||
|
|
||||||
|
public class NotEqualOperatorTest extends RelOperatorTest{
|
||||||
|
@Override
|
||||||
|
protected void init() {
|
||||||
|
testName = "NotEqualOperator";
|
||||||
|
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/operators/";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Boolean getTest1x2ReturnValue() {
|
||||||
|
return new Boolean(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Boolean getTest2x2ReturnValue() {
|
||||||
|
return new Boolean(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Boolean getTest2x1ReturnValue() {
|
||||||
|
return new Boolean(true);
|
||||||
|
}
|
||||||
|
}
|
@ -13,7 +13,7 @@ import org.junit.Test;
|
|||||||
|
|
||||||
import bytecode.SourceFileBytecodeTest;
|
import bytecode.SourceFileBytecodeTest;
|
||||||
|
|
||||||
public class OROperatorTest extends SourceFileBytecodeTest{
|
public class OrOperatorTest extends SourceFileBytecodeTest{
|
||||||
@Override
|
@Override
|
||||||
protected void init() {
|
protected void init() {
|
||||||
testName = "OrOperator";
|
testName = "OrOperator";
|
86
test/bytecode/operators/RelOperatorTest.java
Normal file
86
test/bytecode/operators/RelOperatorTest.java
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
package bytecode.operators;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import org.junit.Test;
|
||||||
|
import bytecode.SourceFileBytecodeTest;
|
||||||
|
|
||||||
|
public abstract class RelOperatorTest extends SourceFileBytecodeTest{
|
||||||
|
@Test
|
||||||
|
public void testConstruct() throws Exception{
|
||||||
|
ClassLoader classLoader = getClassLoader();
|
||||||
|
|
||||||
|
Class cls = classLoader.loadClass(testName);
|
||||||
|
|
||||||
|
Object obj = cls.newInstance();
|
||||||
|
assertTrue(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test1x2() throws Exception{
|
||||||
|
ClassLoader classLoader = getClassLoader();
|
||||||
|
|
||||||
|
Class cls = classLoader.loadClass(testName);
|
||||||
|
|
||||||
|
Object obj = cls.newInstance();
|
||||||
|
|
||||||
|
Integer x = new Integer(1);
|
||||||
|
Integer y = new Integer(2);
|
||||||
|
|
||||||
|
Class[] params = new Class[]{
|
||||||
|
x.getClass(),
|
||||||
|
y.getClass(),
|
||||||
|
};
|
||||||
|
|
||||||
|
Method method = cls.getDeclaredMethod("method", params);
|
||||||
|
Boolean returnValue = (Boolean) method.invoke(obj, x, y);
|
||||||
|
assertEquals(getTest1x2ReturnValue(), returnValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test2x2() throws Exception{
|
||||||
|
ClassLoader classLoader = getClassLoader();
|
||||||
|
|
||||||
|
Class cls = classLoader.loadClass(testName);
|
||||||
|
|
||||||
|
Object obj = cls.newInstance();
|
||||||
|
|
||||||
|
Integer x = new Integer(2);
|
||||||
|
Integer y = new Integer(2);
|
||||||
|
|
||||||
|
Class[] params = new Class[]{
|
||||||
|
x.getClass(),
|
||||||
|
y.getClass(),
|
||||||
|
};
|
||||||
|
|
||||||
|
Method method = cls.getDeclaredMethod("method", params);
|
||||||
|
Boolean returnValue = (Boolean) method.invoke(obj, x, y);
|
||||||
|
assertEquals(getTest2x2ReturnValue(), returnValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test2x1() throws Exception{
|
||||||
|
ClassLoader classLoader = getClassLoader();
|
||||||
|
|
||||||
|
Class cls = classLoader.loadClass(testName);
|
||||||
|
|
||||||
|
Object obj = cls.newInstance();
|
||||||
|
|
||||||
|
Integer x = new Integer(2);
|
||||||
|
Integer y = new Integer(2);
|
||||||
|
|
||||||
|
Class[] params = new Class[]{
|
||||||
|
x.getClass(),
|
||||||
|
y.getClass(),
|
||||||
|
};
|
||||||
|
|
||||||
|
Method method = cls.getDeclaredMethod("method", params);
|
||||||
|
Boolean returnValue = (Boolean) method.invoke(obj, x, y);
|
||||||
|
assertEquals(getTest2x1ReturnValue(), returnValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract Boolean getTest1x2ReturnValue();
|
||||||
|
protected abstract Boolean getTest2x2ReturnValue();
|
||||||
|
protected abstract Boolean getTest2x1ReturnValue();
|
||||||
|
}
|
5
test/bytecode/operators/SmallerEqualOperator.jav
Normal file
5
test/bytecode/operators/SmallerEqualOperator.jav
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
class SmallerEqualOperator{
|
||||||
|
Boolean method(Integer x, Integer y){
|
||||||
|
return x <= y;
|
||||||
|
}
|
||||||
|
}
|
30
test/bytecode/operators/SmallerEqualOperatorTest.java
Normal file
30
test/bytecode/operators/SmallerEqualOperatorTest.java
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
package bytecode.operators;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import org.junit.Test;
|
||||||
|
import bytecode.SourceFileBytecodeTest;
|
||||||
|
|
||||||
|
public class SmallerEqualOperatorTest extends RelOperatorTest{
|
||||||
|
@Override
|
||||||
|
protected void init() {
|
||||||
|
testName = "SmallerEqual";
|
||||||
|
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/operators/";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Boolean getTest1x2ReturnValue() {
|
||||||
|
return new Boolean(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Boolean getTest2x2ReturnValue() {
|
||||||
|
return new Boolean(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Boolean getTest2x1ReturnValue() {
|
||||||
|
return new Boolean(false);
|
||||||
|
}
|
||||||
|
}
|
5
test/bytecode/operators/SmallerOperator.jav
Normal file
5
test/bytecode/operators/SmallerOperator.jav
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
class SmallerOperator{
|
||||||
|
Boolean method(Integer x, Integer y){
|
||||||
|
return x < y;
|
||||||
|
}
|
||||||
|
}
|
30
test/bytecode/operators/SmallerOperatorTest.java
Normal file
30
test/bytecode/operators/SmallerOperatorTest.java
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
package bytecode.operators;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import org.junit.Test;
|
||||||
|
import bytecode.SourceFileBytecodeTest;
|
||||||
|
|
||||||
|
public class SmallerOperatorTest extends RelOperatorTest{
|
||||||
|
@Override
|
||||||
|
protected void init() {
|
||||||
|
testName = "Smaller";
|
||||||
|
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/operators/";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Boolean getTest1x2ReturnValue() {
|
||||||
|
return new Boolean(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Boolean getTest2x2ReturnValue() {
|
||||||
|
return new Boolean(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Boolean getTest2x1ReturnValue() {
|
||||||
|
return new Boolean(false);
|
||||||
|
}
|
||||||
|
}
|
5
test/bytecode/operators/SubOperator.jav
Normal file
5
test/bytecode/operators/SubOperator.jav
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
class SubOperator{
|
||||||
|
Integer method(Integer x, Integer y){
|
||||||
|
return x - y;
|
||||||
|
}
|
||||||
|
}
|
53
test/bytecode/operators/SubOperatorTest.java
Normal file
53
test/bytecode/operators/SubOperatorTest.java
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
package bytecode.operators;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.net.URLClassLoader;
|
||||||
|
import java.util.Vector;
|
||||||
|
|
||||||
|
import org.junit.Ignore;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import bytecode.SourceFileBytecodeTest;
|
||||||
|
|
||||||
|
public class SubOperatorTest extends SourceFileBytecodeTest{
|
||||||
|
@Override
|
||||||
|
protected void init() {
|
||||||
|
testName = "SubOperator";
|
||||||
|
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/operators/";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testConstruct() throws Exception{
|
||||||
|
ClassLoader classLoader = getClassLoader();
|
||||||
|
|
||||||
|
Class cls = classLoader.loadClass(testName);
|
||||||
|
|
||||||
|
Object obj = cls.newInstance();
|
||||||
|
assertTrue(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testTwoIntegers() throws Exception{
|
||||||
|
ClassLoader classLoader = getClassLoader();
|
||||||
|
|
||||||
|
Class cls = classLoader.loadClass(testName);
|
||||||
|
|
||||||
|
Object obj = cls.newInstance();
|
||||||
|
|
||||||
|
Integer x = new Integer(1);
|
||||||
|
Integer y = new Integer(2);
|
||||||
|
|
||||||
|
Class[] params = new Class[]{
|
||||||
|
x.getClass(),
|
||||||
|
y.getClass(),
|
||||||
|
};
|
||||||
|
|
||||||
|
Method method = cls.getDeclaredMethod("method", params);
|
||||||
|
Integer returnValue = (Integer) method.invoke(obj, x, y);
|
||||||
|
assertEquals(new Integer(-1), returnValue);
|
||||||
|
}
|
||||||
|
}
|
@ -1,10 +1,10 @@
|
|||||||
class IfStatement{
|
class IfStatement{
|
||||||
Integer methode(Boolean b){
|
Integer methode(Boolean b){
|
||||||
if(b){
|
if(b){
|
||||||
return 1;
|
return 1;
|
||||||
}else{
|
}else{
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -3,14 +3,22 @@ package bytecode.stackmaptable;
|
|||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import bytecode.SingleClassTester;
|
import bytecode.SingleClassTester;
|
||||||
|
import bytecode.SourceFileBytecodeTest;
|
||||||
|
|
||||||
public class IfStatementTest {
|
public class IfStatementTest extends SourceFileBytecodeTest{
|
||||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/stackmaptable/";
|
@Override
|
||||||
public final static String testFile = "IfStatement.jav";
|
protected void init() {
|
||||||
public final static String outputFile = "IfStatement.class";
|
testName = "IfStatement";
|
||||||
|
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/stackmaptable/";
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test() {
|
public void testConstruct() throws Exception{
|
||||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory);
|
ClassLoader classLoader = getClassLoader();
|
||||||
|
|
||||||
|
Class cls = classLoader.loadClass(testName);
|
||||||
|
|
||||||
|
Object obj = cls.newInstance();
|
||||||
|
assertTrue(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user