Merge branch 'refactoring' of ssh://pl@gohorb.ba-horb.de/bahome/projekt/git/JavaCompilerCore into refactoring

This commit is contained in:
pl 2014-10-09 17:47:49 +02:00
commit 80e286b05a
120 changed files with 955 additions and 400 deletions

View File

@ -3,8 +3,7 @@
<classpathentry kind="src" path="src"/>
<classpathentry excluding=".classpath|.cvsignore|.externalToolBuilders/|.project|.settings/|Papers/|bin/|doc/|examples/|lib/|notizen/|src/|test/|tools/" including="log4j.xml" kind="src" path=""/>
<classpathentry kind="src" path="test"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="lib/log4j-1.2.12.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="lib" path="lib/junit-4.0.jar"/>
<classpathentry kind="lib" path="lib/antlr-4.4-complete.jar"/>
<classpathentry kind="output" path="bin"/>

View File

@ -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

5
bin/.gitignore vendored
View File

@ -1,6 +1,5 @@
/bytecode/
/de/
/mycompiler/
/parser/
/plugindevelopment/
/syntaxTree/
/bytecode/
/parser/

View File

@ -3,10 +3,10 @@
<log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/'>
<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
<appender name="CONSOLE" class="de.dhbwstuttgart.logger.ConsoleAppender">
<param name="Target" value="System.out"/>
<layout class="org.apache.log4j.PatternLayout">
<layout class="de.dhbwstuttgart.logger.PatternLayout">
<param name="ConversionPattern" value="%-15C{1} %-5p [%-9c] %m%n"/>
</layout>
</appender>

View File

@ -3,10 +3,10 @@
<log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/'>
<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
<appender name="CONSOLE" class="de.dhbwstuttgart.logger.ConsoleAppender">
<param name="Target" value="System.out"/>
<layout class="org.apache.log4j.PatternLayout">
<layout class="de.dhbwstuttgart.logger.PatternLayout">
<param name="ConversionPattern" value="%-15C{1} %-5p [%-9c] %m%n"/>
</layout>
</appender>

View File

@ -3,10 +3,10 @@
<log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/'>
<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
<appender name="CONSOLE" class="de.dhbwstuttgart.logger.ConsoleAppender">
<param name="Target" value="System.out"/>
<layout class="org.apache.log4j.PatternLayout">
<layout class="de.dhbwstuttgart.logger.PatternLayout">
<param name="ConversionPattern" value="%-15C{1} %-5p [%-9c] %m%n"/>
</layout>
</appender>

View File

@ -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<SyntaxTreeNode> {
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<GenericTypeVar> 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;
}
}

View File

@ -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

View File

@ -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

View File

@ -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;

View File

@ -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

View File

@ -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

View File

@ -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;

View File

@ -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

View File

@ -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

View File

@ -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;

View File

@ -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

View File

