diff --git a/BCEL/bcelifier/JavaToBCEL.java b/BCEL/bcelifier/JavaToBCEL.java index b16b62c7..2c87bc2f 100644 --- a/BCEL/bcelifier/JavaToBCEL.java +++ b/BCEL/bcelifier/JavaToBCEL.java @@ -32,7 +32,7 @@ public class JavaToBCEL { 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+"NewClass.java"))).start(); + new BCELifier(new ClassParser(rootDirectory+"NewClass.class").parse(), new FileOutputStream(new File(rootDirectory+"NewClassCreator.java"))).start(); } catch (ClassFormatException | IOException e) { e.printStackTrace(); diff --git a/BCEL/bcelifier/NewClass.java b/BCEL/bcelifier/NewClass.java index 49132e9a..af0d2eae 100644 --- a/BCEL/bcelifier/NewClass.java +++ b/BCEL/bcelifier/NewClass.java @@ -1,60 +1,10 @@ package bcelifier; -import org.apache.commons.bcel6.generic.*; -import org.apache.commons.bcel6.classfile.*; -import org.apache.commons.bcel6.*; -import java.io.*; -public class NewClassCreator implements Constants { - private InstructionFactory _factory; - private ConstantPoolGen _cp; - private ClassGen _cg; - - public NewClassCreator() { - _cg = new ClassGen("bcelifier.NewClass", "java.lang.Object", "NewClass.java", ACC_SUPER, new String[] { }); - - _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 MethodGen(0, Type.VOID, Type.NO_ARGS, new String[] { }, "", "bcelifier.NewClass", il, _cp); - - InstructionHandle ih_0 = il.append(_factory.createLoad(Type.OBJECT, 0)); - il.append(_factory.createInvoke("java.lang.Object", "", Type.VOID, Type.NO_ARGS, Constants.INVOKESPECIAL)); - InstructionHandle ih_4 = il.append(_factory.createReturn(Type.VOID)); - method.setMaxStack(); - method.setMaxLocals(); - _cg.addMethod(method.getMethod()); - il.dispose(); - } - - private void createMethod_1() { - InstructionList il = new InstructionList(); - MethodGen method = new MethodGen(0, Type.STRING, new Type[] { Type.STRING }, new String[] { "arg0" }, "method", "bcelifier.NewClass", il, _cp); - - InstructionHandle ih_0 = il.append(_factory.createNew("java.lang.String")); - il.append(InstructionConstants.DUP); - il.append(_factory.createLoad(Type.OBJECT, 1)); - il.append(_factory.createInvoke("java.lang.String", "", Type.VOID, new Type[] { Type.STRING }, Constants.INVOKESPECIAL)); - il.append(_factory.createStore(Type.OBJECT, 2)); - InstructionHandle ih_9 = il.append(_factory.createLoad(Type.OBJECT, 2)); - InstructionHandle ih_10 = il.append(_factory.createReturn(Type.OBJECT)); - method.setMaxStack(); - method.setMaxLocals(); - _cg.addMethod(method.getMethod()); - il.dispose(); - } - - public static void main(String[] args) throws Exception { - bcelifier.NewClassCreator creator = new bcelifier.NewClassCreator(); - creator.create(new FileOutputStream("bcelifier.NewClass.class")); - } +public class NewClass { + public NewClass(Integer i){} + void methode2(){ + new NewClass(1); + } } + diff --git a/BCEL/bcelifier/NewClassCreator.java b/BCEL/bcelifier/NewClassCreator.java new file mode 100644 index 00000000..3f20eed3 --- /dev/null +++ b/BCEL/bcelifier/NewClassCreator.java @@ -0,0 +1,60 @@ +package bcelifier; + +import org.apache.commons.bcel6.generic.*; +import org.apache.commons.bcel6.classfile.*; +import org.apache.commons.bcel6.*; +import java.io.*; + +public class NewClassCreator implements Constants { + private InstructionFactory _factory; + private ConstantPoolGen _cp; + private ClassGen _cg; + + public NewClassCreator() { + _cg = new ClassGen("bcelifier.NewClass", "java.lang.Object", "NewClass.java", ACC_PUBLIC | ACC_SUPER, new String[] { }); + + _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 MethodGen(ACC_PUBLIC, Type.VOID, new Type[] { new ObjectType("java.lang.Integer") }, new String[] { "arg0" }, "", "bcelifier.NewClass", il, _cp); + + InstructionHandle ih_0 = il.append(_factory.createLoad(Type.OBJECT, 0)); + il.append(_factory.createInvoke("java.lang.Object", "", Type.VOID, Type.NO_ARGS, Constants.INVOKESPECIAL)); + InstructionHandle ih_4 = il.append(_factory.createReturn(Type.VOID)); + method.setMaxStack(); + method.setMaxLocals(); + _cg.addMethod(method.getMethod()); + il.dispose(); + } + + private void createMethod_1() { + InstructionList il = new InstructionList(); + MethodGen method = new MethodGen(0, Type.VOID, Type.NO_ARGS, new String[] { }, "methode2", "bcelifier.NewClass", il, _cp); + + InstructionHandle ih_0 = il.append(_factory.createNew("bcelifier.NewClass")); + il.append(InstructionConstants.DUP); + il.append(new PUSH(_cp, 1)); + il.append(_factory.createInvoke("java.lang.Integer", "valueOf", new ObjectType("java.lang.Integer"), new Type[] { Type.INT }, Constants.INVOKESTATIC)); + il.append(_factory.createInvoke("bcelifier.NewClass", "", Type.VOID, new Type[] { new ObjectType("java.lang.Integer") }, Constants.INVOKESPECIAL)); + il.append(InstructionConstants.POP); + InstructionHandle ih_12 = il.append(_factory.createReturn(Type.VOID)); + method.setMaxStack(); + method.setMaxLocals(); + _cg.addMethod(method.getMethod()); + il.dispose(); + } + + public static void main(String[] args) throws Exception { + bcelifier.NewClassCreator creator = new bcelifier.NewClassCreator(); + creator.create(new FileOutputStream("bcelifier.NewClass.class")); + } +} diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/ArgumentList.java b/src/de/dhbwstuttgart/syntaxtree/statement/ArgumentList.java index 3644ec30..1b50ed01 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/ArgumentList.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/ArgumentList.java @@ -1,39 +1,26 @@ -// ino.module.ArgumentList.8621.package package de.dhbwstuttgart.syntaxtree.statement; -// ino.end -// ino.module.ArgumentList.8621.import -import java.util.Iterator; -import de.dhbwstuttgart.typeinference.Menge; +import java.util.Iterator; + +import org.apache.commons.bcel6.generic.InstructionList; + +import de.dhbwstuttgart.typeinference.Menge; +import de.dhbwstuttgart.bytecode.ClassGenerator; import de.dhbwstuttgart.myexception.JVMCodeException; import de.dhbwstuttgart.syntaxtree.FormalParameter; import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode; import de.dhbwstuttgart.typeinference.JavaCodeResult; import de.dhbwstuttgart.typeinference.ResultSet; - - - -// ino.class.ArgumentList.24911.declaration public class ArgumentList extends SyntaxTreeNode -// ino.end -// ino.class.ArgumentList.24911.body { - // ino.attribute.expr.24914.declaration public Menge expr = new Menge(); - // ino.end - // ino.method.get_firstElement.24923.definition public Object get_firstElement() - // ino.end - // ino.method.get_firstElement.24923.body { return expr.firstElement(); } - // ino.end - - /** * @author Andreas Stadelmeier, a10023 @@ -93,6 +80,22 @@ public class ArgumentList extends SyntaxTreeNode public Menge getChildren() { return expr; } - + + public InstructionList generateBytecode(ClassGenerator cg){ + InstructionList ret = new InstructionList(); + for(Expr e : expr){ + ret.append(e.genByteCode(cg)); + } + return ret; + } + + public org.apache.commons.bcel6.generic.Type[] getBytecodeTypeList(ClassGenerator cg){ + org.apache.commons.bcel6.generic.Type[] ret = new org.apache.commons.bcel6.generic.Type[expr.size()]; + int i = 0; + for(Expr e : expr){ + ret[i] = e.getType().getBytecodeType(cg); + i++; + } + return ret; + } } -// ino.end diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/NewClass.java b/src/de/dhbwstuttgart/syntaxtree/statement/NewClass.java index 64655cc0..bdba34bf 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/NewClass.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/NewClass.java @@ -9,10 +9,10 @@ import java.util.Iterator; import org.apache.commons.bcel6.Constants; import org.apache.commons.bcel6.generic.ClassGen; import org.apache.commons.bcel6.generic.InstructionConstants; -import org.apache.commons.bcel6.generic.InstructionFactory; -import org.apache.commons.bcel6.generic.InstructionHandle; + import org.apache.commons.bcel6.generic.InstructionList; -import org.apache.commons.bcel6.generic.NEW; +import org.apache.commons.bcel6.generic.ObjectType; + import de.dhbwstuttgart.typeinference.Menge; import de.dhbwstuttgart.bytecode.ClassGenerator; @@ -60,6 +60,7 @@ public class NewClass extends Expr // ino.attribute.arglist.25837.declaration private ArgumentList arglist; + private boolean isStatement = false; // ino.end // ino.attribute.parserlog.25840.declaration protected static Logger parserlog = Logger.getLogger("parser"); @@ -134,15 +135,7 @@ public class NewClass extends Expr //TODO: Das hier noch vervollständigen ConstraintsSet ret = new ConstraintsSet(); UndConstraint callConstraints = new UndConstraint(); - //Die Auskommentierten Zeilen gehören zu MethodRefNew - //Menge argumentTypeList = new Menge(); - //for(Expr expr : this.arglist.expr){ - // argumentTypeList.add(expr.getTypeVariable()); - //} - //FunN funN= new FunN(null,argumentTypeList); - //Constraint newClassTypeConstraint = new Constraint(null,null); - //ret.add(newClassTypeConstraint); int numArgs = 0; if(this.arglist != null)numArgs = this.arglist.size(); ConstructorAssumption cA = assumptions.getConstructorAssumption(this.get_Name(), numArgs); @@ -152,22 +145,9 @@ public class NewClass extends Expr ret.add(this.arglist.expr.elementAt(i).TYPEExpr(assumptions)); callConstraints.addConstraint( this.arglist.expr.elementAt(i).getType().TYPE(assumptions, this), cA.getParameterType(i).TYPE(assumptions, this)); } - //if(this.arglist != null && this.arglist.expr != null)for(Expr arg : this.arglist.expr){ - // ret.add(arg.TYPEExpr(assumptions)); - //} Type thisT = assumptions.checkType(new RefType(this.get_Name(),this,0), (SyntaxTreeNode)this); this.setType(thisT); - - /* - //Ein new-Aufruf ist nichts anderes als ein MethodCall der Methode - MethodCall newAufruf = new MethodCall(0,0); - this.setType(assumptions.getTypeFor(new RefType(this.get_Name(),0))); - newAufruf.type = this.getType(); - newAufruf.set_Name(""); - newAufruf.set_Receiver(null); - ret.add(new Overloading(assumptions, newAufruf, this.getType()).generateConsstraints()); - */ return ret; } @@ -181,6 +161,7 @@ public class NewClass extends Expr public ConstraintsSet TYPEStmt(TypeAssumptions assumptions){ ConstraintsSet ret = this.TYPEExpr(assumptions); //TypeExpr aufrufen this.setType(new Void(this,0)); //Typ des Statments auf Void setzen. + this.isStatement = true; return ret; } @@ -213,18 +194,21 @@ public class NewClass extends Expr @Override public InstructionList genByteCode(ClassGenerator _cg) { - //TODO bytecode - InstructionFactory _factory = _cg.getInstructionFactory(); InstructionList il = new InstructionList(); - - String name = type.get_Name(); - - il.append(_factory.createNew(name)); - il.append(InstructionConstants.DUP); - il.append(_factory.createInvoke(name, "", org.apache.commons.bcel6.generic.Type.VOID, org.apache.commons.bcel6.generic.Type.NO_ARGS, Constants.INVOKESPECIAL)); - //il.append(InstructionConstants.POP); - - return il; + if(arglist!=null){ + il.append(arglist.generateBytecode(_cg)); + il.append(_cg.getInstructionFactory().createInvoke(this.get_Name(), "", + org.apache.commons.bcel6.generic.Type.VOID, + this.arglist.getBytecodeTypeList(_cg), Constants.INVOKESPECIAL)); + }else{ + il.append(_cg.getInstructionFactory().createInvoke(this.get_Name(), "", + org.apache.commons.bcel6.generic.Type.VOID, + new org.apache.commons.bcel6.generic.Type[]{}, Constants.INVOKESPECIAL)); + } + if(this.isStatement){ + il.append(InstructionConstants.POP); + } + return il; } diff --git a/src/de/dhbwstuttgart/syntaxtree/type/RefType.java b/src/de/dhbwstuttgart/syntaxtree/type/RefType.java index 12777654..fae67654 100755 --- a/src/de/dhbwstuttgart/syntaxtree/type/RefType.java +++ b/src/de/dhbwstuttgart/syntaxtree/type/RefType.java @@ -842,8 +842,8 @@ public class RefType extends ObjectType implements IMatchable cg.addExtraClass(generatedClass.genByteCode(new TypeinferenceResults()).getByteCode()); } - - return "L"+combinedType+";"; + String ret = new org.apache.commons.bcel6.generic.ObjectType(combinedType).getSignature(); + return ret; } public String getCombinedType(ClassGenerator cg){ diff --git a/src/de/dhbwstuttgart/typeinference/unify/Unify.java b/src/de/dhbwstuttgart/typeinference/unify/Unify.java index 7f95f98a..e4b682f9 100755 --- a/src/de/dhbwstuttgart/typeinference/unify/Unify.java +++ b/src/de/dhbwstuttgart/typeinference/unify/Unify.java @@ -1,16 +1,20 @@ //otth/pluemicke2.1.jav funktioniert nicht xxx anschauen // ino.module.Unify.8721.package package de.dhbwstuttgart.typeinference.unify; +import java.util.Collection; // ino.end // ino.module.Unify.8721.import import java.util.Enumeration; import java.util.Hashtable; import java.util.Iterator; +import java.util.function.Function; import java.util.stream.Stream; import de.dhbwstuttgart.logger.Logger; import de.dhbwstuttgart.logger.Section; import de.dhbwstuttgart.logger.SectionLogger; +import de.dhbwstuttgart.logger.Timestamp; +import de.dhbwstuttgart.logger.Timewatch; import de.dhbwstuttgart.core.MyCompiler; import de.dhbwstuttgart.myexception.CTypeReconstructionException; import de.dhbwstuttgart.myexception.MatchException; @@ -30,6 +34,7 @@ import de.dhbwstuttgart.syntaxtree.type.Type; import de.dhbwstuttgart.syntaxtree.type.ObjectType; import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder; import de.dhbwstuttgart.syntaxtree.type.WildcardType; +import de.dhbwstuttgart.typeinference.DeepCloneable; import de.dhbwstuttgart.typeinference.Menge; import de.dhbwstuttgart.typeinference.Pair; import de.dhbwstuttgart.typeinference.Pair.PairOperator; @@ -3489,6 +3494,15 @@ tempKlasse.get_Superclass_Name() ); System.out.println( "P. S.: return T instanceof FreshWildcardType; } + + public static Menge deepClone(Menge m){ + Timewatch watch = Timewatch.getTimewatch(); + Timestamp timer = watch.start("Unify - deepClone"); + Menge ret = m.stream().map((Function)(x -> x.deepClone())).>collect(Menge::new, Menge::add, Menge::addAll); + timer.stop(); + return ret; + } + } // ino.end diff --git a/test/bytecode/Binary.jav b/test/bytecode/Binary.jav new file mode 100644 index 00000000..3ea073fb --- /dev/null +++ b/test/bytecode/Binary.jav @@ -0,0 +1,10 @@ +class Binary{ + +void method() { +a; +a = 20; +b; +b=59 + a; +} + +} \ No newline at end of file diff --git a/test/bytecode/Binary2.jav b/test/bytecode/Binary2.jav new file mode 100644 index 00000000..e89672ac --- /dev/null +++ b/test/bytecode/Binary2.jav @@ -0,0 +1,8 @@ + +class Binary2 { + + Integer m(Integer x) { return x + x; } + + Boolean m(Boolean x) {return x || x; } + +} \ No newline at end of file diff --git a/test/bytecode/BinaryTest.java b/test/bytecode/BinaryTest.java new file mode 100644 index 00000000..37b0ab82 --- /dev/null +++ b/test/bytecode/BinaryTest.java @@ -0,0 +1,34 @@ +package bytecode; + +import static org.junit.Assert.*; + +import java.io.File; +import java.io.IOException; + +import junit.framework.TestCase; + +import org.junit.Test; + +import plugindevelopment.TypeInsertTester; +import de.dhbwstuttgart.core.MyCompiler; +import de.dhbwstuttgart.core.MyCompilerAPI; +import de.dhbwstuttgart.logger.LoggerConfiguration; +import de.dhbwstuttgart.logger.Section; +import de.dhbwstuttgart.parser.JavaParser.yyException; +import de.dhbwstuttgart.typeinference.ByteCodeResult; +import de.dhbwstuttgart.typeinference.Menge; +import de.dhbwstuttgart.typeinference.TypeinferenceResultSet; +import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet; + +public class 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"; + + @Test + public void test() { + SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile); + } + +} diff --git a/test/bytecode/BinaryTest2.java b/test/bytecode/BinaryTest2.java new file mode 100644 index 00000000..842af094 --- /dev/null +++ b/test/bytecode/BinaryTest2.java @@ -0,0 +1,34 @@ +package bytecode; + +import static org.junit.Assert.*; + +import java.io.File; +import java.io.IOException; + +import junit.framework.TestCase; + +import org.junit.Test; + +import plugindevelopment.TypeInsertTester; +import de.dhbwstuttgart.core.MyCompiler; +import de.dhbwstuttgart.core.MyCompilerAPI; +import de.dhbwstuttgart.logger.LoggerConfiguration; +import de.dhbwstuttgart.logger.Section; +import de.dhbwstuttgart.parser.JavaParser.yyException; +import de.dhbwstuttgart.typeinference.ByteCodeResult; +import de.dhbwstuttgart.typeinference.Menge; +import de.dhbwstuttgart.typeinference.TypeinferenceResultSet; +import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet; + +public class 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"; + + @Test + public void test() { + SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory); + } + +} diff --git a/test/bytecode/NewStatement.jav b/test/bytecode/NewStatement.jav new file mode 100644 index 00000000..c654c116 --- /dev/null +++ b/test/bytecode/NewStatement.jav @@ -0,0 +1,10 @@ +class NewStatement{ +public NewStatement(Integer i){} +public NewStatement(String i){} +method() { + NewStatement n; + n = new NewStatement("hallo"); + n = new NewStatement(1); +} + +} \ No newline at end of file diff --git a/test/bytecode/NewStatementTest.java b/test/bytecode/NewStatementTest.java new file mode 100644 index 00000000..ff692332 --- /dev/null +++ b/test/bytecode/NewStatementTest.java @@ -0,0 +1,55 @@ +package bytecode; + +import static org.junit.Assert.*; + +import java.io.File; +import java.io.IOException; +import java.lang.reflect.Method; +import java.net.URL; +import java.net.URLClassLoader; + +import junit.framework.TestCase; + +import org.junit.Test; + +import plugindevelopment.TypeInsertTester; +import de.dhbwstuttgart.core.MyCompiler; +import de.dhbwstuttgart.core.MyCompilerAPI; +import de.dhbwstuttgart.logger.LoggerConfiguration; +import de.dhbwstuttgart.logger.Section; +import de.dhbwstuttgart.parser.JavaParser.yyException; +import de.dhbwstuttgart.typeinference.ByteCodeResult; +import de.dhbwstuttgart.typeinference.Menge; +import de.dhbwstuttgart.typeinference.TypeinferenceResultSet; +import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet; + +public class 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"; + + @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}; + + 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); + } + } + +} diff --git a/test/bytecode/Test2.java b/test/bytecode/Test2.java new file mode 100644 index 00000000..767f6522 --- /dev/null +++ b/test/bytecode/Test2.java @@ -0,0 +1,6 @@ +class Test2{ + + public static void main(java.lang.String[] args){ + new NewStatement(1).method(); +} +} diff --git a/test/bytecode/types/OverloadingTest.java b/test/bytecode/types/OverloadingTest.java index bdbc1092..ea5d1568 100644 --- a/test/bytecode/types/OverloadingTest.java +++ b/test/bytecode/types/OverloadingTest.java @@ -20,7 +20,6 @@ public class OverloadingTest extends SourceFileBytecodeTest{ } - @Test public void testString() { try{ diff --git a/test/plugindevelopment/TypeInsertTests/LambdaTest1.jav b/test/plugindevelopment/TypeInsertTests/LambdaTest1.jav index 9df77818..690e6c9a 100644 --- a/test/plugindevelopment/TypeInsertTests/LambdaTest1.jav +++ b/test/plugindevelopment/TypeInsertTests/LambdaTest1.jav @@ -1,3 +1,4 @@ + class LambdaTest{ String var; @@ -7,4 +8,4 @@ op = () -> (f) -> { return var; }; -} \ No newline at end of file +} diff --git a/test/plugindevelopment/TypeInsertTests/MultipleTypesInsertTester.java b/test/plugindevelopment/TypeInsertTests/MultipleTypesInsertTester.java index 80628a37..db3346a1 100755 --- a/test/plugindevelopment/TypeInsertTests/MultipleTypesInsertTester.java +++ b/test/plugindevelopment/TypeInsertTests/MultipleTypesInsertTester.java @@ -14,6 +14,7 @@ import de.dhbwstuttgart.logger.Section; import de.dhbwstuttgart.logger.SectionLogger; import de.dhbwstuttgart.logger.Timewatch; import de.dhbwstuttgart.parser.JavaParser.yyException; +import de.dhbwstuttgart.syntaxtree.SourceFile; import de.dhbwstuttgart.typeinference.TypeinferenceResultSet; import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertPoint; import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet; @@ -46,8 +47,10 @@ public class MultipleTypesInsertTester extends TypeInsertTester{ MyCompilerAPI compiler = MyCompiler.getAPI(logConfig); try { - compiler.parse(new File(rootDirectory + sourceFileToInfere)); - Menge results = compiler.typeReconstruction(); + SourceFile parsedFile = compiler.parse(new File(rootDirectory + sourceFileToInfere)); + Menge parsedFiles = new Menge<>(); + parsedFiles.add(parsedFile); + Menge results = compiler.typeReconstruction(parsedFiles); System.out.println("Typinferenz ausgeführt!"); //TestCase.assertTrue("Es darf nicht mehr als eine Lösungsmöglichkeit geben und nicht "+results.size(), results.size()==1); for(TypeinferenceResultSet result : results){ @@ -78,8 +81,9 @@ public class MultipleTypesInsertTester extends TypeInsertTester{ String inferedSource = ""; MyCompilerAPI compiler = MyCompiler.getAPI(logConfig); try { - compiler.parse(new File(rootDirectory + sourceFileToInfere)); - Menge results = compiler.typeReconstruction(); + Menge parsedSource = new Menge<>(); + parsedSource.add(compiler.parse(new File(rootDirectory + sourceFileToInfere))); + Menge results = compiler.typeReconstruction(parsedSource); //TestCase.assertTrue("Es darf nicht mehr als eine Lösungsmöglichkeit geben und nicht "+results.size(), results.size()==1); for(TypeinferenceResultSet result : results){ TypeInsertSet point = result.getTypeInsertionPoints();