generateBytecode() um Parameter path erweitert. Alle Tests angepasst
This commit is contained in:
parent
23eab0c9a4
commit
660ef68f7e
@ -636,6 +636,8 @@ public class BytecodeGenMethod implements StatementVisitor {
|
||||
@Override
|
||||
public void visit(MethodCall methodCall) {
|
||||
|
||||
//ClassLoader.getSystemClassLoader().loadClass(className).getMethod(name, parameterTypes)
|
||||
|
||||
System.out.println("Methodcall type : " + resultSet.resolveType(methodCall.getType()).resolvedType.acceptTV(new TypeToDescriptor()));
|
||||
methodCall.receiver.accept(this);
|
||||
methodCall.arglist.accept(this);
|
||||
|
@ -240,8 +240,8 @@ public class JavaTXCompiler {
|
||||
SourceFile ret = generator.convert(tree, environment.packageCrawler);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public void generateBytecode() throws ClassNotFoundException, IOException {
|
||||
// um pfad erweitern
|
||||
public void generateBytecode(String path) throws ClassNotFoundException, IOException {
|
||||
for(File f : sourceFiles.keySet()) {
|
||||
HashMap<String,byte[]> classFiles = new HashMap<>();
|
||||
SourceFile sf = sourceFiles.get(f);
|
||||
@ -249,16 +249,17 @@ public class JavaTXCompiler {
|
||||
BytecodeGen bytecodeGen = new BytecodeGen(classFiles,typeinferenceResult);
|
||||
// BytecodeGen bytecodeGen = new BytecodeGen(classFiles,typeinferenceResult.get(0));
|
||||
bytecodeGen.visit(sf);
|
||||
this.writeClassFile(bytecodeGen.getClassFiles());
|
||||
this.writeClassFile(bytecodeGen.getClassFiles(), path);
|
||||
}
|
||||
}
|
||||
|
||||
private void writeClassFile(HashMap<String, byte[]> classFiles) throws IOException {
|
||||
private void writeClassFile(HashMap<String, byte[]> classFiles, String path) throws IOException {
|
||||
FileOutputStream output;
|
||||
for(String name : classFiles.keySet()) {
|
||||
byte[] bytecode = classFiles.get(name);
|
||||
System.out.println("generating "+name+ ".class file ...");
|
||||
output = new FileOutputStream(new File(System.getProperty("user.dir") + "/testBytecode/generatedBC/" +name+".class"));
|
||||
//output = new FileOutputStream(new File(System.getProperty("user.dir") + "/testBytecode/generatedBC/" +name+".class"));
|
||||
output = new FileOutputStream(new File(path +name+".class"));
|
||||
output.write(bytecode);
|
||||
output.close();
|
||||
System.out.println(name+".class file generated");
|
||||
|
@ -25,8 +25,8 @@ public class BinaryTest {
|
||||
path = System.getProperty("user.dir")+"/test/bytecode/javFiles/BinaryInMeth.jav";
|
||||
fileToTest = new File(path);
|
||||
compiler = new JavaTXCompiler(fileToTest);
|
||||
compiler.generateBytecode();
|
||||
pathToClassFile = System.getProperty("user.dir")+"/testBytecode/generatedBC/";
|
||||
compiler.generateBytecode(pathToClassFile);
|
||||
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
||||
classToTest = loader.loadClass("BinaryInMeth");
|
||||
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
||||
|
@ -27,8 +27,8 @@ public class FacTest {
|
||||
path = System.getProperty("user.dir")+"/test/bytecode/javFiles/Fac.jav";
|
||||
fileToTest = new File(path);
|
||||
compiler = new JavaTXCompiler(fileToTest);
|
||||
compiler.generateBytecode();
|
||||
pathToClassFile = System.getProperty("user.dir")+"/testBytecode/generatedBC/";
|
||||
compiler.generateBytecode(pathToClassFile);
|
||||
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
||||
classToTest = loader.loadClass("Fac");
|
||||
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
||||
|
@ -26,8 +26,8 @@ public class GenTest {
|
||||
path = System.getProperty("user.dir")+"/test/bytecode/javFiles/Gen.jav";
|
||||
fileToTest = new File(path);
|
||||
compiler = new JavaTXCompiler(fileToTest);
|
||||
compiler.generateBytecode();
|
||||
pathToClassFile = System.getProperty("user.dir")+"/testBytecode/generatedBC/";
|
||||
compiler.generateBytecode(pathToClassFile);
|
||||
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
||||
classToTest = loader.loadClass("Gen");
|
||||
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
||||
|
@ -28,8 +28,8 @@ public class GreaterEqualTest {
|
||||
path = System.getProperty("user.dir")+"/test/bytecode/javFiles/GreaterEqual.jav";
|
||||
fileToTest = new File(path);
|
||||
compiler = new JavaTXCompiler(fileToTest);
|
||||
compiler.generateBytecode();
|
||||
pathToClassFile = System.getProperty("user.dir")+"/testBytecode/generatedBC/";
|
||||
compiler.generateBytecode(pathToClassFile);
|
||||
loader = new URLClassLoader(new URL[] {new URL("File://"+pathToClassFile)});
|
||||
classToTest = loader.loadClass("GreaterEqual");
|
||||
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
||||
|
@ -28,8 +28,8 @@ public class GreaterThanTest {
|
||||
path = System.getProperty("user.dir")+"/test/bytecode/javFiles/GreaterThan.jav";
|
||||
fileToTest = new File(path);
|
||||
compiler = new JavaTXCompiler(fileToTest);
|
||||
compiler.generateBytecode();
|
||||
pathToClassFile = System.getProperty("user.dir")+"/testBytecode/generatedBC/";
|
||||
compiler.generateBytecode(pathToClassFile);
|
||||
loader = new URLClassLoader(new URL[] {new URL("File://"+pathToClassFile)});
|
||||
classToTest = loader.loadClass("GreaterThan");
|
||||
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
||||
|
@ -16,7 +16,7 @@ public class LambdaTest {
|
||||
path = System.getProperty("user.dir")+"/test/bytecode/javFiles/Lambda.jav";
|
||||
fileToTest = new File(path);
|
||||
compiler = new JavaTXCompiler(fileToTest);
|
||||
compiler.generateBytecode();
|
||||
compiler.generateBytecode(System.getProperty("user.dir")+"/testBytecode/generatedBC/");
|
||||
}
|
||||
|
||||
|
||||
|
@ -28,8 +28,8 @@ public class LessEqualTest {
|
||||
path = System.getProperty("user.dir")+"/test/bytecode/javFiles/LessEqual.jav";
|
||||
fileToTest = new File(path);
|
||||
compiler = new JavaTXCompiler(fileToTest);
|
||||
compiler.generateBytecode();
|
||||
pathToClassFile = System.getProperty("user.dir")+"/testBytecode/generatedBC/";
|
||||
compiler.generateBytecode(pathToClassFile);
|
||||
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
||||
classToTest = loader.loadClass("LessEqual");
|
||||
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
||||
|
@ -28,8 +28,8 @@ public class LessThanTest {
|
||||
path = System.getProperty("user.dir")+"/test/bytecode/javFiles/LessThan.jav";
|
||||
fileToTest = new File(path);
|
||||
compiler = new JavaTXCompiler(fileToTest);
|
||||
compiler.generateBytecode();
|
||||
pathToClassFile = System.getProperty("user.dir")+"/testBytecode/generatedBC/";
|
||||
compiler.generateBytecode(pathToClassFile);
|
||||
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
||||
classToTest = loader.loadClass("LessThan");
|
||||
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
||||
|
@ -25,8 +25,8 @@ public class MatrixTest {
|
||||
path = System.getProperty("user.dir")+"/test/bytecode/javFiles/Matrix.jav";
|
||||
fileToTest = new File(path);
|
||||
compiler = new JavaTXCompiler(fileToTest);
|
||||
compiler.generateBytecode();
|
||||
pathToClassFile = System.getProperty("user.dir")+"/testBytecode/generatedBC/";
|
||||
compiler.generateBytecode(pathToClassFile);
|
||||
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
||||
classToTest = loader.loadClass("Matrix");
|
||||
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
||||
|
@ -25,8 +25,8 @@ public class OLTest {
|
||||
path = System.getProperty("user.dir")+"/test/bytecode/javFiles/OL.jav";
|
||||
fileToTest = new File(path);
|
||||
compiler = new JavaTXCompiler(fileToTest);
|
||||
compiler.generateBytecode();
|
||||
pathToClassFile = System.getProperty("user.dir")+"/testBytecode/generatedBC/";
|
||||
compiler.generateBytecode(pathToClassFile);
|
||||
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
||||
classToTest = loader.loadClass("OL");
|
||||
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
||||
|
@ -28,8 +28,8 @@ public class OpTest {
|
||||
path = System.getProperty("user.dir")+"/test/bytecode/javFiles/Op.jav";
|
||||
fileToTest = new File(path);
|
||||
compiler = new JavaTXCompiler(fileToTest);
|
||||
compiler.generateBytecode();
|
||||
pathToClassFile = System.getProperty("user.dir")+"/testBytecode/generatedBC/";
|
||||
compiler.generateBytecode(pathToClassFile);
|
||||
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
||||
classToTest = loader.loadClass("Op");
|
||||
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
||||
|
@ -30,8 +30,8 @@ public class OverloadingTest {
|
||||
path = System.getProperty("user.dir")+"/test/bytecode/javFiles/Overloading.jav";
|
||||
fileToTest = new File(path);
|
||||
compiler = new JavaTXCompiler(fileToTest);
|
||||
compiler.generateBytecode();
|
||||
pathToClassFile = System.getProperty("user.dir")+"/testBytecode/generatedBC/";
|
||||
compiler.generateBytecode(pathToClassFile);
|
||||
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
||||
classToTest = loader.loadClass("Overloading");
|
||||
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
||||
|
@ -27,9 +27,8 @@ public class PlusTest {
|
||||
path = System.getProperty("user.dir")+"/test/bytecode/javFiles/Plus.jav";
|
||||
fileToTest = new File(path);
|
||||
compiler = new JavaTXCompiler(fileToTest);
|
||||
compiler.generateBytecode();
|
||||
|
||||
pathToClassFile = System.getProperty("user.dir")+"/testBytecode/generatedBC/";
|
||||
compiler.generateBytecode(pathToClassFile);
|
||||
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
||||
classToTest = loader.loadClass("Plus");
|
||||
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
||||
|
@ -27,8 +27,8 @@ public class PostIncTest {
|
||||
path = System.getProperty("user.dir")+"/test/bytecode/javFiles/PostIncDec.jav";
|
||||
fileToTest = new File(path);
|
||||
compiler = new JavaTXCompiler(fileToTest);
|
||||
compiler.generateBytecode();
|
||||
pathToClassFile = System.getProperty("user.dir")+"/testBytecode/generatedBC/";
|
||||
compiler.generateBytecode(pathToClassFile);
|
||||
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
||||
classToTest = loader.loadClass("PostIncDec");
|
||||
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
||||
|
@ -27,8 +27,8 @@ public class PreIncTest {
|
||||
path = System.getProperty("user.dir")+"/test/bytecode/javFiles/PreInc.jav";
|
||||
fileToTest = new File(path);
|
||||
compiler = new JavaTXCompiler(fileToTest);
|
||||
compiler.generateBytecode();
|
||||
pathToClassFile = System.getProperty("user.dir")+"/testBytecode/generatedBC/";
|
||||
compiler.generateBytecode(pathToClassFile);
|
||||
loader = new URLClassLoader(new URL[] {new URL("file://" + pathToClassFile)});
|
||||
classToTest = loader.loadClass("PreInc");
|
||||
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
||||
|
@ -27,8 +27,8 @@ public class RelOpsTest {
|
||||
path = System.getProperty("user.dir")+"/test/bytecode/javFiles/RelOps.jav";
|
||||
fileToTest = new File(path);
|
||||
compiler = new JavaTXCompiler(fileToTest);
|
||||
compiler.generateBytecode();
|
||||
pathToClassFile = System.getProperty("user.dir")+"/testBytecode/generatedBC/";
|
||||
compiler.generateBytecode(pathToClassFile);
|
||||
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
||||
classToTest = loader.loadClass("RelOps");
|
||||
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
||||
|
@ -26,8 +26,8 @@ public class StaticTest {
|
||||
path = System.getProperty("user.dir")+"/test/bytecode/javFiles/StaticM.jav";
|
||||
fileToTest = new File(path);
|
||||
compiler = new JavaTXCompiler(fileToTest);
|
||||
compiler.generateBytecode();
|
||||
pathToClassFile = System.getProperty("user.dir")+"/testBytecode/generatedBC/";
|
||||
compiler.generateBytecode(pathToClassFile);
|
||||
loader = new URLClassLoader(new URL[] {new URL("file://" + pathToClassFile)});
|
||||
classToTest = loader.loadClass("StaticM");
|
||||
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
||||
|
@ -26,8 +26,8 @@ public class Tph2Test {
|
||||
path = System.getProperty("user.dir")+"/test/bytecode/javFiles/Tph2.jav";
|
||||
fileToTest = new File(path);
|
||||
compiler = new JavaTXCompiler(fileToTest);
|
||||
compiler.generateBytecode();
|
||||
pathToClassFile = System.getProperty("user.dir")+"/testBytecode/generatedBC/";
|
||||
compiler.generateBytecode(pathToClassFile);
|
||||
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
||||
classToTest = loader.loadClass("Tph2");
|
||||
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
||||
|
@ -25,8 +25,8 @@ public class TphTest {
|
||||
path = System.getProperty("user.dir")+"/test/bytecode/javFiles/Tph.jav";
|
||||
fileToTest = new File(path);
|
||||
compiler = new JavaTXCompiler(fileToTest);
|
||||
compiler.generateBytecode();
|
||||
pathToClassFile = System.getProperty("user.dir")+"/testBytecode/generatedBC/";
|
||||
compiler.generateBytecode(pathToClassFile);
|
||||
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
||||
classToTest = loader.loadClass("Tph");
|
||||
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
||||
|
@ -27,8 +27,8 @@ public class WhileTest {
|
||||
path = System.getProperty("user.dir")+"/test/bytecode/javFiles/While.jav";
|
||||
fileToTest = new File(path);
|
||||
compiler = new JavaTXCompiler(fileToTest);
|
||||
compiler.generateBytecode();
|
||||
pathToClassFile = System.getProperty("user.dir")+"/testBytecode/generatedBC/";
|
||||
compiler.generateBytecode(pathToClassFile);
|
||||
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
||||
classToTest = loader.loadClass("While");
|
||||
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
||||
|
BIN
test/logFiles/.log.swp
Normal file
BIN
test/logFiles/.log.swp
Normal file
Binary file not shown.
34
test/logFiles/log
Normal file
34
test/logFiles/log
Normal file
@ -0,0 +1,34 @@
|
||||
FC:\{java.lang.Object=Elem: Node(java.lang.Object)
|
||||
Prec: [java.lang.Object]
|
||||
Desc: [java.lang.Object, Tph]
|
||||
|
||||
, Tph=Elem: Node(Tph)
|
||||
Prec: [java.lang.Object]
|
||||
Desc: []
|
||||
|
||||
}
|
||||
class Tph {
|
||||
|
||||
TPH K m(TPH L a, TPH M b)({
|
||||
TPH N c;
|
||||
(c)::TPH N = ((this)::TPH O.m2((b)::TPH M))::TPH P;
|
||||
return (a)::TPH L;
|
||||
})::TPH Q
|
||||
|
||||
TPH R m2(TPH S b)({
|
||||
return (b)::TPH S;
|
||||
})::TPH T
|
||||
|
||||
Tph()({
|
||||
super(());
|
||||
})::TPH W
|
||||
|
||||
}0 AA: []
|
||||
1 Unifikation: [(L <. K, 1, -1), (R =. P, -1, -1), (O =. Tph, 0), (S <. R, 1, -1), (O <. Tph, 0), (P <. N, -1, -1), (M <. S, 1, 1)]
|
||||
nextSet: [[(O =. Tph, 0)], [(O =. ? extends Tph, 0)]]
|
||||
1 AA: []
|
||||
2 Unifikation: [(L <. K, 1, -1), (R =. P, -1, -1), (S <. P, 1, -1), (O =. Tph, 0), (P <. N, -1, -1), (M <. S, 1, 1)]
|
||||
[(L <. K, 1, -1), (R =. P, -1, -1), (S <. P, 1, -1), (O =. Tph, 0), (P <. N, -1, -1), (M <. S, 1, 1)]
|
||||
Result1 [[(L <. K, 1, -1), (R =. P, -1, -1), (S <. P, 1, -1), (O =. Tph, 0), (P <. N, -1, -1), (M <. S, 1, 1)]]
|
||||
Result1 [[(L <. K, 1, -1), (R =. P, -1, -1), (S <. P, 1, -1), (O =. Tph, 0), (P <. N, -1, -1), (M <. S, 1, 1)]]
|
||||
RES: [[(L <. K, 1, -1), (R =. P, -1, -1), (S <. P, 1, -1), (O =. Tph, 0), (P <. N, -1, -1), (M <. S, 1, 1)]]
|
Loading…
Reference in New Issue
Block a user