@ -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<Interface> getSuperInterfaces();
public void setSuperInterfaces(Vector<Interface> vector);
public Vector<Type> getSuperInterfaces();
public void setSuperInterfaces(Vector<Type> vector);
/*
// ino.attribute.inferencelog.21189.decldescription type=javadoc

View File

@ -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);
}

View File

@ -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!");
}

View File

@ -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<String, Logger> 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 <Klasse>.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;
}
}

View File

@ -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 {
}
}

View File

@ -0,0 +1,7 @@
package de.dhbwstuttgart.logger;
public enum Section {
TYPEINFERENCE,
PARSER,
CODEGEN;
}

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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<Interface> getVector()
public Vector<Type> getTypeVector()
// ino.end
// ino.method.getVector.24392.body
{
Vector<Interface> ret = new Vector<>();
Vector<Type> 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;
}

View File

@ -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){

View File

@ -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:

View File

@ -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;}

View File

@ -281,8 +281,8 @@ public Vector<Pair> testPair = new Vector<Pair>();
//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<UsedId> SuperInterfaces, */
/* Vector<Type> 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,

View File

@ -368,50 +368,50 @@ classdeclaration : CLASS classidentifier classbody
// Vector<UsedId> SuperInterfaces,
// Vector<Type> 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

View File

@ -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<Interface> superif = new Vector<Interface>();
private Vector<Type> superif = new Vector<Type>();
public UsedId getPackageName()
{
@ -89,12 +88,13 @@ public class Class extends SyntaxTreeNode implements AClassOrInterface, IItemWit
return ret;
}
public Vector<Interface> getSuperInterfaces()
public Vector<Type> getSuperInterfaces()
{
return superif;
}
public void setSuperInterfaces(Vector<Interface> superif)
@Override
public void setSuperInterfaces(Vector<Type> 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<Type> paralist = new Vector<Type>(); // Parameterliste 'class xy<para1, para2,...>{}' wird gespeichert
//private Vector<Type> paralist = new Vector<Type>(); // Parameterliste 'class xy<para1, para2,...>{}' wird gespeichert
// ino.end
// ino.attribute.parahash.23026.declaration
private Hashtable<String,String> parahash = new Hashtable<String,String>(); // 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<Field> fielddecl = new Vector<Field>();
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<String> supertypeGenPara) {
this(name,superClass,modifiers,0);
if(supertypeGenPara == null)return;
Vector<GenericTypeVar> 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<Type> ct, Vector<UsedId> usedIdsToCheck,
UsedId superclass, Vector<UsedId> superif, Vector<Type> paralist, int offset){
this(name, mod, cb, ct, usedIdToRefType(superclass),usedIdToRefType(superif),paralist,offset);
}
public Class(String name, ClassBody cb, Vector<Type> ct,
UsedId superclass, Vector<Type> superif, Vector<Type> paralist, int offset) {
this(name,null,cb,ct,usedIdToRefType(superclass),superif,paralist,offset);
}
public Class(String name2, Modifiers modifiers2, ClassBody classBody,
Vector<Type> containedTypes2, UsedId usedId,
Vector<Type> typeVector, Vector<Type> paraVector, int offset2) {
this(name2, modifiers2, classBody, containedTypes2, usedIdToRefType(usedId),typeVector, paraVector, offset2);
}
public Class(String name2, Modifiers object, ClassBody classBody,
Vector<Type> containedTypes2, Vector<Type> typeVector,
Vector<Type> paraVector, int offset2) {
this(name2, object, classBody, containedTypes2,(Type)null, typeVector, paraVector, offset2);
}
private static Vector<Type> usedIdToRefType(Vector<UsedId> superif2) {
Vector<Type> 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<Type> ct, Vector<UsedId> usedIdsToCheck,
UsedId superclass, Vector<Interface> superif, Vector<Type> paralist, int offset)
public Class(String name, Modifiers mod, ClassBody cb, Vector<Type> ct,
Type superclass, Vector<Type> vector, Vector<Type> 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<GenericTypeVar> 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<Field> 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<Type> 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<Type> 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<Type> get_ParaList()
public Vector<? extends Type> get_ParaList()
// ino.end
// ino.method.get_ParaList.23101.body
{
return this.paralist;
//if(this.paralist == null)return new Vector<Type>();
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<Expr> fieldInitializers = new Vector<Expr>();
@ -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<GenericTypeVar>(), 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<GenericTypeVar> getGenericParameter() {
if(this.genericClassParameters == null)return new Vector<GenericTypeVar>();
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;
}
}

View File

@ -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

View File

@ -57,7 +57,7 @@ public abstract class Field extends SyntaxTreeNode implements TypeInsertable, Ty
public Vector<GenericTypeVar> getGenericParameter() {
Vector<GenericTypeVar> ret = new Vector<>();
if(this.genericParameters == null)return ret;
ret.addAll(this.genericParameters);
ret.addAll(this.genericParameters.getVector());
return ret;
}

View File

@ -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

View File

@ -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<GenericTypeVar>{
public class GenericDeclarationList extends SyntaxTreeNode implements Iterable<GenericTypeVar>{
private int offsetOfLastElement;
private Vector<GenericTypeVar> gtvs = new Vector<>();
public GenericDeclarationList(Vector<GenericTypeVar> values, int endOffset) {
this.addAll(values);
this.offsetOfLastElement = endOffset;
}
private void addAll(Vector<GenericTypeVar> 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<GenericTypeVar> iterator() {
return this.gtvs.iterator();
}
@Override
public Vector<SyntaxTreeNode> getChildren() {
Vector<SyntaxTreeNode> ret = new Vector<>();
for(GenericTypeVar gtv : gtvs){
ret.add(gtv);
}
return ret;
}
public int size() {
return gtvs.size();
}
public Vector<GenericTypeVar> getVector() {
return this.gtvs;
}
public void add(GenericTypeVar t) {
this.gtvs.add(t);
}
}

View File

@ -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)
{

View File

@ -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<JavaClassName,Type> substHash = new Hashtable<JavaClassName,Type>(); //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<Pair> vFC = new Vector<Pair>(); // Menge FC
TypeAssumptions globalAssumptions = this.makeBasicAssumptionsFromJRE(imports, false);
globalAssumptions.add(this.getPublicFieldAssumptions());
// 1. Menge <= in FC aufnehmen --> Iteration ueber alle Klassen
Vector<Class> 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<Interface> interfaceIterator=tempKlasse.getSuperInterfaces().iterator();
Iterator<Type> 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<InterfaceVektor.size();i++){
Interface intf= InterfaceVektor.get(i);
if(intf.getSuperInterfaces()!=null){
Iterator<Interface> interfaceIterator=intf.getSuperInterfaces().iterator();
Iterator<Type> 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<Class> 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<Vector<Pair>> 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<Vector<Pair>> xConstraints = new Vector<Vector<Pair>>();// = oderConstraints.getConstraints();
for(Vector<UndConstraint> uC:oderConstraints.getConstraints()){ //mit dem getConstraints-Aufruf wird das Karthesische Produkt erzeugt.
for(Vector<UndConstraint> uC : oderConstraints.getConstraints()){ //mit dem getConstraints-Aufruf wird das Karthesische Produkt erzeugt.
Vector<Pair> cons = new Vector<Pair>();
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<Vector<Pair>>
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<Pair>())));
@ -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<UsedId> 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<UsedId> 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<String,GenericTypeVar> jreSpiderRegistry=new Hashtable<String,GenericTypeVar>();
Vector<GenericTypeVar> typeGenPara = new Vector<GenericTypeVar>();
Vector<String> typeGenPara = new Vector<String>();
for(int j=0;j<tvs.length;j++){
GenericTypeVar gtv=new GenericTypeVar(tvs[j].getName(), parentClass,-1);
typeGenPara.addElement(gtv);
jreSpiderRegistry.put(tvs[j].getName(),gtv);
//GenericTypeVar gtv=new GenericTypeVar(tvs[j].getName(), parentClass,-1);
typeGenPara.addElement(tvs[j].getName());
//jreSpiderRegistry.put(tvs[j].getName(),gtv);
}
Class parentClass = new Class(className, sClass.getType(),mod, typeGenPara);
//BasicAssumptionClass myCl = new BasicAssumptionClass(className, mod);
for(GenericTypeVar classParam : parentClass.getGenericParameter()){
jreSpiderRegistry.put(classParam.getName().toString(),classParam);
}
if(typeGenPara.size()>0){
//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<String> supertypeGenPara = new Vector<>();//Die Generischen Parameter für die Superklasse berechnen:
java.lang.reflect.TypeVariable[] superclassTVS=s.getTypeParameters();
for(int tvi=0;tvi<superclassTVS.length;tvi++){
supertypeGenPara.addElement(superclassTVS[tvi].getName());
}
Class ss = this.getSuperClassOfJREClass(s, ass);
ret = new Class(s.getName(),ss.getType(),new Modifiers(),supertypeGenPara);
ass.addClassAssumption(new ClassAssumption(ss)); //Die beiden SuperKlassen den Assumptions anfügen...
ass.addClassAssumption(new ClassAssumption(ret));
return ret;
}
// ino.method.isBaseType.21412.definition
private boolean isBaseType(String type)
// ino.end
// ino.method.isBaseType.21412.body
@ -1270,23 +1333,28 @@ public class SourceFile
// ino.end
// ino.method.createTypeFromJavaGenericType.21415.body
{
/* auskommentiert, da die Klassen von Sun in der Open JDK 1.8 nicht unterstützt werden.
if(type instanceof TypeVariableImpl){
TypeVariableImpl tvi=((TypeVariableImpl)type);
TypeVariableImpl tvi=((TypeVariableImpl)type);
return(new GenericTypeVar(jreSpiderRegistry.get(tvi.getName()).getName().toString(),parentClass,-1));
}else{
//String jccNameForClass=baseTypeTranslationTable.get(cl.getSimpleName());
String jccNameForClass=baseTypeTranslationTable.get(cl.getName());
if(cl.getSimpleName().equalsIgnoreCase("void")){
return(new Void(parentClass,-1));
}else if(jccNameForClass!=null){
RefType rt=new RefType(jccNameForClass,parentClass,-1);
rt.setPrimitiveFlag(true);
return(rt);
}else{
//return(new RefType(cl.getSimpleName()));
return(new RefType(cl.getName(),parentClass,-1));
}
*/
GenericTypeVar gtv = jreSpiderRegistry.get(type.getTypeName());
if(gtv != null)return gtv;
//new GenericTypeVar(jreSpiderRegistry.get(type.getTypeName()).getName().toString(),parentClass,-1));
//String jccNameForClass=baseTypeTranslationTable.get(cl.getSimpleName());
String jccNameForClass=baseTypeTranslationTable.get(cl.getName());
if(cl.getSimpleName().equalsIgnoreCase("void")){
return(new Void(parentClass,-1));
}else if(jccNameForClass!=null){
RefType rt=new RefType(jccNameForClass,parentClass,-1);
rt.setPrimitiveFlag(true);
return(rt);
}else{
//return(new RefType(cl.getSimpleName()));
return(new RefType(cl.getName(),parentClass,-1));
}
//}
}
// ino.end

