diff --git a/doc/LambdaJavadoc/de/dhbwstuttgart/syntaxtree/BasicAssumptionClass.html b/doc/LambdaJavadoc/de/dhbwstuttgart/syntaxtree/BasicAssumptionClass.html
index ffe47a09..960cbae1 100644
--- a/doc/LambdaJavadoc/de/dhbwstuttgart/syntaxtree/BasicAssumptionClass.html
+++ b/doc/LambdaJavadoc/de/dhbwstuttgart/syntaxtree/BasicAssumptionClass.html
@@ -69,9 +69,9 @@
- Detail:
@@ -100,7 +100,7 @@
- de.dhbwstuttgart.syntaxtree.GTVDeclarationContext
-
-- de.dhbwstuttgart.syntaxtree.Class
+- de.dhbwstuttgart.syntaxtree.ClassOrInterface
-
- Detail:
diff --git a/doc/LambdaJavadoc/de/dhbwstuttgart/syntaxtree/Class.html b/doc/LambdaJavadoc/de/dhbwstuttgart/syntaxtree/Class.html
index 0512f0ca..1c088344 100644
--- a/doc/LambdaJavadoc/de/dhbwstuttgart/syntaxtree/Class.html
+++ b/doc/LambdaJavadoc/de/dhbwstuttgart/syntaxtree/Class.html
@@ -106,7 +106,7 @@ var activeTableTab = "activeTableTab";
- de.dhbwstuttgart.syntaxtree.GTVDeclarationContext
-
-- de.dhbwstuttgart.syntaxtree.Class
+- de.dhbwstuttgart.syntaxtree.ClassOrInterface
diff --git a/doc/LambdaJavadoc/de/dhbwstuttgart/syntaxtree/Interface.html b/doc/LambdaJavadoc/de/dhbwstuttgart/syntaxtree/Interface.html
index 4604aaee..766f9971 100644
--- a/doc/LambdaJavadoc/de/dhbwstuttgart/syntaxtree/Interface.html
+++ b/doc/LambdaJavadoc/de/dhbwstuttgart/syntaxtree/Interface.html
@@ -75,7 +75,7 @@ var activeTableTab = "activeTableTab";
@@ -106,7 +106,7 @@ var activeTableTab = "activeTableTab";
- de.dhbwstuttgart.syntaxtree.GTVDeclarationContext
-
-- de.dhbwstuttgart.syntaxtree.Class
+- de.dhbwstuttgart.syntaxtree.ClassOrInterface
-
diff --git a/doc/LambdaJavadoc/de/dhbwstuttgart/syntaxtree/class-use/Class.html b/doc/LambdaJavadoc/de/dhbwstuttgart/syntaxtree/class-use/Class.html
index 293eb433..45b76ba0 100644
--- a/doc/LambdaJavadoc/de/dhbwstuttgart/syntaxtree/class-use/Class.html
+++ b/doc/LambdaJavadoc/de/dhbwstuttgart/syntaxtree/class-use/Class.html
@@ -3,7 +3,7 @@
-Uses of Class de.dhbwstuttgart.syntaxtree.Class
+Uses of Class de.dhbwstuttgart.syntaxtree.ClassOrInterface
@@ -70,7 +70,7 @@
diff --git a/doc/LambdaJavadoc/de/dhbwstuttgart/typeinference/FunNInterface.html b/doc/LambdaJavadoc/de/dhbwstuttgart/typeinference/FunNInterface.html
index 68f124cd..1789347d 100644
--- a/doc/LambdaJavadoc/de/dhbwstuttgart/typeinference/FunNInterface.html
+++ b/doc/LambdaJavadoc/de/dhbwstuttgart/typeinference/FunNInterface.html
@@ -75,7 +75,7 @@ var activeTableTab = "activeTableTab";
@@ -106,7 +106,7 @@ var activeTableTab = "activeTableTab";
- de.dhbwstuttgart.syntaxtree.GTVDeclarationContext
-
-- de.dhbwstuttgart.syntaxtree.Class
+- de.dhbwstuttgart.syntaxtree.ClassOrInterface
-
diff --git a/src/de/dhbwstuttgart/parser/RunParser.java b/src/de/dhbwstuttgart/parser/RunParser.java
index 9489ca6c..6f04ac55 100644
--- a/src/de/dhbwstuttgart/parser/RunParser.java
+++ b/src/de/dhbwstuttgart/parser/RunParser.java
@@ -5,29 +5,34 @@ import org.antlr.v4.runtime.CommonTokenStream;
import org.antlr.v4.runtime.ParserRuleContext;
import org.antlr.v4.runtime.tree.ParseTreeWalker;
import de.dhbwstuttgart.syntaxtree.*;
+import de.dhbwstuttgart.typecheck.*;
import java.util.Scanner;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
public class RunParser{
- public static void main(String[] args){
- try{
- Scanner sc = new Scanner(System.in);
- String inputString = sc.nextLine();
- while(sc.hasNextLine()) inputString = inputString + sc.nextLine();
- InputStream stream = new ByteArrayInputStream(inputString.getBytes(StandardCharsets.UTF_8));
- ANTLRInputStream input = new ANTLRInputStream(stream);
- Java8Lexer lexer = new Java8Lexer(input);
- CommonTokenStream tokens = new CommonTokenStream(lexer);
- Java8Parser parser = new Java8Parser(tokens);
- ParserRuleContext tree = parser.compilationUnit();
- SyntaxTreeGenerator generator = new SyntaxTreeGenerator(null);
- generator.convert((Java8Parser.CompilationUnitContext) tree);
- }
- catch(Exception e){
- System.out.println("An exception occured which is unknown and on our TODO list.");
- e.printStackTrace();
- }
- }
+ public static void main(String[] args){
+ try{
+ Scanner sc = new Scanner(System.in);
+ String inputString = sc.nextLine();
+ while(sc.hasNextLine()) inputString = inputString + sc.nextLine();
+ InputStream stream = new ByteArrayInputStream(inputString.getBytes(StandardCharsets.UTF_8));
+ ANTLRInputStream input = new ANTLRInputStream(stream);
+ Java8Lexer lexer = new Java8Lexer(input);
+ CommonTokenStream tokens = new CommonTokenStream(lexer);
+ Java8Parser parser = new Java8Parser(tokens);
+ Java8Parser.CompilationUnitContext tree = parser.compilationUnit();
+ SyntaxTreeGenerator generator = new SyntaxTreeGenerator();
+ generator.getNames(tree);
+ SourceFile f = generator.convert((Java8Parser.CompilationUnitContext) tree);
+ for(ClassOrInterface c : f.KlassenVektor){
+ System.out.println(c.getClassName().toString());
+ }
+ }
+ catch(Exception e){
+ System.out.println("An exception occured which is unknown and on our TODO list.");
+ e.printStackTrace();
+ }
+ }
}
diff --git a/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator.java b/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator.java
index 78694e38..bc9c773a 100644
--- a/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator.java
+++ b/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator.java
@@ -1,29 +1,69 @@
package de.dhbwstuttgart.parser;
import de.dhbwstuttgart.syntaxtree.SourceFile;
-import de.dhbwstuttgart.syntaxtree.Class;
-import de.dhbwstuttgart.typecheck.JavaClassRegistry;
+import de.dhbwstuttgart.syntaxtree.ClassOrInterface;
+import de.dhbwstuttgart.typecheck.*;
import java.util.ArrayList;
import java.util.List;
-
-public class SyntaxTreeGenerator {
-
- public SyntaxTreeGenerator(JavaClassRegistry nameReg){
- //TODO: Implement
+import org.antlr.v4.runtime.tree.TerminalNode;
+public class SyntaxTreeGenerator{
+ JavaClassRegistry reg = new JavaClassRegistry();
+ String packageDecl = "";
+
+ public void getNames(Java8Parser.CompilationUnitContext ctx){
+ if(ctx.packageDeclaration() != null){
+ for(TerminalNode t : ctx.packageDeclaration().Identifier()){
+ this.packageDecl = this.packageDecl + "." + t.toString();
+ }
+ this.packageDecl = this.packageDecl.substring(1);
}
-
- public SourceFile convert(Java8Parser.CompilationUnitContext ctx){
- List classes = new ArrayList<>();
- for(Java8Parser.TypeDeclarationContext typeDecl : ctx.typeDeclaration()){
- Class newClass = convert(typeDecl.classDeclaration());
- classes.add(newClass);
+ String nameString = "";
+ for (Java8Parser.TypeDeclarationContext typeDecl : ctx.typeDeclaration()){
+ if(typeDecl.interfaceDeclaration() != null){
+ if(typeDecl.interfaceDeclaration().normalInterfaceDeclaration() != null){
+ if(packageDecl != ""){
+ nameString = packageDecl + "." + typeDecl.interfaceDeclaration().normalInterfaceDeclaration().Identifier().toString();
+ }
+ else{
+ nameString = typeDecl.interfaceDeclaration().normalInterfaceDeclaration().Identifier().toString();
+ }
+ this.reg.existingClasses.add(new JavaClassName(nameString));
}
- return new SourceFile(classes);
+ }
+ else{
+ if(typeDecl.classDeclaration().normalClassDeclaration() != null){
+ if(packageDecl != ""){
+ nameString = packageDecl + "." + typeDecl.classDeclaration().normalClassDeclaration().Identifier().toString();
+ }
+ else{
+ nameString = typeDecl.classDeclaration().normalClassDeclaration().Identifier().toString();
+ }
+ this.reg.existingClasses.add(new JavaClassName(nameString));
+ }
+ }
}
+ }
- private Class convert(Java8Parser.ClassDeclarationContext ctx) {
- //TODO: Implement
- return null;
+ public SourceFile convert(Java8Parser.CompilationUnitContext ctx){
+ List classes = new ArrayList<>();
+ for(Java8Parser.TypeDeclarationContext typeDecl : ctx.typeDeclaration()){
+ ClassOrInterface newClass = convert(typeDecl.classDeclaration());
+ classes.add(newClass);
}
+ return new SourceFile(classes);
+ }
+
+ private ClassOrInterface convert(Java8Parser.ClassDeclarationContext ctx) {
+ ClassOrInterface newClass = new ClassOrInterface();
+ String name = "";
+ if(this.packageDecl != ""){
+ name = packageDecl + "." + ctx.normalClassDeclaration().Identifier().toString();
+ }
+ else{
+ name = ctx.normalClassDeclaration().Identifier().toString();
+ }
+ newClass.setClassName(new JavaClassName(name));
+ return newClass;
+ }
}
diff --git a/src/de/dhbwstuttgart/parser/TODO b/src/de/dhbwstuttgart/parser/TODO
index 2272602d..ae1d80c4 100644
--- a/src/de/dhbwstuttgart/parser/TODO
+++ b/src/de/dhbwstuttgart/parser/TODO
@@ -2,3 +2,4 @@
* Core-Problem: Typinferenz vs. Konstruktoren
* möglicherweise Problem: falsche Return-Expressions
+* Problem: Line-Comments werden nicht erkannt bzw. führen dazu dass das gesamte File nicht geparsed wird (Java8.g4).
diff --git a/src/de/dhbwstuttgart/parser/parse_tree b/src/de/dhbwstuttgart/parser/parse_tree
index a9f6ca2a..13078b55 100644
--- a/src/de/dhbwstuttgart/parser/parse_tree
+++ b/src/de/dhbwstuttgart/parser/parse_tree
@@ -10,3 +10,9 @@
= Idee bei mehreren Files =
* Zunächst alle Files anschauen und Pakate/Klassen für die spätere Verwendung "registrieren".
* Danach erst das komplette Package/alle Klassen imselben Verzeichnis parsen.
+
+== Fragen/PProbleme SyntaxTreeGenerator ==
+
+* ClassRegistry: Unklar, woher diese kommen soll.
+* Konstruktor für Class fehlt.
+* Namenskonflikt Class vs. Class in Java?
diff --git a/src/de/dhbwstuttgart/syntaxtree/Class.java b/src/de/dhbwstuttgart/syntaxtree/Class.java
deleted file mode 100755
index 4914cb85..00000000
--- a/src/de/dhbwstuttgart/syntaxtree/Class.java
+++ /dev/null
@@ -1,265 +0,0 @@
-package de.dhbwstuttgart.syntaxtree;
-
-import de.dhbwstuttgart.logger.Logger;
-import de.dhbwstuttgart.logger.Section;
-import de.dhbwstuttgart.core.IItemWithOffset;
-import de.dhbwstuttgart.typecheck.JavaClassName;
-import de.dhbwstuttgart.syntaxtree.modifier.Modifiers;
-import de.dhbwstuttgart.syntaxtree.statement.Block;
-import de.dhbwstuttgart.syntaxtree.statement.Expr;
-import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar;
-import de.dhbwstuttgart.syntaxtree.type.RefType;
-import de.dhbwstuttgart.syntaxtree.type.Type;
-import de.dhbwstuttgart.typeinference.*;
-import de.dhbwstuttgart.typeinference.assumptions.ClassAssumption;
-import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
-import de.dhbwstuttgart.typeinference.exceptions.NotImplementedException;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Stellt jede Art von Klasse dar. Auch abstrakte Klassen und Interfaces
- */
-public class Class extends GTVDeclarationContext implements IItemWithOffset, Generic, GenericTypeInsertable
-{
- /**
- * Loggerinstanzen
- */
- protected static Logger inferencelog = Logger.getLogger("inference");
- protected static Logger codegenlog = Logger.getLogger("codegen");
- protected static Logger parserlog = Logger.getLogger("parser");
- protected Logger typinferenzLog = Logger.getLogger(Class.class.getName());
-
- protected Modifiers modifiers;
- protected JavaClassName name;
- private Block class_block;
- private List fielddecl = new ArrayList<>();
- private GenericDeclarationList genericClassParameters;
- private int offset;
- private RefType superClass;
- protected boolean isInterface;
- private List implementedInterfaces;
-
- public Class(JavaClassName name, GenericDeclarationList genericDeclarations, List methode, List felder, int offset) {
- super(offset);
- }
-
- /////////////////////////////////////////////////////////////////////////
- // TypeReconstructionAlgorithmus
- /////////////////////////////////////////////////////////////////////////
- /**
- * Ausgangspunkt f�r den Typrekonstruktionsalgorithmus. Hier werden zun�chst
- * die Mengen von Typannahmen V_fields_methods und V_i erstellt, die als Eingabe
- * f�r den Algorithmus dienen.
- * (siehe Algorithmus 5.17 TRProg, Martin Pl�micke)
- *
Author: J�rg B�uerle
- * @param supportData
- * @param globalAssumptions
- * @return Liste aller bisher berechneten, m�glichen Typkombinationen
- * @throws CTypeReconstructionException
- */
- public ConstraintsSet typeReconstruction(TypeAssumptions globalAssumptions)
- {
- //////////////////////////////
- // Und los geht's:
- //////////////////////////////
- inferencelog.info("Rufe TRStart()...", Section.TYPEINFERENCE);
-
- //////////////////////////////
- // Ab hier ...
- // @author A10023 - Andreas Stadelmeier:
- //////////////////////////////
- //Erzeuge Assumptions:
- TypeAssumptions assumptions = this.getPrivateFieldAssumptions();
- //Globale Assumptions anfügen:
- assumptions.add(globalAssumptions);
-
- ConstraintsSet oderConstraints = new ConstraintsSet();
-
-
- typinferenzLog.debug("Erstellte Assumptions: "+assumptions, Section.TYPEINFERENCE);
-
- //Gibt es hier eine ClassCastException stimmt etwas grundsätzlich nicht!
- //this.superClass = (RefType)this.superClass.TYPE(assumptions, this);
-
- for(Field f:this.getFields()){
- oderConstraints.add(f.TYPE(assumptions));
- }
- typinferenzLog.debug("Erstellte Constraints: "+oderConstraints, Section.TYPEINFERENCE);
-
- return oderConstraints;
- }
-
- /**
- * Ermittelt alle privaten Felder und Methoden der Klasse und Erstellt eine Assumption für diese.
- * Bemerkung: Momentan werden noch alle Felder dieser Klasse zurückgegeben.
- * @return Die erstellten TypeAssumptions
- */
- private TypeAssumptions getPrivateFieldAssumptions() {
- if(this.typeAssumptions != null)return this.typeAssumptions; //Das sorgt dafür, dass die Assumptions nur einmalig generiert werden.
- TypeAssumptions assumptions = new TypeAssumptions(this.getName());
-
- for(Field field : this.getFields()){
- if(!field.isPublic())assumptions.add(field.createTypeAssumptions(this));
- }
-
- this.typeAssumptions = assumptions; //Diese müssen anschlieÃend nicht wieder generiert werden.
- return assumptions;
- }
-
- /**
- *
Author: Martin Pl�micke
- * @return
- */
- public String toString()
- {
- return name.toString();
- }
-
- public String getTypeInformation(Menge methodList, Menge fieldList){
- String ret = this.name+": ";
- for(Expr field : fieldList){
- ret+=field.getTypeInformation()+"\n";
- }
- for(Method m : methodList){
- ret+=m.getTypeInformation()+"\n";
- }
- return ret;
- }
-
-
- /**
- * Generiert den JavaCode dieser Klasse im Falle für das übergebene resultSet.
- * Dem ResultSet entsprechend werden in diesem Java-Code die TypePlaceholder durch die in ResultSet stehenden Typen ersetzt.
- * @return Java-Sourcefile
- */
- public JavaCodeResult printJavaCode(ResultSet reconstructionResult){
- JavaCodeResult ret = new JavaCodeResult("class ");
-
- JavaCodeResult classBodyCode = new JavaCodeResult();
- if(this.modifiers!=null)classBodyCode.attach(this.modifiers.printJavaCode(reconstructionResult)).attach(" ");
-
- classBodyCode.attach(this.name + " extends ").attach(this.superClass.printJavaCode(reconstructionResult)).attach("\n");
-
- JavaCodeResult bodyString = new JavaCodeResult("{\n");
- for(Field field : this.fielddecl)bodyString.attach( field.printJavaCode(reconstructionResult) ).attach( "\n" );
- bodyString.attach("}\n");
-
- classBodyCode.attach(bodyString);
-
- //Zuerst die generischen Parameter für diese Klasse berechnen:
- //this.createGenericTypeVars(classBodyCode.getUnresolvedTPH());
-
- if(this.genericClassParameters != null && this.genericClassParameters.size()>0){
- ret.attach("<");
-
- Iterator it = this.genericClassParameters.iterator();
- while(it.hasNext()){
- GenericTypeVar tph = it.next();
- ret.attach(tph.printJavaCode(reconstructionResult));
- if(it.hasNext())ret.attach(", ");
- }
- ret.attach(">");
- }
-
- String stringReturn = ret.attach(classBodyCode).toString();
-
- return new JavaCodeResult(stringReturn);
- }
-
- public int getOffset(){
- return this.offset;
- }
-
- /**
- * Erstellt einen RefType, welcher auf diese Klasse verweist
- * Ersetzt alle Generischen Variablen in der Parameterliste mit TPH
- * @return
- */
- public RefType getType() {
- return new RefType(this.getName().toString(), this.get_ParaList(),this, 0);
- }
-
-
- /**
- * Ermittelt die Sichtbaren Felder und Methoden der Klasse.
- * (Momentan sind im Projekt alle Felder und Methoden "package private", da der Parser keine Access-Modifier einlesen kann.
- * @return
- */
- public TypeAssumptions getPublicFieldAssumptions() {
- TypeAssumptions ret = new TypeAssumptions();//this.getPrivateFieldAssumptions();
- ret.addClassAssumption(new ClassAssumption(this));
- for(Field f : this.getFields()){
- if(f.isPublic())ret.add(f.createTypeAssumptions(this));
- }
- for(GenericTypeVar gtv : this.getGenericParameter()){
- ret.add(gtv.createAssumptions());
- }
- return ret;
- }
-
- @Override
- public boolean equals(Object obj){
- if(!(obj instanceof Class))return false;
- Class cl = (Class) obj;
- if(!(cl.getName().equals(this.getName())))return false;
-
- return true;
- }
-
- @Override
- public GenericDeclarationList getGenericParameter() {
- return this.genericClassParameters;
- }
-
- @Override
- public List extends SyntaxTreeNode> getChildren() {
- throw new NotImplementedException();
- }
-
- @Override
- public String getDescription(){
- return "class "+this.getName();
- }
-
- @Override
- public void setGenericParameter(GenericDeclarationList params) {
- this.genericClassParameters = params;
- }
-
- @Override
- public String getGenericVarDeclarationString(String genericVarDeclaration) {
- if(this.genericClassParameters != null){
- return ", "+genericVarDeclaration;
- }else{
- return "<"+genericVarDeclaration+">";
- }
- }
-
- @Override
- public int getGenericVarDeclarationOffset(){
- // Falls Generische Parameterliste vorhanden, hier Wert der Liste zurückgegebn
- if(this.genericClassParameters != null){
- return this.genericClassParameters.getEndOffset();
- }else{
- return this.offset;
- }
- }
-
- /**
- * Die Super Klasse dieser Klasse.
- * @return null für Klasse Object
- */
- public RefType getSuperClass(){
- return this.superClass;
- }
- @Override
- public boolean isClass() {
- return true;
- }
-
- public boolean isInterface(){
- return isInterface;
- }
-}
diff --git a/src/de/dhbwstuttgart/syntaxtree/ClassOrInterface.java b/src/de/dhbwstuttgart/syntaxtree/ClassOrInterface.java
new file mode 100755
index 00000000..bfa66808
--- /dev/null
+++ b/src/de/dhbwstuttgart/syntaxtree/ClassOrInterface.java
@@ -0,0 +1,252 @@
+package de.dhbwstuttgart.syntaxtree;
+
+import de.dhbwstuttgart.core.IItemWithOffset;
+import de.dhbwstuttgart.logger.Section;
+import de.dhbwstuttgart.typecheck.JavaClassName;
+import de.dhbwstuttgart.syntaxtree.modifier.Modifiers;
+import de.dhbwstuttgart.syntaxtree.statement.Block;
+import de.dhbwstuttgart.syntaxtree.statement.Expr;
+import de.dhbwstuttgart.syntaxtree.type.RefType;
+import de.dhbwstuttgart.typeinference.ConstraintsSet;
+import de.dhbwstuttgart.typeinference.JavaCodeResult;
+import de.dhbwstuttgart.typeinference.Menge;
+import de.dhbwstuttgart.typeinference.ResultSet;
+import de.dhbwstuttgart.typeinference.assumptions.ClassAssumption;
+import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
+import de.dhbwstuttgart.typeinference.exceptions.NotImplementedException;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * Stellt jede Art von Klasse dar. Auch abstrakte Klassen und Interfaces
+ */
+public class ClassOrInterface extends GTVDeclarationContext implements IItemWithOffset, Generic{
+ protected Modifiers modifiers;
+ protected JavaClassName name;
+ private Block class_block;
+ private List fielddecl = new ArrayList<>();
+ private GenericDeclarationList genericClassParameters;
+ private int offset;
+ private RefType superClass;
+ protected boolean isInterface;
+ private List implementedInterfaces;
+ private List fields;
+
+ public ClassOrInterface(int offset) {
+ super(offset);
+ }
+
+ // Gets class name
+ public JavaClassName getClassName(){
+ return this.name;
+ }
+
+
+ /////////////////////////////////////////////////////////////////////////
+ // TypeReconstructionAlgorithmus
+ /////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Ausgangspunkt f�r den Typrekonstruktionsalgorithmus. Hier werden zun�chst
+ * die Mengen von Typannahmen V_fields_methods und V_i erstellt, die als Eingabe
+ * f�r den Algorithmus dienen.
+ * (siehe Algorithmus 5.17 TRProg, Martin Pl�micke)
+ *
Author: J�rg B�uerle
+ *
+ * @param supportData
+ * @param globalAssumptions
+ * @return Liste aller bisher berechneten, m�glichen Typkombinationen
+ * @throws CTypeReconstructionException
+ */
+ public ConstraintsSet typeReconstruction(TypeAssumptions globalAssumptions) {
+ //////////////////////////////
+ // Und los geht's:
+ //////////////////////////////
+ inferencelog.info("Rufe TRStart()...", Section.TYPEINFERENCE);
+
+ //////////////////////////////
+ // Ab hier ...
+ // @author A10023 - Andreas Stadelmeier:
+ //////////////////////////////
+ //Erzeuge Assumptions:
+ TypeAssumptions assumptions = this.getPrivateFieldAssumptions();
+ //Globale Assumptions anfügen:
+ assumptions.add(globalAssumptions);
+
+ ConstraintsSet oderConstraints = new ConstraintsSet();
+
+
+ typinferenzLog.debug("Erstellte Assumptions: " + assumptions, Section.TYPEINFERENCE);
+
+ //Gibt es hier eine ClassCastException stimmt etwas grundsätzlich nicht!
+ //this.superClass = (RefType)this.superClass.TYPE(assumptions, this);
+
+ for (Field f : this.getFields()) {
+ oderConstraints.add(f.TYPE(assumptions));
+ }
+ typinferenzLog.debug("Erstellte Constraints: " + oderConstraints, Section.TYPEINFERENCE);
+
+ return oderConstraints;
+ }
+
+ /**
+ * Ermittelt alle privaten Felder und Methoden der Klasse und Erstellt eine Assumption für diese.
+ * Bemerkung: Momentan werden noch alle Felder dieser Klasse zurückgegeben.
+ * @return Die erstellten TypeAssumptions
+ */
+ private TypeAssumptions getPrivateFieldAssumptions() {
+ if(this.typeAssumptions != null)return this.typeAssumptions; //Das sorgt dafür, dass die Assumptions nur einmalig generiert werden.
+ TypeAssumptions assumptions = new TypeAssumptions(this.getName());
+
+ for(Field field : this.getFields()){
+ if(!field.isPublic())assumptions.add(field.createTypeAssumptions(this));
+ }
+
+ this.typeAssumptions = assumptions; //Diese müssen anschlieÃend nicht wieder generiert werden.
+ return assumptions;
+ }
+
+ /**
+ *
Author: Martin Pl�micke
+ * @return
+ */
+ public String toString()
+ {
+ return name.toString();
+ }
+
+ /**
+ * Generiert den JavaCode dieser Klasse im Falle für das übergebene resultSet.
+ * Dem ResultSet entsprechend werden in diesem Java-Code die TypePlaceholder durch die in ResultSet stehenden Typen ersetzt.
+ * @return Java-Sourcefile
+ */
+ public JavaCodeResult printJavaCode(ResultSet reconstructionResult){
+ JavaCodeResult ret = new JavaCodeResult("class ");
+
+ JavaCodeResult classBodyCode = new JavaCodeResult();
+ if(this.modifiers!=null)classBodyCode.attach(this.modifiers.printJavaCode(reconstructionResult)).attach(" ");
+
+ classBodyCode.attach(this.name + " extends ").attach(this.superClass.printJavaCode(reconstructionResult)).attach("\n");
+
+ JavaCodeResult bodyString = new JavaCodeResult("{\n");
+ for(Field field : this.fielddecl)bodyString.attach( field.printJavaCode(reconstructionResult) ).attach( "\n" );
+ bodyString.attach("}\n");
+
+ classBodyCode.attach(bodyString);
+
+ //Zuerst die generischen Parameter für diese Klasse berechnen:
+ //this.createGenericTypeVars(classBodyCode.getUnresolvedTPH());
+
+ if(this.genericClassParameters != null && this.genericClassParameters.size()>0){
+ ret.attach("<");
+
+ Iterator it = this.genericClassParameters.iterator();
+ while(it.hasNext()){
+ GenericTypeVar tph = it.next();
+ ret.attach(tph.printJavaCode(reconstructionResult));
+ if(it.hasNext())ret.attach(", ");
+ }
+ ret.attach(">");
+ }
+
+ String stringReturn = ret.attach(classBodyCode).toString();
+
+ return new JavaCodeResult(stringReturn);
+ }
+
+ public int getOffset(){
+ return this.offset;
+ }
+
+ /**
+ * Erstellt einen RefType, welcher auf diese Klasse verweist
+ * Ersetzt alle Generischen Variablen in der Parameterliste mit TPH
+ * @return
+ */
+ public RefType getType() {
+ return new RefType(this.getName().toString(), this.get_ParaList(),this, 0);
+ }
+
+
+ /**
+ * Ermittelt die Sichtbaren Felder und Methoden der Klasse.
+ * (Momentan sind im Projekt alle Felder und Methoden "package private", da der Parser keine Access-Modifier einlesen kann.
+ * @return
+ */
+ public TypeAssumptions getPublicFieldAssumptions() {
+ TypeAssumptions ret = new TypeAssumptions();//this.getPrivateFieldAssumptions();
+ ret.addClassAssumption(new ClassAssumption(this));
+ for(Field f : this.getFields()){
+ if(f.isPublic())ret.add(f.createTypeAssumptions(this));
+ }
+ for(GenericTypeVar gtv : this.getGenericParameter()){
+ ret.add(gtv.createAssumptions());
+ }
+ return ret;
+ }
+
+ @Override
+ public boolean equals(Object obj){
+ if(!(obj instanceof Class))return false;
+ Class cl = (Class) obj;
+ if(!(cl.getName().equals(this.getName())))return false;
+
+ return true;
+ }
+
+ @Override
+ public GenericDeclarationList getGenericParameter() {
+ return this.genericClassParameters;
+ }
+
+ @Override
+ public List extends SyntaxTreeNode> getChildren() {
+ throw new NotImplementedException();
+ }
+
+ @Override
+ public String getDescription(){
+ return "class "+this.getName();
+ }
+
+ @Override
+ public String getGenericVarDeclarationString(String genericVarDeclaration) {
+ if(this.genericClassParameters != null){
+ return ", "+genericVarDeclaration;
+ }else{
+ return "<"+genericVarDeclaration+">";
+ }
+ }
+
+ @Override
+ public int getGenericVarDeclarationOffset(){
+ // Falls Generische Parameterliste vorhanden, hier Wert der Liste zurückgegebn
+ if(this.genericClassParameters != null){
+ return this.genericClassParameters.getEndOffset();
+ }else{
+ return this.offset;
+ }
+ }
+
+ /**
+ * Die Super Klasse dieser Klasse.
+ * @return null für Klasse Object
+ */
+ public RefType getSuperClass(){
+ return this.superClass;
+ }
+ @Override
+ public boolean isClass() {
+ return true;
+ }
+
+ public boolean isInterface(){
+ return isInterface;
+ }
+
+ public List getFields() {
+ return fields;
+ }
+}
diff --git a/src/de/dhbwstuttgart/syntaxtree/SourceFile.java b/src/de/dhbwstuttgart/syntaxtree/SourceFile.java
index 67982275..6b974c70 100755
--- a/src/de/dhbwstuttgart/syntaxtree/SourceFile.java
+++ b/src/de/dhbwstuttgart/syntaxtree/SourceFile.java
@@ -1,8 +1,5 @@
package de.dhbwstuttgart.syntaxtree;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
+import java.util.*;
import de.dhbwstuttgart.typeinference.*;
@@ -14,10 +11,7 @@ import de.dhbwstuttgart.core.MyCompiler;
import de.dhbwstuttgart.typecheck.JavaClassName;
import de.dhbwstuttgart.syntaxtree.factory.UnifyTypeFactory;
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.Void;
import de.dhbwstuttgart.typeinference.assumptions.ClassAssumption;
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
import de.dhbwstuttgart.typeinference.exceptions.DebugException;
@@ -31,23 +25,38 @@ import de.dhbwstuttgart.typeinference.unify.model.UnifyPair;
-public class SourceFile extends SyntaxTreeNode
-{
-
- protected static Logger codegenlog = Logger.getLogger("codegen");
- protected static Logger inferencelog = Logger.getLogger("inference");
-
- private String pkgName;
-
- public List KlassenVektor = new Menge();
- private List imports;
+public class SourceFile extends SyntaxTreeNode{
+
+ private String pkgName;
+
+ public List KlassenVektor = new ArrayList<>();
+ private List imports;
/**
* Die SourceFile repräsntiert eine zu einem Syntaxbaum eingelesene Java-Datei.
* SourceFile stellt dabei den Wurzelknoten des Syntaxbaumes dar.
*/
- public SourceFile(List classDefinitions) {
+ public SourceFile(String pkgName,List classDefinitions,List imports){
+ super(0);
this.KlassenVektor = classDefinitions;
+ if(pkgName != null){
+ this.pkgName = pkgName;
+ }
+ if(imports != null){
+ this.imports = imports;
+ }
+ }
+
+ public SourceFile(List classDefinitions){
+ this(null, classDefinitions, null);
+ }
+
+ public SourceFile(String pkgName, List classDefinitions){
+ this(pkgName, classDefinitions, null);
+ }
+
+ public SourceFile(List classDefinitions, List imports){
+ this(null, classDefinitions, imports);
}
/**
@@ -546,4 +555,3 @@ public class SourceFile extends SyntaxTreeNode
}
}
-// ino.end
diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/Executeable.java b/src/de/dhbwstuttgart/syntaxtree/statement/Executeable.java
index 7550f6c7..407ca0ca 100755
--- a/src/de/dhbwstuttgart/syntaxtree/statement/Executeable.java
+++ b/src/de/dhbwstuttgart/syntaxtree/statement/Executeable.java
@@ -2,6 +2,7 @@
package de.dhbwstuttgart.syntaxtree.statement;
import java.util.Iterator;
+import de.dhbwstuttgart.syntaxtree.type.RefType;
import org.apache.bcel.generic.InstructionList;
import de.dhbwstuttgart.typeinference.Menge;
@@ -10,27 +11,15 @@ import de.dhbwstuttgart.logger.Logger;
import de.dhbwstuttgart.bytecode.ClassGenerator;
import de.dhbwstuttgart.core.MyCompiler;
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
-import de.dhbwstuttgart.syntaxtree.type.Type;
-import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
-import de.dhbwstuttgart.typeinference.Pair;
-import de.dhbwstuttgart.typeinference.Typeable;
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
import de.dhbwstuttgart.typeinference.unify.TypeUnify;
-public abstract class Executeable extends SyntaxTreeNode implements Typeable
+public abstract class Executeable extends SyntaxTreeNode
{
- private Type type;
- public Executeable(Type type,int offset) {
- super(offset);
- this.type = type;
- }
-
- public Type getType(){
- return type;
- }
-
+ public Executeable(int offset) {
+ super(offset); }
+
public abstract InstructionList genByteCode(ClassGenerator _cg, TypeinferenceResultSet rs);
- //public abstract String getTypeInformation();
}
diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/Expr.java b/src/de/dhbwstuttgart/syntaxtree/statement/Expr.java
index 510d38f0..e8fc1aa4 100755
--- a/src/de/dhbwstuttgart/syntaxtree/statement/Expr.java
+++ b/src/de/dhbwstuttgart/syntaxtree/statement/Expr.java
@@ -1,29 +1,26 @@
package de.dhbwstuttgart.syntaxtree.statement;
-import java.util.Hashtable;
-import java.util.Iterator;
-
-import org.apache.bcel.generic.ClassGen;
-import org.apache.bcel.generic.InstructionList;
-
-import de.dhbwstuttgart.typeinference.Menge;
-import de.dhbwstuttgart.syntaxtree.Class;
-import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
-import de.dhbwstuttgart.syntaxtree.type.Type;
-import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
+import de.dhbwstuttgart.syntaxtree.type.RefType;
+import de.dhbwstuttgart.typeinference.Typeable;
import de.dhbwstuttgart.typeinference.ConstraintsSet;
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
import de.dhbwstuttgart.typeinference.exceptions.NotImplementedException;
-public abstract class Expr extends Executeable
+public abstract class Expr extends Executeable implements Typeable
{
+ private RefType type;
- public Expr(Type type, int offset) {
- super(type, offset);
+ public Expr(RefType type, int offset) {
+ super(offset);
+ this.type = type;
}
+ public RefType getType(){
+ return type;
+ }
+
public abstract String get_Name();
/**
diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/ForStmt.java b/src/de/dhbwstuttgart/syntaxtree/statement/ForStmt.java
index f1fe577f..72fae4a0 100755
--- a/src/de/dhbwstuttgart/syntaxtree/statement/ForStmt.java
+++ b/src/de/dhbwstuttgart/syntaxtree/statement/ForStmt.java
@@ -1,11 +1,6 @@
package de.dhbwstuttgart.syntaxtree.statement;
-import java.util.Enumeration;
-import java.util.Hashtable;
-import java.util.Iterator;
-
import org.apache.bcel.generic.BranchInstruction;
-import org.apache.bcel.generic.ClassGen;
import org.apache.bcel.generic.GOTO;
import org.apache.bcel.generic.IF_ICMPGE;
import org.apache.bcel.generic.InstructionHandle;
@@ -15,25 +10,12 @@ import org.apache.bcel.generic.NOP;
import de.dhbwstuttgart.typeinference.exceptions.NotImplementedException;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.bytecode.ClassGenerator;
-import de.dhbwstuttgart.logger.Logger;
-import de.dhbwstuttgart.syntaxtree.Class;
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
-import de.dhbwstuttgart.syntaxtree.operator.LogOp;
-import de.dhbwstuttgart.syntaxtree.operator.Operator;
-import de.dhbwstuttgart.syntaxtree.operator.RelOp;
-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.syntaxtree.type.Void;
import de.dhbwstuttgart.typeinference.ConstraintsSet;
import de.dhbwstuttgart.typeinference.JavaCodeResult;
-import de.dhbwstuttgart.typeinference.Pair;
import de.dhbwstuttgart.typeinference.ResultSet;
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
-import de.dhbwstuttgart.typeinference.exceptions.NotImplementedException;
-import de.dhbwstuttgart.typeinference.unify.TypeUnify;
public class ForStmt extends Statement
{
@@ -48,53 +30,18 @@ public class ForStmt extends Statement
public ForStmt(int offset, int variableLength)
{
- super(offset,variableLength);
+ super(offset);
}
-
- void sc_check(Menge classname, Hashtable ch, Hashtable bh, boolean ext, Hashtable parach, Hashtable parabh)
-
- {
-
- }
-
+
public String toString()
{
return "FOR ";
}
-
- public void wandleRefTypeAttributes2GenericAttributes(Menge paralist, Menge genericMethodParameters)
- {
- if(body_Loop_block!=null){
- body_Loop_block.wandleRefTypeAttributes2GenericAttributes(paralist,genericMethodParameters);
- }
-
- }
-
- public void set_head_Initializer(Expr expr) {
- head_Initializer = expr;
-
- }
-
- public void set_head_Condition(Expr expr) {
- head_Condition = expr;
-
- }
-
- public void set_head_Loop_expr(Expr expr) {
- head_Loop_expr = expr;
-
- }
-
- public void set_body_Loop_block(Statement statement) {
- body_Loop_block = statement;
-
- }
@Override
public ConstraintsSet TYPEStmt(TypeAssumptions assumptions) {
//TODO: TYPEStmt
ConstraintsSet ret = new ConstraintsSet();
- this.setType(TypePlaceholder.fresh(this));
ret.add(body_Loop_block.TYPEStmt(assumptions));
diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/LocalVarDecl.java b/src/de/dhbwstuttgart/syntaxtree/statement/LocalVarDecl.java
index a7e793b4..603112b6 100755
--- a/src/de/dhbwstuttgart/syntaxtree/statement/LocalVarDecl.java
+++ b/src/de/dhbwstuttgart/syntaxtree/statement/LocalVarDecl.java
@@ -1,26 +1,12 @@
-// ino.module.LocalVarDecl.8638.package
package de.dhbwstuttgart.syntaxtree.statement;
-// ino.end
-// ino.module.LocalVarDecl.8638.import
-import java.util.Enumeration;
-import java.util.Hashtable;
-import org.apache.bcel.generic.ClassGen;
import org.apache.bcel.generic.InstructionList;
-
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.logger.Logger;
import de.dhbwstuttgart.bytecode.ClassGenerator;
-import de.dhbwstuttgart.core.MyCompiler;
-import de.dhbwstuttgart.syntaxtree.Class;
-import de.dhbwstuttgart.syntaxtree.ClassHelper;
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
-import de.dhbwstuttgart.syntaxtree.misc.DeclId;
-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.syntaxtree.type.Void;
import de.dhbwstuttgart.typeinference.ConstraintsSet;
import de.dhbwstuttgart.typeinference.JavaCodeResult;
import de.dhbwstuttgart.typeinference.ResultSet;
@@ -28,275 +14,37 @@ import de.dhbwstuttgart.typeinference.TypeInsertable;
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
import de.dhbwstuttgart.typeinference.assumptions.LocalVarAssumption;
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
-import de.dhbwstuttgart.typeinference.exceptions.DebugException;
-import de.dhbwstuttgart.typeinference.exceptions.TypeinferenceException;
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertPoint;
-
-
-// ino.class.LocalVarDecl.25540.declaration
public class LocalVarDecl extends Statement implements TypeInsertable
-// ino.end
-// ino.class.LocalVarDecl.25540.body
{
- // ino.method.LocalVarDecl.25545.definition
- public LocalVarDecl(int offset,int variableLength)
- // ino.end
- // ino.method.LocalVarDecl.25545.body
+ public LocalVarDecl(RefType type, int offset)
{
- super(offset,variableLength);
+ super(offset);
+ this.type = type;
}
- // ino.end
-
- // ino.attribute.declid.25548.declaration
- private Menge declid = new Menge();
- // ino.end
- // ino.attribute.paralist.25554.declaration
- private Menge paralist = null;
- // ino.end
- // ino.attribute.parahash.25557.declaration
- private Hashtable parahash = null;
- // ino.end
- // ino.attribute.inferencelog.25560.declaration
+
+ private String name;
+ private RefType type;
protected static Logger inferencelog = Logger.getLogger("inference");
// ino.end
// ino.attribute.parserlog.25563.declaration
protected static Logger parserlog = Logger.getLogger("parser");
- // ino.end
- // ino.attribute.block.25566.declaration
- public Block block;
- // ino.end
-
- // ino.method.set_DeclId.25575.definition
- public void set_DeclId(DeclId did)
- // ino.end
- // ino.method.set_DeclId.25575.body
- {
- this.declid.addElement(did);
- }
- // ino.end
- // ino.method.get_Name.25578.definition
public String get_Name()
- // ino.end
- // ino.method.get_Name.25578.body
{
- DeclId hilf;
- hilf=declid.elementAt(0);
- return hilf.get_Name();
+ return name;
}
- // ino.end
- // ino.method.set_ParaList.25581.definition
- public void set_ParaList(Menge pl)
- // ino.end
- // ino.method.set_ParaList.25581.body
- {
- this.paralist = pl;
- }
- // ino.end
-
- /*
- // ino.method.check_anz.25590.definition
- public void check_anz(Type type, Menge paralist, Menge classlist)
- throws SCStatementException
- // ino.end
- // ino.method.check_anz.25590.body
- {
- boolean flag = false;
- for(Enumeration e2 = classlist.elements();e2.hasMoreElements();){
- Class c = e2.nextElement();
- // System.out.println("vergleiche "+type.get_Type_()+" mit "+c.getName());
- if(c.getName().equals(type.getName())){
- // System.out.println("if(c.getName().equals(type.get_Type())){");
- if(c.get_ParaList().size()>0 && paralist!=null){
-
- parserlog.debug("Type "+type.getName()+" in classlist gefunden!");
- parserlog.debug("Anzahl der localvar.paralist:"+ paralist.size()+" class.paralist: (soll) "+c.get_ParaList().size());
- if(paralist.size()==c.get_ParaList().size()){
-
- for(Enumeration e3=paralist.elements();e3.hasMoreElements();){
- Type t = (Type)e3.nextElement();
- parserlog.debug("Type "+t.getName()+" wird gerade untersucht");
-
- try
- {
- if ( t instanceof RefType )
- {
- check_anz(t, ((RefType)t).get_ParaList(),classlist);
- }
- }
- catch(SCStatementException ex)
- {
- throw ex;
- }
- }
- flag = true;
- parserlog.debug("flag gesetzt");
- break;
- }
- else{
- SCStatementException ex = new SCStatementException();
- SCExcept e = new SCExcept();
- e.set_error("Klasse "+c.getName()+" ist falsch parametrisiert!");
- e.set_function("complete_parahashtable() --> check_anz()");
- e.set_statement(type.getName().toString());
- ex.addException(e);
- throw ex;
- }
- }
- else if(c.get_ParaList().size()==0 && paralist!=null){
- SCStatementException ex = new SCStatementException();
- SCExcept e = new SCExcept();
- e.set_error("Klasse "+c.getName()+" ist nicht parametrisierbar!");
- e.set_function("complete_parahashtable() --> check_anz()");
- e.set_statement(type.getName().toString());
- ex.addException(e);
- throw ex;
- }
- else if(paralist==null && c.get_ParaList().size()>0){
- parserlog.debug(paralist.toString());
- parserlog.debug(c.getName()+" "+c.get_ParaList().size());
- SCStatementException ex = new SCStatementException();
- SCExcept e = new SCExcept();
- e.set_error("Klasse "+c.getName()+" �berhaupt garnicht parametrisiert!");
- e.set_function("complete_parahashtable() --> check_anz()");
- e.set_statement(type.getName().toString());
- ex.addException(e);
- throw ex;
-
- }
- else{
- flag = true;
- parserlog.debug(type.getName()+" nicht parametrisierbar");
- break;
- }
- }
- }
- if(!flag)
- {
- SCStatementException ex = new SCStatementException();
- SCExcept e = new SCExcept();
- if ( type instanceof RefType )
- {
- e.set_error("Type " + type.getName()+ " falsche Parameter-Anzahl " + ((RefType)type).get_ParaList().size());
- }
- e.set_function("complete_parahashtable() --> check_anz()");
- e.set_statement(type.getName().toString());
- ex.addException(e);
- throw ex;
- }
-
- }
- // ino.end
- */
- public Menge getDeclidMenge()
- // ino.end
- // ino.method.getDeclidMenge.25596.body
- {
- return declid;
- }
- // ino.end
- // ino.method.setDeclidMenge.25599.definition
- public void setDeclidMenge(Menge declid)
- // ino.end
- // ino.method.setDeclidMenge.25599.body
- {
- this.declid = declid;
- }
- // ino.end
-
- // ino.method.getLineNumber.25602.defdescription type=javadoc
- /**
- *
Author: J�rg B�uerle
- * @return
- */
- // ino.end
- // ino.method.getLineNumber.25602.definition
- public int getLineNumber()
- // ino.end
- // ino.method.getLineNumber.25602.body
- {
- if(declid.size()<=0)
- return MyCompiler.NO_LINENUMBER;
- else{
- return declid.elementAt(0).getLineNumber();
- }
- }
- // ino.end
-
- // ino.method.getOffset.25605.defdescription type=javadoc
- /**
- *
Author: Thomas Hornberger
- * @return
- */
- // ino.end
- // ino.method.getOffset.25605.definition
- public int getOffset()
- // ino.end
- // ino.method.getOffset.25605.body
- {
- if(declid.size()<=0)
- return MyCompiler.NO_LINENUMBER;
- else{
- return declid.elementAt(0).getOffset();
- }
- }
- // ino.end
-
-
-
- // ino.method.getTypeLineNumber.25611.defdescription type=javadoc
- /**
- *
Author: J�rg B�uerle
- * @return
- */
- // ino.end
- // ino.method.getTypeLineNumber.25611.definition
- public int getTypeLineNumber()
- // ino.end
- // ino.method.getTypeLineNumber.25611.body
- {
- return this.getLineNumber();
- }
- // ino.end
-
-
- // ino.method.toString.25617.defdescription type=javadoc
/**
*
Author: Martin Pl�micke
* @return
*/
- // ino.end
- // ino.method.toString.25617.definition
public String toString()
- // ino.end
- // ino.method.toString.25617.body
{
- if(this.getType() == null)return "no type " + declid.toString();
- return this.getType().toString() + " " + declid.toString();
+ return this.getType().toString() + " " + get_Name();
}
- // ino.end
- // ino.method.wandleRefTypeAttributes2GenericAttributes.25620.definition
- public void wandleRefTypeAttributes2GenericAttributes(Menge paralist, Menge genericMethodParameters)
- // ino.end
- // ino.method.wandleRefTypeAttributes2GenericAttributes.25620.body
- {
-
- Type fpType=getType();
- // Nur wenn es sich um ein RefType-Field handelt
- Type pendantPara = null;
- if(fpType instanceof RefType)
- pendantPara = ((RefType)fpType).findGenericType(paralist, new Menge());
- //GenericTypeVar pendantPara=ClassHelper.findGenericType(fpType,paralist,genericMethodParameters);
- if(pendantPara!=null){ //Wenn generisch, dann modifizieren
- setType(pendantPara);
- }
-
-
- }
- // ino.end
/**
@@ -307,30 +55,14 @@ public class LocalVarDecl extends Statement implements TypeInsertable
@Override
public ConstraintsSet TYPEStmt(TypeAssumptions assumptions) {
ConstraintsSet ret = new ConstraintsSet();
- if((this.getType() instanceof RefType)){
- Type replaceType = null;
- replaceType = assumptions.checkType((RefType)this.getType(), this);
- this.setType(replaceType);
- }
assumptions.addAssumption(new LocalVarAssumption(this, this.getType())); //Bevor der Typ auf Void gesetzt wird.
- //if(this.getType() == null)throw new DebugException("Parser Post Processing nicht aufgerufen");
- ret.add(ConstraintsSet.createSingleConstraint(this.getType().TYPE(assumptions, this), this.getType().TYPE(assumptions, this)));
- //assumptions.remove(null); // falls Variable mit diesem Namen bereits vorhanden.
- this.setReturnType(new Void(this,0)); //Return typ einer Variablendeklaration ist Void
+ ret.add(ConstraintsSet.createSingleConstraint(this.getType(), this.getType());
return ret;
}
@Override
public String getDescription(){
- if(this.getType() == null)return "no type " + declid.toString();
- if(this.getType() instanceof TypePlaceholder)return declid.toString();
- return this.getType().toString() + " " + declid.toString();
- }
-
- @Override
- public void parserPostProcessing(SyntaxTreeNode parent) {
- super.parserPostProcessing(parent);
- if(this.getType()==null || this.getType() instanceof TypePlaceholder)this.setType(TypePlaceholder.fresh(this));
+ return this.getType().toString() + " " + get_Name();
}
@Override
@@ -348,11 +80,6 @@ public class LocalVarDecl extends Statement implements TypeInsertable
ret.attach(this.get_Name()+";");
return ret;}
- @Override
- public void setOffset(int offset) {
- this.offset = offset;
- }
-
@Override
public String getIdentifier() {
return this.get_Name();
@@ -376,5 +103,9 @@ public class LocalVarDecl extends Statement implements TypeInsertable
_cg.getMethodGenerator().getStoreIndex(get_Name());
return new InstructionList();
}
-}
-// ino.end
+
+ @Override
+ public RefType getType() {
+ return type;
+ }
+}
\ No newline at end of file
diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/MethodCall.java b/src/de/dhbwstuttgart/syntaxtree/statement/MethodCall.java
index c47a4442..9484cf03 100755
--- a/src/de/dhbwstuttgart/syntaxtree/statement/MethodCall.java
+++ b/src/de/dhbwstuttgart/syntaxtree/statement/MethodCall.java
@@ -49,11 +49,11 @@ public class MethodCall extends Expr
}
// ino.method.MethodCall.25627.definition
- public MethodCall(int offset, int variableLength)
+ public MethodCall(int offset)
// ino.end
// ino.method.MethodCall.25627.body
{
- super(offset,variableLength);
+ super(offset);
}
// ino.end
diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/NotExpr.java b/src/de/dhbwstuttgart/syntaxtree/statement/NotExpr.java
index 46b4f4ea..b9d2e7fb 100755
--- a/src/de/dhbwstuttgart/syntaxtree/statement/NotExpr.java
+++ b/src/de/dhbwstuttgart/syntaxtree/statement/NotExpr.java
@@ -1,22 +1,11 @@
-// ino.module.NotExpr.8643.package
package de.dhbwstuttgart.syntaxtree.statement;
-// ino.end
-// ino.module.NotExpr.8643.import
-import java.util.Hashtable;
-import java.util.Iterator;
-
-import org.apache.bcel.generic.ClassGen;
-import org.apache.bcel.generic.InstructionList;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.bytecode.ClassGenerator;
import de.dhbwstuttgart.logger.Logger;
import de.dhbwstuttgart.syntaxtree.Class;
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
-import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar;
import de.dhbwstuttgart.syntaxtree.type.RefType;
-import de.dhbwstuttgart.syntaxtree.type.Type;
-import de.dhbwstuttgart.syntaxtree.type.Void;
import de.dhbwstuttgart.typeinference.ConstraintsSet;
import de.dhbwstuttgart.typeinference.JavaCodeResult;
import de.dhbwstuttgart.typeinference.OderConstraint;
@@ -26,95 +15,48 @@ import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
import de.dhbwstuttgart.typeinference.unify.TypeUnify;
import de.dhbwstuttgart.typeinference.exceptions.NotImplementedException;
+import org.apache.bcel.generic.InstructionList;
-
-
-// ino.class.NotExpr.25873.declaration
public class NotExpr extends UnaryExpr
-// ino.end
-// ino.class.NotExpr.25873.body
{
- // ino.method.NotExpr.25877.definition
- public NotExpr(int offset,int variableLength)
- // ino.end
- // ino.method.NotExpr.25877.body
+ public NotExpr(int offset)
{
- super(offset,variableLength);
+ super(offset);
}
- // ino.end
- // ino.attribute.not.25880.declaration
+
private UnaryNot not;
- // ino.end
- // ino.attribute.expr.25883.declaration
public Expr expr;
- // ino.end
- // ino.attribute.parserlog.25886.declaration
protected static Logger parserlog = Logger.getLogger("parser");
- // ino.end
-
- // ino.method.get_Name.25892.definition
+
public String get_Name()
- // ino.end
- // ino.method.get_Name.25892.body
{
return null;
}
- // ino.end
- // ino.method.get_Expr.25895.definition
public Expr get_Expr()
- // ino.end
- // ino.method.get_Expr.25895.body
{
return expr;
}
- // ino.end
- // ino.method.set_UnaryNot.25898.definition
public void set_UnaryNot(UnaryNot unot)
- // ino.end
- // ino.method.set_UnaryNot.25898.body
{
this.not = unot;
}
- // ino.end
- // ino.method.set_Expr.25901.definition
public void set_Expr(Expr ex)
- // ino.end
- // ino.method.set_Expr.25901.body
{
this.expr = ex;
}
- // ino.end
-
-/*
- public void if_codegen(ClassFile classfile, Code_attribute code, boolean sw) throws JVMCodeException {
- if(expr instanceof NotExpr) if_codegen(classfile, code, !sw);
- else {
- expr.codegen(classfile, code);
- not.if_codegen(classfile, code, sw);
- }
- }
-*/
-
- // ino.end
- // ino.method.wandleRefTypeAttributes2GenericAttributes.25916.definition
- public void wandleRefTypeAttributes2GenericAttributes(Menge paralist, Menge genericMethodParameters)
- // ino.end
- // ino.method.wandleRefTypeAttributes2GenericAttributes.25916.body
- {
- }
- // ino.end
@Override
public ConstraintsSet TYPEExpr(TypeAssumptions assumptions) {
ConstraintsSet ret = new ConstraintsSet();
OderConstraint constraint = new OderConstraint();
- constraint.addConstraint(this.getType().TYPE(assumptions, this), new RefType("Boolean",this,-1).TYPE(assumptions, this));
+ expr.TYPEExpr(assumptions);
+ constraint.addConstraint(expr.getType(), assumptions.getBooleanType());
ret.add(constraint);
return ret;
}
@@ -139,4 +81,3 @@ public JavaCodeResult printJavaCode(ResultSet resultSet) {
}
}
-// ino.end
diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/PositivExpr.java b/src/de/dhbwstuttgart/syntaxtree/statement/PositivExpr.java
index 01a09b97..1d9f3bee 100755
--- a/src/de/dhbwstuttgart/syntaxtree/statement/PositivExpr.java
+++ b/src/de/dhbwstuttgart/syntaxtree/statement/PositivExpr.java
@@ -1,102 +1,27 @@
-// ino.module.PositivExpr.8645.package
package de.dhbwstuttgart.syntaxtree.statement;
-// ino.end
-// ino.module.PositivExpr.8645.import
-import java.util.Hashtable;
-
-import org.apache.bcel.generic.ClassGen;
-import org.apache.bcel.generic.InstructionList;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.bytecode.ClassGenerator;
import de.dhbwstuttgart.logger.Logger;
-import de.dhbwstuttgart.syntaxtree.Class;
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
-import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar;
-import de.dhbwstuttgart.syntaxtree.type.Type;
import de.dhbwstuttgart.typeinference.ConstraintsSet;
import de.dhbwstuttgart.typeinference.JavaCodeResult;
import de.dhbwstuttgart.typeinference.ResultSet;
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
import de.dhbwstuttgart.typeinference.exceptions.NotImplementedException;
+import org.apache.bcel.generic.InstructionList;
-
-
-// ino.class.PositivExpr.25947.declaration
public class PositivExpr extends UnaryExpr
-// ino.end
-// ino.class.PositivExpr.25947.body
{
- // ino.method.PositivExpr.25951.definition
- public PositivExpr(int offset,int variableLength)
- // ino.end
- // ino.method.PositivExpr.25951.body
+ public PositivExpr(int offset)
{
- super(offset,variableLength);
+ super(offset);
}
- // ino.end
- // ino.attribute.plus.25954.declaration
protected UnaryPlus plus;
- // ino.end
- // ino.attribute.expr.25957.declaration
public Expr expr;
- // ino.end
- // ino.attribute.parserlog.25960.declaration
protected static Logger parserlog = Logger.getLogger("parser");
- // ino.end
-
-
-
- // ino.method.set_UnaryPlus.25963.definition
- public void set_UnaryPlus(UnaryPlus up)
- // ino.end
- // ino.method.set_UnaryPlus.25963.body
- {
- this.plus = up;
- }
- // ino.end
-
- // ino.method.set_Expr.25966.definition
- public void set_Expr(Expr ex)
- // ino.end
- // ino.method.set_Expr.25966.body
- {
- this.expr = ex;
- }
- // ino.end
-
- // ino.method.get_Name.25969.definition
- public String get_Name()
- // ino.end
- // ino.method.get_Name.25969.body
- {
- return null;
- }
- // ino.end
-
- /*
- // ino.method.sc_check.25972.definition
- public void sc_check(Menge classname, Hashtable ch, Hashtable bh, boolean ext, Hashtable parach, Hashtable parabh)
- // ino.end
- // ino.method.sc_check.25972.body
- {
- if(ext)
- parserlog.debug(" ---PositivExpr---");
- //Wartet noch auf Implementierung
- }
- // ino.end
- */
-
- // ino.method.wandleRefTypeAttributes2GenericAttributes.25984.definition
- public void wandleRefTypeAttributes2GenericAttributes(Menge paralist, Menge genericMethodParameters)
- // ino.end
- // ino.method.wandleRefTypeAttributes2GenericAttributes.25984.body
- {
- }
- // ino.end
-
@Override
public ConstraintsSet TYPEExpr(TypeAssumptions assumptions) {
@@ -105,7 +30,7 @@ public class PositivExpr extends UnaryExpr
}
@Override
-public JavaCodeResult printJavaCode(ResultSet resultSet) {
+ public JavaCodeResult printJavaCode(ResultSet resultSet) {
// TODO Auto-generated method stub
return null;
}
@@ -124,4 +49,3 @@ public JavaCodeResult printJavaCode(ResultSet resultSet) {
}
}
-// ino.end
diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/PreDecExpr.java b/src/de/dhbwstuttgart/syntaxtree/statement/PreDecExpr.java
index a278d666..1d4a00d5 100755
--- a/src/de/dhbwstuttgart/syntaxtree/statement/PreDecExpr.java
+++ b/src/de/dhbwstuttgart/syntaxtree/statement/PreDecExpr.java
@@ -1,9 +1,5 @@
// ino.module.PreDecExpr.8648.package
package de.dhbwstuttgart.syntaxtree.statement;
-// ino.end
-// ino.module.PreDecExpr.8648.import
-import java.util.Hashtable;
-import java.util.Iterator;
import org.apache.bcel.generic.ClassGen;
import org.apache.bcel.generic.InstructionList;
@@ -13,10 +9,7 @@ import de.dhbwstuttgart.bytecode.ClassGenerator;
import de.dhbwstuttgart.logger.Logger;
import de.dhbwstuttgart.syntaxtree.Class;
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
-import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar;
import de.dhbwstuttgart.syntaxtree.type.RefType;
-import de.dhbwstuttgart.syntaxtree.type.Type;
-import de.dhbwstuttgart.syntaxtree.type.Void;
import de.dhbwstuttgart.typeinference.ConstraintsSet;
import de.dhbwstuttgart.typeinference.JavaCodeResult;
import de.dhbwstuttgart.typeinference.Pair;
@@ -47,33 +40,11 @@ public class PreDecExpr extends UnaryExpr
protected static Logger parserlog = Logger.getLogger("parser");
// ino.end
-
-
- // ino.method.set_Expr.26068.definition
- public void set_Expr(Expr ex)
- // ino.end
- // ino.method.set_Expr.26068.body
- {
- this.expr = ex;
- }
- // ino.end
- // ino.method.get_Name.26071.definition
+
public String get_Name()
- // ino.end
- // ino.method.get_Name.26071.body
{
return null;
}
- // ino.end
-
- // ino.end
- // ino.method.wandleRefTypeAttributes2GenericAttributes.26086.definition
- public void wandleRefTypeAttributes2GenericAttributes(Menge paralist, Menge genericMethodParameters)
- // ino.end
- // ino.method.wandleRefTypeAttributes2GenericAttributes.26086.body
- {
- }
- // ino.end
@Override
public JavaCodeResult printJavaCode(ResultSet resultSet) {
diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/PreIncExpr.java b/src/de/dhbwstuttgart/syntaxtree/statement/PreIncExpr.java
index 5c200071..307082d6 100755
--- a/src/de/dhbwstuttgart/syntaxtree/statement/PreIncExpr.java
+++ b/src/de/dhbwstuttgart/syntaxtree/statement/PreIncExpr.java
@@ -1,22 +1,11 @@
-// ino.module.PreIncExpr.8649.package
package de.dhbwstuttgart.syntaxtree.statement;
-// ino.end
-// ino.module.PreIncExpr.8649.import
-import java.util.Hashtable;
-import java.util.Iterator;
-
-import org.apache.bcel.generic.ClassGen;
-import org.apache.bcel.generic.InstructionList;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.bytecode.ClassGenerator;
import de.dhbwstuttgart.logger.Logger;
import de.dhbwstuttgart.syntaxtree.Class;
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
-import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar;
import de.dhbwstuttgart.syntaxtree.type.RefType;
-import de.dhbwstuttgart.syntaxtree.type.Type;
-import de.dhbwstuttgart.syntaxtree.type.Void;
import de.dhbwstuttgart.typeinference.ConstraintsSet;
import de.dhbwstuttgart.typeinference.JavaCodeResult;
import de.dhbwstuttgart.typeinference.Pair;
@@ -29,34 +18,16 @@ import de.dhbwstuttgart.typeinference.exceptions.NotImplementedException;
-// ino.class.PreIncExpr.26089.declaration
public class PreIncExpr extends UnaryExpr
-// ino.end
-// ino.class.PreIncExpr.26089.body
{
- // ino.method.PreIncExpr.26093.definition
- public PreIncExpr(int offset,int variableLength)
- // ino.end
- // ino.method.PreIncExpr.26093.body
+ public PreIncExpr(int offset)
{
- super(offset,variableLength);
+ super(offset);
}
- // ino.end
- // ino.attribute.parserlog.26099.declaration
+
protected static Logger parserlog = Logger.getLogger("parser");
- // ino.end
-
-
-
-
- // ino.method.set_Expr.26102.definition
- public void set_Expr(Expr ex)
- // ino.end
- // ino.method.set_Expr.26102.body
- {
- this.expr = ex;
- }
- // ino.end
+
+
// ino.method.get_Name.26105.definition
public String get_Name()
diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/Receiver.java b/src/de/dhbwstuttgart/syntaxtree/statement/Receiver.java
index 2b0dbb0d..0992d7cf 100755
--- a/src/de/dhbwstuttgart/syntaxtree/statement/Receiver.java
+++ b/src/de/dhbwstuttgart/syntaxtree/statement/Receiver.java
@@ -1,9 +1,5 @@
-// ino.module.Receiver.8650.package
package de.dhbwstuttgart.syntaxtree.statement;
-// ino.end
-// ino.module.Receiver.8650.import
-import java.util.Hashtable;
-import de.dhbwstuttgart.typeinference.Menge;
+
import de.dhbwstuttgart.bytecode.ClassGenerator;
import de.dhbwstuttgart.logger.Logger;
import de.dhbwstuttgart.syntaxtree.Class;
@@ -16,87 +12,37 @@ import de.dhbwstuttgart.typeinference.assumptions.ClassAssumption;
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
import de.dhbwstuttgart.typeinference.exceptions.TypeinferenceException;
-
-
-
-// ino.class.Receiver.26123.declaration
public class Receiver
-// ino.end
-// ino.class.Receiver.26123.body
{
- // ino.attribute.expr.26126.declaration
private Expr expr;
private TypeAssumptions typeAssumptions;
- // ino.end
- // ino.attribute.parserlog.26129.declaration
protected static Logger parserlog = Logger.getLogger("parser");
- // ino.end
- // ino.method.Receiver.26132.defdescription type=javadoc
/**
* Autor: J�rg B�uerle
* @param expr
*/
- // ino.end
- // ino.method.Receiver.26132.definition
public Receiver(Expr expr)
- // ino.end
- // ino.method.Receiver.26132.body
{
this.expr = expr;
}
- // ino.end
-
- // ino.method.get_Type.26138.definition
- public String get_Type()
- // ino.end
- // ino.method.get_Type.26138.body
- {
- return expr.getTypeName();
- }
- // ino.end
- // ino.method.set_Expr.26141.definition
- public void set_Expr(Expr express)
- // ino.end
- // ino.method.set_Expr.26141.body
- {
- expr=express;
- }
- // ino.end
-
- // ino.method.get_Expr.26144.definition
public Expr get_Expr()
- // ino.end
- // ino.method.get_Expr.26144.body
{
return expr;
}
- // ino.end
- // ino.method.toString.26147.defdescription type=javadoc
/**
*
Author: Martin Pl�micke
* @return
*/
- // ino.end
- // ino.method.toString.26147.definition
public String toString()
- // ino.end
- // ino.method.toString.26147.body
{
return expr.toString();
}
- // ino.end
-
- /*
- public void setClass(Class cl){
- this.receiverClass = cl;
- }
- */
public Class getReceiverClass(ClassGenerator cg, TypeinferenceResultSet rs){
- de.dhbwstuttgart.syntaxtree.type.Type receiverType = this.get_Expr().getType();
+ RefType receiverType = this.get_Expr().getType();
if(receiverType instanceof TypePlaceholder){
receiverType = rs.getTypeOfPlaceholder((TypePlaceholder)receiverType);
}
@@ -124,4 +70,3 @@ public class Receiver
}
}
-// ino.end
diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/Statement.java b/src/de/dhbwstuttgart/syntaxtree/statement/Statement.java
index f8103e0d..66e9cad2 100755
--- a/src/de/dhbwstuttgart/syntaxtree/statement/Statement.java
+++ b/src/de/dhbwstuttgart/syntaxtree/statement/Statement.java
@@ -1,42 +1,20 @@
-// ino.module.Statement.8652.package
package de.dhbwstuttgart.syntaxtree.statement;
-import java.util.Enumeration;
-import java.util.Hashtable;
-
-import org.apache.bcel.generic.ClassGen;
-import org.apache.bcel.generic.ConstantPoolGen;
-import org.apache.bcel.generic.InstructionFactory;
-import org.apache.bcel.generic.InstructionList;
-
import de.dhbwstuttgart.typeinference.Menge;
-import de.dhbwstuttgart.bytecode.ClassGenerator;
-import de.dhbwstuttgart.core.IItemWithOffset;
-import de.dhbwstuttgart.syntaxtree.Class;
-import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
-import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar;
-import de.dhbwstuttgart.syntaxtree.type.Type;
-import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
import de.dhbwstuttgart.typeinference.ConstraintsSet;
-import de.dhbwstuttgart.typeinference.JavaCodeResult;
import de.dhbwstuttgart.typeinference.Pair;
import de.dhbwstuttgart.typeinference.ResultSet;
-import de.dhbwstuttgart.typeinference.Typeable;
-import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
public abstract class Statement extends Executeable
{
-
-
- public Statement(Type type,int offset)
+ public Statement(int offset)
{
- super(type,offset);
+ super(offset);
}
-
/**
* @author AI10023 - Andreas Stadelmeier
* Implementierung des Java 8 - Typinferenzalgorithmus von Martin Plümicke
@@ -58,14 +36,6 @@ public abstract class Statement extends Executeable
public String getDescription(){
return this.printJavaCode(new ResultSet(new Menge())).toString();
}
-
- public void setReturnType(Type t){
- }
-
- public Type getReturnType(){
- return new de.dhbwstuttgart.syntaxtree.type.Void(-1);
- }
-
}
\ No newline at end of file
diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/This.java b/src/de/dhbwstuttgart/syntaxtree/statement/This.java
index 767e18f7..88c907f8 100755
--- a/src/de/dhbwstuttgart/syntaxtree/statement/This.java
+++ b/src/de/dhbwstuttgart/syntaxtree/statement/This.java
@@ -1,9 +1,11 @@
// ino.module.This.8654.package
package de.dhbwstuttgart.syntaxtree.statement;
// ino.end
-// ino.module.This.8654.import
-import java.util.Hashtable;
+// ino.module.This.8654.import
+import de.dhbwstuttgart.logger.Logger;
+
+import de.dhbwstuttgart.syntaxtree.type.RefType;
import org.apache.bcel.generic.ClassGen;
import org.apache.bcel.generic.InstructionFactory;
import org.apache.bcel.generic.InstructionHandle;
@@ -17,10 +19,6 @@ import de.dhbwstuttgart.logger.Logger;
import de.dhbwstuttgart.syntaxtree.Class;
import de.dhbwstuttgart.syntaxtree.Constructor;
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
-import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar;
-import de.dhbwstuttgart.syntaxtree.type.RefType;
-import de.dhbwstuttgart.syntaxtree.type.Type;
-import de.dhbwstuttgart.syntaxtree.type.Void;
import de.dhbwstuttgart.typeinference.ConstraintsSet;
import de.dhbwstuttgart.typeinference.JavaCodeResult;
import de.dhbwstuttgart.typeinference.ResultSet;
@@ -33,104 +31,26 @@ import de.dhbwstuttgart.typeinference.exceptions.TypeinferenceException;
// ino.class.This.26261.declaration
public class This extends Expr
-// ino.end
-// ino.class.This.26261.body
{
- // ino.method.This.26265.definition
- public This(int offset,int variableLength)
- // ino.end
- // ino.method.This.26265.body
+ public This(RefType type, int offset)
{
- super(offset,variableLength);
+ super(type, offset);
}
- // ino.end
-
- public This(SyntaxTreeNode parent){
- this(0,0);
- this.parent = parent;
- }
-
- // ino.attribute.arglist.26268.declaration
public ArgumentList arglist;
- // ino.end
-
- // ino.attribute.parserlog.26271.declaration
protected static Logger parserlog = Logger.getLogger("parser");
- // ino.end
-
-
- // ino.method.set_ArgumentList.26274.definition
- public void set_ArgumentList(ArgumentList al)
- // ino.end
- // ino.method.set_ArgumentList.26274.body
- {
- this.arglist = al;
- }
- // ino.end
- public ArgumentList getArgumentList()
- {
- return this.arglist;
- }
-
- // ino.method.set_UsedId.26277.definition
- public void set_UsedId(UsedId ui)
- // ino.end
- // ino.method.set_UsedId.26277.body
- {
- this.usedid = ui;
- }
- // ino.end
-
- /*
- // ino.method.sc_check.26280.definition
- public void sc_check(Menge classname, Hashtable ch, Hashtable bh, boolean ext, Hashtable parach, Hashtable parabh)
- throws SCStatementException
- // ino.end
- // ino.method.sc_check.26280.body
- {
- if(ext)
- parserlog.debug(" ---This---");
- }
- // ino.end
- */
-
- // ino.method.get_Name.26286.definition
public String get_Name()
- // ino.end
- // ino.method.get_Name.26286.body
{ return null; }
- // ino.end
-
-
- // ino.method.wandleRefTypeAttributes2GenericAttributes.26295.definition
- public void wandleRefTypeAttributes2GenericAttributes(Menge paralist, Menge genericMethodParameters)
- // ino.end
- // ino.method.wandleRefTypeAttributes2GenericAttributes.26295.body
- {
- }
- // ino.end
@Override
public ConstraintsSet TYPEExpr(TypeAssumptions assumptions) {
ConstraintsSet ret = new ConstraintsSet();
- //this.set_Type(new);
- //this.setType(assumptions.getThisValue());//Die Assumption für this als TypeVariable setzen.
- this.setType(this.getParentClass().getType());
return ret;
}
- @Override
- public ConstraintsSet TYPEStmt(TypeAssumptions assumptions) {
- throw new TypeinferenceException("this ist keine Anweisung", this);
- }
-
public String toString()
- // ino.end
- // ino.method.toString.25738.body
{
- //return receiver/*.toString()*/ + " " + usedid.toString();
- return type + " (" + "this" +"(" + this.getArgumentList() + "))";
+ return "this";
}
@Override
diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/UnaryExpr.java b/src/de/dhbwstuttgart/syntaxtree/statement/UnaryExpr.java
index da6ac5b3..e7f1deb3 100755
--- a/src/de/dhbwstuttgart/syntaxtree/statement/UnaryExpr.java
+++ b/src/de/dhbwstuttgart/syntaxtree/statement/UnaryExpr.java
@@ -21,9 +21,9 @@ public abstract class UnaryExpr extends MethodCall
{
public Expr expr;
- public UnaryExpr(int offset,int variableLength)
+ public UnaryExpr(int offset)
{
- super(offset,variableLength);
+ super(offset);
}
@Override
diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/WhileStmt.java b/src/de/dhbwstuttgart/syntaxtree/statement/WhileStmt.java
index 82078680..7412a90f 100755
--- a/src/de/dhbwstuttgart/syntaxtree/statement/WhileStmt.java
+++ b/src/de/dhbwstuttgart/syntaxtree/statement/WhileStmt.java
@@ -1,7 +1,6 @@
// ino.module.WhileStmt.8659.package
package de.dhbwstuttgart.syntaxtree.statement;
-// ino.end
-// ino.module.WhileStmt.8659.import
+
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Iterator;
@@ -18,12 +17,7 @@ import de.dhbwstuttgart.bytecode.ClassGenerator;
import de.dhbwstuttgart.logger.Logger;
import de.dhbwstuttgart.syntaxtree.Class;
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
-import de.dhbwstuttgart.syntaxtree.operator.LogOp;
-import de.dhbwstuttgart.syntaxtree.operator.Operator;
-import de.dhbwstuttgart.syntaxtree.operator.RelOp;
-import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar;
import de.dhbwstuttgart.syntaxtree.type.RefType;
-import de.dhbwstuttgart.syntaxtree.type.Type;
import de.dhbwstuttgart.typeinference.ConstraintsSet;
import de.dhbwstuttgart.typeinference.JavaCodeResult;
import de.dhbwstuttgart.typeinference.Pair;
@@ -32,90 +26,38 @@ import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
import de.dhbwstuttgart.typeinference.UndConstraint;
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
import de.dhbwstuttgart.typeinference.exceptions.NotImplementedException;
-import de.dhbwstuttgart.typeinference.unify.TypeUnify;
-
-
-
-// ino.class.WhileStmt.26326.declaration
public class WhileStmt extends Statement
-// ino.end
-// ino.class.WhileStmt.26326.body
{
- // ino.method.WhileStmt.26330.definition
- public WhileStmt(int offset, int variableLength)
- // ino.end
- // ino.method.WhileStmt.26330.body
+ public WhileStmt(Expr boolExpr, Statement loop_block,int offset)
{
- super(offset,variableLength);
+ super(offset);
+ expr = boolExpr;
+ this.loop_block = loop_block;
}
- // ino.end
- // ino.attribute.expr.26333.declaration
public Expr expr;
- // ino.end
- // ino.attribute.loop_block.26336.declaration
public Statement loop_block;
- // ino.end
// ino.attribute.parserlog.26339.declaration
protected static Logger parserlog = Logger.getLogger("parser");
- // ino.end
-
- // ino.method.set_Expr.26342.definition
- public void set_Expr(Expr exp)
- // ino.end
- // ino.method.set_Expr.26342.body
- {
- this.expr = exp;
- }
- // ino.end
- // ino.method.set_Loop_block.26345.definition
- public void set_Loop_block(Statement blk)
- // ino.end
- // ino.method.set_Loop_block.26345.body
- {
- this.loop_block = blk;
- }
- // ino.end
-
-
- // ino.method.toString.26360.defdescription type=javadoc
/**
*
Author: Martin Pl�micke
* @return
*/
- // ino.end
- // ino.method.toString.26360.definition
public String toString()
- // ino.end
- // ino.method.toString.26360.body
{
return "WHILE " + loop_block.toString();
}
- // ino.end
-
- // ino.method.wandleRefTypeAttributes2GenericAttributes.26363.definition
- public void wandleRefTypeAttributes2GenericAttributes(Menge paralist, Menge genericMethodParameters)
- // ino.end
- // ino.method.wandleRefTypeAttributes2GenericAttributes.26363.body
- {
- if(loop_block!=null){
- loop_block.wandleRefTypeAttributes2GenericAttributes(paralist,genericMethodParameters);
- }
-
- }
- // ino.end
@Override
public ConstraintsSet TYPEStmt(TypeAssumptions assumptions) {
ConstraintsSet ret = new ConstraintsSet();
ret.add(expr.TYPEExpr(assumptions));
- UndConstraint exprMustBeBool = ConstraintsSet.createSingleConstraint(expr.getType().TYPE(assumptions, this), new RefType("Boolean",this, 0).TYPE(assumptions, this)); // while(expr){}; expr <. boolean
+ UndConstraint exprMustBeBool = ConstraintsSet.createSingleConstraint(expr.getType(), assumptions.getBooleanType()); // while(expr){}; expr <. boolean
ret.add(exprMustBeBool);
ret.add(this.loop_block.TYPEStmt(assumptions));
- this.setType(loop_block.getType());
return ret;
}
diff --git a/src/de/dhbwstuttgart/syntaxtree/type/ExtendsWildcardType.java b/src/de/dhbwstuttgart/syntaxtree/type/ExtendsWildcardType.java
index e6ee1044..c4f21b50 100755
--- a/src/de/dhbwstuttgart/syntaxtree/type/ExtendsWildcardType.java
+++ b/src/de/dhbwstuttgart/syntaxtree/type/ExtendsWildcardType.java
@@ -7,6 +7,8 @@ import de.dhbwstuttgart.typeinference.JavaCodeResult;
import de.dhbwstuttgart.typeinference.ResultSet;
import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
+import java.util.List;
+
/**
* Stellt eine Wildcard mit oberer Grenze dar.
@@ -16,7 +18,7 @@ import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions;
*
*/
-public class ExtendsWildcardType extends WildcardType implements ITypeContainer, IMatchable{
+public class ExtendsWildcardType extends WildcardType {
/**
* Author: Arne Lüdtke
@@ -28,7 +30,7 @@ public class ExtendsWildcardType extends WildcardType implements ITypeContainer,
this.name = new JavaClassName(this.toString());
}
- public ExtendsWildcardType(ObjectType extendsType) {
+ public ExtendsWildcardType(RefType extendsType) {
this(extendsType.getOffset(),extendsType);
}
@@ -38,7 +40,7 @@ public class ExtendsWildcardType extends WildcardType implements ITypeContainer,
* Beispiel: ? extends Integer.
* Integer wird zurückgegeben.
*/
- public ObjectType get_ExtendsType()
+ public RefType get_ExtendsType()
{
return this.innerType;
}
@@ -85,7 +87,7 @@ public class ExtendsWildcardType extends WildcardType implements ITypeContainer,
* Das gleiche wie get_ExtendsType().
* Ãberschreibt die Methode der Superklasse.
*/
- public Type GetWildcardType()
+ public RefType GetWildcardType()
{
return this.get_ExtendsType();
}
@@ -95,7 +97,7 @@ public class ExtendsWildcardType extends WildcardType implements ITypeContainer,
* Setzt den Typ in der Wildcard
* @param T - Type to be set
*/
- public void SetWildcardType(ObjectType T)
+ public void SetWildcardType(RefType T)
{
//if(T instanceof RefType)
this.innerType = (RefType)T;
@@ -106,7 +108,7 @@ public class ExtendsWildcardType extends WildcardType implements ITypeContainer,
* Das gleiche wie get_ExtendsType().
* Implementiert ITypeContainer
*/
- public ObjectType getContainedType()
+ public RefType getContainedType()
{
return this.get_ExtendsType();
}
@@ -116,7 +118,7 @@ public class ExtendsWildcardType extends WildcardType implements ITypeContainer,
* Gibt den Typen zurück, der bei einem match im Unify verwendet werden soll.
* Wird über IMatchable implementiert.
*/
- public ObjectType getMatchType()
+ public RefType getMatchType()
{
return this.get_ExtendsType();
}
@@ -127,8 +129,8 @@ public class ExtendsWildcardType extends WildcardType implements ITypeContainer,
}
@Override
- public Menge getInvolvedTypePlaceholder() {
- Menge ret = super.getInvolvedTypePlaceholder();
+ public List getInvolvedTypePlaceholder() {
+ List ret = super.getInvolvedTypePlaceholder();
ret.addAll(this.innerType.getInvolvedTypePlaceholder());
return ret;
}
@@ -138,24 +140,12 @@ public class ExtendsWildcardType extends WildcardType implements ITypeContainer,
super.parserPostProcessing(parent);
this.innerType.parserPostProcessing(this);
}
-
- @Override
- public Type TYPE(TypeAssumptions ass, SyntaxTreeNode parent) {
- //Folgender TypeCast ist sicher. Wird ein ObjectType in einen ConstraintType umgewandelt und wieder zurück, kann kein Fehler auftreten.
- this.innerType = (ObjectType) this.innerType.TYPE(ass, parent);
- return super.TYPE(ass, parent);
- }
-
- /*
- @Override
- public org.apache.bcel.generic.Type getBytecodeType(ClassGenerator cg) {
- return new de.dhbwstuttgart.bytecode.WildcardType(this.innerType.get_Name(), "+");
- }
- */
- @Override
+
+ /*
public String get_Name() {
- return "? extends "+this.innerType.get_Name();
+ return "? extends "+this.innerType.getName();
}
+ */
}
diff --git a/src/de/dhbwstuttgart/syntaxtree/type/RefType.java b/src/de/dhbwstuttgart/syntaxtree/type/RefType.java
index c6016afb..24224e8b 100755
--- a/src/de/dhbwstuttgart/syntaxtree/type/RefType.java
+++ b/src/de/dhbwstuttgart/syntaxtree/type/RefType.java
@@ -1,12 +1,9 @@
package de.dhbwstuttgart.syntaxtree.type;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
import de.dhbwstuttgart.bytecode.ClassGenerator;
import de.dhbwstuttgart.typecheck.JavaClassName;
-import de.dhbwstuttgart.syntaxtree.Class;
-import de.dhbwstuttgart.syntaxtree.SourceFile;
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
import de.dhbwstuttgart.syntaxtree.factory.ASTFactory;
import de.dhbwstuttgart.typeinference.JavaCodeResult;
diff --git a/src/de/dhbwstuttgart/syntaxtree/type/TypePlaceholder.java b/src/de/dhbwstuttgart/syntaxtree/type/TypePlaceholder.java
index 3269b1e5..0c9cfd89 100755
--- a/src/de/dhbwstuttgart/syntaxtree/type/TypePlaceholder.java
+++ b/src/de/dhbwstuttgart/syntaxtree/type/TypePlaceholder.java
@@ -1,5 +1,6 @@
package de.dhbwstuttgart.syntaxtree.type;
import java.util.Hashtable;
+import java.util.List;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.logger.*;
@@ -31,12 +32,6 @@ public class TypePlaceholder extends RefType
private static Hashtable m_TypePlaceholdersRegistry = new Hashtable();
private SyntaxTreeNode parent;
-
- @Override
- public Type TYPE(TypeAssumptions ass, SyntaxTreeNode parent) {
- return this;
- }
-
/**
* Privater Konstruktor - Eine TypePlaceholder-Variable wird �ber die
* Factory-Methode fresh()
erzeugt.
@@ -237,9 +232,9 @@ public class TypePlaceholder extends RefType
}
@Override
- public Menge getUnresolvedTPH(ResultSet resultSet) {
- Menge ret = super.getUnresolvedTPH(resultSet);
- Type t = resultSet.getTypeEqualTo(this);
+ public List getUnresolvedTPH(ResultSet resultSet) {
+ List ret = super.getUnresolvedTPH(resultSet);
+ RefType t = resultSet.getTypeEqualTo(this);
if(t instanceof TypePlaceholder){
ret.add((TypePlaceholder)t);
}
@@ -248,7 +243,7 @@ public class TypePlaceholder extends RefType
@Override
public org.apache.bcel.generic.Type getBytecodeType(ClassGenerator cg, TypeinferenceResultSet rs) {
- Type resolvedType = rs.getTypeOfPlaceholder(this);
+ RefType resolvedType = rs.getTypeOfPlaceholder(this);
if(resolvedType instanceof TypePlaceholder){
return DHBWInstructionFactory.createObjectType();
}
@@ -261,7 +256,7 @@ public class TypePlaceholder extends RefType
System.out.println("");
return null;
}
- Type resolvedType = rs.getTypeOfPlaceholder(this);
+ RefType resolvedType = rs.getTypeOfPlaceholder(this);
if(resolvedType instanceof TypePlaceholder){
cg.addUsedTPH((TypePlaceholder)resolvedType);
return new TypePlaceholderType((TypePlaceholder)resolvedType).getSignature();
@@ -269,23 +264,4 @@ public class TypePlaceholder extends RefType
return resolvedType.getBytecodeSignature(cg, rs);
}
- @Override
- public String getClassSignature(ClassGenerator cg, TypeinferenceResultSet rs) {
- //Die Signaturen in der Klasse bauen sich für Generische Variabeln (also TPHs) folgendermaßen auf: "GVAR:SuperClass"
- String ret = this.get_Name();//this.getBytecodeSignature(cg);
- //ret = ret.substring(1, ret.length()-1) + ":"; //";" mit ":" ersetzen
- ret+=":";
- Menge possibleTPHs = cg.getUsedTPH();
- possibleTPHs.remove(this);
- //TODO: hier komplett überarbeiten. Wann wird ein TPH eine generische Variable, das sollte geklärt werden.
- org.apache.bcel.generic.Type nearestType = null;//cg.getNearestUsedType(this, possibleTPHs);
- //if(nearestType instanceof TypePlaceholderType){ //Handelt es sich um einen weiteren TPH als nächsten Typ, so ist es ein allgemeiner Typ und wir nehmen Object als Superklasse
- if(nearestType == null){
- ret += cg.getInstructionFactory().createObjectType().getSignature();
- }else{
- ret += nearestType.getSignature();
- }
- return ret;
- }
-
}
diff --git a/src/de/dhbwstuttgart/syntaxtree/type/WildcardType.java b/src/de/dhbwstuttgart/syntaxtree/type/WildcardType.java
index ed1fede7..cc3208e4 100755
--- a/src/de/dhbwstuttgart/syntaxtree/type/WildcardType.java
+++ b/src/de/dhbwstuttgart/syntaxtree/type/WildcardType.java
@@ -56,12 +56,6 @@ public abstract class WildcardType extends RefType{
public JavaCodeResult printJavaCode(ResultSet resultSet) {
throw new NotImplementedException();
}
-
- @Override
- public RefType TYPE(TypeAssumptions ass, SyntaxTreeNode parent) {
- this.innerType = innerType.TYPE(ass, this);
- return this;
- }
public boolean equals(Object obj)
{
@@ -84,10 +78,5 @@ public abstract class WildcardType extends RefType{
public String getBytecodeSignature(ClassGenerator cg, TypeinferenceResultSet rs) {
return this.innerType.getBytecodeSignature(cg, rs);
}
-
- @Override
- public JavaClassName getName() {
- return new JavaClassName(this.get_Name());
- }
}
diff --git a/src/de/dhbwstuttgart/typecheck/JavaClassName.java b/src/de/dhbwstuttgart/typecheck/JavaClassName.java
index d62ad06b..e0a39ea8 100644
--- a/src/de/dhbwstuttgart/typecheck/JavaClassName.java
+++ b/src/de/dhbwstuttgart/typecheck/JavaClassName.java
@@ -7,19 +7,13 @@ import java.util.List;
* Stellt den Namen einer Java Klasse dar.
* Dieser kann auch den Packagenamen mit beinhalten: de.dhbwstuttgart.typeinference.Menge
*
- * @author janulrich
- *
- *
+ * @author Andreas Stadelmeier
*/
public class JavaClassName {
private String name;
private PackageName packageName;
-
- /**
- * TODO: JavaClassName sollten aus den Assumptions generiert werden.
- * Diese wissen, welche Typen und Typnamen existieren und können direkt auf Korrektheit prüfen.
- */
+
public JavaClassName(String name){
if(name == null)throw new NullPointerException();
@@ -38,15 +32,14 @@ public class JavaClassName {
this.name = names[names.length-1];
}
}
-
- //Auto-generated hashCode:
+
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((name == null) ? 0 : name.hashCode());
- //result = prime * result
- // + ((packageName == null) ? 0 : packageName.hashCode()); //PackageName does not infect hashCode
+ result = prime * result
+ + ((packageName == null) ? 0 : packageName.hashCode()); //PackageName does not infect hashCode
return result;
}
diff --git a/src/de/dhbwstuttgart/typeinference/ConstraintsSet.java b/src/de/dhbwstuttgart/typeinference/ConstraintsSet.java
index dd4a2ff1..2caf5b32 100755
--- a/src/de/dhbwstuttgart/typeinference/ConstraintsSet.java
+++ b/src/de/dhbwstuttgart/typeinference/ConstraintsSet.java
@@ -4,6 +4,7 @@ import java.util.Iterator;
import java.util.Set;
import java.util.Vector;
import de.dhbwstuttgart.logger.Logger;
+import de.dhbwstuttgart.syntaxtree.type.RefType;
import de.dhbwstuttgart.syntaxtree.type.Type;
import de.dhbwstuttgart.logger.*;
import de.dhbwstuttgart.typeinference.unify.Unifikationsalgorithmus;
@@ -87,7 +88,7 @@ public class ConstraintsSet extends UndMenge implements Iterable{
* @param p1
* @param p2
*/
- public void addConstraint(Type p1, Type p2){
+ public void addConstraint(RefType p1, RefType p2){
addConstraint(new Pair(p1,p2));
}
diff --git a/src/de/dhbwstuttgart/typeinference/UndConstraint.java b/src/de/dhbwstuttgart/typeinference/UndConstraint.java
index bb6914ee..69dad9ed 100755
--- a/src/de/dhbwstuttgart/typeinference/UndConstraint.java
+++ b/src/de/dhbwstuttgart/typeinference/UndConstraint.java
@@ -4,6 +4,7 @@ import java.util.Collection;
import java.util.Set;
import java.util.Vector;
+import de.dhbwstuttgart.syntaxtree.type.RefType;
import de.dhbwstuttgart.syntaxtree.type.Type;
import de.dhbwstuttgart.typeinference.exceptions.DebugException;
import de.dhbwstuttgart.typeinference.unify.Unifikationsalgorithmus;
@@ -31,7 +32,7 @@ public class UndConstraint extends UndMenge {
return ret.iterator().next();
}
- public void addConstraint(Type type, Type rT) {
+ public void addConstraint(RefType type, RefType rT) {
Pair p = new Pair(type, rT);
addConstraint(p);
}
diff --git a/src/de/dhbwstuttgart/typeinference/assumptions/Assumption.java b/src/de/dhbwstuttgart/typeinference/assumptions/Assumption.java
index db64c33c..121cb076 100644
--- a/src/de/dhbwstuttgart/typeinference/assumptions/Assumption.java
+++ b/src/de/dhbwstuttgart/typeinference/assumptions/Assumption.java
@@ -1,7 +1,7 @@
package de.dhbwstuttgart.typeinference.assumptions;
+import de.dhbwstuttgart.syntaxtree.type.RefType;
import de.dhbwstuttgart.typecheck.JavaClassName;
-import de.dhbwstuttgart.syntaxtree.type.Type;
import de.dhbwstuttgart.typeinference.TypeInsertable;
public class Assumption {
@@ -18,7 +18,7 @@ public class Assumption {
this.typable = ass;
}
- public Type getAssumedType() {
+ public RefType getAssumedType() {
return this.typable.getType();
}
diff --git a/src/de/dhbwstuttgart/typeinference/assumptions/LocalVarAssumption.java b/src/de/dhbwstuttgart/typeinference/assumptions/LocalVarAssumption.java
index 11530f64..52c7918b 100644
--- a/src/de/dhbwstuttgart/typeinference/assumptions/LocalVarAssumption.java
+++ b/src/de/dhbwstuttgart/typeinference/assumptions/LocalVarAssumption.java
@@ -1,20 +1,20 @@
package de.dhbwstuttgart.typeinference.assumptions;
import de.dhbwstuttgart.syntaxtree.statement.LocalVarDecl;
-import de.dhbwstuttgart.syntaxtree.type.Type;
+import de.dhbwstuttgart.syntaxtree.type.RefType;
public class LocalVarAssumption extends Assumption {
private LocalVarDecl localVar;
- private Type type;
+ private RefType type;
- public LocalVarAssumption(LocalVarDecl localVar, Type declaredType){
+ public LocalVarAssumption(LocalVarDecl localVar, RefType declaredType){
super(localVar);
this.localVar = localVar;
this.type = declaredType;
}
@Override
- public Type getAssumedType() {
+ public RefType getAssumedType() {
return this.type;
}
diff --git a/src/de/dhbwstuttgart/typeinference/assumptions/TypeAssumptions.java b/src/de/dhbwstuttgart/typeinference/assumptions/TypeAssumptions.java
index 65bb44d8..8d852750 100755
--- a/src/de/dhbwstuttgart/typeinference/assumptions/TypeAssumptions.java
+++ b/src/de/dhbwstuttgart/typeinference/assumptions/TypeAssumptions.java
@@ -287,6 +287,10 @@ public class TypeAssumptions {
return null;
}
+ public RefType getBooleanType() {
+ return new RefType("java.lang.Boolean",-1);
+ }
+
/**
* 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.