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(){
|
||||
try {
|
||||
//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+"IntLiteral.class").parse(), new FileOutputStream(new File(rootDirectory+"IntLiteralCreator.java"))).start();
|
||||
new BCELifier(new ClassParser(rootDirectory+"MethodCall.class").parse(), new FileOutputStream(new File(rootDirectory+"MethodCallCreator.java"))).start();
|
||||
new BCELifier(new ClassParser(rootDirectory+"FieldDeclaration.class").parse(), new FileOutputStream(new File(rootDirectory+"FieldDeclarationCreator.java"))).start();
|
||||
new BCELifier(new ClassParser(rootDirectory+"Null.class").parse(), new FileOutputStream(new File(rootDirectory+"NullCreator.java"))).start();
|
||||
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+"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+"This.class").parse(), new FileOutputStream(new File(rootDirectory+"ThisCreator.java"))).start();
|
||||
//new BCELifier(new ClassParser(rootDirectory+"IntLiteral.class").parse(), new FileOutputStream(new File(rootDirectory+"IntLiteralCreator.java"))).start();
|
||||
//new BCELifier(new ClassParser(rootDirectory+"MethodCall.class").parse(), new FileOutputStream(new File(rootDirectory+"MethodCallCreator.java"))).start();
|
||||
//new BCELifier(new ClassParser(rootDirectory+"FieldDeclaration.class").parse(), new FileOutputStream(new File(rootDirectory+"FieldDeclarationCreator.java"))).start();
|
||||
//new BCELifier(new ClassParser(rootDirectory+"Null.class").parse(), new FileOutputStream(new File(rootDirectory+"NullCreator.java"))).start();
|
||||
//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+"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+"IfStatement.class").parse(), new FileOutputStream(new File(rootDirectory+"IfStatementCreator.java"))).start();
|
||||
} catch (ClassFormatException | IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -139,7 +139,7 @@ public class DHBWInstructionFactory extends InstructionFactory{
|
||||
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));
|
||||
}
|
||||
|
||||
@ -147,7 +147,7 @@ public class DHBWInstructionFactory extends InstructionFactory{
|
||||
return InstructionFactory.createStore(bytecodeType, getStoreIndex(variableName));
|
||||
}
|
||||
|
||||
public Integer getStoreIndex(String variableName) {
|
||||
public static Integer getStoreIndex(String variableName) {
|
||||
if(storeIndexes.get(variableName) == null){
|
||||
Integer index = storeIndexes.size()+1;
|
||||
storeIndexes.put(variableName, index);
|
||||
|
@ -1,6 +1,7 @@
|
||||
// ino.module.Method.8564.package
|
||||
package de.dhbwstuttgart.syntaxtree;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Hashtable;
|
||||
@ -406,45 +407,37 @@ public class Method extends Field implements IItemWithOffset, TypeInsertable
|
||||
DHBWInstructionFactory _factory = cg.getInstructionFactory();
|
||||
|
||||
for(TypeinferenceResultSet t: typeInterferenceResults){
|
||||
DHBWConstantPoolGen _cp = cg.getConstantPool();
|
||||
InstructionList il = new InstructionList();
|
||||
Class parentClass = this.getParentClass();
|
||||
|
||||
//Die Argumentliste generieren:
|
||||
org.apache.commons.bcel6.generic.Type[] argumentTypes = org.apache.commons.bcel6.generic.Type.NO_ARGS;
|
||||
String[] argumentNames = new String[]{};
|
||||
if(this.parameterlist != null && this.parameterlist.size() > 0){
|
||||
argumentTypes = new org.apache.commons.bcel6.generic.Type[this.parameterlist.size()];
|
||||
argumentNames = new String[this.parameterlist.size()];
|
||||
int i = 0;
|
||||
for(FormalParameter parameter : this.parameterlist){
|
||||
argumentTypes[i] = parameter.getType().getBytecodeType(cg, t);
|
||||
argumentNames[i] = parameter.getIdentifier();
|
||||
|
||||
|
||||
_factory.getStoreIndex(parameter.getIdentifier());
|
||||
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
String nameAndSignature = get_Method_Name()+Arrays.toString(argumentTypes);
|
||||
|
||||
Logger.getLogger("nameAndSignature").error(nameAndSignature, Section.CODEGEN);
|
||||
|
||||
addMethodToClassGenerator(cg, _factory, t);
|
||||
}
|
||||
}
|
||||
|
||||
short constants = Constants.ACC_PUBLIC; //Per Definition ist jede Methode public
|
||||
if(this.modifiers != null && this.modifiers.includesModifier(new Static())) constants += Constants.ACC_STATIC;
|
||||
|
||||
Type returnType = this.getType();
|
||||
private void addMethodToClassGenerator(ClassGenerator cg, DHBWInstructionFactory _factory, TypeinferenceResultSet t) {
|
||||
DHBWConstantPoolGen _cp = cg.getConstantPool();
|
||||
InstructionList il = new InstructionList();
|
||||
|
||||
ArrayList<org.apache.commons.bcel6.generic.Type> argumentTypes = new ArrayList<org.apache.commons.bcel6.generic.Type>();
|
||||
ArrayList<String> argumentNames = new ArrayList<String>();
|
||||
|
||||
if(this.parameterlist != null && this.parameterlist.size() > 0){
|
||||
generateArgumentList(argumentTypes, argumentNames, cg, _factory, t);
|
||||
}
|
||||
|
||||
short constants = Constants.ACC_PUBLIC;
|
||||
if(this.modifiers != null && this.modifiers.includesModifier(new Static())) constants += Constants.ACC_STATIC;
|
||||
|
||||
Type returnType = this.getType();
|
||||
|
||||
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);
|
||||
|
||||
cg.addMethod(method.createMethod(cg, getParameterList(), returnType, get_Block(), t));
|
||||
}
|
||||
|
||||
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());
|
||||
|
||||
//Methode generieren:
|
||||
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));
|
||||
|
||||
Logger.getLogger("createMethod").debug(this.toString(), Section.CODEGEN);
|
||||
_factory.getStoreIndex(parameter.getIdentifier());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -170,7 +170,7 @@ public class UnifyTypeFactory {
|
||||
}
|
||||
|
||||
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);
|
||||
ret.set_ParaList(convert(t.getTypeParams()));
|
||||
return ret;
|
||||
|
@ -5,8 +5,17 @@ package de.dhbwstuttgart.syntaxtree.operator;
|
||||
import java.util.HashMap;
|
||||
import java.util.Hashtable;
|
||||
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.JVMCodeException;
|
||||
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.exceptions.DebugException;
|
||||
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;
|
||||
}
|
||||
|
||||
@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
|
||||
|
@ -4,6 +4,9 @@ package de.dhbwstuttgart.syntaxtree.operator;
|
||||
// ino.module.DivideOp.8596.import
|
||||
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.syntaxtree.SyntaxTreeNode;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.Binary;
|
||||
@ -26,8 +29,9 @@ public class DivideOp extends MulOp
|
||||
}
|
||||
// ino.end
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
ArithmeticInstruction getOperator(String returnType) {
|
||||
return new IDIV();
|
||||
}
|
||||
}
|
||||
// ino.end
|
||||
|
@ -47,36 +47,8 @@ public class EqualOp extends RelOp
|
||||
// ino.end
|
||||
|
||||
@Override
|
||||
public InstructionList genByteCode(ClassGenerator _cg, TypeinferenceResultSet rs, Binary operator) {
|
||||
DHBWInstructionFactory _factory = _cg.getInstructionFactory();
|
||||
|
||||
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;
|
||||
BranchInstruction getOperator() {
|
||||
return new IF_ICMPNE(null);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -4,6 +4,9 @@ package de.dhbwstuttgart.syntaxtree.operator;
|
||||
// ino.module.GreaterEquOp.8598.import
|
||||
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.syntaxtree.SyntaxTreeNode;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.Binary;
|
||||
@ -25,6 +28,11 @@ public class GreaterEquOp extends RelOp
|
||||
super(offset,variableLength);
|
||||
}
|
||||
// ino.end
|
||||
|
||||
@Override
|
||||
BranchInstruction getOperator() {
|
||||
return new IF_ICMPLT(null);
|
||||
}
|
||||
|
||||
}
|
||||
// ino.end
|
||||
|
@ -4,6 +4,9 @@ package de.dhbwstuttgart.syntaxtree.operator;
|
||||
// ino.module.GreaterOp.8599.import
|
||||
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.syntaxtree.statement.Binary;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.Expr;
|
||||
@ -25,5 +28,10 @@ public class GreaterOp extends RelOp
|
||||
}
|
||||
// ino.end
|
||||
|
||||
@Override
|
||||
BranchInstruction getOperator() {
|
||||
return new IF_ICMPLE(null);
|
||||
}
|
||||
|
||||
}
|
||||
// ino.end
|
||||
|
@ -4,6 +4,9 @@ package de.dhbwstuttgart.syntaxtree.operator;
|
||||
// ino.module.LessEquOp.8600.import
|
||||
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.syntaxtree.statement.Binary;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.Expr;
|
||||
@ -25,5 +28,10 @@ public class LessEquOp extends RelOp
|
||||
}
|
||||
// ino.end
|
||||
|
||||
@Override
|
||||
BranchInstruction getOperator() {
|
||||
return new IF_ICMPGT(null);
|
||||
}
|
||||
|
||||
}
|
||||
// ino.end
|
||||
|
@ -3,6 +3,8 @@ package de.dhbwstuttgart.syntaxtree.operator;
|
||||
// ino.end
|
||||
// ino.module.LessOp.8601.import
|
||||
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.syntaxtree.statement.Binary;
|
||||
@ -25,5 +27,10 @@ public class LessOp extends RelOp
|
||||
}
|
||||
// ino.end
|
||||
|
||||
@Override
|
||||
BranchInstruction getOperator() {
|
||||
return new IF_ICMPGE(null);
|
||||
}
|
||||
|
||||
}
|
||||
// ino.end
|
||||
|
@ -4,6 +4,10 @@ package de.dhbwstuttgart.syntaxtree.operator;
|
||||
// ino.module.MinusOp.8603.import
|
||||
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.syntaxtree.statement.Binary;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.Expr;
|
||||
@ -25,6 +29,8 @@ public class MinusOp extends AddOp
|
||||
}
|
||||
// ino.end
|
||||
|
||||
|
||||
ArithmeticInstruction getOperator(String returnType) {
|
||||
return new ISUB();
|
||||
}
|
||||
}
|
||||
// ino.end
|
||||
|
@ -4,6 +4,9 @@ package de.dhbwstuttgart.syntaxtree.operator;
|
||||
// ino.module.ModuloOp.8604.import
|
||||
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.syntaxtree.statement.Binary;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.Expr;
|
||||
@ -25,5 +28,10 @@ public class ModuloOp extends MulOp
|
||||
}
|
||||
// ino.end
|
||||
|
||||
@Override
|
||||
ArithmeticInstruction getOperator(String returnType) {
|
||||
return new IREM();
|
||||
}
|
||||
|
||||
}
|
||||
// ino.end
|
||||
|
@ -6,16 +6,27 @@ package de.dhbwstuttgart.syntaxtree.operator;
|
||||
import java.util.HashMap;
|
||||
import java.util.Hashtable;
|
||||
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.syntaxtree.statement.Binary;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.Expr;
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
||||
import de.dhbwstuttgart.syntaxtree.type.Type;
|
||||
import de.dhbwstuttgart.typeinference.Pair;
|
||||
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
||||
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
|
||||
import de.dhbwstuttgart.typeinference.exceptions.DebugException;
|
||||
import de.dhbwstuttgart.typeinference.unify.TypeUnify;
|
||||
import de.dhbwstuttgart.typeinference.exceptions.NotImplementedException;
|
||||
|
||||
// ino.class.MulOp.24231.declaration
|
||||
public abstract class MulOp extends Operator
|
||||
@ -50,6 +61,44 @@ public abstract class MulOp extends Operator
|
||||
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
|
||||
|
@ -3,7 +3,6 @@ package de.dhbwstuttgart.syntaxtree.operator;
|
||||
// ino.end
|
||||
// ino.module.NotEqualOp.8606.import
|
||||
import java.util.Iterator;
|
||||
import de.dhbwstuttgart.typeinference.Menge;
|
||||
|
||||
import de.dhbwstuttgart.myexception.CTypeReconstructionException;
|
||||
import de.dhbwstuttgart.myexception.JVMCodeException;
|
||||
@ -13,6 +12,9 @@ import de.dhbwstuttgart.syntaxtree.statement.Null;
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
||||
import de.dhbwstuttgart.typeinference.Pair;
|
||||
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
|
||||
public class NotEqualOp extends RelOp
|
||||
@ -28,5 +30,10 @@ public class NotEqualOp extends RelOp
|
||||
}
|
||||
// ino.end
|
||||
|
||||
@Override
|
||||
BranchInstruction getOperator() {
|
||||
return new IF_ACMPEQ(null);
|
||||
}
|
||||
|
||||
}
|
||||
// ino.end
|
||||
|
@ -6,6 +6,7 @@ import java.util.HashMap;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.apache.commons.bcel6.Constants;
|
||||
import org.apache.commons.bcel6.generic.InstructionList;
|
||||
|
||||
import de.dhbwstuttgart.typeinference.Menge;
|
||||
@ -75,5 +76,13 @@ public abstract class Operator extends SyntaxTreeNode
|
||||
public Menge<SyntaxTreeNode> getChildren() {
|
||||
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
|
||||
|
@ -41,54 +41,9 @@ public class PlusOp extends AddOp
|
||||
super(offset,variableLength);
|
||||
}
|
||||
// ino.end
|
||||
|
||||
@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";
|
||||
}
|
||||
|
||||
private ArithmeticInstruction getOperator(String returnType) {
|
||||
|
||||
ArithmeticInstruction getOperator(String returnType) {
|
||||
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
|
||||
|
@ -6,14 +6,24 @@ package de.dhbwstuttgart.syntaxtree.operator;
|
||||
import java.util.HashMap;
|
||||
import java.util.Hashtable;
|
||||
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.JVMCodeException;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.Binary;
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
||||
import de.dhbwstuttgart.syntaxtree.type.Type;
|
||||
import de.dhbwstuttgart.typeinference.Pair;
|
||||
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
||||
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
|
||||
import de.dhbwstuttgart.typeinference.exceptions.DebugException;
|
||||
import de.dhbwstuttgart.typeinference.unify.TypeUnify;
|
||||
@ -54,6 +64,45 @@ public abstract class RelOp extends Operator
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@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
|
||||
|
@ -5,6 +5,9 @@ package de.dhbwstuttgart.syntaxtree.operator;
|
||||
// ino.module.TimesOp.8611.import
|
||||
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.syntaxtree.statement.Binary;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.Expr;
|
||||
@ -23,5 +26,10 @@ public class TimesOp extends MulOp
|
||||
}
|
||||
// ino.end
|
||||
|
||||
@Override
|
||||
ArithmeticInstruction getOperator(String returnType) {
|
||||
return new IMUL();
|
||||
}
|
||||
|
||||
}
|
||||
// ino.end
|
||||
|
@ -38,10 +38,6 @@ import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
|
||||
import de.dhbwstuttgart.typeinference.exceptions.NotImplementedException;
|
||||
import de.dhbwstuttgart.typeinference.unify.TypeUnify;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public class ForStmt extends Statement
|
||||
{
|
||||
|
||||
|
@ -6,7 +6,11 @@ import java.util.Enumeration;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.apache.commons.bcel6.generic.BranchInstruction;
|
||||
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 de.dhbwstuttgart.typeinference.Menge;
|
||||
@ -138,8 +142,20 @@ public class WhileStmt extends Statement
|
||||
|
||||
@Override
|
||||
public InstructionList genByteCode(ClassGenerator _cg, TypeinferenceResultSet rs) {
|
||||
// TODO Bytecode
|
||||
throw new NotImplementedException();
|
||||
//TOD: while Statement
|
||||
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
|
||||
|
@ -20,15 +20,20 @@ import de.dhbwstuttgart.typeinference.Menge;
|
||||
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
||||
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet;
|
||||
|
||||
public class AssignTest {
|
||||
|
||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||
public final static String testFile = "Assign.jav";
|
||||
public final static String outputFile = "Assign.class";
|
||||
public class AssignTest extends SourceFileBytecodeTest{
|
||||
@Override
|
||||
protected void init() {
|
||||
testName = "Assign";
|
||||
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
|
||||
}
|
||||
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.typedeployment.TypeInsertSet;
|
||||
|
||||
public class BinaryTest {
|
||||
|
||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||
public final static String testFile = "Binary.jav";
|
||||
public final static String outputFile = "Binary.class";
|
||||
public class BinaryTest extends SourceFileBytecodeTest{
|
||||
@Override
|
||||
protected void init() {
|
||||
testName = "Binary";
|
||||
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
|
||||
}
|
||||
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.typedeployment.TypeInsertSet;
|
||||
|
||||
public class BinaryTest2 {
|
||||
|
||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||
public final static String testFile = "Binary2.jav";
|
||||
public final static String outputFile = "Binary2.class";
|
||||
public class BinaryTest2 extends SourceFileBytecodeTest{
|
||||
@Override
|
||||
protected void init() {
|
||||
testName = "Binary2";
|
||||
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory);
|
||||
}
|
||||
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.typedeployment.TypeInsertSet;
|
||||
|
||||
public class BoolLitTest {
|
||||
|
||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||
public final static String testFile = "BoolLit.jav";
|
||||
public final static String outputFile = "BoolLit.class";
|
||||
public class BoolLitTest extends SourceFileBytecodeTest{
|
||||
@Override
|
||||
protected void init() {
|
||||
testName = "BoolLit";
|
||||
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
|
||||
}
|
||||
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.typedeployment.TypeInsertSet;
|
||||
|
||||
public class CharLitTest {
|
||||
|
||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||
public final static String testFile = "CharLitTest.jav";
|
||||
public final static String outputFile = "CharLitTest.class";
|
||||
public class CharLitTest extends SourceFileBytecodeTest{
|
||||
@Override
|
||||
protected void init() {
|
||||
testName = "CharLit";
|
||||
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
|
||||
}
|
||||
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.typedeployment.TypeInsertSet;
|
||||
|
||||
public class ConditionTest {
|
||||
|
||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||
public final static String testFile = "Condition.jav";
|
||||
public final static String outputFile = "Condition.class";
|
||||
public class ConditionTest extends SourceFileBytecodeTest{
|
||||
@Override
|
||||
protected void init() {
|
||||
testName = "Condition";
|
||||
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
|
||||
}
|
||||
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.typedeployment.TypeInsertSet;
|
||||
|
||||
public class EmptyClassTest {
|
||||
|
||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||
public final static String testFile = "EmptyClass.jav";
|
||||
public final static String outputFile = "EmptyClass.class";
|
||||
public class EmptyClassTest extends SourceFileBytecodeTest{
|
||||
@Override
|
||||
protected void init() {
|
||||
testName = "EmptyClass";
|
||||
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
|
||||
}
|
||||
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;
|
||||
|
||||
public class FieldDeclarationTest {
|
||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||
public final static String testFile = "FieldDeclaration.jav";
|
||||
public final static String outputFile = "FieldDeclaration.class";
|
||||
public class FieldDeclarationTest extends SourceFileBytecodeTest{
|
||||
@Override
|
||||
protected void init() {
|
||||
testName = "FieldDeclaration";
|
||||
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
|
||||
public void testConstruct() throws Exception{
|
||||
ClassLoader classLoader = getClassLoader();
|
||||
|
||||
Class cls = classLoader.loadClass(testName);
|
||||
|
||||
Object obj = cls.newInstance();
|
||||
assertTrue(true);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
class IfElse{
|
||||
method(){
|
||||
for( i = 0; i < 10 ; i = i++){
|
||||
class ForTest{
|
||||
void method(){
|
||||
for(Integer i = 0; i < 10 ; i = i + 1){
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -3,14 +3,20 @@ package bytecode;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
public class ForTest {
|
||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||
public final static String testFile = "ForTest.jav";
|
||||
public final static String outputFile = "ForTest.class";
|
||||
public class ForTest extends SourceFileBytecodeTest{
|
||||
@Override
|
||||
protected void init() {
|
||||
testName = "ForTest";
|
||||
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void test() {
|
||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
|
||||
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;
|
||||
|
||||
public class IdTest {
|
||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||
public final static String testFile = "Id.jav";
|
||||
public final static String outputFile = "Id.class";
|
||||
public class IdTest extends SourceFileBytecodeTest{
|
||||
@Override
|
||||
protected void init() {
|
||||
testName = "Id";
|
||||
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
|
||||
public void testConstruct() throws Exception{
|
||||
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;
|
||||
}
|
@ -2,13 +2,20 @@ package bytecode;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class IdentityFieldTest {
|
||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||
public final static String testFile = "IdentityField.jav";
|
||||
public final static String outputFile = "IdentityField.class";
|
||||
public class IdentityFieldTest extends SourceFileBytecodeTest{
|
||||
@Override
|
||||
protected void init() {
|
||||
testName = "IdentityField";
|
||||
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
|
||||
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;
|
||||
|
||||
public class IdentityTest {
|
||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||
public final static String testFile = "Identity.jav";
|
||||
public final static String outputFile = "Identity.class";
|
||||
public class IdentityTest extends SourceFileBytecodeTest{
|
||||
@Override
|
||||
protected void init() {
|
||||
testName = "Identity";
|
||||
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
|
||||
public void testConstruct() throws Exception{
|
||||
ClassLoader classLoader = getClassLoader();
|
||||
|
||||
Class cls = classLoader.loadClass(testName);
|
||||
|
||||
Object obj = cls.newInstance();
|
||||
assertTrue(true);
|
||||
}
|
||||
}
|
||||
}
|
@ -4,6 +4,8 @@ class IfElseIfStatement{
|
||||
return 0;
|
||||
}else if(flag){
|
||||
return 1;
|
||||
}else{
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,13 +2,20 @@ package bytecode;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class IfElseIfStatementTest {
|
||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||
public final static String testFile = "IfElseIfStatement.jav";
|
||||
public final static String outputFile = "IfElseIfStatement.class";
|
||||
public class IfElseIfStatementTest extends SourceFileBytecodeTest{
|
||||
@Override
|
||||
protected void init() {
|
||||
testName = "IfElseIfStatement";
|
||||
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory);
|
||||
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;
|
||||
|
||||
public class IfElseStatementTest {
|
||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||
public final static String testFile = "IfElseStatement.jav";
|
||||
public final static String outputFile = "IfElseStatement.class";
|
||||
public class IfElseStatementTest extends SourceFileBytecodeTest{
|
||||
@Override
|
||||
protected void init() {
|
||||
testName = "IfElseStatement";
|
||||
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory);
|
||||
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;
|
||||
|
||||
public class IfStatementTest {
|
||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||
public final static String testFile = "IfStatement.jav";
|
||||
public final static String outputFile = "IfStatement.class";
|
||||
public class IfStatementTest extends SourceFileBytecodeTest{
|
||||
@Override
|
||||
protected void init() {
|
||||
testName = "IfStatement";
|
||||
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory);
|
||||
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.typedeployment.TypeInsertSet;
|
||||
|
||||
public class LambdaExpr2 {
|
||||
|
||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||
public final static String testFile = "LambdaExpr2.jav";
|
||||
public final static String outputFile = "LambdaExpr2.class";
|
||||
public class LambdaExpr2Test extends SourceFileBytecodeTest{
|
||||
@Override
|
||||
protected void init() {
|
||||
testName = "LambdaExpr";
|
||||
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void test() {
|
||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
|
||||
}
|
||||
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.typedeployment.TypeInsertSet;
|
||||
|
||||
public class LambdaExpr {
|
||||
|
||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||
public final static String testFile = "LambdaExpr.jav";
|
||||
public final static String outputFile = "LambdaExpr.class";
|
||||
public class LambdaExprTest extends SourceFileBytecodeTest{
|
||||
@Override
|
||||
protected void init() {
|
||||
testName = "LambdaExpr";
|
||||
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
|
||||
}
|
||||
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.typedeployment.TypeInsertSet;
|
||||
|
||||
public class MainTest {
|
||||
|
||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||
public final static String testFile = "Main.jav";
|
||||
public final static String outputFile = "Main.class";
|
||||
public class MainTest extends SourceFileBytecodeTest{
|
||||
@Override
|
||||
protected void init() {
|
||||
testName = "Main";
|
||||
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory);
|
||||
}
|
||||
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;
|
||||
|
||||
class Matrix extends Vector<Vector<Integer>> {
|
||||
class Matrix_lambda extends Vector<Vector<Integer>> {
|
||||
op = (Matrix m) -> (f) -> f.apply(this, m);
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
|
||||
class Matrix2 {
|
||||
class Matrix_lambda2 {
|
||||
op = (f) -> f.apply(2);
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
|
||||
class Matrix3 {
|
||||
class Matrix_lambda3 {
|
||||
op = (f) -> f.apply();
|
||||
}
|
@ -2,13 +2,20 @@ package bytecode;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class Matrix_lambdaTest {
|
||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||
public final static String testFile = "Matrix_lambda.jav";
|
||||
public final static String outputFile = "Matrix_lambda.class";
|
||||
public class Matrix_lambdaTest extends SourceFileBytecodeTest{
|
||||
@Override
|
||||
protected void init() {
|
||||
testName = "Matrix_lambda";
|
||||
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
|
||||
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;
|
||||
|
||||
public class Matrix_lambdaTest2 {
|
||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||
public final static String testFile = "Matrix_lambda2.jav";
|
||||
public final static String outputFile = "Matrix2.class";
|
||||
public class Matrix_lambdaTest2 extends SourceFileBytecodeTest{
|
||||
@Override
|
||||
protected void init() {
|
||||
testName = "Matrix_lambda2";
|
||||
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
|
||||
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;
|
||||
|
||||
public class Matrix_lambdaTest3 {
|
||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||
public final static String testFile = "Matrix_lambda3.jav";
|
||||
public final static String outputFile = "Matrix3.class";
|
||||
public class Matrix_lambdaTest3 extends SourceFileBytecodeTest{
|
||||
@Override
|
||||
protected void init() {
|
||||
testName = "Matrix_lambda3";
|
||||
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
|
||||
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.typedeployment.TypeInsertSet;
|
||||
|
||||
public class MethodCallTest {
|
||||
|
||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||
public final static String testFile = "MethodCall.jav";
|
||||
public final static String outputFile = "MethodCall.class";
|
||||
public class MethodCallTest extends SourceFileBytecodeTest{
|
||||
@Override
|
||||
protected void init() {
|
||||
testName = "MethodCall";
|
||||
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
|
||||
}
|
||||
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.typedeployment.TypeInsertSet;
|
||||
|
||||
public class MethodEmpty {
|
||||
|
||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||
public final static String testFile = "MethodEmpty.jav";
|
||||
public final static String outputFile = "MethodEmpty.class";
|
||||
public class MethodEmpty extends SourceFileBytecodeTest{
|
||||
@Override
|
||||
protected void init() {
|
||||
testName = "MethodEmpty";
|
||||
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
|
||||
}
|
||||
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.typedeployment.TypeInsertSet;
|
||||
|
||||
public class MethodEmptyRetType {
|
||||
|
||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||
public final static String testFile = "MethodEmptyRetType.jav";
|
||||
public final static String outputFile = "MethodEmptyRetType.class";
|
||||
public class MethodEmptyRetType extends SourceFileBytecodeTest{
|
||||
@Override
|
||||
protected void init() {
|
||||
testName = "MethodEmptyRetType";
|
||||
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
|
||||
}
|
||||
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.typedeployment.TypeInsertSet;
|
||||
|
||||
public class NewStatementTest {
|
||||
|
||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||
public final static String testFile = "NewStatement.jav";
|
||||
public final static String outputFile = "NewStatement.class";
|
||||
public class NewStatementTest extends SourceFileBytecodeTest{
|
||||
@Override
|
||||
protected void init() {
|
||||
testName = "NewStatement";
|
||||
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory);
|
||||
}
|
||||
/*
|
||||
@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};
|
||||
public void testConstruct() throws Exception{
|
||||
ClassLoader classLoader = getClassLoader();
|
||||
|
||||
ClassLoader classLoader = new URLClassLoader(urls);
|
||||
|
||||
Class untypedVectorTest = classLoader.loadClass("UntypedVector");
|
||||
|
||||
for(Method method: untypedVectorTest.getDeclaredMethods()){
|
||||
System.out.println(method.toGenericString());
|
||||
}
|
||||
}catch(Exception e){
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
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.typedeployment.TypeInsertSet;
|
||||
|
||||
public class ParameterTest {
|
||||
|
||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||
public final static String testFile = "Parameter.jav";
|
||||
public final static String outputFile = "Parameter.class";
|
||||
public class ParameterTest extends SourceFileBytecodeTest{
|
||||
@Override
|
||||
protected void init() {
|
||||
testName = "Parameter";
|
||||
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
|
||||
}
|
||||
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.typedeployment.TypeInsertSet;
|
||||
|
||||
public class PostDecrement {
|
||||
|
||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||
public final static String testFile = "PostDecrement.jav";
|
||||
public final static String outputFile = "PostDecrement.class";
|
||||
public class PostDecrement extends SourceFileBytecodeTest{
|
||||
@Override
|
||||
protected void init() {
|
||||
testName = "PostDecrement";
|
||||
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void test() {
|
||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
|
||||
}
|
||||
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.typedeployment.TypeInsertSet;
|
||||
|
||||
public class PostIncrement {
|
||||
|
||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||
public final static String testFile = "PostIncrement.jav";
|
||||
public final static String outputFile = "PostIncrement.class";
|
||||
public class PostIncrement extends SourceFileBytecodeTest{
|
||||
@Override
|
||||
protected void init() {
|
||||
testName = "PostIncrement";
|
||||
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void test() {
|
||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
|
||||
}
|
||||
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.typedeployment.TypeInsertSet;
|
||||
|
||||
public class ReturnTest {
|
||||
|
||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||
public final static String testFile = "Return.jav";
|
||||
public final static String outputFile = "Return.class";
|
||||
public class ReturnTest extends SourceFileBytecodeTest{
|
||||
@Override
|
||||
protected void init() {
|
||||
testName = "Return";
|
||||
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
|
||||
}
|
||||
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;
|
||||
|
||||
public class RunnableTest {
|
||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||
public final static String testFile = "Runnable.jav";
|
||||
public final static String outputFile = "Runnable.class";
|
||||
public class RunnableTest extends SourceFileBytecodeTest{
|
||||
@Override
|
||||
protected void init() {
|
||||
testName = "Runnable";
|
||||
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
|
||||
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.typedeployment.TypeInsertSet;
|
||||
|
||||
public class StringLitTest {
|
||||
|
||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||
public final static String testFile = "StringLitTest.jav";
|
||||
public final static String outputFile = "StringLitTest.class";
|
||||
public class StringLitTest extends SourceFileBytecodeTest{
|
||||
@Override
|
||||
protected void init() {
|
||||
testName = "StringLitTest";
|
||||
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
|
||||
}
|
||||
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.typedeployment.TypeInsertSet;
|
||||
|
||||
public class SystemOutPrintlnTest {
|
||||
|
||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||
public final static String testFile = "SystemOutPrintln.jav";
|
||||
public final static String outputFile = "SystemOutPrintln.class";
|
||||
public class SystemOutPrintlnTest extends SourceFileBytecodeTest{
|
||||
@Override
|
||||
protected void init() {
|
||||
testName = "SystemOutPrintln";
|
||||
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory);
|
||||
}
|
||||
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{
|
||||
|
||||
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{
|
||||
method(){
|
||||
while(true){
|
||||
|
||||
class WhileTest{
|
||||
void method(){
|
||||
Integer i;
|
||||
i = 1;
|
||||
while(i < 10){
|
||||
i = i + 1;
|
||||
}
|
||||
}
|
||||
}
|
@ -2,13 +2,20 @@ package bytecode;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class WhileTest {
|
||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||
public final static String testFile = "WhileTest.jav";
|
||||
public final static String outputFile = "WhileTest.class";
|
||||
public class WhileTest extends SourceFileBytecodeTest{
|
||||
@Override
|
||||
protected void init() {
|
||||
testName = "WhileTest";
|
||||
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile);
|
||||
public void testConstruct() throws Exception{
|
||||
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 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 EqualOperatorTest extends SourceFileBytecodeTest{
|
||||
public class EqualOperatorTest extends RelOperatorTest{
|
||||
@Override
|
||||
protected void init() {
|
||||
testName = "EqualOperator";
|
||||
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/operators/";
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConstruct() throws Exception{
|
||||
ClassLoader classLoader = getClassLoader();
|
||||
@Override
|
||||
protected Boolean getTest1x2ReturnValue() {
|
||||
return new Boolean(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Boolean getTest2x2ReturnValue() {
|
||||
return new Boolean(true);
|
||||
}
|
||||
|
||||
Class cls = classLoader.loadClass(testName);
|
||||
|
||||
Object obj = cls.newInstance();
|
||||
assertTrue(true);
|
||||
@Override
|
||||
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;
|
||||
|
||||
public class OROperatorTest extends SourceFileBytecodeTest{
|
||||
public class OrOperatorTest extends SourceFileBytecodeTest{
|
||||
@Override
|
||||
protected void init() {
|
||||
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{
|
||||
Integer methode(Boolean b){
|
||||
if(b){
|
||||
return 1;
|
||||
Integer methode(Boolean b){
|
||||
if(b){
|
||||
return 1;
|
||||
}else{
|
||||
return 2;
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -3,14 +3,22 @@ package bytecode.stackmaptable;
|
||||
import org.junit.Test;
|
||||
|
||||
import bytecode.SingleClassTester;
|
||||
import bytecode.SourceFileBytecodeTest;
|
||||
|
||||
public class IfStatementTest {
|
||||
public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/stackmaptable/";
|
||||
public final static String testFile = "IfStatement.jav";
|
||||
public final static String outputFile = "IfStatement.class";
|
||||
public class IfStatementTest extends SourceFileBytecodeTest{
|
||||
@Override
|
||||
protected void init() {
|
||||
testName = "IfStatement";
|
||||
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/stackmaptable/";
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory);
|
||||
public void testConstruct() throws Exception{
|
||||
ClassLoader classLoader = getClassLoader();
|
||||
|
||||
Class cls = classLoader.loadClass(testName);
|
||||
|
||||
Object obj = cls.newInstance();
|
||||
assertTrue(true);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user