View File

@ -4,7 +4,7 @@ package de.dhbwstuttgart.syntaxtree.misc;
// ino.module.DeclId.8558.import
import java.util.Vector;
import org.apache.log4j.Logger;
import de.dhbwstuttgart.logger.Logger;
// ino.end

View File

@ -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;

View File

@ -7,7 +7,7 @@ import java.util.HashMap;
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;
@ -37,7 +37,6 @@ import de.dhbwstuttgart.typeinference.SingleConstraint;
import de.dhbwstuttgart.typeinference.UndConstraint;
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
import de.dhbwstuttgart.typeinference.unify.CSubstitutionSet;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;

View File

@ -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;
@ -27,9 +27,9 @@ import de.dhbwstuttgart.typeinference.JavaCodeResult;
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.exceptions.TypeinferenceException;
import de.dhbwstuttgart.typeinference.unify.CSubstitutionSet;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;

View File

@ -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;
@ -126,7 +126,7 @@ public class BoolLiteral extends Literal
@Override
public ConstraintsSet TYPEExpr(TypeAssumptions assumptions) {
this.type = assumptions.getTypeFor(new RefType("java.lang.Boolean",this,-1), this).getType();
this.type = assumptions.checkType(new RefType("java.lang.Boolean",this,-1), this);
return new ConstraintsSet();
}

