diff --git a/.classpath b/.classpath index 11f44fce..46d57734 100755 --- a/.classpath +++ b/.classpath @@ -3,8 +3,7 @@ - - + diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs index 794d6ee6..2e8ab188 100755 --- a/.settings/org.eclipse.jdt.core.prefs +++ b/.settings/org.eclipse.jdt.core.prefs @@ -1,12 +1,13 @@ eclipse.preferences.version=1 instance/org.eclipse.core.net/org.eclipse.core.net.hasMigrated=true org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.compliance=1.8 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.7 +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/bin/.gitignore b/bin/.gitignore index 56a30e6a..8ac1c637 100644 --- a/bin/.gitignore +++ b/bin/.gitignore @@ -1,6 +1,5 @@ -/bytecode/ /de/ /mycompiler/ -/parser/ /plugindevelopment/ -/syntaxTree/ +/bytecode/ +/parser/ diff --git a/bin/log4j.xml b/bin/log4j.xml index 41480fbd..64e7c5db 100755 --- a/bin/log4j.xml +++ b/bin/log4j.xml @@ -3,10 +3,10 @@ - + - + diff --git a/bin/log4jTesting.xml b/bin/log4jTesting.xml index 642079a3..dc30c245 100755 --- a/bin/log4jTesting.xml +++ b/bin/log4jTesting.xml @@ -3,10 +3,10 @@ - + - + diff --git a/log4j.xml b/log4j.xml index 41480fbd..64e7c5db 100755 --- a/log4j.xml +++ b/log4j.xml @@ -3,10 +3,10 @@ - + - + diff --git a/src/de/dhbwstuttgart/antlr/VisitorTest.java b/src/de/dhbwstuttgart/antlr/VisitorTest.java index e3cf519a..2effc93d 100644 --- a/src/de/dhbwstuttgart/antlr/VisitorTest.java +++ b/src/de/dhbwstuttgart/antlr/VisitorTest.java @@ -12,9 +12,13 @@ import org.junit.Test; import de.dhbwstuttgart.antlr.Java8Parser.ClassDeclarationContext; import de.dhbwstuttgart.antlr.Java8Parser.CompilationUnitContext; import de.dhbwstuttgart.antlr.Java8Parser.TypeDeclarationContext; +import de.dhbwstuttgart.antlr.Java8Parser.TypeParameterContext; +import de.dhbwstuttgart.antlr.Java8Parser.TypeParametersContext; +import de.dhbwstuttgart.syntaxtree.GenericDeclarationList; import de.dhbwstuttgart.syntaxtree.SourceFile; import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode; import de.dhbwstuttgart.syntaxtree.Class; +import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar; public class VisitorTest { @@ -62,7 +66,28 @@ class EvalVisitor extends Java8BaseVisitor { public Class visitClassDeclaration(ClassDeclarationContext ctx) { String name = ctx.Identifier().getText(); int offset = ctx.Identifier().getSymbol().getStartIndex(); + TypeParametersContext tpctx = ctx.typeParameters(); + GenericDeclarationList gtvList = (GenericDeclarationList) visit(tpctx); + return new Class(name, offset); } + @Override + public GenericDeclarationList visitTypeParameters(TypeParametersContext ctx) { + Vector list = new Vector<>(); + int endOffset = 0; + for(TypeParameterContext tpctx : ctx.typeParameter()){ + tpctx.Identifier(); + } + GenericDeclarationList ret = new GenericDeclarationList(list, endOffset); + return ret; + } + + @Override + public GenericTypeVar visitTypeParameter(TypeParameterContext ctx) { + GenericTypeVar ret = null;//new GenericTypeVar(name, parent, offset); + return ret; + } + + } diff --git a/src/de/dhbwstuttgart/bytecode/Attribute.java b/src/de/dhbwstuttgart/bytecode/Attribute.java index 57998779..a7e33972 100755 --- a/src/de/dhbwstuttgart/bytecode/Attribute.java +++ b/src/de/dhbwstuttgart/bytecode/Attribute.java @@ -7,9 +7,10 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; -import org.apache.log4j.Logger; // ino.end + +import de.dhbwstuttgart.logger.Logger; import de.dhbwstuttgart.myexception.JVMCodeException; // ino.class.Attribute.21446.declaration diff --git a/src/de/dhbwstuttgart/bytecode/CPInfo.java b/src/de/dhbwstuttgart/bytecode/CPInfo.java index a3591b64..425011a2 100755 --- a/src/de/dhbwstuttgart/bytecode/CPInfo.java +++ b/src/de/dhbwstuttgart/bytecode/CPInfo.java @@ -7,7 +7,8 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; -import org.apache.log4j.Logger; +import de.dhbwstuttgart.logger.Logger; + // ino.end // ino.class.CPInfo.22026.declaration diff --git a/src/de/dhbwstuttgart/bytecode/ClassFile.java b/src/de/dhbwstuttgart/bytecode/ClassFile.java index ba7de8e5..d5165110 100755 --- a/src/de/dhbwstuttgart/bytecode/ClassFile.java +++ b/src/de/dhbwstuttgart/bytecode/ClassFile.java @@ -12,8 +12,6 @@ import java.io.IOException; import java.io.OutputStream; import java.lang.reflect.Array; import java.util.Vector; - -import org.apache.log4j.Logger; // ino.end @@ -23,7 +21,9 @@ import org.apache.log4j.Logger; + import de.dhbwstuttgart.core.MyCompiler; +import de.dhbwstuttgart.logger.Logger; import de.dhbwstuttgart.myexception.JVMCodeException; import de.dhbwstuttgart.syntaxtree.Interface; import de.dhbwstuttgart.syntaxtree.ParameterList; diff --git a/src/de/dhbwstuttgart/bytecode/CodeAttribute.java b/src/de/dhbwstuttgart/bytecode/CodeAttribute.java index d8a6dfdf..6cff7bc5 100755 --- a/src/de/dhbwstuttgart/bytecode/CodeAttribute.java +++ b/src/de/dhbwstuttgart/bytecode/CodeAttribute.java @@ -16,7 +16,6 @@ import java.util.Vector; import de.dhbwstuttgart.myexception.JVMCodeException; import de.dhbwstuttgart.syntaxtree.type.Type; -import sun.reflect.generics.reflectiveObjects.NotImplementedException; // ino.class.CodeAttribute.21681.declaration public class CodeAttribute extends Attribute diff --git a/src/de/dhbwstuttgart/bytecode/ExceptionTable.java b/src/de/dhbwstuttgart/bytecode/ExceptionTable.java index 8c5dbe48..7d22e35f 100755 --- a/src/de/dhbwstuttgart/bytecode/ExceptionTable.java +++ b/src/de/dhbwstuttgart/bytecode/ExceptionTable.java @@ -7,7 +7,7 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; -import org.apache.log4j.Logger; +import de.dhbwstuttgart.logger.Logger; // ino.end // ino.class.ExceptionTable.22047.declaration diff --git a/src/de/dhbwstuttgart/bytecode/FieldInfo.java b/src/de/dhbwstuttgart/bytecode/FieldInfo.java index 9347bb60..1118e3ba 100755 --- a/src/de/dhbwstuttgart/bytecode/FieldInfo.java +++ b/src/de/dhbwstuttgart/bytecode/FieldInfo.java @@ -8,7 +8,7 @@ import java.io.IOException; import java.io.OutputStream; import java.util.Vector; -import org.apache.log4j.Logger; +import de.dhbwstuttgart.logger.Logger; // ino.end import de.dhbwstuttgart.myexception.JVMCodeException; diff --git a/src/de/dhbwstuttgart/bytecode/JVMCode.java b/src/de/dhbwstuttgart/bytecode/JVMCode.java index 1966ae88..24f9b23f 100755 --- a/src/de/dhbwstuttgart/bytecode/JVMCode.java +++ b/src/de/dhbwstuttgart/bytecode/JVMCode.java @@ -4,7 +4,7 @@ package de.dhbwstuttgart.bytecode; // ino.module.JVMCode.8547.import import java.util.Vector; -import org.apache.log4j.Logger; +import de.dhbwstuttgart.logger.Logger; // ino.end diff --git a/src/de/dhbwstuttgart/bytecode/Key.java b/src/de/dhbwstuttgart/bytecode/Key.java index 77df160e..6f4eee5b 100755 --- a/src/de/dhbwstuttgart/bytecode/Key.java +++ b/src/de/dhbwstuttgart/bytecode/Key.java @@ -6,7 +6,7 @@ package de.dhbwstuttgart.bytecode; import java.io.FileOutputStream; import java.io.OutputStream; -import org.apache.log4j.Logger; +import de.dhbwstuttgart.logger.Logger; // ino.end // ino.class.Key.22890.declaration diff --git a/src/de/dhbwstuttgart/bytecode/MethodInfo.java b/src/de/dhbwstuttgart/bytecode/MethodInfo.java index a083b106..ef2f9163 100755 --- a/src/de/dhbwstuttgart/bytecode/MethodInfo.java +++ b/src/de/dhbwstuttgart/bytecode/MethodInfo.java @@ -8,7 +8,7 @@ import java.io.IOException; import java.io.OutputStream; import java.util.Vector; -import org.apache.log4j.Logger; +import de.dhbwstuttgart.logger.Logger; // ino.end import de.dhbwstuttgart.myexception.JVMCodeException; diff --git a/src/de/dhbwstuttgart/bytecode/SignatureInfo.java b/src/de/dhbwstuttgart/bytecode/SignatureInfo.java index cb434597..c7fa7873 100755 --- a/src/de/dhbwstuttgart/bytecode/SignatureInfo.java +++ b/src/de/dhbwstuttgart/bytecode/SignatureInfo.java @@ -8,7 +8,7 @@ import java.io.IOException; import java.io.OutputStream; import java.util.Vector; -import org.apache.log4j.Logger; +import de.dhbwstuttgart.logger.Logger; // ino.end diff --git a/src/de/dhbwstuttgart/core/AClassOrInterface.java b/src/de/dhbwstuttgart/core/AClassOrInterface.java index 16a6f16f..cf3ba515 100755 --- a/src/de/dhbwstuttgart/core/AClassOrInterface.java +++ b/src/de/dhbwstuttgart/core/AClassOrInterface.java @@ -6,7 +6,7 @@ package de.dhbwstuttgart.core; // ino.module.AClassOrInterface.8526.import import java.util.Vector; -import org.apache.log4j.Logger; +import de.dhbwstuttgart.logger.Logger; // ino.end @@ -15,11 +15,15 @@ import org.apache.log4j.Logger; + + import de.dhbwstuttgart.myexception.JVMCodeException; import de.dhbwstuttgart.parser.JavaClassName; import de.dhbwstuttgart.syntaxtree.Interface; import de.dhbwstuttgart.syntaxtree.misc.UsedId; import de.dhbwstuttgart.syntaxtree.modifier.Modifiers; +import de.dhbwstuttgart.syntaxtree.type.RefType; +import de.dhbwstuttgart.syntaxtree.type.Type; // ino.class.AClassOrInterface.21186.description type=javadoc /** @@ -37,8 +41,8 @@ public interface AClassOrInterface { public JavaClassName getName(); - public Vector getSuperInterfaces(); - public void setSuperInterfaces(Vector vector); + public Vector getSuperInterfaces(); + public void setSuperInterfaces(Vector vector); /* // ino.attribute.inferencelog.21189.decldescription type=javadoc diff --git a/src/de/dhbwstuttgart/core/ConsoleInterface.java b/src/de/dhbwstuttgart/core/ConsoleInterface.java index 576077d7..e453b0b1 100755 --- a/src/de/dhbwstuttgart/core/ConsoleInterface.java +++ b/src/de/dhbwstuttgart/core/ConsoleInterface.java @@ -5,14 +5,13 @@ import static org.junit.Assert.fail; import java.util.*; -import org.apache.log4j.Logger; -import org.apache.log4j.varia.NullAppender; +import de.dhbwstuttgart.logger.Logger; import de.dhbwstuttgart.typeinference.TypeinferenceResultSet; import de.dhbwstuttgart.typeinference.exceptions.TypeinferenceException; public class ConsoleInterface { private static final String directory = System.getProperty("user.dir"); - + private static final Logger log = Logger.getLogger( ConsoleInterface.class.getName() ); /** * @param args */ @@ -21,7 +20,7 @@ public class ConsoleInterface { for(String file : args){ filenames.add(file); } - Logger.getRootLogger().addAppender(new NullAppender()); // sämtliches Logging unterdrücken + Logger.setStandardOutput(null); // sämtliches Logging unterdrücken run(filenames); } diff --git a/src/de/dhbwstuttgart/core/MyCompiler.java b/src/de/dhbwstuttgart/core/MyCompiler.java index dd384b93..375cd684 100755 --- a/src/de/dhbwstuttgart/core/MyCompiler.java +++ b/src/de/dhbwstuttgart/core/MyCompiler.java @@ -13,11 +13,8 @@ import java.io.Reader; import java.io.StringReader; import java.util.Vector; -import org.apache.log4j.Logger; -import org.apache.log4j.xml.DOMConfigurator; +import de.dhbwstuttgart.logger.Logger; -import com.sun.corba.se.spi.orbutil.fsm.Guard.Result; -import com.sun.org.apache.xerces.internal.impl.xs.identity.Field; import de.dhbwstuttgart.bytecode.ClassFile; import de.dhbwstuttgart.myexception.CTypeReconstructionException; @@ -69,13 +66,13 @@ public class MyCompiler implements MyCompilerAPI // Logger // ino.end // ino.attribute.codegenlog.21265.declaration - protected static Logger codegenlog = Logger.getLogger("codegen"); + //protected static Logger codegenlog = Logger.getLogger("codegen"); // ino.end // ino.attribute.inferencelog.21268.declaration - protected static Logger inferencelog = Logger.getLogger("inference"); + protected static Logger inferencelog = Logger.getLogger(MyCompiler.class.getName()); // ino.end // ino.attribute.parserlog.21271.declaration - protected static Logger parserlog = Logger.getLogger("parser"); + //protected static Logger parserlog = Logger.getLogger("parser"); // ino.end // ino.attribute.OutputDir.21274.declaration @@ -183,7 +180,7 @@ public class MyCompiler implements MyCompilerAPI } else { - parserlog.error( "SEMANTIK-CHECK-FEHLER: Parameter " + TempParameter.getName() + " muss weitere Parameter besitzen (laut Klassendefinition)" ); + //parserlog.error( "SEMANTIK-CHECK-FEHLER: Parameter " + TempParameter.getName() + " muss weitere Parameter besitzen (laut Klassendefinition)" ); //FIXME Throw exception instead of simple exit System.exit( 1 ); } @@ -515,6 +512,8 @@ public class MyCompiler implements MyCompilerAPI // ino.end // ino.method.typeReconstruction.21304.body { + Logger.setStandardOutput(System.out); //TODO: Hier noch das Log-Level richtig setzen (je nachdem ob debugt wird oder nicht) + if(m_AbstractSyntaxTree==null){ throw new NullPointerException("Es wurde noch kein Abstrakter Syntaxbaum erstellt!"); } diff --git a/src/de/dhbwstuttgart/logger/Logger.java b/src/de/dhbwstuttgart/logger/Logger.java new file mode 100644 index 00000000..3003da8e --- /dev/null +++ b/src/de/dhbwstuttgart/logger/Logger.java @@ -0,0 +1,79 @@ +package de.dhbwstuttgart.logger; + +import java.io.PrintStream; +import java.util.HashMap; +import java.util.logging.Level; + +public class Logger { + + private static PrintStream standardOutput; + private static final HashMap LOGGER_DIRECTORY = new HashMap<>(); + + private String name; + private final java.util.logging.Logger log; + + private Logger(String name, PrintStream output) { + this.name = name; + this.log = java.util.logging.Logger.getLogger( name ); + if(output != null)log.addHandler(new OutputHandler(output)); + log.setLevel(Level.FINE); + } + + /** + * Logt eine Debug Message, welche zusätzlich einer bestimmten Section zugewiesen wird. + * Dadurch lässt sich die DEBUG ausgabe übersichtlicher gestalten. + * @param message + * @param section + */ + public void debug(String message, Section section){ + output(message, Level.FINE); + } + + public void debug(String message){ + //output(message, Level.FINE); + } + + /** + * Liefert den Logger mit dem angegebenen Namen. + * Üblicherweise wird diese Methode mit dem Namen der Klasse aufgerufen, in welcher der Logger tätig ist. + * @param name - Name der Klasse ( Ermittelbar mittels .class.getName() ) + * @return + */ + public static Logger getLogger(String name) { + Logger ret; + if(LOGGER_DIRECTORY.containsKey(name)){ + ret = LOGGER_DIRECTORY.get(name); + }else{ + ret = new Logger(name, standardOutput); + LOGGER_DIRECTORY.put(name, ret); + } + return ret; + } + + private void output(String msg , Level logLevel){ + log.log(logLevel, msg); + /* + if(output != null){ + output.println(msg); + }else if(standardOutput != null){ + standardOutput.println(msg); + } + */ + } + + public void info(String message) { + output(message, Level.INFO); + } + + public void error(String message) { + output(message, Level.WARNING); + } + + /** + * wird hier null übergeben, so wird sämtliches Logging unterdrückt. + */ + public static void setStandardOutput(PrintStream outputStream) { + Logger.standardOutput = outputStream; + } + +} diff --git a/src/de/dhbwstuttgart/logger/OutputHandler.java b/src/de/dhbwstuttgart/logger/OutputHandler.java new file mode 100644 index 00000000..fc57d746 --- /dev/null +++ b/src/de/dhbwstuttgart/logger/OutputHandler.java @@ -0,0 +1,29 @@ +package de.dhbwstuttgart.logger; + +import java.io.PrintStream; +import java.util.logging.Handler; +import java.util.logging.LogRecord; + +public class OutputHandler extends Handler{ + + private PrintStream output; + + public OutputHandler(PrintStream output){ + this.output = output; + } + + @Override + public void publish(LogRecord record) { + output.println(record.getMessage()); + } + + @Override + public void flush() { + } + + @Override + public void close() throws SecurityException { + } + + +} diff --git a/src/de/dhbwstuttgart/logger/Section.java b/src/de/dhbwstuttgart/logger/Section.java new file mode 100644 index 00000000..9fb2c66c --- /dev/null +++ b/src/de/dhbwstuttgart/logger/Section.java @@ -0,0 +1,7 @@ +package de.dhbwstuttgart.logger; + +public enum Section { + TYPEINFERENCE, + PARSER, + CODEGEN; +} diff --git a/src/de/dhbwstuttgart/myexception/SCClassException.java b/src/de/dhbwstuttgart/myexception/SCClassException.java index 03ed35ee..c6d87741 100755 --- a/src/de/dhbwstuttgart/myexception/SCClassException.java +++ b/src/de/dhbwstuttgart/myexception/SCClassException.java @@ -4,7 +4,7 @@ package de.dhbwstuttgart.myexception; // ino.module.SCClassException.8576.import import java.util.Enumeration; import java.util.Vector; -import org.apache.log4j.Logger; +import de.dhbwstuttgart.logger.Logger; // ino.end diff --git a/src/de/dhbwstuttgart/myexception/SCExcept.java b/src/de/dhbwstuttgart/myexception/SCExcept.java index fd5d6ba8..e8ad93d5 100755 --- a/src/de/dhbwstuttgart/myexception/SCExcept.java +++ b/src/de/dhbwstuttgart/myexception/SCExcept.java @@ -3,7 +3,7 @@ package de.dhbwstuttgart.myexception; // ino.end // ino.module.SCExcept.8577.import -import org.apache.log4j.Logger; +import de.dhbwstuttgart.logger.Logger; // ino.end // ino.class.SCExcept.23838.declaration diff --git a/src/de/dhbwstuttgart/myexception/SCException.java b/src/de/dhbwstuttgart/myexception/SCException.java index d996cc66..9c96f2bd 100755 --- a/src/de/dhbwstuttgart/myexception/SCException.java +++ b/src/de/dhbwstuttgart/myexception/SCException.java @@ -4,7 +4,7 @@ package de.dhbwstuttgart.myexception; // ino.module.SCException.8578.import import java.util.Enumeration; import java.util.Vector; -import org.apache.log4j.Logger; +import de.dhbwstuttgart.logger.Logger; // ino.end diff --git a/src/de/dhbwstuttgart/parser/InterfaceList.java b/src/de/dhbwstuttgart/parser/InterfaceList.java index e7438067..a3b8b82d 100755 --- a/src/de/dhbwstuttgart/parser/InterfaceList.java +++ b/src/de/dhbwstuttgart/parser/InterfaceList.java @@ -7,6 +7,8 @@ import java.util.Vector; import de.dhbwstuttgart.syntaxtree.Interface; import de.dhbwstuttgart.syntaxtree.misc.UsedId; +import de.dhbwstuttgart.syntaxtree.type.RefType; +import de.dhbwstuttgart.syntaxtree.type.Type; // ino.class.InterfaceList.24383.description type=javadoc /** @@ -36,13 +38,13 @@ public class InterfaceList // ino.end // ino.method.getVector.24392.definition - public Vector getVector() + public Vector getTypeVector() // ino.end // ino.method.getVector.24392.body { - Vector ret = new Vector<>(); + Vector ret = new Vector<>(); for(UsedId name : superif){ - ret.add(new Interface(name.get_Name_1Element(), name.getOffset())); + ret.add(new Interface(name.get_Name_1Element(), name.getOffset()).getType()); } return ret; } diff --git a/src/de/dhbwstuttgart/parser/JavaClassName.java b/src/de/dhbwstuttgart/parser/JavaClassName.java index dbb87943..31609fe3 100644 --- a/src/de/dhbwstuttgart/parser/JavaClassName.java +++ b/src/de/dhbwstuttgart/parser/JavaClassName.java @@ -17,6 +17,7 @@ public class JavaClassName { private PackageName packageName; public JavaClassName(String name){ + if(name == null)throw new NullPointerException(); String[] names = name.split("[.]"); boolean match = true; if(names.length == 1){ diff --git a/src/de/dhbwstuttgart/parser/JavaLexer.java b/src/de/dhbwstuttgart/parser/JavaLexer.java index 4c5ccab1..788641ac 100644 --- a/src/de/dhbwstuttgart/parser/JavaLexer.java +++ b/src/de/dhbwstuttgart/parser/JavaLexer.java @@ -1291,7 +1291,7 @@ public class JavaLexer { case -37: break; case 37: - {org.apache.log4j.Logger.getLogger("parser").debug("Kommentar: "+yytext());} + {de.dhbwstuttgart.logger.Logger.getLogger("parser").debug("Kommentar: "+yytext());} case -38: break; case 38: diff --git a/src/de/dhbwstuttgart/parser/JavaLexer.lex b/src/de/dhbwstuttgart/parser/JavaLexer.lex index 60f3806e..9df37ace 100755 --- a/src/de/dhbwstuttgart/parser/JavaLexer.lex +++ b/src/de/dhbwstuttgart/parser/JavaLexer.lex @@ -167,7 +167,7 @@ null { //">>=" {this.token = new Token(JavaParser.SIGNEDSHIFTRIGHTEQUAL, yytext(), yyline, yychar);return true;} //">>>=" {this.token = new Token(JavaParser.UNSIGNEDSHIFTRIGHTEQUAL, yytext(), yyline, yychar);return true;} {ws}|\n { /* System.out.print(yytext()); */ } -\\.\n {org.apache.log4j.Logger.getLogger("parser").debug("Kommentar: "+yytext());} +\\.\n {de.dhbwstuttgart.logger.Logger.getLogger("parser").debug("Kommentar: "+yytext());} "->" {this.token = new Token(JavaParser.LAMBDAASSIGNMENT, yytext(), yyline, yychar);return true;} diff --git a/src/de/dhbwstuttgart/parser/JavaParser.java b/src/de/dhbwstuttgart/parser/JavaParser.java index 585e4cb8..8ab37814 100644 --- a/src/de/dhbwstuttgart/parser/JavaParser.java +++ b/src/de/dhbwstuttgart/parser/JavaParser.java @@ -281,8 +281,8 @@ public Vector testPair = new Vector(); //t "fielddeclarator : variabledeclarator '=' expression", //t "fielddeclarator : variabledeclarator", //t "genericdeclarationlist : '<' boundedMethodParameters '>'", -//t "fielddeclaration : fielddeclarator ';'", //t "fielddeclaration : type fielddeclarator ';'", +//t "fielddeclaration : fielddeclarator ';'", //t "fielddeclaration : genericdeclarationlist type fielddeclarator ';'", //t "fielddeclaration : variabledeclarators ';'", //t "fielddeclaration : type variabledeclarators ';'", @@ -833,7 +833,7 @@ case 20: /* Vector SuperInterfaces, */ /* Vector Parameterliste*/ - yyVal = new Class(((ClassAndParameter)yyVals[-1+yyTop]).getName(), null, ((ClassBody)yyVals[0+yyTop]), containedTypes, usedIdsToCheck, null, null, ((ClassAndParameter)yyVals[-1+yyTop]).getParaVector(), ((Token)yyVals[-2+yyTop]).getOffset()); + yyVal = new Class(((ClassAndParameter)yyVals[-1+yyTop]).getName(), null, ((ClassBody)yyVals[0+yyTop]), containedTypes, null, ((ClassAndParameter)yyVals[-1+yyTop]).getParaVector(), ((Token)yyVals[-2+yyTop]).getOffset()); this.initContainedTypes(); this.initUsedIdsToCheck(); } @@ -841,7 +841,7 @@ case 20: case 21: // line 376 "./../src/de/dhbwstuttgart/parser/JavaParser.jay" { - yyVal = new Class(((ClassAndParameter)yyVals[-1+yyTop]).getName(), ((Modifiers)yyVals[-3+yyTop]), ((ClassBody)yyVals[0+yyTop]), containedTypes,usedIdsToCheck, null, null, ((ClassAndParameter)yyVals[-1+yyTop]).getParaVector(), ((Token)yyVals[-2+yyTop]).getOffset()); + yyVal = new Class(((ClassAndParameter)yyVals[-1+yyTop]).getName(), ((Modifiers)yyVals[-3+yyTop]), ((ClassBody)yyVals[0+yyTop]), containedTypes, null, ((ClassAndParameter)yyVals[-1+yyTop]).getParaVector(), ((Token)yyVals[-2+yyTop]).getOffset()); this.initContainedTypes(); this.initUsedIdsToCheck(); } @@ -849,7 +849,7 @@ case 21: case 22: // line 382 "./../src/de/dhbwstuttgart/parser/JavaParser.jay" { - yyVal = new Class(((ClassAndParameter)yyVals[-2+yyTop]).getName(), null, ((ClassBody)yyVals[0+yyTop]), containedTypes,usedIdsToCheck, ((UsedId)yyVals[-1+yyTop]), null, ((ClassAndParameter)yyVals[-2+yyTop]).getParaVector(), ((Token)yyVals[-3+yyTop]).getOffset()); + yyVal = new Class(((ClassAndParameter)yyVals[-2+yyTop]).getName(), null, ((ClassBody)yyVals[0+yyTop]), containedTypes, ((UsedId)yyVals[-1+yyTop]), null, ((ClassAndParameter)yyVals[-2+yyTop]).getParaVector(), ((Token)yyVals[-3+yyTop]).getOffset()); this.initContainedTypes(); this.initUsedIdsToCheck(); } @@ -857,7 +857,7 @@ case 22: case 23: // line 388 "./../src/de/dhbwstuttgart/parser/JavaParser.jay" { - yyVal = new Class(((ClassAndParameter)yyVals[-2+yyTop]).getName(), ((Modifiers)yyVals[-4+yyTop]), ((ClassBody)yyVals[0+yyTop]), containedTypes, usedIdsToCheck, ((UsedId)yyVals[-1+yyTop]), null, ((ClassAndParameter)yyVals[-2+yyTop]).getParaVector(), ((Token)yyVals[-3+yyTop]).getOffset()); + yyVal = new Class(((ClassAndParameter)yyVals[-2+yyTop]).getName(), ((Modifiers)yyVals[-4+yyTop]), ((ClassBody)yyVals[0+yyTop]), containedTypes, ((UsedId)yyVals[-1+yyTop]), null, ((ClassAndParameter)yyVals[-2+yyTop]).getParaVector(), ((Token)yyVals[-3+yyTop]).getOffset()); this.initContainedTypes(); this.initUsedIdsToCheck(); } @@ -865,7 +865,7 @@ case 23: case 24: // line 395 "./../src/de/dhbwstuttgart/parser/JavaParser.jay" { - yyVal = new Class(((ClassAndParameter)yyVals[-2+yyTop]).getName(), null, ((ClassBody)yyVals[0+yyTop]), containedTypes, usedIdsToCheck, null, ((InterfaceList)yyVals[-1+yyTop]).getVector(), ((ClassAndParameter)yyVals[-2+yyTop]).getParaVector(), ((Token)yyVals[-3+yyTop]).getOffset()); + yyVal = new Class(((ClassAndParameter)yyVals[-2+yyTop]).getName(), null, ((ClassBody)yyVals[0+yyTop]), containedTypes, ((InterfaceList)yyVals[-1+yyTop]).getTypeVector(), ((ClassAndParameter)yyVals[-2+yyTop]).getParaVector(), ((Token)yyVals[-3+yyTop]).getOffset()); this.initContainedTypes(); this.initUsedIdsToCheck(); } @@ -873,7 +873,7 @@ case 24: case 25: // line 401 "./../src/de/dhbwstuttgart/parser/JavaParser.jay" { - yyVal = new Class(((ClassAndParameter)yyVals[-2+yyTop]).getName(), ((Modifiers)yyVals[-4+yyTop]), ((ClassBody)yyVals[0+yyTop]), containedTypes, usedIdsToCheck, null, ((InterfaceList)yyVals[-1+yyTop]).getVector(), ((ClassAndParameter)yyVals[-2+yyTop]).getParaVector(), ((Token)yyVals[-3+yyTop]).getOffset()); + yyVal = new Class(((ClassAndParameter)yyVals[-2+yyTop]).getName(), ((Modifiers)yyVals[-4+yyTop]), ((ClassBody)yyVals[0+yyTop]), containedTypes, ((InterfaceList)yyVals[-1+yyTop]).getTypeVector(), ((ClassAndParameter)yyVals[-2+yyTop]).getParaVector(), ((Token)yyVals[-3+yyTop]).getOffset()); this.initContainedTypes(); this.initUsedIdsToCheck(); } @@ -881,7 +881,7 @@ case 25: case 26: // line 407 "./../src/de/dhbwstuttgart/parser/JavaParser.jay" { - yyVal = new Class(((ClassAndParameter)yyVals[-3+yyTop]).getName(), null, ((ClassBody)yyVals[0+yyTop]), containedTypes,usedIdsToCheck, ((UsedId)yyVals[-2+yyTop]), ((InterfaceList)yyVals[-1+yyTop]).getVector(), ((ClassAndParameter)yyVals[-3+yyTop]).getParaVector(), ((Token)yyVals[-4+yyTop]).getOffset()); + yyVal = new Class(((ClassAndParameter)yyVals[-3+yyTop]).getName(), null, ((ClassBody)yyVals[0+yyTop]), containedTypes, ((UsedId)yyVals[-2+yyTop]), ((InterfaceList)yyVals[-1+yyTop]).getTypeVector(), ((ClassAndParameter)yyVals[-3+yyTop]).getParaVector(), ((Token)yyVals[-4+yyTop]).getOffset()); this.initContainedTypes(); this.initUsedIdsToCheck(); } @@ -889,7 +889,7 @@ case 26: case 27: // line 413 "./../src/de/dhbwstuttgart/parser/JavaParser.jay" { - yyVal = new Class(((ClassAndParameter)yyVals[-3+yyTop]).getName(), ((Modifiers)yyVals[-5+yyTop]), ((ClassBody)yyVals[0+yyTop]), containedTypes, usedIdsToCheck, ((UsedId)yyVals[-2+yyTop]), ((InterfaceList)yyVals[-1+yyTop]).getVector(), ((ClassAndParameter)yyVals[-3+yyTop]).getParaVector(), ((Token)yyVals[-4+yyTop]).getOffset()); + yyVal = new Class(((ClassAndParameter)yyVals[-3+yyTop]).getName(), ((Modifiers)yyVals[-5+yyTop]), ((ClassBody)yyVals[0+yyTop]), containedTypes, ((UsedId)yyVals[-2+yyTop]), ((InterfaceList)yyVals[-1+yyTop]).getTypeVector(), ((ClassAndParameter)yyVals[-3+yyTop]).getParaVector(), ((Token)yyVals[-4+yyTop]).getOffset()); this.initContainedTypes(); this.initUsedIdsToCheck(); } @@ -978,7 +978,7 @@ case 36: pl.getParalist().addElement(new GenericTypeVar(((Token)yyVals[0+yyTop]).getLexem(),null, ((Token)yyVals[0+yyTop]).getOffset())); /*pl.getParalist().addElement( new TypePlaceholder($1.getLexem()) );*/ /* ########################################################### */ - org.apache.log4j.Logger.getLogger("parser").debug( "IDENTIFIER --> Paralist f�r " + ((Token)yyVals[0+yyTop]).getLexem() + " TV"); + de.dhbwstuttgart.logger.Logger.getLogger("parser").debug( "IDENTIFIER --> Paralist f�r " + ((Token)yyVals[0+yyTop]).getLexem() + " TV"); yyVal = pl; } break; @@ -989,7 +989,7 @@ case 37: RefType t = new RefType( ((Token)yyVals[-3+yyTop]).getLexem(),null,((Token)yyVals[-3+yyTop]).getOffset() ); t.set_ParaList( ((ParaList)yyVals[-1+yyTop]).get_ParaList() ); pl.getParalist().addElement(t); - org.apache.log4j.Logger.getLogger("parser").debug( "IDENTIFIER '<' paralist '>' --> Paralist f�r " + ((Token)yyVals[-3+yyTop]).getLexem() + ": RefType"); + de.dhbwstuttgart.logger.Logger.getLogger("parser").debug( "IDENTIFIER '<' paralist '>' --> Paralist f�r " + ((Token)yyVals[-3+yyTop]).getLexem() + ": RefType"); yyVal = pl; } break; @@ -1010,8 +1010,8 @@ case 39: ((ParaList)yyVals[-2+yyTop]).getParalist().addElement(new GenericTypeVar(((Token)yyVals[0+yyTop]).getLexem(), null,((Token)yyVals[0+yyTop]).getOffset())); /*$1.getParalist().addElement(new TypePlaceholder($3.getLexem()));*/ /* ########################################################### */ - org.apache.log4j.Logger.getLogger("parser").debug( "paralist ',' IDENTIFIER --> Paralist f�r " + ((Token)yyVals[0+yyTop]).getLexem() + ": TV"); - org.apache.log4j.Logger.getLogger("parser").debug( "paralist: " + ((ParaList)yyVals[-2+yyTop]).getParalist()); + de.dhbwstuttgart.logger.Logger.getLogger("parser").debug( "paralist ',' IDENTIFIER --> Paralist f�r " + ((Token)yyVals[0+yyTop]).getLexem() + ": TV"); + de.dhbwstuttgart.logger.Logger.getLogger("parser").debug( "paralist: " + ((ParaList)yyVals[-2+yyTop]).getParalist()); yyVal=((ParaList)yyVals[-2+yyTop]); } break; @@ -1021,7 +1021,7 @@ case 40: RefType t = new RefType( ((Token)yyVals[-3+yyTop]).getLexem(),null ,((Token)yyVals[-3+yyTop]).getOffset() ); t.set_ParaList( ((ParaList)yyVals[-1+yyTop]).get_ParaList() ); ((ParaList)yyVals[-5+yyTop]).getParalist().addElement(t); - org.apache.log4j.Logger.getLogger("parser").debug( "paralist ',' IDENTIFIER '<' paralist '>' --> Paralist f�r " + ((Token)yyVals[-3+yyTop]).getLexem() + ": RefType"); + de.dhbwstuttgart.logger.Logger.getLogger("parser").debug( "paralist ',' IDENTIFIER '<' paralist '>' --> Paralist f�r " + ((Token)yyVals[-3+yyTop]).getLexem() + ": RefType"); yyVal=((ParaList)yyVals[-5+yyTop]); } break; @@ -1396,13 +1396,13 @@ case 89: case 90: // line 854 "./../src/de/dhbwstuttgart/parser/JavaParser.jay" { + ((FieldDeclaration)yyVals[-1+yyTop]).setType(((Type)yyVals[-2+yyTop])); yyVal=((FieldDeclaration)yyVals[-1+yyTop]); } break; case 91: - // line 858 "./../src/de/dhbwstuttgart/parser/JavaParser.jay" + // line 859 "./../src/de/dhbwstuttgart/parser/JavaParser.jay" { - ((FieldDeclaration)yyVals[-1+yyTop]).setType(((Type)yyVals[-2+yyTop])); yyVal=((FieldDeclaration)yyVals[-1+yyTop]); } break; @@ -1423,7 +1423,7 @@ case 93: case 94: // line 875 "./../src/de/dhbwstuttgart/parser/JavaParser.jay" { - org.apache.log4j.Logger.getLogger("parser").debug("T->Parser->fielddeclaration ...: type " + ((Type)yyVals[-2+yyTop])); + de.dhbwstuttgart.logger.Logger.getLogger("parser").debug("T->Parser->fielddeclaration ...: type " + ((Type)yyVals[-2+yyTop])); ((FieldDeclaration)yyVals[-1+yyTop]).setType(((Type)yyVals[-2+yyTop])); yyVal = ((FieldDeclaration)yyVals[-1+yyTop]); } @@ -1955,7 +1955,7 @@ case 155: case 156: // line 1316 "./../src/de/dhbwstuttgart/parser/JavaParser.jay" { - org.apache.log4j.Logger.getLogger("parser").debug("T->Parser->referenctype: " + ((UsedId)yyVals[0+yyTop])); + de.dhbwstuttgart.logger.Logger.getLogger("parser").debug("T->Parser->referenctype: " + ((UsedId)yyVals[0+yyTop])); RefType RT = new RefType(null,((UsedId)yyVals[0+yyTop]).getOffset()); /*ausgetauscht PL 05-07-30*/ @@ -2002,7 +2002,7 @@ case 160: case 161: // line 1393 "./../src/de/dhbwstuttgart/parser/JavaParser.jay" { - org.apache.log4j.Logger.getLogger("parser").debug("\nFunktionsdeklaration mit typlosen Parametern: " + ((DeclId)yyVals[0+yyTop]).name); + de.dhbwstuttgart.logger.Logger.getLogger("parser").debug("\nFunktionsdeklaration mit typlosen Parametern: " + ((DeclId)yyVals[0+yyTop]).name); FormalParameter FP = new FormalParameter(((DeclId)yyVals[0+yyTop])); @@ -2011,7 +2011,7 @@ case 161: /*Type T = TypePlaceholder.fresh(); //auskommentiert von Andreas Stadelmeier*/ /* Type T = new TypePlaceholder(""); /* otth: Name wird automatisch berechnet * /*/ /* ###########################################################*/ - /*org.apache.log4j.Logger.getLogger("parser").debug("\n--> berechneter Name: " + T.getName());*/ + /*de.dhbwstuttgart.logger.Logger.getLogger("parser").debug("\n--> berechneter Name: " + T.getName());*/ /*auskommentiert von Andreas Stadelmeier (a10023) FP.setType( T );*/ /*FP.set_DeclId($1);*/ @@ -2132,7 +2132,7 @@ case 176: case 177: // line 1500 "./../src/de/dhbwstuttgart/parser/JavaParser.jay" { - org.apache.log4j.Logger.getLogger("parser").debug("P -> Lokale Variable angelegt!"); + de.dhbwstuttgart.logger.Logger.getLogger("parser").debug("P -> Lokale Variable angelegt!"); LocalVarDecl LVD = new LocalVarDecl(((Type)yyVals[-1+yyTop]).getOffset(),((Type)yyVals[-1+yyTop]).getVariableLength()); LVD.setType(((Type)yyVals[-1+yyTop])); LVD.setDeclidVector(((FieldDeclaration)yyVals[0+yyTop]).getDeclIdVector()); @@ -2142,7 +2142,7 @@ case 177: case 178: // line 1511 "./../src/de/dhbwstuttgart/parser/JavaParser.jay" { - org.apache.log4j.Logger.getLogger("parser").debug("P -> Lokale Variable angelegt!"); + de.dhbwstuttgart.logger.Logger.getLogger("parser").debug("P -> Lokale Variable angelegt!"); LocalVarDecl LVD = new LocalVarDecl(((FieldDeclaration)yyVals[0+yyTop]).getOffset(),((FieldDeclaration)yyVals[0+yyTop]).getVariableLength()); /*auskommentiert von Andreas Stadelmeier (a10023) LVD.setType(TypePlaceholder.fresh());*/ LVD.setDeclidVector(((FieldDeclaration)yyVals[0+yyTop]).getDeclIdVector()); @@ -2296,7 +2296,7 @@ case 193: case 194: // line 1650 "./../src/de/dhbwstuttgart/parser/JavaParser.jay" { - org.apache.log4j.Logger.getLogger("parser").debug("conditionalexpression"); + de.dhbwstuttgart.logger.Logger.getLogger("parser").debug("conditionalexpression"); yyVal=((Expr)yyVals[0+yyTop]); } break; @@ -2361,7 +2361,7 @@ case 203: case 204: // line 1703 "./../src/de/dhbwstuttgart/parser/JavaParser.jay" { - org.apache.log4j.Logger.getLogger("parser").debug("\nParser --> Zuweisung1!\n"); + de.dhbwstuttgart.logger.Logger.getLogger("parser").debug("\nParser --> Zuweisung1!\n"); Assign Ass = new Assign(((UsedId)yyVals[-2+yyTop]).getOffset(),((UsedId)yyVals[-2+yyTop]).getVariableLength()); LocalOrFieldVar LOFV = new LocalOrFieldVar(((UsedId)yyVals[-2+yyTop]).getOffset(),((UsedId)yyVals[-2+yyTop]).getVariableLength()); LOFV.set_UsedId(((UsedId)yyVals[-2+yyTop])); @@ -2369,7 +2369,7 @@ case 204: /*auskommentiert von Andreas Stadelmeier (a10023) Ass.setType(TypePlaceholder.fresh());*/ if( ((Operator)yyVals[-1+yyTop]) == null ) { - org.apache.log4j.Logger.getLogger("parser").debug("\nParser --> Zuweisung1 --> " + ((Expr)yyVals[0+yyTop]) + " \n"); + de.dhbwstuttgart.logger.Logger.getLogger("parser").debug("\nParser --> Zuweisung1 --> " + ((Expr)yyVals[0+yyTop]) + " \n"); Ass.set_Expr( LOFV,((Expr)yyVals[0+yyTop]) ); } else @@ -2378,7 +2378,7 @@ case 204: Bin.set_Expr1(LOFV); Bin.set_Operator(((Operator)yyVals[-1+yyTop])); Bin.set_Expr2(((Expr)yyVals[0+yyTop])); - org.apache.log4j.Logger.getLogger("parser").debug("\nParser --> Zuweisung1 --> Binary\n"); + de.dhbwstuttgart.logger.Logger.getLogger("parser").debug("\nParser --> Zuweisung1 --> Binary\n"); /*auskommentiert von Andreas Stadelmeier (a10023) Bin.setType(TypePlaceholder.fresh());*/ Ass.set_Expr( LOFV, Bin ); } @@ -2608,7 +2608,7 @@ case 232: case 233: // line 1933 "./../src/de/dhbwstuttgart/parser/JavaParser.jay" { - org.apache.log4j.Logger.getLogger("parser").debug("M1"); + de.dhbwstuttgart.logger.Logger.getLogger("parser").debug("M1"); MethodCall MC = new MethodCall(((UsedId)yyVals[-2+yyTop]).getOffset(),((UsedId)yyVals[-2+yyTop]).getVariableLength()); UsedId udidmeth = new UsedId(((UsedId)yyVals[-2+yyTop]).getOffset()); udidmeth.set_Name((String)((((UsedId)yyVals[-2+yyTop]).get_Name()).elementAt(((UsedId)yyVals[-2+yyTop]).get_Name().size()-1))); @@ -2640,7 +2640,7 @@ case 233: case 234: // line 1963 "./../src/de/dhbwstuttgart/parser/JavaParser.jay" { - org.apache.log4j.Logger.getLogger("parser").debug("M2"); + de.dhbwstuttgart.logger.Logger.getLogger("parser").debug("M2"); MethodCall MCarg = new MethodCall(((UsedId)yyVals[-3+yyTop]).getOffset(),((UsedId)yyVals[-3+yyTop]).getVariableLength()); UsedId udidmeth = new UsedId(((UsedId)yyVals[-3+yyTop]).getOffset()); udidmeth.set_Name((String)((((UsedId)yyVals[-3+yyTop]).get_Name()).elementAt(((UsedId)yyVals[-3+yyTop]).get_Name().size()-1))); @@ -2673,7 +2673,7 @@ case 234: case 235: // line 1994 "./../src/de/dhbwstuttgart/parser/JavaParser.jay" { - org.apache.log4j.Logger.getLogger("parser").debug("M3"); + de.dhbwstuttgart.logger.Logger.getLogger("parser").debug("M3"); MethodCall MCpr = new MethodCall(((Expr)yyVals[-4+yyTop]).getOffset(),((Expr)yyVals[-4+yyTop]).getVariableLength()); /* PL 05-08-21 primary ist kein UsedId*/ @@ -2694,7 +2694,7 @@ case 235: case 236: // line 2013 "./../src/de/dhbwstuttgart/parser/JavaParser.jay" { - org.apache.log4j.Logger.getLogger("parser").debug("M4"); + de.dhbwstuttgart.logger.Logger.getLogger("parser").debug("M4"); MethodCall MCPA = new MethodCall(((Expr)yyVals[-5+yyTop]).getOffset(),((Expr)yyVals[-5+yyTop]).getVariableLength()); /* PL 05-08-21 primary ist kein UsedId*/ @@ -3209,8 +3209,8 @@ case 289: 3, 2, 3, 2, 3, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 2, 1, 3, 3, 1, 0, 3, 1, 1, 1, - 1, 2, 2, 3, 6, 2, 3, 1, 3, 2, - 3, 4, 2, 3, 4, 2, 2, 3, 3, 4, + 1, 2, 2, 3, 6, 2, 3, 1, 3, 3, + 2, 4, 2, 3, 4, 2, 2, 3, 3, 4, 2, 3, 3, 4, 2, 1, 1, 3, 1, 3, 1, 3, 1, 3, 3, 2, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, @@ -3248,7 +3248,7 @@ case 289: 34, 0, 0, 0, 77, 21, 0, 0, 33, 0, 0, 0, 31, 0, 82, 0, 0, 0, 113, 0, 0, 132, 0, 142, 96, 0, 134, 46, 57, 0, - 93, 90, 0, 0, 0, 0, 0, 0, 0, 0, + 93, 91, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 83, 26, 51, 29, 53, 66, 0, 86, 0, 55, 43, 44, 73, 74, 23, 0, 25, 35, 111, 0, 108, 0, 0, 0, 254, 0, @@ -3261,7 +3261,7 @@ case 289: 165, 141, 0, 0, 0, 0, 0, 0, 0, 245, 286, 0, 0, 276, 0, 0, 0, 0, 0, 0, 0, 194, 173, 87, 241, 242, 248, 249, 174, 195, - 255, 259, 99, 0, 119, 94, 91, 0, 0, 0, + 255, 259, 99, 0, 119, 94, 90, 0, 0, 0, 135, 0, 0, 84, 0, 101, 0, 0, 0, 27, 0, 0, 0, 198, 0, 0, 0, 229, 230, 219, 0, 0, 0, 98, 144, 167, 216, 0, 0, 231, diff --git a/src/de/dhbwstuttgart/parser/JavaParser.jay b/src/de/dhbwstuttgart/parser/JavaParser.jay index e163827e..80d2bd39 100755 --- a/src/de/dhbwstuttgart/parser/JavaParser.jay +++ b/src/de/dhbwstuttgart/parser/JavaParser.jay @@ -368,50 +368,50 @@ classdeclaration : CLASS classidentifier classbody // Vector SuperInterfaces, // Vector Parameterliste - $$ = new Class($2.getName(), null, $3, containedTypes, usedIdsToCheck, null, null, $2.getParaVector(), $1.getOffset()); + $$ = new Class($2.getName(), null, $3, containedTypes, null, $2.getParaVector(), $1.getOffset()); this.initContainedTypes(); this.initUsedIdsToCheck(); } | modifiers CLASS classidentifier classbody { - $$ = new Class($3.getName(), $1, $4, containedTypes,usedIdsToCheck, null, null, $3.getParaVector(), $2.getOffset()); + $$ = new Class($3.getName(), $1, $4, containedTypes, null, $3.getParaVector(), $2.getOffset()); this.initContainedTypes(); this.initUsedIdsToCheck(); } | CLASS classidentifier super classbody { - $$ = new Class($2.getName(), null, $4, containedTypes,usedIdsToCheck, $3, null, $2.getParaVector(), $1.getOffset()); + $$ = new Class($2.getName(), null, $4, containedTypes, $3, null, $2.getParaVector(), $1.getOffset()); this.initContainedTypes(); this.initUsedIdsToCheck(); } | modifiers CLASS classidentifier super classbody { - $$ = new Class($3.getName(), $1, $5, containedTypes, usedIdsToCheck, $4, null, $3.getParaVector(), $2.getOffset()); + $$ = new Class($3.getName(), $1, $5, containedTypes, $4, null, $3.getParaVector(), $2.getOffset()); this.initContainedTypes(); this.initUsedIdsToCheck(); } ///* auskommentiert von Andreas Stadelmeier A10023 | CLASS classidentifier interfaces classbody { - $$ = new Class($2.getName(), null, $4, containedTypes, usedIdsToCheck, null, $3.getVector(), $2.getParaVector(), $1.getOffset()); + $$ = new Class($2.getName(), null, $4, containedTypes, $3.getTypeVector(), $2.getParaVector(), $1.getOffset()); this.initContainedTypes(); this.initUsedIdsToCheck(); } | modifiers CLASS classidentifier interfaces classbody { - $$ = new Class($3.getName(), $1, $5, containedTypes, usedIdsToCheck, null, $4.getVector(), $3.getParaVector(), $2.getOffset()); + $$ = new Class($3.getName(), $1, $5, containedTypes, $4.getTypeVector(), $3.getParaVector(), $2.getOffset()); this.initContainedTypes(); this.initUsedIdsToCheck(); } | CLASS classidentifier super interfaces classbody { - $$ = new Class($2.getName(), null, $5, containedTypes,usedIdsToCheck, $3, $4.getVector(), $2.getParaVector(), $1.getOffset()); + $$ = new Class($2.getName(), null, $5, containedTypes, $3, $4.getTypeVector(), $2.getParaVector(), $1.getOffset()); this.initContainedTypes(); this.initUsedIdsToCheck(); } | modifiers CLASS classidentifier super interfaces classbody { - $$ = new Class($3.getName(), $1, $6, containedTypes, usedIdsToCheck, $4, $5.getVector(), $3.getParaVector(), $2.getOffset()); + $$ = new Class($3.getName(), $1, $6, containedTypes, $4, $5.getTypeVector(), $3.getParaVector(), $2.getOffset()); this.initContainedTypes(); this.initUsedIdsToCheck(); } @@ -486,7 +486,7 @@ paralist : IDENTIFIER pl.getParalist().addElement(new GenericTypeVar($1.getLexem(),null, $1.getOffset())); //pl.getParalist().addElement( new TypePlaceholder($1.getLexem()) ); /* ########################################################### */ - org.apache.log4j.Logger.getLogger("parser").debug( "IDENTIFIER --> Paralist f�r " + $1.getLexem() + " TV"); + de.dhbwstuttgart.logger.Logger.getLogger("parser").debug( "IDENTIFIER --> Paralist f�r " + $1.getLexem() + " TV"); $$ = pl; } | IDENTIFIER '<' paralist '>' @@ -495,7 +495,7 @@ paralist : IDENTIFIER RefType t = new RefType( $1.getLexem(),null,$1.getOffset() ); t.set_ParaList( $3.get_ParaList() ); pl.getParalist().addElement(t); - org.apache.log4j.Logger.getLogger("parser").debug( "IDENTIFIER '<' paralist '>' --> Paralist f�r " + $1.getLexem() + ": RefType"); + de.dhbwstuttgart.logger.Logger.getLogger("parser").debug( "IDENTIFIER '<' paralist '>' --> Paralist f�r " + $1.getLexem() + ": RefType"); $$ = pl; } | wildcardparameter @@ -512,8 +512,8 @@ paralist : IDENTIFIER $1.getParalist().addElement(new GenericTypeVar($3.getLexem(), null,$3.getOffset())); //$1.getParalist().addElement(new TypePlaceholder($3.getLexem())); /* ########################################################### */ - org.apache.log4j.Logger.getLogger("parser").debug( "paralist ',' IDENTIFIER --> Paralist f�r " + $3.getLexem() + ": TV"); - org.apache.log4j.Logger.getLogger("parser").debug( "paralist: " + $1.getParalist()); + de.dhbwstuttgart.logger.Logger.getLogger("parser").debug( "paralist ',' IDENTIFIER --> Paralist f�r " + $3.getLexem() + ": TV"); + de.dhbwstuttgart.logger.Logger.getLogger("parser").debug( "paralist: " + $1.getParalist()); $$=$1; } @@ -522,7 +522,7 @@ paralist : IDENTIFIER RefType t = new RefType( $3.getLexem(),null ,$3.getOffset() ); t.set_ParaList( $5.get_ParaList() ); $1.getParalist().addElement(t); - org.apache.log4j.Logger.getLogger("parser").debug( "paralist ',' IDENTIFIER '<' paralist '>' --> Paralist f�r " + $3.getLexem() + ": RefType"); + de.dhbwstuttgart.logger.Logger.getLogger("parser").debug( "paralist ',' IDENTIFIER '<' paralist '>' --> Paralist f�r " + $3.getLexem() + ": RefType"); $$=$1; } | paralist ',' wildcardparameter @@ -850,15 +850,15 @@ genericdeclarationlist : '<' boundedMethodParameters '>' } -fielddeclaration : fielddeclarator ';' - { - $$=$1; - } - | type fielddeclarator ';' +fielddeclaration : type fielddeclarator ';' { $2.setType($1); $$=$2; } + | fielddeclarator ';' + { + $$=$1; + } | genericdeclarationlist type fielddeclarator ';' {//angefügt von Andreas Stadelmeier $3.setType($2); @@ -873,7 +873,7 @@ fielddeclaration : fielddeclarator ';' | type variabledeclarators ';' { - org.apache.log4j.Logger.getLogger("parser").debug("T->Parser->fielddeclaration ...: type " + $1); + de.dhbwstuttgart.logger.Logger.getLogger("parser").debug("T->Parser->fielddeclaration ...: type " + $1); $2.setType($1); $$ = $2; } @@ -1314,7 +1314,7 @@ referencelongtype : typename parameter referencetype :classorinterfacetype { - org.apache.log4j.Logger.getLogger("parser").debug("T->Parser->referenctype: " + $1); + de.dhbwstuttgart.logger.Logger.getLogger("parser").debug("T->Parser->referenctype: " + $1); RefType RT = new RefType(null,$1.getOffset()); //ausgetauscht PL 05-07-30 @@ -1385,13 +1385,13 @@ formalparameter : type variabledeclaratorid //FP.set_DeclId($5); $$=FP; - org.apache.log4j.Logger.getLogger("parser").debug("P->Polymorphes Methodenargument hinzugefuegt: Name = " + $5.get_Name() + " Typ = " + $1.getName()); + de.dhbwstuttgart.logger.Logger.getLogger("parser").debug("P->Polymorphes Methodenargument hinzugefuegt: Name = " + $5.get_Name() + " Typ = " + $1.getName()); } */ | variabledeclaratorid { - org.apache.log4j.Logger.getLogger("parser").debug("\nFunktionsdeklaration mit typlosen Parametern: " + $1.name); + de.dhbwstuttgart.logger.Logger.getLogger("parser").debug("\nFunktionsdeklaration mit typlosen Parametern: " + $1.name); FormalParameter FP = new FormalParameter($1); @@ -1400,7 +1400,7 @@ formalparameter : type variabledeclaratorid //Type T = TypePlaceholder.fresh(); //auskommentiert von Andreas Stadelmeier // Type T = new TypePlaceholder(""); /* otth: Name wird automatisch berechnet */ // ########################################################### - //org.apache.log4j.Logger.getLogger("parser").debug("\n--> berechneter Name: " + T.getName()); + //de.dhbwstuttgart.logger.Logger.getLogger("parser").debug("\n--> berechneter Name: " + T.getName()); //auskommentiert von Andreas Stadelmeier (a10023) FP.setType( T ); //FP.set_DeclId($1); @@ -1498,7 +1498,7 @@ integraltype :INT localvariabledeclaration : type variabledeclarators { - org.apache.log4j.Logger.getLogger("parser").debug("P -> Lokale Variable angelegt!"); + de.dhbwstuttgart.logger.Logger.getLogger("parser").debug("P -> Lokale Variable angelegt!"); LocalVarDecl LVD = new LocalVarDecl($1.getOffset(),$1.getVariableLength()); LVD.setType($1); LVD.setDeclidVector($2.getDeclIdVector()); @@ -1509,7 +1509,7 @@ localvariabledeclaration : type variabledeclarators /* ########################################################### */ |variabledeclarators { - org.apache.log4j.Logger.getLogger("parser").debug("P -> Lokale Variable angelegt!"); + de.dhbwstuttgart.logger.Logger.getLogger("parser").debug("P -> Lokale Variable angelegt!"); LocalVarDecl LVD = new LocalVarDecl($1.getOffset(),$1.getVariableLength()); //auskommentiert von Andreas Stadelmeier (a10023) LVD.setType(TypePlaceholder.fresh()); LVD.setDeclidVector($1.getDeclIdVector()); @@ -1648,7 +1648,7 @@ forstatement assignmentexpression : conditionalexpression { - org.apache.log4j.Logger.getLogger("parser").debug("conditionalexpression"); + de.dhbwstuttgart.logger.Logger.getLogger("parser").debug("conditionalexpression"); $$=$1; } | assignment @@ -1701,7 +1701,7 @@ conditionalexpression :conditionalorexpression assignment :lefthandside assignmentoperator assignmentexpression { - org.apache.log4j.Logger.getLogger("parser").debug("\nParser --> Zuweisung1!\n"); + de.dhbwstuttgart.logger.Logger.getLogger("parser").debug("\nParser --> Zuweisung1!\n"); Assign Ass = new Assign($1.getOffset(),$1.getVariableLength()); LocalOrFieldVar LOFV = new LocalOrFieldVar($1.getOffset(),$1.getVariableLength()); LOFV.set_UsedId($1); @@ -1709,7 +1709,7 @@ assignment :lefthandside assignmentoperator assignmentexpr //auskommentiert von Andreas Stadelmeier (a10023) Ass.setType(TypePlaceholder.fresh()); if( $2 == null ) { - org.apache.log4j.Logger.getLogger("parser").debug("\nParser --> Zuweisung1 --> " + $3 + " \n"); + de.dhbwstuttgart.logger.Logger.getLogger("parser").debug("\nParser --> Zuweisung1 --> " + $3 + " \n"); Ass.set_Expr( LOFV,$3 ); } else @@ -1718,7 +1718,7 @@ assignment :lefthandside assignmentoperator assignmentexpr Bin.set_Expr1(LOFV); Bin.set_Operator($2); Bin.set_Expr2($3); - org.apache.log4j.Logger.getLogger("parser").debug("\nParser --> Zuweisung1 --> Binary\n"); + de.dhbwstuttgart.logger.Logger.getLogger("parser").debug("\nParser --> Zuweisung1 --> Binary\n"); //auskommentiert von Andreas Stadelmeier (a10023) Bin.setType(TypePlaceholder.fresh()); Ass.set_Expr( LOFV, Bin ); } @@ -1931,7 +1931,7 @@ postdecrementexpression :postfixexpression DECREMENT methodinvocation: name '(' ')' { - org.apache.log4j.Logger.getLogger("parser").debug("M1"); + de.dhbwstuttgart.logger.Logger.getLogger("parser").debug("M1"); MethodCall MC = new MethodCall($1.getOffset(),$1.getVariableLength()); UsedId udidmeth = new UsedId($1.getOffset()); udidmeth.set_Name((String)(($1.get_Name()).elementAt($1.get_Name().size()-1))); @@ -1961,7 +1961,7 @@ methodinvocation: } | name '('argumentlist')' { - org.apache.log4j.Logger.getLogger("parser").debug("M2"); + de.dhbwstuttgart.logger.Logger.getLogger("parser").debug("M2"); MethodCall MCarg = new MethodCall($1.getOffset(),$1.getVariableLength()); UsedId udidmeth = new UsedId($1.getOffset()); udidmeth.set_Name((String)(($1.get_Name()).elementAt($1.get_Name().size()-1))); @@ -1992,7 +1992,7 @@ methodinvocation: } | primary '.' IDENTIFIER '(' ')' { - org.apache.log4j.Logger.getLogger("parser").debug("M3"); + de.dhbwstuttgart.logger.Logger.getLogger("parser").debug("M3"); MethodCall MCpr = new MethodCall($1.getOffset(),$1.getVariableLength()); // PL 05-08-21 primary ist kein UsedId @@ -2011,7 +2011,7 @@ methodinvocation: } | primary '.' IDENTIFIER '('argumentlist ')' { - org.apache.log4j.Logger.getLogger("parser").debug("M4"); + de.dhbwstuttgart.logger.Logger.getLogger("parser").debug("M4"); MethodCall MCPA = new MethodCall($1.getOffset(),$1.getVariableLength()); // PL 05-08-21 primary ist kein UsedId diff --git a/src/de/dhbwstuttgart/syntaxtree/Class.java b/src/de/dhbwstuttgart/syntaxtree/Class.java index 10b46807..a23e235a 100755 --- a/src/de/dhbwstuttgart/syntaxtree/Class.java +++ b/src/de/dhbwstuttgart/syntaxtree/Class.java @@ -9,8 +9,8 @@ import java.util.Hashtable; import java.util.Iterator; import java.util.Vector; -import org.apache.log4j.Logger; - +import de.dhbwstuttgart.logger.Logger; +import de.dhbwstuttgart.logger.Section; import de.dhbwstuttgart.core.AClassOrInterface; import de.dhbwstuttgart.core.IItemWithOffset; import de.dhbwstuttgart.parser.JavaClassName; @@ -33,7 +33,6 @@ import de.dhbwstuttgart.typeinference.exceptions.TypeinferenceException; import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertPoint; import de.dhbwstuttgart.typeinference.unify.FC_TTO; import de.dhbwstuttgart.typeinference.unify.Unify; -import sun.reflect.generics.reflectiveObjects.NotImplementedException; // ino.class.Class.23010.declaration @@ -45,13 +44,13 @@ public class Class extends SyntaxTreeNode implements AClassOrInterface, IItemWit * Log4j - Loggerinstanzen */ protected static Logger inferencelog = Logger.getLogger("inference"); - protected static Logger codegenlog = Logger.getLogger("codegen"); - protected static Logger parserlog = Logger.getLogger("parser"); + //protected static Logger codegenlog = Logger.getLogger("codegen"); + //protected static Logger parserlog = Logger.getLogger("parser"); protected UsedId pkgName; protected Modifiers modifiers; protected String name; - private Vector superif = new Vector(); + private Vector superif = new Vector(); public UsedId getPackageName() { @@ -89,12 +88,13 @@ public class Class extends SyntaxTreeNode implements AClassOrInterface, IItemWit return ret; } - public Vector getSuperInterfaces() + public Vector getSuperInterfaces() { return superif; } - public void setSuperInterfaces(Vector superif) + @Override + public void setSuperInterfaces(Vector superif) { this.superif = superif; } @@ -112,7 +112,7 @@ public class Class extends SyntaxTreeNode implements AClassOrInterface, IItemWit private Block class_block; // ino.end // ino.attribute.paralist.23023.declaration - private Vector paralist = new Vector(); // Parameterliste 'class xy{}' wird gespeichert + //private Vector paralist = new Vector(); // Parameterliste 'class xy{}' wird gespeichert // ino.end // ino.attribute.parahash.23026.declaration private Hashtable parahash = new Hashtable(); // parametrisierten Attrib. werden mit den Paramet.aus paralist verk. @@ -137,14 +137,14 @@ public class Class extends SyntaxTreeNode implements AClassOrInterface, IItemWit private TypeAssumptions typeAssumptions = null;//muss mit null Initialisiert werden. Darf nur über getTypeAssumptions abgerufen werden. // ino.attribute.parserlog.23038.declaration - protected Logger parselog = Logger.getLogger("parser"); + //protected Logger parselog = Logger.getLogger("parser"); // ino.end - protected Logger typinferenzLog = Logger.getLogger("Typeinference"); + protected Logger typinferenzLog = Logger.getLogger(Class.class.getName()); private SyntaxTreeNode parent; private Vector fielddecl = new Vector(); private GenericDeclarationList genericClassParameters; private int offset; - private Class superClass; + private Type superClass; // ino.method.Class.23041.definition @@ -158,13 +158,33 @@ public class Class extends SyntaxTreeNode implements AClassOrInterface, IItemWit } this.offset = offset; if(!name.equals("Object"))//Alle Klassen außer Object erben von Object: - this.superClass = new Class("Object", -1); + this.superClass = new Class("Object", -1).getType(); } // ino.end - public Class(String name, Class superClass, int offset){ - this(name,offset); - this.superClass = superClass; + /** + * Erstellt eine Klasse, welche nur für die Assumptions verwendet wird. + * Sie enthält keine unnötigen Informationen, wie Offset oder ClassBody. + * @param name + * @param superClass + * @param modifiers + * @param supertypeGenPara - Eine Liste von Namen, welche die Generischen Parameter der Klasse darstellen. + */ + public Class(String name, RefType superClass, Modifiers modifiers, + Vector supertypeGenPara) { + this(name,superClass,modifiers,0); + if(supertypeGenPara == null)return; + Vector gtvs = new Vector<>(); + for(String gname : supertypeGenPara){ + GenericTypeVar newGTV=new GenericTypeVar(gname,this,0); + gtvs.add(newGTV); + } + this.genericClassParameters = new GenericDeclarationList(gtvs,0); + } + + public Class(String name, RefType superClass, Modifiers mod, int offset){ + this(name,mod,offset); + if(superClass == null)this.superClass = new Class("Object",-1).getType(); } // ino.method.Class.23044.definition @@ -177,15 +197,44 @@ public class Class extends SyntaxTreeNode implements AClassOrInterface, IItemWit } // ino.end - // ino.method.Class.23047.defdescription type=javadoc + public Class(String name, Modifiers mod, ClassBody cb, Vector ct, Vector usedIdsToCheck, + UsedId superclass, Vector superif, Vector paralist, int offset){ + this(name, mod, cb, ct, usedIdToRefType(superclass),usedIdToRefType(superif),paralist,offset); + } + public Class(String name, ClassBody cb, Vector ct, + UsedId superclass, Vector superif, Vector paralist, int offset) { + this(name,null,cb,ct,usedIdToRefType(superclass),superif,paralist,offset); + } + public Class(String name2, Modifiers modifiers2, ClassBody classBody, + Vector containedTypes2, UsedId usedId, + Vector typeVector, Vector paraVector, int offset2) { + this(name2, modifiers2, classBody, containedTypes2, usedIdToRefType(usedId),typeVector, paraVector, offset2); + } + public Class(String name2, Modifiers object, ClassBody classBody, + Vector containedTypes2, Vector typeVector, + Vector paraVector, int offset2) { + this(name2, object, classBody, containedTypes2,(Type)null, typeVector, paraVector, offset2); + } + private static Vector usedIdToRefType(Vector superif2) { + Vector ret = new Vector<>(); + for(UsedId id : superif2)ret.add(usedIdToRefType(id)); + return ret; + } + private static Type usedIdToRefType(UsedId superclass2) { + RefType ret = new RefType(superclass2.getSimpleName(), null, superclass2.getOffset()); + ret.set_ParaList(superclass2.get_ParaList()); + return ret; + } + + // ino.method.Class.23047.defdescription type=javadoc /** * Konstruktor, der die Angabe aller Parameter ermoeglicht. * Zur Uebersichtlichkeit in der Grammatik. */ // ino.end // ino.method.Class.23047.definition - public Class(String name, Modifiers mod, ClassBody cb, Vector ct, Vector usedIdsToCheck, - UsedId superclass, Vector superif, Vector paralist, int offset) + public Class(String name, Modifiers mod, ClassBody cb, Vector ct, + Type superclass, Vector vector, Vector paralist, int offset) // ino.end // ino.method.Class.23047.body { @@ -194,11 +243,19 @@ public class Class extends SyntaxTreeNode implements AClassOrInterface, IItemWit if (cb != null) set_ClassBody(cb); if (ct != null) setContainedTypes(ct); if (superclass != null){ - this.superClass = new Class(superClass.getName().toString(),-1); + this.superClass = superclass; } - if (superif != null) setSuperInterfaces(superif); + if (vector != null) setSuperInterfaces(vector); if (paralist != null){ - this.set_ParaList(paralist); + //this.set_ParaList(paralist); + Vector gtvList = new Vector<>(); + int lastItemOffset = 0; + for(Type paraT : paralist){ + GenericTypeVar gtv = new GenericTypeVar(paraT.get_Name(),this, paraT.getOffset()); + gtvList.add(gtv); + lastItemOffset = paraT.getOffset() + paraT.get_Name().length(); + } + this.genericClassParameters = new GenericDeclarationList(gtvList, lastItemOffset); } if(usedIdsToCheck!=null) this.usedIdsToCheck=usedIdsToCheck; @@ -210,11 +267,11 @@ public class Class extends SyntaxTreeNode implements AClassOrInterface, IItemWit } - parserlog.debug("Neue Klasse: " + name); + //parserlog.debug("Neue Klasse: " + name); } // ino.end - + public Vector getFields() { return fielddecl; @@ -258,7 +315,7 @@ public class Class extends SyntaxTreeNode implements AClassOrInterface, IItemWit } // ino.end - + /* // ino.method.complete_paralist.23062.definition public Vector complete_paralist(boolean ext) // ino.end @@ -277,7 +334,7 @@ public class Class extends SyntaxTreeNode implements AClassOrInterface, IItemWit return this.paralist; } // ino.end - + */ /** @@ -428,6 +485,7 @@ public class Class extends SyntaxTreeNode implements AClassOrInterface, IItemWit } // ino.end + /* // ino.method.set_ParaList.23098.definition public void set_ParaList(Vector para) // ino.end @@ -436,13 +494,15 @@ public class Class extends SyntaxTreeNode implements AClassOrInterface, IItemWit this.paralist = para; } // ino.end - + */ + // ino.method.get_ParaList.23101.definition - public Vector get_ParaList() + public Vector get_ParaList() // ino.end // ino.method.get_ParaList.23101.body { - return this.paralist; + //if(this.paralist == null)return new Vector(); + return this.getGenericParameter(); } // ino.end @@ -598,7 +658,7 @@ public class Class extends SyntaxTreeNode implements AClassOrInterface, IItemWit ////////////////////////////// inferencelog.info("Rufe TRStart()..."); - typinferenzLog.debug("Erstellte FiniteClosure: "+supportData); + typinferenzLog.debug("Erstellte FiniteClosure: "+supportData, Section.TYPEINFERENCE); ////////////////////////////// // Ab hier ... // @author A10023 - Andreas Stadelmeier: @@ -610,14 +670,14 @@ public class Class extends SyntaxTreeNode implements AClassOrInterface, IItemWit ConstraintsSet oderConstraints = new ConstraintsSet(); - for(Type gparam : this.paralist){ + for(Type gparam : this.get_ParaList()){ if(gparam instanceof GenericTypeVar)assumptions.add(((GenericTypeVar)gparam).createAssumptions()); //Constraints für die Generischen Variablen erstellen und diese dem AssumptionsSet hinzufügen } - for(Type gparam : this.paralist){ + for(Type gparam : this.get_ParaList()){ if(gparam instanceof GenericTypeVar)oderConstraints.add(((GenericTypeVar)gparam).TYPE(assumptions)); //Constraints für die Generischen Variablen erstellen und diese dem AssumptionsSet hinzufügen } - typinferenzLog.debug("Erstellte Assumptions: "+assumptions); + typinferenzLog.debug("Erstellte Assumptions: "+assumptions, Section.TYPEINFERENCE); /* //Generiere Liste mit Expressions, welche zur Initialisierung von Feldern verwendet werden. Vector fieldInitializers = new Vector(); @@ -636,7 +696,7 @@ public class Class extends SyntaxTreeNode implements AClassOrInterface, IItemWit for(Field f:this.getFields()){ oderConstraints.add(f.TYPE(assumptions)); } - typinferenzLog.debug("Erstellte Constraints: "+oderConstraints); + typinferenzLog.debug("Erstellte Constraints: "+oderConstraints, Section.TYPEINFERENCE); return oderConstraints; @@ -1097,6 +1157,9 @@ public class Class extends SyntaxTreeNode implements AClassOrInterface, IItemWit for(Field f : this.getFields()){ if(f.isPublic())ret.add(f.createTypeAssumptions(this)); } + for(GenericTypeVar gtv : this.getGenericParameter()){ + ret.add(gtv.createAssumptions()); + } return ret; } @@ -1140,10 +1203,12 @@ public class Class extends SyntaxTreeNode implements AClassOrInterface, IItemWit } if(this.genericClassParameters == null)this.setGenericParameter(new GenericDeclarationList(new Vector(), 0)); + /*//Nicht mehr notwendig, Generische Klassenparameter werden nun immer direkt in die genericClassParameters gespeichert. for(Type t : this.get_ParaList()){ if(t instanceof GenericTypeVar)this.genericClassParameters.add((GenericTypeVar)t); else this.genericClassParameters.add(new GenericTypeVar(t.get_Name(),this,-1)); } + */ for(Type t : this.get_ParaList()){ t.parserPostProcessing(this); } @@ -1184,7 +1249,7 @@ public class Class extends SyntaxTreeNode implements AClassOrInterface, IItemWit @Override public Vector getGenericParameter() { if(this.genericClassParameters == null)return new Vector(); - return this.genericClassParameters; + return this.genericClassParameters.getVector(); } @Override @@ -1225,7 +1290,7 @@ public class Class extends SyntaxTreeNode implements AClassOrInterface, IItemWit * Die Super Klasse dieser Klasse. * @return null für Klasse Object */ - public Class getSuperClass(){ + public Type getSuperClass(){ return this.superClass; } } diff --git a/src/de/dhbwstuttgart/syntaxtree/ClassBody.java b/src/de/dhbwstuttgart/syntaxtree/ClassBody.java index 3dd79b67..da24d8cd 100755 --- a/src/de/dhbwstuttgart/syntaxtree/ClassBody.java +++ b/src/de/dhbwstuttgart/syntaxtree/ClassBody.java @@ -6,7 +6,7 @@ import java.util.Enumeration; import java.util.Hashtable; import java.util.Vector; -import org.apache.log4j.Logger; +import de.dhbwstuttgart.logger.Logger; // ino.end diff --git a/src/de/dhbwstuttgart/syntaxtree/Field.java b/src/de/dhbwstuttgart/syntaxtree/Field.java index 51766f7a..2ba3ce6b 100644 --- a/src/de/dhbwstuttgart/syntaxtree/Field.java +++ b/src/de/dhbwstuttgart/syntaxtree/Field.java @@ -57,7 +57,7 @@ public abstract class Field extends SyntaxTreeNode implements TypeInsertable, Ty public Vector getGenericParameter() { Vector ret = new Vector<>(); if(this.genericParameters == null)return ret; - ret.addAll(this.genericParameters); + ret.addAll(this.genericParameters.getVector()); return ret; } diff --git a/src/de/dhbwstuttgart/syntaxtree/FormalParameter.java b/src/de/dhbwstuttgart/syntaxtree/FormalParameter.java index cb726848..d3d67c87 100755 --- a/src/de/dhbwstuttgart/syntaxtree/FormalParameter.java +++ b/src/de/dhbwstuttgart/syntaxtree/FormalParameter.java @@ -5,7 +5,8 @@ package de.dhbwstuttgart.syntaxtree; // ino.module.FormalParameter.8561.import import java.util.Vector; -import org.apache.log4j.Logger; +import de.dhbwstuttgart.logger.Logger; + import de.dhbwstuttgart.bytecode.ClassFile; import de.dhbwstuttgart.bytecode.CodeAttribute; import de.dhbwstuttgart.syntaxtree.misc.DeclId; @@ -15,10 +16,10 @@ import de.dhbwstuttgart.typeinference.JavaCodeResult; import de.dhbwstuttgart.typeinference.ResultSet; import de.dhbwstuttgart.typeinference.TypeInsertable; import de.dhbwstuttgart.typeinference.Typeable; +import de.dhbwstuttgart.typeinference.exceptions.NotImplementedException; import de.dhbwstuttgart.typeinference.exceptions.TypeinferenceException; import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertPoint; import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet; -import sun.reflect.generics.reflectiveObjects.NotImplementedException; // ino.class.FormalParameter.23391.declaration public class FormalParameter extends SyntaxTreeNode implements Typeable, TypeInsertable diff --git a/src/de/dhbwstuttgart/syntaxtree/GenericDeclarationList.java b/src/de/dhbwstuttgart/syntaxtree/GenericDeclarationList.java index 115e60e3..9a722981 100644 --- a/src/de/dhbwstuttgart/syntaxtree/GenericDeclarationList.java +++ b/src/de/dhbwstuttgart/syntaxtree/GenericDeclarationList.java @@ -1,5 +1,9 @@ package de.dhbwstuttgart.syntaxtree; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; import java.util.Vector; import de.dhbwstuttgart.parser.GenericVarDeclarationList; @@ -12,16 +16,57 @@ import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar; * @author janulrich * */ -public class GenericDeclarationList extends Vector{ +public class GenericDeclarationList extends SyntaxTreeNode implements Iterable{ private int offsetOfLastElement; - + private Vector gtvs = new Vector<>(); + public GenericDeclarationList(Vector values, int endOffset) { this.addAll(values); this.offsetOfLastElement = endOffset; } + private void addAll(Vector values) { + this.gtvs.addAll(values); + } + public int getEndOffset(){ return offsetOfLastElement; } + + @Override + public int getOffset() { + return getEndOffset(); + } + + @Override + public int getVariableLength() { + return 0; + } + + @Override + public Iterator iterator() { + return this.gtvs.iterator(); + } + + @Override + public Vector getChildren() { + Vector ret = new Vector<>(); + for(GenericTypeVar gtv : gtvs){ + ret.add(gtv); + } + return ret; + } + + public int size() { + return gtvs.size(); + } + + public Vector getVector() { + return this.gtvs; + } + + public void add(GenericTypeVar t) { + this.gtvs.add(t); + } } diff --git a/src/de/dhbwstuttgart/syntaxtree/Method.java b/src/de/dhbwstuttgart/syntaxtree/Method.java index db84fb99..6d8725b8 100755 --- a/src/de/dhbwstuttgart/syntaxtree/Method.java +++ b/src/de/dhbwstuttgart/syntaxtree/Method.java @@ -7,7 +7,7 @@ import java.util.Hashtable; import java.util.Iterator; import java.util.Vector; -import org.apache.log4j.Logger; +import de.dhbwstuttgart.logger.Logger; import de.dhbwstuttgart.bytecode.ClassFile; import de.dhbwstuttgart.core.IItemWithOffset; @@ -527,7 +527,7 @@ public class Method extends Field implements IItemWithOffset, TypeInsertable } //TypeCheck, falls es sich um einen RefType handelt: - this.returntype = this.returntype.TYPE(localAss, this).getType(); + this.returntype = this.returntype.checkTYPE(localAss, this); /* if(this.returntype!=null && (this.returntype instanceof RefType)&& !(this.returntype instanceof mycompiler.mytype.Void)){//Sonderfall der Methode: Ihr Typ darf Void definiert werden. @@ -540,7 +540,7 @@ public class Method extends Field implements IItemWithOffset, TypeInsertable //Die Parameter zu den Assumptions hinzufügen: if(this.parameterlist!=null)for(FormalParameter param : this.parameterlist){ - param.setType(param.getType().TYPE(localAss, this).getType()); + param.setType(param.getType().checkTYPE(localAss, this)); /* if(param.getType() instanceof RefType) { diff --git a/src/de/dhbwstuttgart/syntaxtree/SourceFile.java b/src/de/dhbwstuttgart/syntaxtree/SourceFile.java index 4c7046f9..59482510 100755 --- a/src/de/dhbwstuttgart/syntaxtree/SourceFile.java +++ b/src/de/dhbwstuttgart/syntaxtree/SourceFile.java @@ -10,8 +10,8 @@ import java.util.Hashtable; import java.util.Iterator; import java.util.Vector; -import org.apache.log4j.Logger; - +import de.dhbwstuttgart.logger.Logger; +import de.dhbwstuttgart.logger.Section; import de.dhbwstuttgart.bytecode.ClassFile; import de.dhbwstuttgart.core.AClassOrInterface; import de.dhbwstuttgart.core.MyCompiler; @@ -45,9 +45,8 @@ import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions; import de.dhbwstuttgart.typeinference.exceptions.DebugException; import de.dhbwstuttgart.typeinference.exceptions.TypeinferenceException; import de.dhbwstuttgart.typeinference.unify.FC_TTO; +import de.dhbwstuttgart.typeinference.unify.Unifier; import de.dhbwstuttgart.typeinference.unify.Unify; -import sun.reflect.generics.reflectiveObjects.NotImplementedException; -import sun.reflect.generics.reflectiveObjects.TypeVariableImpl; @@ -252,7 +251,7 @@ public class SourceFile */ // ino.end // ino.method.createPairFromClassAndSuperclass.21400.definition - private Pair createPairFromClassAndSuperclass(Class baseClass, Class superclass, Vector classParaOrg, Vector superclassParaOrg) + private Pair createPairFromClassAndSuperclass(Class baseClass, Type superclass, Vector classParaOrg, Vector superclassParaOrg, TypeAssumptions ass) // ino.end // ino.method.createPairFromClassAndSuperclass.21400.body { @@ -269,10 +268,12 @@ public class SourceFile new RefType( superclassName.toString(), superclassParaOrg,-1) ); */ - Pair P = new Pair(baseClass.getType(), superclass.getType()); + Pair P = new Pair(baseClass.getType().TYPE(ass, baseClass).getType(), superclass.TYPE(ass, baseClass).getType()); //PL 04-12-29 freshe Variablen ANFANG RefType r1 = (RefType)P.getTA1Copy(); - RefType r2 = (RefType)P.getTA2Copy(); + RefType r2 = (RefType)P.getTA2Copy(); + r1 = (RefType) r1.TYPE(ass, baseClass).getType(); + r2 = (RefType) r2.TYPE(ass, baseClass).getType(); // #JB# 05.04.2005 // ########################################################### Hashtable substHash = new Hashtable(); //fuer jedes Paar komplett neue Variablen @@ -297,7 +298,7 @@ public class SourceFile */ // ino.end // ino.method.makeFC.21403.definition - public FC_TTO makeFC( ) + public FC_TTO makeFC( TypeAssumptions ass ) // ino.end // ino.method.makeFC.21403.body { @@ -305,23 +306,38 @@ public class SourceFile // Menge FC bilden Vector vFC = new Vector(); // Menge FC - + TypeAssumptions globalAssumptions = this.makeBasicAssumptionsFromJRE(imports, false); + globalAssumptions.add(this.getPublicFieldAssumptions()); // 1. Menge <= in FC aufnehmen --> Iteration ueber alle Klassen + Vector basicAssumptionsClassVector = new Vector<>(); //die Klassen aus den BasicAssumptions + for(ClassAssumption cAss : ass.getClassAssumptions()){ + Type t1 = cAss.getAssumedClass().getType(); + Type t2 = cAss.getAssumedClass().getSuperClass(); + Pair p = new Pair(t1, t2); + //System.out.println("FCPair: "+p); + if(! t1.equals(t2)){//Um FC_TTO darf kein T <. T stehen. + //vFC.add(p); //Wird momentan nicht hinzugefügt + basicAssumptionsClassVector.add(cAss.getAssumedClass());//Klasse ohne die Superklasse anfügen + }else{ + //System.out.println("Wurde nicht aufgenommen"); + } + } + for( int i = 0; i < KlassenVektor.size(); i++ ) { Class tempKlasse = KlassenVektor.elementAt(i); inferencelog.debug("Verarbeite "+tempKlasse.getName()); //TODO: SuperKlasse erstellen, dies sollte am besten beim Konstruktoraufruf von Class geschehen. Diese kann dann mit getSuperClass abgefragt werden. if( tempKlasse.superclassid != null ) { // Klasse hat Superklasse - Pair P=createPairFromClassAndSuperclass(tempKlasse,tempKlasse.getSuperClass(),tempKlasse.get_ParaList(),tempKlasse.superclassid.get_ParaList()); + Pair P=createPairFromClassAndSuperclass(tempKlasse,tempKlasse.getSuperClass(),tempKlasse.get_ParaList(),tempKlasse.superclassid.get_ParaList(), globalAssumptions); vFC.add( P ); } if(tempKlasse.getSuperInterfaces()!=null){ - Iterator interfaceIterator=tempKlasse.getSuperInterfaces().iterator(); + Iterator interfaceIterator=tempKlasse.getSuperInterfaces().iterator(); while(interfaceIterator.hasNext()){ - Interface intf=interfaceIterator.next(); - Pair P=createPairFromClassAndSuperclass(tempKlasse,intf,tempKlasse.get_ParaList(),intf.get_ParaList()); + RefType intf=(RefType) interfaceIterator.next(); + Pair P=createPairFromClassAndSuperclass(tempKlasse,intf,tempKlasse.get_ParaList(),intf.get_ParaList(),globalAssumptions); vFC.add( P ); } @@ -330,10 +346,10 @@ public class SourceFile for(int i=0; i interfaceIterator=intf.getSuperInterfaces().iterator(); + Iterator interfaceIterator=intf.getSuperInterfaces().iterator(); while(interfaceIterator.hasNext()){ - Interface superintf=interfaceIterator.next(); - Pair P=createPairFromClassAndSuperclass(intf,superintf,intf.getParaList(), superintf.get_ParaList()); + RefType superintf=(RefType) interfaceIterator.next(); + Pair P=createPairFromClassAndSuperclass(intf,superintf,intf.getParaList(), superintf.get_ParaList(),globalAssumptions); vFC.add( P ); } @@ -608,10 +624,13 @@ public class SourceFile // printMenge( "nach trans: FC", vFC, 6 ); - FC_TTO fctto = new FC_TTO(vFC, tto,KlassenVektor); + Vector KlassenVektorunImportierteKlassen = new Vector<>(); + KlassenVektorunImportierteKlassen.addAll(basicAssumptionsClassVector); + KlassenVektorunImportierteKlassen.addAll(KlassenVektor); + + FC_TTO fctto = new FC_TTO(vFC, tto, KlassenVektorunImportierteKlassen); return fctto; } - // ino.end public TypeAssumptions getPublicFieldAssumptions(){ TypeAssumptions publicAssumptions = new TypeAssumptions(null); @@ -647,18 +666,20 @@ public class SourceFile //Logger initialisieren: Logger typinferenzLog = Logger.getLogger("Typeinference"); - //FiniteClosure generieren: - FC_TTO finiteClosure = this.makeFC(); - //Alle Assumptions für diese SourceFile sammeln: for(Class klasse : this.KlassenVektor){ globalAssumptions.add(klasse.getPublicFieldAssumptions()); } //Assumptions der importierten Klassen sammeln: - TypeAssumptions importAssumptions = this.makeBasicAssumptionsFromJRE(imports); + TypeAssumptions importAssumptions = this.makeBasicAssumptionsFromJRE(imports, true); globalAssumptions.add(importAssumptions); - typinferenzLog.debug("Von JRE erstellte Assumptions: "+importAssumptions); + typinferenzLog.debug("Von JRE erstellte Assumptions: "+importAssumptions, Section.TYPEINFERENCE); + + //FiniteClosure generieren: + FC_TTO finiteClosure = this.makeFC(globalAssumptions); + + typinferenzLog.debug("FiniteClosure: \n"+finiteClosure, Section.TYPEINFERENCE); ConstraintsSet oderConstraints = new ConstraintsSet(); //Alle Constraints der in dieser SourceFile enthaltenen Klassen sammeln: @@ -669,16 +690,25 @@ public class SourceFile //////////////// //Karthesisches Produkt bilden: //////////////// + + //Unmögliche ConstraintsSets aussortieren durch Unifizierung + Unifier unifier = (pairs)->{ + Vector> retValue = new Vector<>(); + retValue = Unify.unify(pairs, finiteClosure); + return retValue;}; + oderConstraints.filterWrongConstraints(unifier); + oderConstraints.unifyUndConstraints(unifier); + typinferenzLog.debug("Übriggebliebene Konstraints:\n"+oderConstraints+"\n", Section.TYPEINFERENCE); //Die Constraints in Pair's umwandeln (Karthesisches Produkt bilden): Vector> xConstraints = new Vector>();// = oderConstraints.getConstraints(); - for(Vector uC:oderConstraints.getConstraints()){ //mit dem getConstraints-Aufruf wird das Karthesische Produkt erzeugt. + for(Vector uC : oderConstraints.getConstraints()){ //mit dem getConstraints-Aufruf wird das Karthesische Produkt erzeugt. Vector cons = new Vector(); for(UndConstraint undCons:uC){ cons.addAll(undCons.getConstraintPairs()); } xConstraints.add(cons); } - typinferenzLog.debug("Karthesisches Produkt der Constraints: "+xConstraints); + typinferenzLog.debug("Karthesisches Produkt der Constraints: "+xConstraints, Section.TYPEINFERENCE); finiteClosure.generateFullyNamedTypes(globalAssumptions); @@ -752,7 +782,7 @@ public class SourceFile result.addAll(unifyResult); // Debugoutput:Vector> - typinferenzLog.debug("Unifiziertes Ergebnis: "+result); + typinferenzLog.debug("Unifiziertes Ergebnis: "+result, Section.TYPEINFERENCE); /* // Prüfe ob eindeutige Lösung: @@ -774,7 +804,7 @@ public class SourceFile //typinferenzLog.debug(supportData.getFiniteClosure()); //typinferenzLog.debug("Typinformationen: \n"+this.getTypeInformation(this.getMethodList(), fieldInitializers)); - typinferenzLog.debug("\nJavaFiles:\n"); + typinferenzLog.debug("\nJavaFiles:\n", Section.TYPEINFERENCE); //typinferenzLog.debug(this.printJavaCode(new ResultSet(new Vector()))); @@ -789,8 +819,8 @@ public class SourceFile ret.add(reconstructionResult); //ResultSet res = new ResultSet(resultSet); - typinferenzLog.debug("JavaFile für ResultSet "+reconstructionResult+"\n"); - typinferenzLog.debug(klasse.printJavaCode(reconstructionResult)); + typinferenzLog.debug("JavaFile für ResultSet "+reconstructionResult+"\n", Section.TYPEINFERENCE); + typinferenzLog.debug(klasse.printJavaCode(reconstructionResult), Section.TYPEINFERENCE); } } @@ -1075,8 +1105,13 @@ public class SourceFile return ret; }*/ - // ino.method.makeBasicAssumptionsFromJRE.21409.definition - private TypeAssumptions makeBasicAssumptionsFromJRE(Vector imports) + /** + * Erstellt die Assumptions der standardmäßig importierten Packages (java.lang.) sowie der von imports übergebenen Klassen zusammen. + * @param imports + * @param withSuptypes - Gibt an, ob auch die subklassen der Packages den Assumptions angefügt werden sollen. + * @return + */ + private TypeAssumptions makeBasicAssumptionsFromJRE(Vector imports, boolean withSubtypes) // ino.end // ino.method.makeBasicAssumptionsFromJRE.21409.body { @@ -1112,24 +1147,31 @@ public class SourceFile //String className=x.getSimpleName(); String className=x.getName(); + //Ermittle die Superklasse: + Class sClass = new Class("Object",0); + if(withSubtypes)sClass = getSuperClassOfJREClass(x, basicAssumptions); - - Class parentClass = new Class(className, mod, 0); - // Generische Typen erzeugen + // Namen von Generische Typen erzeugen Hashtable jreSpiderRegistry=new Hashtable(); - Vector typeGenPara = new Vector(); + Vector typeGenPara = new Vector(); for(int j=0;j0){ //auskommentiert von Andreas Stadelmeier: //basicAssumptions.addGenericTypeVars(className, typeGenPara); - parentClass.set_ParaList((Vector)typeGenPara);//myCl.set_ParaList((Vector)typeGenPara); + //parentClass.set_ParaList((Vector)typeGenPara);//myCl.set_ParaList((Vector)typeGenPara); } @@ -1157,7 +1199,7 @@ public class SourceFile GenericTypeVar newGTV=new GenericTypeVar(superclassTVS[tvi].getName(),parentClass,-1); supertypeGenPara.addElement(newGTV); } - + if(supertypeGenPara.size()==0){ supertypeGenPara=null; } @@ -1239,9 +1281,30 @@ public class SourceFile } // ino.end + private Class getSuperClassOfJREClass(java.lang.Class x, TypeAssumptions ass) { + Class ret; + java.lang.Class s = x.getSuperclass(); + if(s == null){ + return new Class("java.lang.Object",new Modifiers(), 0); + } - - // ino.method.isBaseType.21412.definition + Vector supertypeGenPara = new Vector<>();//Die Generischen Parameter für die Superklasse berechnen: + java.lang.reflect.TypeVariable[] superclassTVS=s.getTypeParameters(); + for(int tvi=0;tvi0){ - parserlog.debug(paralist); + parserlog.debug(paralist.toString()); parserlog.debug(c.getName()+" "+c.get_ParaList().size()); SCStatementException ex = new SCStatementException(); SCExcept e = new SCExcept(); @@ -378,7 +378,7 @@ public class LocalVarDecl extends Statement implements TypeInsertable ConstraintsSet ret = new ConstraintsSet(); if((this.getType() instanceof RefType)){ Type replaceType = null; - replaceType = assumptions.getTypeFor((RefType)this.getType(), this).getType(); + replaceType = assumptions.checkType((RefType)this.getType(), this); this.setType(replaceType); } assumptions.addAssumption(new LocalVarAssumption(this, this.getType())); //Bevor der Typ auf Void gesetzt wird. diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/LongLiteral.java b/src/de/dhbwstuttgart/syntaxtree/statement/LongLiteral.java index b4e0da4e..c35f333a 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/LongLiteral.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/LongLiteral.java @@ -6,7 +6,7 @@ import java.util.Hashtable; import java.util.Vector; -import org.apache.log4j.Logger; +import de.dhbwstuttgart.logger.Logger; import de.dhbwstuttgart.bytecode.ClassFile; import de.dhbwstuttgart.bytecode.CodeAttribute; @@ -25,8 +25,6 @@ import de.dhbwstuttgart.typeinference.JavaCodeResult; import de.dhbwstuttgart.typeinference.ResultSet; import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions; import de.dhbwstuttgart.typeinference.unify.CSubstitutionSet; -import sun.reflect.generics.reflectiveObjects.NotImplementedException; -// ino.end diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/MethodCall.java b/src/de/dhbwstuttgart/syntaxtree/statement/MethodCall.java index a2c418d0..d6e596c1 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/MethodCall.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/MethodCall.java @@ -5,7 +5,7 @@ package de.dhbwstuttgart.syntaxtree.statement; import java.util.Hashtable; import java.util.Vector; -import org.apache.log4j.Logger; +import de.dhbwstuttgart.logger.Logger; import de.dhbwstuttgart.bytecode.ClassFile; import de.dhbwstuttgart.bytecode.CodeAttribute; diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/NegativeExpr.java b/src/de/dhbwstuttgart/syntaxtree/statement/NegativeExpr.java index c83cfe5a..108ec380 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/NegativeExpr.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/NegativeExpr.java @@ -6,7 +6,7 @@ import java.util.Hashtable; import java.util.Iterator; import java.util.Vector; -import org.apache.log4j.Logger; +import de.dhbwstuttgart.logger.Logger; import de.dhbwstuttgart.bytecode.ClassFile; import de.dhbwstuttgart.bytecode.CodeAttribute; diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/NewArray.java b/src/de/dhbwstuttgart/syntaxtree/statement/NewArray.java index 94e9af5c..a1f03f3c 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/NewArray.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/NewArray.java @@ -6,7 +6,7 @@ import java.util.Hashtable; import java.util.Vector; -import org.apache.log4j.Logger; +import de.dhbwstuttgart.logger.Logger; import de.dhbwstuttgart.bytecode.ClassFile; import de.dhbwstuttgart.bytecode.CodeAttribute; import de.dhbwstuttgart.bytecode.JVMCode; diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/NewClass.java b/src/de/dhbwstuttgart/syntaxtree/statement/NewClass.java index 8270ab74..ce586551 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/NewClass.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/NewClass.java @@ -8,7 +8,7 @@ import java.util.Iterator; import java.util.Vector; -import org.apache.log4j.Logger; +import de.dhbwstuttgart.logger.Logger; import de.dhbwstuttgart.bytecode.ClassFile; import de.dhbwstuttgart.bytecode.CodeAttribute; import de.dhbwstuttgart.bytecode.JVMCode; @@ -88,46 +88,6 @@ public class NewClass extends Expr } // ino.end - // ino.method.sc_check.25852.definition - public void sc_check(Vector classname, Hashtable bh, Hashtable ch, boolean ext, Hashtable parach, Hashtable parabh) - throws SCStatementException - // ino.end - // ino.method.sc_check.25852.body - { - if(ext) - parserlog.debug(" ---NewClass---"); - Class cl; - String usedid = this.usedid.get_Name_1Element(); - String next = null; - for(Enumeration el = classname.elements(); el.hasMoreElements();) - { - cl = el.nextElement(); - next = (String)cl.getName().toString(); - if(ext) - parserlog.debug("Vergleiche "+usedid+" mit "+next); - if(usedid.equals(next)) - { - this.set_Type(new Type(next,this,getOffset())); - break; - } - else next = null; - } - if(next == null) - { - if(ext) - parserlog.error("Typfehler --> NewClass.sc_check()" ); - SCStatementException stex = new SCStatementException(); - SCExcept ex = new SCExcept(); - ex.set_error("Typfehler"); - ex.set_statement("NewClass: Klasse "+usedid+" existiert nicht im Vector classname."); - stex.addException(ex); - throw stex; - } - if(ext) - parserlog.debug("Klasse "+usedid+" im class-Vector gefunden"); - } - // ino.end - // ino.method.set_ArgumentList.25855.definition public void set_ArgumentList(ArgumentList al) // ino.end @@ -223,8 +183,8 @@ public class NewClass extends Expr //if(this.arglist != null && this.arglist.expr != null)for(Expr arg : this.arglist.expr){ // ret.add(arg.TYPEExpr(assumptions)); //} - - this.setType(assumptions.getTypeFor(new RefType(this.get_Name(),this,0), this).getType()); + Type thisT = assumptions.checkType(new RefType(this.get_Name(),this,0), (SyntaxTreeNode)this); + this.setType(thisT); /* diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/NotExpr.java b/src/de/dhbwstuttgart/syntaxtree/statement/NotExpr.java index 0b7a2a55..e859441e 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/NotExpr.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/NotExpr.java @@ -6,7 +6,7 @@ import java.util.Hashtable; import java.util.Iterator; import java.util.Vector; -import org.apache.log4j.Logger; +import de.dhbwstuttgart.logger.Logger; import de.dhbwstuttgart.bytecode.ClassFile; import de.dhbwstuttgart.bytecode.CodeAttribute; diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/Null.java b/src/de/dhbwstuttgart/syntaxtree/statement/Null.java index 66bc356c..b60060c4 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/Null.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/Null.java @@ -6,7 +6,7 @@ import java.util.Hashtable; import java.util.Vector; -import org.apache.log4j.Logger; +import de.dhbwstuttgart.logger.Logger; import de.dhbwstuttgart.bytecode.ClassFile; import de.dhbwstuttgart.bytecode.CodeAttribute; import de.dhbwstuttgart.bytecode.JVMCode; @@ -42,7 +42,7 @@ public class Null extends Literal // ino.method.Null.25926.body { super(-1,-1); - this.setType(new Type("__NULL__",this,getOffset())); + //this.setType(new Type("__NULL__",this,getOffset())); } // ino.end diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/PositivExpr.java b/src/de/dhbwstuttgart/syntaxtree/statement/PositivExpr.java index bea0c19d..4e2ff472 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/PositivExpr.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/PositivExpr.java @@ -6,7 +6,7 @@ import java.util.Hashtable; import java.util.Vector; -import org.apache.log4j.Logger; +import de.dhbwstuttgart.logger.Logger; import de.dhbwstuttgart.bytecode.ClassFile; import de.dhbwstuttgart.bytecode.CodeAttribute; import de.dhbwstuttgart.myexception.CTypeReconstructionException; diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/PostDecExpr.java b/src/de/dhbwstuttgart/syntaxtree/statement/PostDecExpr.java index 99b83e51..2c224f97 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/PostDecExpr.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/PostDecExpr.java @@ -6,7 +6,7 @@ import java.util.Hashtable; import java.util.Iterator; import java.util.Vector; -import org.apache.log4j.Logger; +import de.dhbwstuttgart.logger.Logger; import de.dhbwstuttgart.bytecode.ClassFile; import de.dhbwstuttgart.bytecode.CodeAttribute; diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/PostIncExpr.java b/src/de/dhbwstuttgart/syntaxtree/statement/PostIncExpr.java index 3837a3aa..02959a14 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/PostIncExpr.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/PostIncExpr.java @@ -6,7 +6,7 @@ import java.util.Hashtable; import java.util.Iterator; import java.util.Vector; -import org.apache.log4j.Logger; +import de.dhbwstuttgart.logger.Logger; import de.dhbwstuttgart.bytecode.ClassFile; import de.dhbwstuttgart.bytecode.CodeAttribute; diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/PreDecExpr.java b/src/de/dhbwstuttgart/syntaxtree/statement/PreDecExpr.java index a40139a3..778f7491 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/PreDecExpr.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/PreDecExpr.java @@ -6,7 +6,7 @@ import java.util.Hashtable; import java.util.Iterator; import java.util.Vector; -import org.apache.log4j.Logger; +import de.dhbwstuttgart.logger.Logger; import de.dhbwstuttgart.bytecode.ClassFile; import de.dhbwstuttgart.bytecode.CodeAttribute; diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/PreIncExpr.java b/src/de/dhbwstuttgart/syntaxtree/statement/PreIncExpr.java index 97a5bc0d..51553b2f 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/PreIncExpr.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/PreIncExpr.java @@ -6,7 +6,7 @@ import java.util.Hashtable; import java.util.Iterator; import java.util.Vector; -import org.apache.log4j.Logger; +import de.dhbwstuttgart.logger.Logger; import de.dhbwstuttgart.bytecode.ClassFile; import de.dhbwstuttgart.bytecode.CodeAttribute; diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/Receiver.java b/src/de/dhbwstuttgart/syntaxtree/statement/Receiver.java index bfe41dd7..8ed2da92 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/Receiver.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/Receiver.java @@ -5,7 +5,7 @@ package de.dhbwstuttgart.syntaxtree.statement; import java.util.Hashtable; import java.util.Vector; -import org.apache.log4j.Logger; +import de.dhbwstuttgart.logger.Logger; // ino.end diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/Return.java b/src/de/dhbwstuttgart/syntaxtree/statement/Return.java index 407133fd..d0c13f81 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/Return.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/Return.java @@ -5,7 +5,7 @@ package de.dhbwstuttgart.syntaxtree.statement; import java.util.Hashtable; import java.util.Vector; -import org.apache.log4j.Logger; +import de.dhbwstuttgart.logger.Logger; import de.dhbwstuttgart.bytecode.ClassFile; import de.dhbwstuttgart.bytecode.CodeAttribute; import de.dhbwstuttgart.bytecode.JVMCode; @@ -24,7 +24,6 @@ import de.dhbwstuttgart.typeinference.ResultSet; import de.dhbwstuttgart.typeinference.SingleConstraint; import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions; import de.dhbwstuttgart.typeinference.unify.CSubstitutionSet; -import sun.reflect.generics.reflectiveObjects.NotImplementedException; diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/Statement.java b/src/de/dhbwstuttgart/syntaxtree/statement/Statement.java index b4b9b8ae..120a015c 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/Statement.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/Statement.java @@ -23,7 +23,6 @@ import de.dhbwstuttgart.typeinference.Pair; import de.dhbwstuttgart.typeinference.ResultSet; import de.dhbwstuttgart.typeinference.Typeable; import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions; -import sun.reflect.generics.reflectiveObjects.NotImplementedException; diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/StringLiteral.java b/src/de/dhbwstuttgart/syntaxtree/statement/StringLiteral.java index 56fbe6ac..63123426 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/StringLiteral.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/StringLiteral.java @@ -6,7 +6,7 @@ import java.util.Hashtable; import java.util.Vector; -import org.apache.log4j.Logger; +import de.dhbwstuttgart.logger.Logger; import de.dhbwstuttgart.bytecode.ClassFile; import de.dhbwstuttgart.bytecode.CodeAttribute; import de.dhbwstuttgart.bytecode.JVMCode; @@ -121,7 +121,7 @@ public class StringLiteral extends Literal @Override public ConstraintsSet TYPEExpr(TypeAssumptions assumptions) { - this.set_Type(assumptions.getTypeFor(new RefType("String",this,0), this).getType()); + this.set_Type(assumptions.checkType(new RefType("String",this,0), this)); return new ConstraintsSet(); } diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/This.java b/src/de/dhbwstuttgart/syntaxtree/statement/This.java index 7733b5aa..e7c836fa 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/This.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/This.java @@ -5,7 +5,7 @@ package de.dhbwstuttgart.syntaxtree.statement; import java.util.Hashtable; import java.util.Vector; -import org.apache.log4j.Logger; +import de.dhbwstuttgart.logger.Logger; import de.dhbwstuttgart.bytecode.ClassFile; import de.dhbwstuttgart.bytecode.CodeAttribute; import de.dhbwstuttgart.bytecode.JVMCode; diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/WhileStmt.java b/src/de/dhbwstuttgart/syntaxtree/statement/WhileStmt.java index 9cef4194..8d1e0ddc 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/WhileStmt.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/WhileStmt.java @@ -7,7 +7,7 @@ import java.util.Hashtable; import java.util.Iterator; import java.util.Vector; -import org.apache.log4j.Logger; +import de.dhbwstuttgart.logger.Logger; import de.dhbwstuttgart.bytecode.ClassFile; import de.dhbwstuttgart.bytecode.CodeAttribute; @@ -31,9 +31,9 @@ import de.dhbwstuttgart.typeinference.Pair; import de.dhbwstuttgart.typeinference.ResultSet; import de.dhbwstuttgart.typeinference.SingleConstraint; import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions; +import de.dhbwstuttgart.typeinference.exceptions.NotImplementedException; import de.dhbwstuttgart.typeinference.unify.CSubstitutionSet; import de.dhbwstuttgart.typeinference.unify.Unify; -import sun.reflect.generics.reflectiveObjects.NotImplementedException; diff --git a/src/de/dhbwstuttgart/syntaxtree/type/BoundedGenericTypeVar.java b/src/de/dhbwstuttgart/syntaxtree/type/BoundedGenericTypeVar.java index d75715df..ebe21b0d 100755 --- a/src/de/dhbwstuttgart/syntaxtree/type/BoundedGenericTypeVar.java +++ b/src/de/dhbwstuttgart/syntaxtree/type/BoundedGenericTypeVar.java @@ -13,8 +13,6 @@ import de.dhbwstuttgart.typeinference.ConstraintsSet; import de.dhbwstuttgart.typeinference.SingleConstraint; import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions; import de.dhbwstuttgart.typeinference.exceptions.TypeinferenceException; -import sun.reflect.generics.reflectiveObjects.NotImplementedException; -// ino.end // ino.class.BoundedGenericTypeVar.26464.description type=javadoc /** @@ -93,7 +91,7 @@ public class BoundedGenericTypeVar extends GenericTypeVar if(this.bounds != null){ for(Type ev : this.bounds){ ConstraintType extendsType = ass.getTypeFor(ev, this); - if(extendsType == null)throw new TypeinferenceException("Der Typ "+ev.getName()+" ist nicht korrekt", this); + //if(extendsType == null)throw new TypeinferenceException("Der Typ "+ev.getName()+" ist nicht korrekt", this); ret.add(new SingleConstraint(ass.getTypeFor(this, this), extendsType )); } } diff --git a/src/de/dhbwstuttgart/syntaxtree/type/FreshWildcardType.java b/src/de/dhbwstuttgart/syntaxtree/type/FreshWildcardType.java index 364681db..829f0f40 100755 --- a/src/de/dhbwstuttgart/syntaxtree/type/FreshWildcardType.java +++ b/src/de/dhbwstuttgart/syntaxtree/type/FreshWildcardType.java @@ -6,7 +6,7 @@ import de.dhbwstuttgart.parser.JavaClassName; import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode; import de.dhbwstuttgart.typeinference.JavaCodeResult; import de.dhbwstuttgart.typeinference.ResultSet; -import sun.reflect.generics.reflectiveObjects.NotImplementedException; +import de.dhbwstuttgart.typeinference.exceptions.NotImplementedException; public class FreshWildcardType extends Type { diff --git a/src/de/dhbwstuttgart/syntaxtree/type/GenericTypeVar.java b/src/de/dhbwstuttgart/syntaxtree/type/GenericTypeVar.java index 405f84b5..229bfaeb 100755 --- a/src/de/dhbwstuttgart/syntaxtree/type/GenericTypeVar.java +++ b/src/de/dhbwstuttgart/syntaxtree/type/GenericTypeVar.java @@ -44,7 +44,7 @@ public class GenericTypeVar extends Type // ino.method.GenericTypeVar.26509.defdescription type=line // private Hashtable> m_TypeErasureList; // ino.end - private static HashMap tph = new HashMap(); + private static HashMap tph = new HashMap<>(); /** * @@ -170,12 +170,14 @@ public class GenericTypeVar extends Type */ return new JavaCodeResult(this.name.toString()); } - - public TypePlaceholder getTypePlaceHolder() { - if(!GenericTypeVar.tph.containsKey(this)){ - GenericTypeVar.tph.put(this, TypePlaceholder.fresh(this.getName().toString(),this)); + + public TypePlaceholder getTypePlaceHolder(SyntaxTreeNode environment) { + String hashValue = this.getName().toString()+environment.hashCode(); + if(!GenericTypeVar.tph.containsKey(hashValue)){ + GenericTypeVar.tph.put(hashValue, TypePlaceholder.fresh(hashValue,this)); } - return GenericTypeVar.tph.get(this); + return GenericTypeVar.tph.get(hashValue); + //return TypePlaceholder.fresh(this.getParent()); //if(this.tph == null)this.tph = TypePlaceholder.fresh(); //return this.tph; } diff --git a/src/de/dhbwstuttgart/syntaxtree/type/ParaList.java b/src/de/dhbwstuttgart/syntaxtree/type/ParaList.java index efa0b35f..6ac63a02 100755 --- a/src/de/dhbwstuttgart/syntaxtree/type/ParaList.java +++ b/src/de/dhbwstuttgart/syntaxtree/type/ParaList.java @@ -3,7 +3,7 @@ package de.dhbwstuttgart.syntaxtree.type; // ino.end // ino.module.ParaList.8674.import import java.util.Vector; -import org.apache.log4j.Logger; +import de.dhbwstuttgart.logger.Logger; // ino.end diff --git a/src/de/dhbwstuttgart/syntaxtree/type/RefType.java b/src/de/dhbwstuttgart/syntaxtree/type/RefType.java index 801eb60f..af50be02 100755 --- a/src/de/dhbwstuttgart/syntaxtree/type/RefType.java +++ b/src/de/dhbwstuttgart/syntaxtree/type/RefType.java @@ -8,7 +8,7 @@ import java.util.Hashtable; import java.util.Iterator; import java.util.Vector; -import org.apache.log4j.Logger; +import de.dhbwstuttgart.logger.Logger; import de.dhbwstuttgart.bytecode.JVMCode; import de.dhbwstuttgart.core.IItemWithOffset; @@ -24,7 +24,6 @@ import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions; import de.dhbwstuttgart.typeinference.exceptions.TypeinferenceException; import de.dhbwstuttgart.typeinference.unify.CSubstitutionGenVar; import de.dhbwstuttgart.typeinference.unify.CSubstitutionSet; -import sun.reflect.generics.reflectiveObjects.NotImplementedException; @@ -57,10 +56,10 @@ public class RefType extends Type implements IMatchable private boolean primitiveFlag=false; // ino.end // ino.attribute.parserlog.26628.declaration - protected static Logger parserlog = Logger.getLogger("parser"); + //protected static Logger parserlog = Logger.getLogger("parser"); // ino.end // ino.attribute.codegenlog.26631.declaration - protected static Logger codegenlog = Logger.getLogger("codegen"); + //protected static Logger codegenlog = Logger.getLogger("codegen"); // ino.end @@ -212,12 +211,12 @@ public class RefType extends Type implements IMatchable * Wandelt die Parameter des RefTypes in TPHs um, sofern es sich um Generische Variablen handelt. * @return */ - public void GTV2TPH(){ + public void GTV2TPH(SyntaxTreeNode environment){ Vector paralist = new Vector(); if(this.get_ParaList()!=null)for(Type t : this.get_ParaList()){ - if(t instanceof GenericTypeVar)paralist.add(((GenericTypeVar)t).getTypePlaceHolder()); + if(t instanceof GenericTypeVar)paralist.add(((GenericTypeVar)t).getTypePlaceHolder(environment)); else{ - if(t instanceof RefType)((RefType) t).GTV2TPH(); + if(t instanceof RefType)((RefType) t).GTV2TPH(environment); paralist.add(t); } } @@ -269,6 +268,7 @@ public class RefType extends Type implements IMatchable // ino.end public void setName( JavaClassName name ){ + if(name == null)throw new NullPointerException(); this.name = name; } @@ -801,16 +801,16 @@ public class RefType extends Type implements IMatchable @Override public ConstraintType TYPE(TypeAssumptions ass, SyntaxTreeNode parent){ - //Der RefType muss zusätzlich seine Parameter prüfen. - Vector parameterList = new Vector<>(); - Vector parameterList2 = new Vector<>(); - if(this.parameter!=null)for(Type param : this.parameter){ - ConstraintType ct = param.TYPE(ass, parent); - parameterList.add(ct); - parameterList2.add(ct.getType()); - } - this.parameter = parameterList2; ConstraintType t = super.TYPE(ass,parent); + //((RefType)t.getType()).set_ParaList(this.get_ParaList()); + return t; + } + + @Override + public Type checkTYPE(TypeAssumptions ass, SyntaxTreeNode method) { + Type t = ass.checkType(this, parent); + if(t==null) + throw new TypeinferenceException("Der Typ "+this.getName()+" ist nicht korrekt", parent); return t; } diff --git a/src/de/dhbwstuttgart/syntaxtree/type/Type.java b/src/de/dhbwstuttgart/syntaxtree/type/Type.java index 13f22fd7..ef26b1e7 100755 --- a/src/de/dhbwstuttgart/syntaxtree/type/Type.java +++ b/src/de/dhbwstuttgart/syntaxtree/type/Type.java @@ -5,7 +5,6 @@ package de.dhbwstuttgart.syntaxtree.type; import java.util.ArrayList; import java.util.Vector; -import sun.reflect.generics.reflectiveObjects.NotImplementedException; import de.dhbwstuttgart.bytecode.JVMCode; import de.dhbwstuttgart.core.IItemWithOffset; import de.dhbwstuttgart.parser.JavaClassName; @@ -19,9 +18,9 @@ import de.dhbwstuttgart.typeinference.exceptions.TypeinferenceException; - +//TODO: Die Klasse Type muss abstract werden! // ino.class.Type.26716.declaration -public class Type extends SyntaxTreeNode implements IItemWithOffset +public abstract class Type extends SyntaxTreeNode implements IItemWithOffset // ino.end // ino.class.Type.26716.body { @@ -181,6 +180,7 @@ public class Type extends SyntaxTreeNode implements IItemWithOffset if(obj instanceof Type){ // String name2 = ((Type)obj).printJavaCode(new ResultSet()).toString(); //return printJavaCode(new ResultSet()).toString().equals(name2); + if(((Type)obj).name == null)return false; //Auch wenn der Name dieses Typs auch null ist. Typen sind nur gleich wenn sie einen gleichen Namen haben, welcher nicht null ist. return ((Type)obj).name.equals(name); } else{ @@ -200,7 +200,7 @@ public class Type extends SyntaxTreeNode implements IItemWithOffset // ino.end // ino.method.clone.26768.body { - return new Type(this.getName().toString(), this.getParent(),getOffset()); + return new RefType(this.getName().toString(), this.getParent(),getOffset()); } // ino.end @@ -298,7 +298,7 @@ public class Type extends SyntaxTreeNode implements IItemWithOffset */ //TODO: checkType wird nicht mehr gebraucht. TYPE übernimmt dessen Aufgabe. Es muss nur sichergestellt werden, dass jeder Typ in den Constraints landet, dadurch wird für jeden Typ die Methode TYPE aufgerufen. public ConstraintType TYPE(TypeAssumptions ass, SyntaxTreeNode parent){ - ConstraintType t = ass.getTypeFor(this, this); + ConstraintType t = ass.getTypeFor(this, parent); if(t==null) throw new TypeinferenceException("Der Typ "+this.getName()+" ist nicht korrekt", parent); return t; @@ -317,6 +317,10 @@ public class Type extends SyntaxTreeNode implements IItemWithOffset public Vector getChildren() { return new Vector<>(); } + + public Type checkTYPE(TypeAssumptions ass, SyntaxTreeNode method){ + return this; + } } // ino.end diff --git a/src/de/dhbwstuttgart/syntaxtree/type/TypePlaceholder.java b/src/de/dhbwstuttgart/syntaxtree/type/TypePlaceholder.java index b8b20c44..6f5fb6b3 100755 --- a/src/de/dhbwstuttgart/syntaxtree/type/TypePlaceholder.java +++ b/src/de/dhbwstuttgart/syntaxtree/type/TypePlaceholder.java @@ -6,7 +6,7 @@ package de.dhbwstuttgart.syntaxtree.type; import java.util.Hashtable; import java.util.Iterator; import java.util.Vector; -import java.util.logging.Logger; +import de.dhbwstuttgart.logger.*; import de.dhbwstuttgart.core.MyCompiler; import de.dhbwstuttgart.parser.JavaClassName; @@ -31,6 +31,7 @@ public class TypePlaceholder extends Type // ino.end // ino.class.TypePlaceholder.26780.body { + private static final Logger log = Logger.getLogger(TypePlaceholder.class.getName()); // ino.attribute.strNextName.26785.declaration private static String strNextName = "A"; // ino.end @@ -55,6 +56,7 @@ public class TypePlaceholder extends Type { super(parent, -1); this.name = new JavaClassName(typeName); + if(parent != null)log.debug("Erstelle TPH "+typeName+" für SyntaxTreeNode: "+parent, Section.TYPEINFERENCE); } // ino.end diff --git a/src/de/dhbwstuttgart/syntaxtree/type/Void.java b/src/de/dhbwstuttgart/syntaxtree/type/Void.java index 2ef1cd1c..1e58e564 100755 --- a/src/de/dhbwstuttgart/syntaxtree/type/Void.java +++ b/src/de/dhbwstuttgart/syntaxtree/type/Void.java @@ -74,5 +74,11 @@ public class Void extends RefType public ConstraintType TYPE(TypeAssumptions ass, SyntaxTreeNode parent){ return new ConstraintType(this); } + + @Override + public Type checkTYPE(TypeAssumptions ass, SyntaxTreeNode method) { + return this;//VOID ist immer korrekt, das wird vom Parser geprüft + } + } // ino.end diff --git a/src/de/dhbwstuttgart/syntaxtree/type/WildcardType.java b/src/de/dhbwstuttgart/syntaxtree/type/WildcardType.java index 0a28db06..56312b90 100755 --- a/src/de/dhbwstuttgart/syntaxtree/type/WildcardType.java +++ b/src/de/dhbwstuttgart/syntaxtree/type/WildcardType.java @@ -3,7 +3,8 @@ package de.dhbwstuttgart.syntaxtree.type; import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode; import de.dhbwstuttgart.typeinference.JavaCodeResult; import de.dhbwstuttgart.typeinference.ResultSet; -import sun.reflect.generics.reflectiveObjects.NotImplementedException; +import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions; +import de.dhbwstuttgart.typeinference.exceptions.NotImplementedException; /** * Stellt eine Wildcard in Java dar. diff --git a/src/de/dhbwstuttgart/typeinference/ConstraintType.java b/src/de/dhbwstuttgart/typeinference/ConstraintType.java index f4ff991a..09ccb730 100644 --- a/src/de/dhbwstuttgart/typeinference/ConstraintType.java +++ b/src/de/dhbwstuttgart/typeinference/ConstraintType.java @@ -1,6 +1,7 @@ package de.dhbwstuttgart.typeinference; import de.dhbwstuttgart.syntaxtree.type.*; +import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions; public class ConstraintType{ @@ -18,5 +19,4 @@ public class ConstraintType{ public Type getType() { return t; } - } diff --git a/src/de/dhbwstuttgart/typeinference/ConstraintsSet.java b/src/de/dhbwstuttgart/typeinference/ConstraintsSet.java index 889cf0a6..f67fb6d0 100755 --- a/src/de/dhbwstuttgart/typeinference/ConstraintsSet.java +++ b/src/de/dhbwstuttgart/typeinference/ConstraintsSet.java @@ -2,8 +2,12 @@ package de.dhbwstuttgart.typeinference; import java.util.Iterator; import java.util.Vector; +import de.dhbwstuttgart.logger.Logger; +import de.dhbwstuttgart.logger.*; +import de.dhbwstuttgart.typeinference.unify.Unifier; public class ConstraintsSet implements Iterable{ + private static final Logger log = Logger.getLogger(ConstraintsSet.class.getName()); private Vector constraintsSet; public ConstraintsSet(){ @@ -50,6 +54,45 @@ public class ConstraintsSet implements Iterable{ return constraintsSet.iterator(); } + public void filterWrongConstraints(Unifier unify) { + for(OderConstraint constraint : this){ + constraint.filterWrongConstraints(unify); + } + } - + /** + * Nimmt alle UndConstraints und filtert mithilfe dieser die falschen Constraints aus den OderConstraints + * @param unifier + */ + public void unifyUndConstraints(Unifier unifier) { + Vector uCons = this.filterUndConstraints(); + Vector alleUndConstraints = new Vector<>(); + for(UndConstraint undConstraint : uCons){ + alleUndConstraints.addAll(undConstraint.getConstraintPairs()); + } + this.filterWrongConstraints( + (pairs)->{ + Vector undConstraintsUndPairs = new Vector<>(); + undConstraintsUndPairs.addAll(pairs); + undConstraintsUndPairs.addAll(alleUndConstraints); + log.debug("Versuche Pairs auszusondern:\n"+pairs, Section.TYPEINFERENCE); + log.debug("Unifiziere:\n"+undConstraintsUndPairs, Section.TYPEINFERENCE); + Vector> unifyResult = unifier.apply(undConstraintsUndPairs); + return unifyResult; + }); + } + + /** + * Aus dem ConstraintsSet [ u1, u2, ... (OderConstraint), ... uN ] werden alle + * UndConstraints, welche sich nicht innerhalb eines OderConstraints befinden, herausgefiltert + * @return [u1, ... , uN] + */ + private Vector filterUndConstraints() { + Vector ret = new Vector<>(); + for(OderConstraint con : constraintsSet){ + UndConstraint filtered = con.filterUndConstraints(); + if(filtered != null)ret.add(filtered); + } + return ret; + } } diff --git a/src/de/dhbwstuttgart/typeinference/FunNInterface.java b/src/de/dhbwstuttgart/typeinference/FunNInterface.java index c41c228c..fcc6b452 100644 --- a/src/de/dhbwstuttgart/typeinference/FunNInterface.java +++ b/src/de/dhbwstuttgart/typeinference/FunNInterface.java @@ -4,7 +4,9 @@ import java.util.Vector; import de.dhbwstuttgart.parser.JavaClassName; import de.dhbwstuttgart.syntaxtree.Class; +import de.dhbwstuttgart.syntaxtree.modifier.Modifiers; import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar; +import de.dhbwstuttgart.syntaxtree.type.RefType; import de.dhbwstuttgart.syntaxtree.type.Type; import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder; import de.dhbwstuttgart.typeinference.assumptions.ClassAssumption; @@ -21,14 +23,15 @@ public class FunNInterface extends Class{ //TODO: getType muss einen Typ mit der ParameterListe zurückliefern. - private Vector gtvparalist; + //private Vector gtvparalist; /** * Ein FunN-Interface enthält nur eine Methode (namens apply). Ist also ein Funktionales Interface. * @param N - Die Anzahl der Parameter der apply-Methode. Beispiel N = 1 ergibt R apply(T1 par1); */ public FunNInterface(int N) { - super("Fun"+N, 0); + super("Fun"+N, null, new Modifiers(), FunNInterface.makeParaList(N)); + /* GenericTypeVar gtv; Vector paralist = new Vector<>(); gtv = new GenericTypeVar("R",this, 0); @@ -43,8 +46,18 @@ public class FunNInterface extends Class{ //paralist.add(TypePlaceholder.fresh()); } this.set_ParaList(paralist); + */ } + private static Vector makeParaList(int n) { + Vector ret = new Vector<>(); + ret.add("R"); + for(int i = 1; i<=n;i++){ + ret.add("T"+i); + } + return ret; + } + /** * @return Im Falle von einem FunN-Interface ist dies die apply-Methode */ @@ -54,7 +67,7 @@ public class FunNInterface extends Class{ TypeAssumptions ret = new TypeAssumptions(); ret.addAssumption(new MethodAssumption(this.getApplyFunction(), this)); ret.addClassAssumption(new ClassAssumption(this)); - for(GenericTypeVar gtv : this.gtvparalist)ret.addGenericVarAssumption(gtv); + for(GenericTypeVar gtv : this.getGenericParameter())ret.addGenericVarAssumption(gtv); return ret; } diff --git a/src/de/dhbwstuttgart/typeinference/FunNMethod.java b/src/de/dhbwstuttgart/typeinference/FunNMethod.java index 07b8acf8..cf056020 100644 --- a/src/de/dhbwstuttgart/typeinference/FunNMethod.java +++ b/src/de/dhbwstuttgart/typeinference/FunNMethod.java @@ -15,7 +15,7 @@ public class FunNMethod extends Method{ * * @param N - Anzahl der Parameter (Beispiel: Fun2) */ - public FunNMethod(Vector paralist){ + public FunNMethod(Vector paralist){ super(0); //Hat keinen Offset, da nur theoretisch gedachte Methode int N = paralist.size(); //In der paraliste ist der erste Parameter der Rückgabetyp this.setType(paralist.firstElement()); diff --git a/src/de/dhbwstuttgart/typeinference/JavaCodeResult.java b/src/de/dhbwstuttgart/typeinference/JavaCodeResult.java index bd9c1978..fe902460 100755 --- a/src/de/dhbwstuttgart/typeinference/JavaCodeResult.java +++ b/src/de/dhbwstuttgart/typeinference/JavaCodeResult.java @@ -3,7 +3,6 @@ package de.dhbwstuttgart.typeinference; import java.util.Vector; import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder; -import sun.reflect.generics.reflectiveObjects.NotImplementedException; public class JavaCodeResult{ diff --git a/src/de/dhbwstuttgart/typeinference/OderConstraint.java b/src/de/dhbwstuttgart/typeinference/OderConstraint.java index 62eb2096..1f2762d4 100755 --- a/src/de/dhbwstuttgart/typeinference/OderConstraint.java +++ b/src/de/dhbwstuttgart/typeinference/OderConstraint.java @@ -2,13 +2,18 @@ package de.dhbwstuttgart.typeinference; import java.util.Vector; +import de.dhbwstuttgart.logger.Logger; +import de.dhbwstuttgart.logger.Section; import de.dhbwstuttgart.syntaxtree.type.RefType; import de.dhbwstuttgart.syntaxtree.type.Type; import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder; +import de.dhbwstuttgart.typeinference.unify.Unifier; public class OderConstraint{ private Vector oderConstraintPairs; + private final static Logger logger = Logger.getLogger(OderConstraint.class.getName()); + /** * Erstellt ein neues Oder Constraint und fügt bereits ein Constraint hinzu. * @param p1 @@ -78,5 +83,25 @@ public class OderConstraint{ public void addConstraint(UndConstraint methodConstraint) { oderConstraintPairs.add(methodConstraint); } + + void filterWrongConstraints(Unifier unifier) { + Vector filteredConstraints = new Vector<>(); + for(UndConstraint cons : this.getUndConstraints()){ + Vector> unifierResult = unifier.apply(cons.getConstraintPairs()); + if(!unifierResult.isEmpty()){ + filteredConstraints.add(cons); + }else{ + logger.debug("Ausgesondertes Constraint: "+cons, Section.TYPEINFERENCE); + } + } + this.oderConstraintPairs = filteredConstraints; + } + + UndConstraint filterUndConstraints() { + if(this.oderConstraintPairs.size()==1){ + return this.oderConstraintPairs.firstElement(); + } + return null; + } } diff --git a/src/de/dhbwstuttgart/typeinference/Pair.java b/src/de/dhbwstuttgart/typeinference/Pair.java index b3126aa4..114bc97e 100755 --- a/src/de/dhbwstuttgart/typeinference/Pair.java +++ b/src/de/dhbwstuttgart/typeinference/Pair.java @@ -121,7 +121,7 @@ public class Pair if(OperatorSmallerExtends()) Operator = "0){ + ret.set_ParaList(tr.getParaList()); + } + + //Der RefType muss zusätzlich seine Parameter prüfen. + Vector parameterList = new Vector<>(); + if(ret.get_ParaList()!=null)for(Type param : ret.get_ParaList()){ + ConstraintType ct = param.TYPE(this, inNode); + parameterList.add(ct.getType()); + } + ret.set_ParaList(parameterList); + return new ConstraintType(ret); } } @@ -311,12 +319,28 @@ public class TypeAssumptions { if(ass.getIdentifier().equals(t.getName())){ if(! ass.getAssumedType().getParentClass().getName().equals(this.thisClassName)){ //Ist die Generische Variable nicht aus dieser Klasse, so muss sie zu einem TPH umgewandelt werden: - return new ConstraintType(ass.getAssumedType().getTypePlaceHolder()); + return new ConstraintType(ass.getAssumedType().getTypePlaceHolder(inNode)); } return new ConstraintType(ass.getAssumedType()); } } - //return null; + //Spezialfälle bei char, int, boolean, .... + String name = t.getName().toString(); + switch(name){ + case "int": + return new ConstraintType(new RefType("java.lang.Integer",t.getParent(),t.getOffset())); + case "boolean": + return new ConstraintType(new RefType("java.lang.Boolean",t.getParent(),t.getOffset())); + case "double": + return new ConstraintType(new RefType("java.lang.Double",t.getParent(),t.getOffset())); + case "float": + return new ConstraintType(new RefType("java.lang.Float",t.getParent(),t.getOffset())); + case "long": + return new ConstraintType(new RefType("java.lang.Long",t.getParent(),t.getOffset())); + case "char": + return new ConstraintType(new RefType("java.lang.Character",t.getParent(),t.getOffset())); + } + throw new TypeinferenceException("Der Typ "+t.getName()+" ist nicht korrekt",inNode); } @@ -339,7 +363,7 @@ public class TypeAssumptions { */ public ConstructorAssumption getConstructorAssumption(String name, int size) { for(ConstructorAssumption ca : this.constructorAssumptions){ - System.out.println(ca.getIdentifier().toString() + ca.getParaCount()); + log.debug("Durchsuche Assumptions: "+ca.getIdentifier().toString() +" -Anzahl Parameter: "+ ca.getParaCount()); if(ca.getParaCount()==size && ca.getIdentifier().equals(name))return ca; } return null; @@ -355,6 +379,16 @@ public class TypeAssumptions { this.genericVarAssumptions.add(new GenericVarAssumption(genericTypeVar)); } + public Vector getClassAssumptions() { + return this.classAssumptions; + } + + public Type checkType(RefType type, SyntaxTreeNode parent) { + ConstraintType t = this.getTypeFor(type, parent); //Richtigkeit des Typnahmensprüfen + type.setName(t.getType().getName()); //Und diesen auf den Typ anwenden + return t.getType(); + } + /** * Prüft einen Typ auf das vorhandensein in den BasicAssumptions. * Dabei werden alle Konstruktoren nach diesem Typ durchsucht. Denn jede Klasse hat einen Konstruktor und der muss in den TypeAssumptions vorhanden sein. diff --git a/src/de/dhbwstuttgart/typeinference/exceptions/NotImplementedException.java b/src/de/dhbwstuttgart/typeinference/exceptions/NotImplementedException.java new file mode 100644 index 00000000..5daaef67 --- /dev/null +++ b/src/de/dhbwstuttgart/typeinference/exceptions/NotImplementedException.java @@ -0,0 +1,5 @@ +package de.dhbwstuttgart.typeinference.exceptions; + +public class NotImplementedException extends RuntimeException { + +} diff --git a/src/de/dhbwstuttgart/typeinference/typedeployment/TypeInsertSet.java b/src/de/dhbwstuttgart/typeinference/typedeployment/TypeInsertSet.java index 671a560d..1a34a845 100644 --- a/src/de/dhbwstuttgart/typeinference/typedeployment/TypeInsertSet.java +++ b/src/de/dhbwstuttgart/typeinference/typedeployment/TypeInsertSet.java @@ -5,7 +5,7 @@ import java.util.HashMap; import java.util.Iterator; import java.util.Vector; -import org.apache.log4j.Logger; +import de.dhbwstuttgart.logger.Logger; import de.dhbwstuttgart.core.IItemWithOffset; import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode; diff --git a/src/de/dhbwstuttgart/typeinference/unify/CSubstitution.java b/src/de/dhbwstuttgart/typeinference/unify/CSubstitution.java index 05cac78e..7e86182c 100755 --- a/src/de/dhbwstuttgart/typeinference/unify/CSubstitution.java +++ b/src/de/dhbwstuttgart/typeinference/unify/CSubstitution.java @@ -6,7 +6,7 @@ package de.dhbwstuttgart.typeinference.unify; import java.util.Iterator; import java.util.Vector; -import org.apache.log4j.Logger; +import de.dhbwstuttgart.logger.Logger; // ino.end diff --git a/src/de/dhbwstuttgart/typeinference/unify/FC_TTO.java b/src/de/dhbwstuttgart/typeinference/unify/FC_TTO.java index b1e8fe69..440bbd50 100755 --- a/src/de/dhbwstuttgart/typeinference/unify/FC_TTO.java +++ b/src/de/dhbwstuttgart/typeinference/unify/FC_TTO.java @@ -74,8 +74,8 @@ public class FC_TTO public void generateFullyNamedTypes(TypeAssumptions ass) { for(Pair p : this.FC){ - p.TA1 = ass.getTypeFor(p.TA1, null).getType(); - p.TA2 = ass.getTypeFor(p.TA2, null).getType(); + p.TA1 = ass.getTypeFor(p.TA1, p.TA1.getParent()).getType(); + p.TA2 = ass.getTypeFor(p.TA2, p.TA2.getParent()).getType(); } } } diff --git a/src/de/dhbwstuttgart/typeinference/unify/Unifier.java b/src/de/dhbwstuttgart/typeinference/unify/Unifier.java new file mode 100644 index 00000000..f51eb9b9 --- /dev/null +++ b/src/de/dhbwstuttgart/typeinference/unify/Unifier.java @@ -0,0 +1,11 @@ +package de.dhbwstuttgart.typeinference.unify; + +import java.util.Vector; + +import de.dhbwstuttgart.typeinference.Pair; + +public interface Unifier { + + public Vector> apply (Vector E); + +} diff --git a/src/de/dhbwstuttgart/typeinference/unify/Unify.java b/src/de/dhbwstuttgart/typeinference/unify/Unify.java index 3317cbea..886226a5 100755 --- a/src/de/dhbwstuttgart/typeinference/unify/Unify.java +++ b/src/de/dhbwstuttgart/typeinference/unify/Unify.java @@ -7,7 +7,7 @@ import java.util.Enumeration; import java.util.Hashtable; import java.util.Iterator; import java.util.Vector; -import org.apache.log4j.Logger; +import de.dhbwstuttgart.logger.Logger; import de.dhbwstuttgart.core.MyCompiler; import de.dhbwstuttgart.myexception.CTypeReconstructionException; import de.dhbwstuttgart.myexception.MatchException; @@ -128,7 +128,7 @@ public class Unify //WAS PASSIERT MIT EINE PAAR HIER DRIN BLEIBT??? Eq_12.addElement(P); printMenge("Eq_12", Eq_12, 6); - inferencelog.debug(P.OperatorEqual()); + //inferencelog.debug(P.OperatorEqual()); } else if (P.TA1 instanceof BoundedGenericTypeVar && P.TA2 instanceof RefType) { //PL 06-06-13 @@ -224,7 +224,7 @@ public class Unify else ready = false; sigma.addElement(new Pair(r1, r2)); } - inferencelog.debug(ready); + //inferencelog.debug(ready); if (!ready) { printMenge("Sigma", sigma, 6); @@ -1068,6 +1068,10 @@ throws MatchException for(int i=0; i < FCtype.get_ParaList().size(); i++) { if (FCtype.get_ParaList().elementAt(i) instanceof GenericTypeVar) { inferencelog.debug("PUT"); + //TODO Auf Korrektheit prüfen: + if(tomatch.getParaList().size() != FCtype.getParaList().size()){ + throw new MatchException("Different Parameter Sizes!"); + }//Angefügt von Andreas Stadelmeier (ENDE) ht.put(((GenericTypeVar)FCtype.get_ParaList().elementAt(i)).getName(), tomatch.get_ParaList().elementAt(i)); } diff --git a/test/log4jTesting.xml b/test/log4jTesting.xml index 642079a3..dc30c245 100755 --- a/test/log4jTesting.xml +++ b/test/log4jTesting.xml @@ -3,10 +3,10 @@ - + - + diff --git a/test/mycompiler/test/AllTests.java b/test/mycompiler/test/AllTests.java index c793951e..c4e1235a 100755 --- a/test/mycompiler/test/AllTests.java +++ b/test/mycompiler/test/AllTests.java @@ -13,7 +13,7 @@ import mycompiler.test.operators.AllTestsOperators; import mycompiler.test.primitiveTypes.AllTestsPrimitiveTypes; import mycompiler.test.trivial.AllTestsTrivial; -import org.apache.log4j.xml.DOMConfigurator; +import de.dhbwstuttgart.logger.xml.DOMConfigurator; public class AllTests { diff --git a/test/mycompiler/test/Log4jWrapper.java b/test/mycompiler/test/Log4jWrapper.java index 45692360..715dedb2 100755 --- a/test/mycompiler/test/Log4jWrapper.java +++ b/test/mycompiler/test/Log4jWrapper.java @@ -1,6 +1,6 @@ package mycompiler.test; -import org.apache.log4j.xml.DOMConfigurator; +import de.dhbwstuttgart.logger.xml.DOMConfigurator; /** * needed to assure one-time execution of configure script diff --git a/test/mycompiler/test/inferenceByCharacteristic/TestInferenceOwnTypeByMethodCall.java b/test/mycompiler/test/inferenceByCharacteristic/TestInferenceOwnTypeByMethodCall.java index fb2bf184..aac98c00 100755 --- a/test/mycompiler/test/inferenceByCharacteristic/TestInferenceOwnTypeByMethodCall.java +++ b/test/mycompiler/test/inferenceByCharacteristic/TestInferenceOwnTypeByMethodCall.java @@ -1,6 +1,6 @@ package mycompiler.test.inferenceByCharacteristic; -import org.apache.log4j.xml.DOMConfigurator; +import de.dhbwstuttgart.logger.xml.DOMConfigurator; import de.dhbwstuttgart.syntaxtree.type.RefType; import mycompiler.test.AbstractInferenceTest; diff --git a/test/mycompiler/test/unittest/typeReconstructionTest/TrMakeFCTest.java b/test/mycompiler/test/unittest/typeReconstructionTest/TrMakeFCTest.java index 2863bf1c..ae4f48cd 100755 --- a/test/mycompiler/test/unittest/typeReconstructionTest/TrMakeFCTest.java +++ b/test/mycompiler/test/unittest/typeReconstructionTest/TrMakeFCTest.java @@ -4,8 +4,8 @@ import java.util.Vector; import junit.framework.TestCase; -import org.apache.log4j.Logger; -import org.apache.log4j.xml.DOMConfigurator; +import de.dhbwstuttgart.logger.Logger; +import de.dhbwstuttgart.logger.xml.DOMConfigurator; import de.dhbwstuttgart.syntaxtree.Class; import de.dhbwstuttgart.syntaxtree.ClassBody; diff --git a/test/mycompiler/test/unittest/typeReconstructionTest/TrSubUnifyTest.java b/test/mycompiler/test/unittest/typeReconstructionTest/TrSubUnifyTest.java index 537464c6..e9ea300f 100755 --- a/test/mycompiler/test/unittest/typeReconstructionTest/TrSubUnifyTest.java +++ b/test/mycompiler/test/unittest/typeReconstructionTest/TrSubUnifyTest.java @@ -5,8 +5,8 @@ import java.util.Vector; import junit.framework.TestCase; -import org.apache.log4j.Logger; -import org.apache.log4j.xml.DOMConfigurator; +import de.dhbwstuttgart.logger.Logger; +import de.dhbwstuttgart.logger.xml.DOMConfigurator; import org.junit.After; import org.junit.Before; import org.junit.BeforeClass; diff --git a/test/mycompiler/test/unittest/typeReconstructionTest/TrUnifyTest.java b/test/mycompiler/test/unittest/typeReconstructionTest/TrUnifyTest.java index 75765509..7a42c8d2 100755 --- a/test/mycompiler/test/unittest/typeReconstructionTest/TrUnifyTest.java +++ b/test/mycompiler/test/unittest/typeReconstructionTest/TrUnifyTest.java @@ -4,7 +4,7 @@ import java.util.Vector; import junit.framework.TestCase; -import org.apache.log4j.xml.DOMConfigurator; +import de.dhbwstuttgart.logger.xml.DOMConfigurator; import org.junit.After; import org.junit.Before; import org.junit.Test; diff --git a/test/parser/AntlrTest.jav b/test/parser/AntlrTest.jav new file mode 100644 index 00000000..31ab067d --- /dev/null +++ b/test/parser/AntlrTest.jav @@ -0,0 +1,6 @@ +class Test{ +method(){ + if(true)i++; + if(true)i--; + else i++; +}} \ No newline at end of file diff --git a/test/parser/FieldVarTest.jav b/test/parser/FieldVarTest.jav new file mode 100644 index 00000000..aeeecdbf --- /dev/null +++ b/test/parser/FieldVarTest.jav @@ -0,0 +1,3 @@ +class Test{ +Typ a; +} \ No newline at end of file diff --git a/test/parser/GeneralParserTest.java b/test/parser/GeneralParserTest.java index 7edd2fb8..6f0985db 100644 --- a/test/parser/GeneralParserTest.java +++ b/test/parser/GeneralParserTest.java @@ -33,6 +33,7 @@ public class GeneralParserTest{ filenames.add("ImportTest.jav"); filenames.add("BoundedParameter.jav"); filenames.add("GenericFieldVarTest.jav"); + filenames.add("FieldVarTest.jav"); MyCompilerAPI compiler = MyCompiler.getAPI(); try{ for(String filename : filenames) diff --git a/test/plugindevelopment/TypeInsertTester.java b/test/plugindevelopment/TypeInsertTester.java index aba7e5b8..f60fb506 100644 --- a/test/plugindevelopment/TypeInsertTester.java +++ b/test/plugindevelopment/TypeInsertTester.java @@ -10,12 +10,7 @@ import java.nio.file.Files; import java.nio.file.Paths; import java.util.Vector; -import org.apache.log4j.ConsoleAppender; -import org.apache.log4j.FileAppender; -import org.apache.log4j.Level; -import org.apache.log4j.Logger; -import org.apache.log4j.PatternLayout; -import org.apache.log4j.SimpleLayout; +import de.dhbwstuttgart.logger.Logger; import de.dhbwstuttgart.core.MyCompiler; import de.dhbwstuttgart.core.MyCompilerAPI; @@ -28,14 +23,17 @@ import junit.framework.TestCase; public class TypeInsertTester{ - private static Logger inferencelog = Logger.getLogger("Typeinference"); + private static Logger inferencelog = Logger.getLogger(TypeInsertTester.class.getName()); static{ { + Logger.setStandardOutput(System.out); + /* // Ausgabeoptionen fuer die Logger ConsoleAppender logAppender = new ConsoleAppender(new SimpleLayout()); logAppender.setTarget("System.out"); logAppender.activateOptions(); inferencelog.addAppender(logAppender); //Bei den Tests wird der Log auch in System.out geschrieben. + */ } } static final String rootDirectory = System.getProperty("user.dir")+"/test/plugindevelopment/"; diff --git a/test/plugindevelopment/TypeInsertTests/GenericTypeVarTest.jav b/test/plugindevelopment/TypeInsertTests/GenericTypeVarTest.jav index 6c08eff5..772f649b 100644 --- a/test/plugindevelopment/TypeInsertTests/GenericTypeVarTest.jav +++ b/test/plugindevelopment/TypeInsertTests/GenericTypeVarTest.jav @@ -8,4 +8,4 @@ methode(){ class GTVTest2{ GTV2 var2; -} \ No newline at end of file +} diff --git a/test/plugindevelopment/TypeInsertTests/GenericTypeVarTest2.jav b/test/plugindevelopment/TypeInsertTests/GenericTypeVarTest2.jav index 30a9b171..c1fd0e50 100644 --- a/test/plugindevelopment/TypeInsertTests/GenericTypeVarTest2.jav +++ b/test/plugindevelopment/TypeInsertTests/GenericTypeVarTest2.jav @@ -1,8 +1,8 @@ class GTVTest{ GTVTest2 var; -var2; methode(){ + var2; return var.test(var2); } } diff --git a/test/plugindevelopment/TypeInsertTests/LambdaTest24.java b/test/plugindevelopment/TypeInsertTests/LambdaTest24.java index 59de42e5..b3086da7 100644 --- a/test/plugindevelopment/TypeInsertTests/LambdaTest24.java +++ b/test/plugindevelopment/TypeInsertTests/LambdaTest24.java @@ -10,7 +10,7 @@ public class LambdaTest24 { @Test public void run(){ Vector mustContain = new Vector(); - //mustContain.add("Matrix ret"); + mustContain.add("Fun2"); MultipleTypesInsertTester.testSingleInsert(this.TEST_FILE, mustContain); } } diff --git a/test/plugindevelopment/TypeInsertTests/LambdaTest25.jav b/test/plugindevelopment/TypeInsertTests/LambdaTest25.jav new file mode 100644 index 00000000..a499b2bd --- /dev/null +++ b/test/plugindevelopment/TypeInsertTests/LambdaTest25.jav @@ -0,0 +1,8 @@ +import java.util.Vector; + +class ImportGeneric { + + m (Vector x) { + return x.elementAt(1); + } +} diff --git a/test/plugindevelopment/TypeInsertTests/LambdaTest25.java b/test/plugindevelopment/TypeInsertTests/LambdaTest25.java new file mode 100644 index 00000000..1737acee --- /dev/null +++ b/test/plugindevelopment/TypeInsertTests/LambdaTest25.java @@ -0,0 +1,16 @@ +package plugindevelopment.TypeInsertTests; + +import java.util.Vector; + +import org.junit.Test; + +public class LambdaTest25 { + private static final String TEST_FILE = "LambdaTest25.jav"; + + @Test + public void run(){ + Vector mustContain = new Vector(); + mustContain.add("Integer m"); + MultipleTypesInsertTester.testSingleInsert(this.TEST_FILE, mustContain); + } +} diff --git a/test/plugindevelopment/TypeInsertTests/TypedMatrixSimpleTest.jav b/test/plugindevelopment/TypeInsertTests/TypedMatrixSimpleTest.jav new file mode 100644 index 00000000..72d00877 --- /dev/null +++ b/test/plugindevelopment/TypeInsertTests/TypedMatrixSimpleTest.jav @@ -0,0 +1,24 @@ +import java.util.Vector; + +class Matrix extends Vector> { + + Matrix mul(Matrix m){ + Matrix ret; + ret = new Matrix(); + Integer i; + i = 0; + while(i < this.size()) { + Vector v1; + Vector v2; + v1 = this.elementAt(i); + v2 = new Vector(); + Integer j; + j = 0; + + ret.addElement(v2); + i++; + } + return ret; + } + +} \ No newline at end of file diff --git a/test/plugindevelopment/TypeInsertTests/TypedMatrixSimpleTest.java b/test/plugindevelopment/TypeInsertTests/TypedMatrixSimpleTest.java new file mode 100644 index 00000000..2db27805 --- /dev/null +++ b/test/plugindevelopment/TypeInsertTests/TypedMatrixSimpleTest.java @@ -0,0 +1,16 @@ +package plugindevelopment.TypeInsertTests; + +import java.util.Vector; + +import org.junit.Test; + +public class TypedMatrixSimpleTest { + private static final String TEST_FILE = "TypedMatrixSimpleTest.jav"; + + @Test + public void run(){ + Vector mustContain = new Vector(); + mustContain.add("Integer erg;"); + MultipleTypesInsertTester.testSingleInsert(this.TEST_FILE, mustContain); + } +} diff --git a/test/plugindevelopment/TypeInsertTests/TypedMatrixTest.jav b/test/plugindevelopment/TypeInsertTests/TypedMatrixTest.jav new file mode 100644 index 00000000..c9bbd601 --- /dev/null +++ b/test/plugindevelopment/TypeInsertTests/TypedMatrixTest.jav @@ -0,0 +1,35 @@ +import java.util.Vector; + +class Matrix extends Vector> { + + Matrix mul(Matrix m){ + Matrix ret; + ret = new Matrix(); + Integer i; + i = 0; + while(i < this.size()) { + Vector v1; + Vector v2; + v1 = this.elementAt(i); + v2 = new Vector(); + Integer j; + j = 0; + while(j < this.size()) { + Integer erg; + erg = 0; + Integer k; + k = 0; + while(k < v1.size()) { + erg = erg + v1.elementAt(k).intValue() * m.elementAt(k).elementAt(j).intValue(); + k++; + } + v2.addElement(new Integer(erg)); + j++; + } + ret.addElement(v2); + i++; + } + return ret; + } + +} \ No newline at end of file diff --git a/test/plugindevelopment/TypeInsertTests/TypedMatrixTest.java b/test/plugindevelopment/TypeInsertTests/TypedMatrixTest.java new file mode 100644 index 00000000..810af999 --- /dev/null +++ b/test/plugindevelopment/TypeInsertTests/TypedMatrixTest.java @@ -0,0 +1,16 @@ +package plugindevelopment.TypeInsertTests; + +import java.util.Vector; + +import org.junit.Test; + +public class TypedMatrixTest { + private static final String TEST_FILE = "TypedMatrixTest.jav"; + + @Test + public void run(){ + Vector mustContain = new Vector(); + mustContain.add("Integer erg;"); + MultipleTypesInsertTester.testSingleInsert(this.TEST_FILE, mustContain); + } +}