View File

@ -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;
import de.dhbwstuttgart.bytecode.JVMCode;

View File

@ -4,7 +4,7 @@ package de.dhbwstuttgart.syntaxtree.statement;
// ino.module.CharLiteral.8628.import
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;

View File

@ -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;
@ -26,8 +26,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
@ -164,7 +162,7 @@ public class DoubleLiteral extends Literal
@Override
public ConstraintsSet TYPEExpr(TypeAssumptions assumptions) {
this.setType(assumptions.getTypeFor(new RefType("Double",this,this.getOffset()), this).getType());
this.setType(assumptions.checkType(new RefType("Double",this,this.getOffset()), this));
return new ConstraintsSet();
}

View File

@ -5,8 +5,8 @@ package de.dhbwstuttgart.syntaxtree.statement;
import java.util.Hashtable;
import java.util.Vector;
import de.dhbwstuttgart.logger.Logger;
import org.apache.log4j.Logger;
import de.dhbwstuttgart.bytecode.ClassFile;
import de.dhbwstuttgart.bytecode.CodeAttribute;
import de.dhbwstuttgart.myexception.CTypeReconstructionException;
@ -19,8 +19,8 @@ import de.dhbwstuttgart.typeinference.ConstraintsSet;
import de.dhbwstuttgart.typeinference.JavaCodeResult;
import de.dhbwstuttgart.typeinference.ResultSet;
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
import de.dhbwstuttgart.typeinference.exceptions.NotImplementedException;
import de.dhbwstuttgart.typeinference.unify.CSubstitutionSet;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;

View File

@ -14,7 +14,7 @@ import de.dhbwstuttgart.syntaxtree.type.Type;
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
import de.dhbwstuttgart.typeinference.ConstraintsSet;
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
import de.dhbwstuttgart.typeinference.exceptions.NotImplementedException;

View File

@ -6,7 +6,7 @@ package de.dhbwstuttgart.syntaxtree.statement;
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.syntaxtree.type.Type;

View File

@ -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;

View File

@ -5,7 +5,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;
@ -27,9 +27,8 @@ import de.dhbwstuttgart.typeinference.JavaCodeResult;
import de.dhbwstuttgart.typeinference.Pair;
import de.dhbwstuttgart.typeinference.ResultSet;
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
import de.dhbwstuttgart.typeinference.exceptions.NotImplementedException;
import de.dhbwstuttgart.typeinference.unify.Unify;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;

View File

@ -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;
@ -33,9 +33,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.MUB;
import de.dhbwstuttgart.typeinference.unify.Unify;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;

View File

@ -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;

View File

@ -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;
import de.dhbwstuttgart.bytecode.ClassFile;

View File

@ -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;
@ -22,7 +22,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;
@ -161,7 +160,7 @@ public class IntLiteral extends Literal
public ConstraintsSet TYPEExpr(TypeAssumptions assumptions) {
ConstraintsSet ret = new ConstraintsSet();
//this.setType(new IntegerType());
this.set_Type(assumptions.getTypeFor(new RefType("java.lang.Integer",this,-1), this).getType());
this.set_Type(assumptions.checkType(new RefType("java.lang.Integer",this,-1), this));
return ret;
}

View File

@ -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;
import de.dhbwstuttgart.bytecode.ClassFile;
import de.dhbwstuttgart.bytecode.CodeAttribute;
import de.dhbwstuttgart.bytecode.JVMCode;
@ -28,7 +28,6 @@ import de.dhbwstuttgart.typeinference.SingleConstraint;
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
import de.dhbwstuttgart.typeinference.exceptions.TypeinferenceException;
import de.dhbwstuttgart.typeinference.unify.CSubstitutionSet;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
@ -178,7 +177,8 @@ public class LocalOrFieldVar extends Expr
//gibt es eine Assumption für den die LocalOrFieldVar-Variablen, dann folgendes ausführen:
Type thisTypeAssumption = assumptions.getVarType(this.get_Name(), this.getParentClass());
if(thisTypeAssumption == null)throw new TypeinferenceException("Eine Variable "+this.get_Name()+" ist in den Assumptions nicht vorhanden",this);
this.setType(thisTypeAssumption);
Type thisType = thisTypeAssumption.checkTYPE(assumptions, this);
this.setType(thisType);
//ret.add(new Constraint(thisTypeAssumption, this.getTypeVariable()));
return ret;
}

View File

@ -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;
import de.dhbwstuttgart.bytecode.ClassFile;
import de.dhbwstuttgart.bytecode.CodeAttribute;
@ -209,7 +209,7 @@ public class LocalVarDecl extends Statement implements TypeInsertable
throw ex;
}
else if(paralist==null && c.get_ParaList().size()>0){
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.

View File

@ -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

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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<Class> classname, Hashtable bh, Hashtable<String, String> ch, boolean ext, Hashtable parach, Hashtable<String, 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<Class> 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);
/*

View File

@ -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;

View File

@ -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

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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

View File

@ -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;

View File

@ -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;

View File

@ -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();
}

View File

@ -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;

View File

@ -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;

View File

@ -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 ));
}
}

View File

@ -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 {

View File

@ -44,7 +44,7 @@ public class GenericTypeVar extends Type
// ino.method.GenericTypeVar.26509.defdescription type=line
// private Hashtable<String, Vector<GenericTypeVar>> m_TypeErasureList;
// ino.end
private static HashMap<GenericTypeVar,TypePlaceholder> tph = new HashMap<GenericTypeVar,TypePlaceholder>();
private static HashMap<String,TypePlaceholder> 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;
}

View File

@ -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

View File

@ -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<Type> paralist = new Vector<Type>();
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<ConstraintType> parameterList = new Vector<>();
Vector<Type> 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;
}

View File

@ -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<SyntaxTreeNode> getChildren() {
return new Vector<>();
}
public Type checkTYPE(TypeAssumptions ass, SyntaxTreeNode method){
return this;
}
}
// ino.end

View File

@ -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

View File

@ -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

View File

@ -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.

View File

@ -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;
}
}

View File

@ -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<OderConstraint>{
private static final Logger log = Logger.getLogger(ConstraintsSet.class.getName());
private Vector<OderConstraint> constraintsSet;
public ConstraintsSet(){
@ -50,6 +54,45 @@ public class ConstraintsSet implements Iterable<OderConstraint>{
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<UndConstraint> uCons = this.filterUndConstraints();
Vector<Pair> alleUndConstraints = new Vector<>();
for(UndConstraint undConstraint : uCons){
alleUndConstraints.addAll(undConstraint.getConstraintPairs());
}
this.filterWrongConstraints(
(pairs)->{
Vector<Pair> 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<Vector<Pair>> 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<UndConstraint> filterUndConstraints() {
Vector<UndConstraint> ret = new Vector<>();
for(OderConstraint con : constraintsSet){
UndConstraint filtered = con.filterUndConstraints();
if(filtered != null)ret.add(filtered);
}
return ret;
}
}

View File

@ -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<GenericTypeVar> gtvparalist;
//private Vector<GenericTypeVar> 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 <code>R apply(T1 par1);</code>
*/
public FunNInterface(int N) {
super("Fun"+N, 0);
super("Fun"+N, null, new Modifiers(), FunNInterface.makeParaList(N));
/*
GenericTypeVar gtv;
Vector<Type> 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<String> makeParaList(int n) {
Vector<String> 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;
}

View File

@ -15,7 +15,7 @@ public class FunNMethod extends Method{
*
* @param N - Anzahl der Parameter (Beispiel: Fun2<R, T1, T2>)
*/
public FunNMethod(Vector<Type> paralist){
public FunNMethod(Vector<? extends Type> 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());

View File

@ -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{

View File

@ -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<UndConstraint> 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<UndConstraint> filteredConstraints = new Vector<>();
for(UndConstraint cons : this.getUndConstraints()){
Vector<Vector<Pair>> 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;
}
}

View File

@ -121,7 +121,7 @@ public class Pair
if(OperatorSmallerExtends())
Operator = "<?";
return "(" + strElement1 + " " + Operator + " " + strElement2 + ")";
return "\n(" + strElement1 + " " + Operator + " " + strElement2 + ")";
/*- Equals: " + bEqual*/
}

View File

@ -3,6 +3,7 @@ package de.dhbwstuttgart.typeinference;
import java.util.Vector;
import de.dhbwstuttgart.syntaxtree.type.Type;
import de.dhbwstuttgart.typeinference.unify.Unifier;
/**
* Stellt ein Constraint dar, welches aus mehreren Constraint-Paaren besteht. Diese gelten alle stets gleichzeitig / sind per "Und" miteinander verknüpft.
@ -36,5 +37,14 @@ public class UndConstraint extends OderConstraint {
}
return ret+"]";
}
@Override
void filterWrongConstraints(Unifier unifier) {
//In einem UndConstraint gibt es keine falschen Constraints
}
@Override
UndConstraint filterUndConstraints(){
return this;
}
}

View File

@ -4,6 +4,7 @@ import java.util.Iterator;
import java.util.Vector;
import de.dhbwstuttgart.core.IItemWithOffset;
import de.dhbwstuttgart.logger.Logger;
import de.dhbwstuttgart.parser.JavaClassName;
import de.dhbwstuttgart.syntaxtree.Class;
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
@ -16,7 +17,6 @@ import de.dhbwstuttgart.typeinference.FunN;
import de.dhbwstuttgart.typeinference.FunNInterface;
import de.dhbwstuttgart.typeinference.FunNMethod;
import de.dhbwstuttgart.typeinference.exceptions.TypeinferenceException;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
/**
* Eine Sammlung von TypeAssumptions.
@ -32,12 +32,7 @@ import sun.reflect.generics.reflectiveObjects.NotImplementedException;
*/
public class TypeAssumptions {
/*
* Folgende Vorgehensweise:
* -Lokale Variablen werden in einem extra AssumptionSet gespeichert. Das Assumption Set hat nicht die Aufgabe Closures zu verwalten.
* -... genauso verhält es sich für Parameter. Parameter verhalten sich beim Abrufen wie lokale Variablen, werden aber zuerst durchsucht.
*
*/
private static final Logger log = Logger.getLogger( TypeAssumptions.class.getName() );
//private static CTypeAssumptionSet globalAssumptions = new CTypeAssumptionSet();
private JavaClassName thisClassName;
@ -164,7 +159,7 @@ public class TypeAssumptions {
}
//Ebenso wie die Generischen Variablen:
for(GenericVarAssumption ass : this.genericVarAssumptions){
if(ass.getIdentifier().equals(variableName))return ass.getAssumedType();
}
//und zuletzt die Felder der Klasse in dessen Namensraum sich dieses AssumptionSet befindet.
@ -174,8 +169,8 @@ public class TypeAssumptions {
}
}
//Wird keine Assumption gefunden, muss ein Fehler vorliegen:
//throw new TypeinferenceException("Eine Variable "+variableName+" ist in den Assumptions nicht vorhanden");
return null;
throw new TypeinferenceException("Eine Variable "+variableName+" ist in den Assumptions nicht vorhanden", inScope);
//return null;
}
/**
@ -301,7 +296,20 @@ public class TypeAssumptions {
if(match && t instanceof RefType){
RefType tr = (RefType)t;
RefType ret = ass.getAssumedClass().getType(); //Dadurch erhält der RefType den vollen Namen (bsp. java.lang.Integer)
ret.set_ParaList(tr.getParaList());
//Falls der RefType mit Parametern angegeben wurde, so müssen diese erhalten bleiben:
if(tr.get_ParaList()!=null && tr.getParaList().size()>0){
ret.set_ParaList(tr.getParaList());
}
//Der RefType muss zusätzlich seine Parameter prüfen.
Vector<Type> 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<ClassAssumption> 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.

View File

@ -0,0 +1,5 @@
package de.dhbwstuttgart.typeinference.exceptions;
public class NotImplementedException extends RuntimeException {
}

View File

@ -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;

View File

@ -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

View File

@ -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();
}
}
}

View File

@ -0,0 +1,11 @@
package de.dhbwstuttgart.typeinference.unify;
import java.util.Vector;
import de.dhbwstuttgart.typeinference.Pair;
public interface Unifier {
public Vector<Vector<Pair>> apply (Vector<Pair> E);
}

View File

@ -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));
}

Some files were not shown because too many files have changed in this diff Show More