From a44baeaa34d23bb560876703936a87fcd924219c Mon Sep 17 00:00:00 2001 From: JanUlrich Date: Thu, 2 Mar 2017 18:16:14 +0100 Subject: [PATCH] Beginnen mit Typinferenzalgorithmus --- doc/LambdaJavadoc/allclasses-frame.html | 8 +- doc/LambdaJavadoc/allclasses-noframe.html | 8 +- .../de/dhbwstuttgart/core/MyCompiler.html | 8 +- .../de/dhbwstuttgart/core/MyCompilerAPI.html | 12 +- .../class-use/JavaParser.yyException.html | 8 +- .../de/dhbwstuttgart/parser/package-use.html | 6 +- .../syntaxtree/class-use/SyntaxTreeNode.html | 8 +- .../dhbwstuttgart/syntaxtree/package-use.html | 6 +- .../exceptions/DebugException.html | 8 +- .../exceptions/NotImplementedException.html | 12 +- .../typeinference/exceptions/ParserError.html | 24 +- .../exceptions/TypeinferenceException.html | 10 +- .../exceptions/class-use/DebugException.html | 15 +- .../class-use/NotImplementedException.html | 15 +- .../exceptions/class-use/ParserError.html | 19 +- .../class-use/TypeinferenceException.html | 29 +- .../exceptions/package-frame.html | 12 +- .../exceptions/package-summary.html | 12 +- .../exceptions/package-tree.html | 17 +- .../typeinference/exceptions/package-use.html | 14 +- doc/LambdaJavadoc/index-files/index-13.html | 2 +- doc/LambdaJavadoc/index-files/index-14.html | 4 +- doc/LambdaJavadoc/index-files/index-15.html | 2 +- doc/LambdaJavadoc/index-files/index-16.html | 4 +- doc/LambdaJavadoc/index-files/index-19.html | 6 +- doc/LambdaJavadoc/index-files/index-4.html | 6 +- doc/LambdaJavadoc/index-files/index-7.html | 4 +- doc/LambdaJavadoc/overview-frame.html | 2 +- doc/LambdaJavadoc/overview-summary.html | 2 +- doc/LambdaJavadoc/overview-tree.html | 10 +- doc/LambdaJavadoc/serialized-form.html | 18 +- .../dhbwstuttgart/core/IItemWithOffset.java | 3 + src/de/dhbwstuttgart/core/JavaTXCompiler.java | 11 +- src/de/dhbwstuttgart/core/MyCompiler.java | 10 - src/de/dhbwstuttgart/core/MyCompilerAPI.java | 19 - .../exceptions/DebugException.java | 8 + .../exceptions/NotImplementedException.java | 11 + .../dhbwstuttgart/exceptions/ParserError.java | 10 + .../exceptions/TypeinferenceException.java | 46 + src/de/dhbwstuttgart/parser/JavaTXParser.java | 1 - src/de/dhbwstuttgart/parser/NullToken.java | 57 ++ .../parser/SyntaxTreeGenerator.java | 4 +- .../syntaxtree/ClassOrInterface.java | 1 + src/de/dhbwstuttgart/syntaxtree/Field.java | 1 + .../syntaxtree/FormalParameter.java | 3 +- .../syntaxtree/GTVDeclarationContext.java | 5 + .../syntaxtree/GenericDeclarationList.java | 1 + .../syntaxtree/GenericTypeVar.java | 10 +- src/de/dhbwstuttgart/syntaxtree/Method.java | 3 +- .../syntaxtree/ParameterList.java | 7 +- .../dhbwstuttgart/syntaxtree/SourceFile.java | 2 + .../syntaxtree/SyntaxTreeNode.java | 9 + .../syntaxtree/operator/AddOp.java | 5 +- .../syntaxtree/operator/DivideOp.java | 5 +- .../syntaxtree/operator/EqualOp.java | 9 +- .../syntaxtree/operator/GreaterEquOp.java | 6 +- .../syntaxtree/operator/GreaterOp.java | 8 +- .../syntaxtree/operator/LessEquOp.java | 9 +- .../syntaxtree/operator/LessOp.java | 4 +- .../syntaxtree/operator/LogOp.java | 1 + .../syntaxtree/operator/MinusOp.java | 6 +- .../syntaxtree/operator/ModuloOp.java | 4 +- .../syntaxtree/operator/MulOp.java | 5 + .../syntaxtree/operator/NotEqualOp.java | 8 +- .../syntaxtree/operator/Operator.java | 4 + .../syntaxtree/operator/PlusOp.java | 6 +- .../syntaxtree/operator/RelOp.java | 7 +- .../syntaxtree/operator/TimesOp.java | 4 +- .../syntaxtree/statement/ArgumentList.java | 5 +- .../syntaxtree/statement/Expr.java | 3 +- .../syntaxtree/statement/Expression.java | 2 +- .../syntaxtree/statement/InstVar.java | 4 +- .../syntaxtree/statement/Statement.java | 1 + .../syntaxtree/statement/UnaryPlus.java | 1 + .../syntaxtree/type/RefType.java | 1 + .../syntaxtree/type/RefTypeOrTPH.java | 6 +- .../syntaxtree/type/TypePlaceholder.java | 5 +- src/de/dhbwstuttgart/typeinference/Pair.java | 109 +++ .../unify/GuavaSetOperations.java | 23 + .../typeinference/unify/Mapping.java | 72 ++ .../unify/MartelliMontanariUnify.java | 107 +++ .../typeinference/unify/RuleSet.java | 833 ++++++++++++++++++ .../typeinference/unify/TypeUnify.java | 24 + .../typeinference/unify/TypeUnifyTask.java | 626 +++++++++++++ .../unify/Unifikationsalgorithmus.java | 11 + .../unify/interfaces/IFiniteClosure.java | 64 ++ .../unify/interfaces/IRuleSet.java | 90 ++ .../unify/interfaces/ISetOperations.java | 16 + .../unify/interfaces/IUnify.java | 35 + .../unify/model/ExtendsType.java | 87 ++ .../unify/model/FiniteClosure.java | 413 +++++++++ .../typeinference/unify/model/FunNType.java | 88 ++ .../typeinference/unify/model/Node.java | 99 +++ .../unify/model/PairOperator.java | 42 + .../unify/model/PlaceholderType.java | 119 +++ .../unify/model/ReferenceType.java | 76 ++ .../typeinference/unify/model/SuperType.java | 82 ++ .../typeinference/unify/model/TypeParams.java | 176 ++++ .../typeinference/unify/model/Unifier.java | 142 +++ .../typeinference/unify/model/UnifyPair.java | 99 +++ .../typeinference/unify/model/UnifyType.java | 99 +++ .../unify/model/WildcardType.java | 67 ++ test/javFiles/Methods.jav | 11 + test/parser/FeatherWeightJavaTest.java | 2 +- test/parser/GeneralParserTest.java | 2 +- test/typeinference/JavaTXCompilerTest.java | 22 + 106 files changed, 4046 insertions(+), 242 deletions(-) delete mode 100755 src/de/dhbwstuttgart/core/MyCompiler.java delete mode 100755 src/de/dhbwstuttgart/core/MyCompilerAPI.java create mode 100644 src/de/dhbwstuttgart/exceptions/DebugException.java create mode 100644 src/de/dhbwstuttgart/exceptions/NotImplementedException.java create mode 100644 src/de/dhbwstuttgart/exceptions/ParserError.java create mode 100755 src/de/dhbwstuttgart/exceptions/TypeinferenceException.java create mode 100644 src/de/dhbwstuttgart/parser/NullToken.java create mode 100755 src/de/dhbwstuttgart/typeinference/Pair.java create mode 100644 src/de/dhbwstuttgart/typeinference/unify/GuavaSetOperations.java create mode 100644 src/de/dhbwstuttgart/typeinference/unify/Mapping.java create mode 100644 src/de/dhbwstuttgart/typeinference/unify/MartelliMontanariUnify.java create mode 100644 src/de/dhbwstuttgart/typeinference/unify/RuleSet.java create mode 100644 src/de/dhbwstuttgart/typeinference/unify/TypeUnify.java create mode 100644 src/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java create mode 100644 src/de/dhbwstuttgart/typeinference/unify/Unifikationsalgorithmus.java create mode 100644 src/de/dhbwstuttgart/typeinference/unify/interfaces/IFiniteClosure.java create mode 100644 src/de/dhbwstuttgart/typeinference/unify/interfaces/IRuleSet.java create mode 100644 src/de/dhbwstuttgart/typeinference/unify/interfaces/ISetOperations.java create mode 100644 src/de/dhbwstuttgart/typeinference/unify/interfaces/IUnify.java create mode 100644 src/de/dhbwstuttgart/typeinference/unify/model/ExtendsType.java create mode 100644 src/de/dhbwstuttgart/typeinference/unify/model/FiniteClosure.java create mode 100644 src/de/dhbwstuttgart/typeinference/unify/model/FunNType.java create mode 100644 src/de/dhbwstuttgart/typeinference/unify/model/Node.java create mode 100644 src/de/dhbwstuttgart/typeinference/unify/model/PairOperator.java create mode 100644 src/de/dhbwstuttgart/typeinference/unify/model/PlaceholderType.java create mode 100644 src/de/dhbwstuttgart/typeinference/unify/model/ReferenceType.java create mode 100644 src/de/dhbwstuttgart/typeinference/unify/model/SuperType.java create mode 100644 src/de/dhbwstuttgart/typeinference/unify/model/TypeParams.java create mode 100644 src/de/dhbwstuttgart/typeinference/unify/model/Unifier.java create mode 100644 src/de/dhbwstuttgart/typeinference/unify/model/UnifyPair.java create mode 100644 src/de/dhbwstuttgart/typeinference/unify/model/UnifyType.java create mode 100644 src/de/dhbwstuttgart/typeinference/unify/model/WildcardType.java create mode 100644 test/javFiles/Methods.jav create mode 100644 test/typeinference/JavaTXCompilerTest.java diff --git a/doc/LambdaJavadoc/allclasses-frame.html b/doc/LambdaJavadoc/allclasses-frame.html index 1564fc38f..5c1df00f5 100644 --- a/doc/LambdaJavadoc/allclasses-frame.html +++ b/doc/LambdaJavadoc/allclasses-frame.html @@ -55,7 +55,7 @@
  • CSubstitutionSet
  • CTypeReconstructionException
  • CVectorSet
  • -
  • DebugException
  • +
  • DebugException
  • DeclId
  • DivideOp
  • DoubleLiteral
  • @@ -203,7 +203,7 @@
  • NodeEqualTest
  • NotEqualOp
  • NotExpr
  • -
  • NotImplementedException
  • +
  • NotImplementedException
  • Null
  • ObjectType
  • OderConstraint
  • @@ -228,7 +228,7 @@
  • ParameterAssumption
  • ParameterInsertTest
  • ParameterList
  • -
  • ParserError
  • +
  • ParserError
  • PlusOp
  • PositivExpr
  • PostDecExpr
  • @@ -282,7 +282,7 @@
  • TypeAssumptions
  • TypedMatrixSimpleTest
  • TypedMatrixTest
  • -
  • TypeinferenceException
  • +
  • TypeinferenceException
  • TypeinferenceResultSet
  • TypeInsertable
  • TypeInsertPoint
  • diff --git a/doc/LambdaJavadoc/allclasses-noframe.html b/doc/LambdaJavadoc/allclasses-noframe.html index 7e5b721c2..bf338b139 100644 --- a/doc/LambdaJavadoc/allclasses-noframe.html +++ b/doc/LambdaJavadoc/allclasses-noframe.html @@ -55,7 +55,7 @@
  • CSubstitutionSet
  • CTypeReconstructionException
  • CVectorSet
  • -
  • DebugException
  • +
  • DebugException
  • DeclId
  • DivideOp
  • DoubleLiteral
  • @@ -203,7 +203,7 @@
  • NodeEqualTest
  • NotEqualOp
  • NotExpr
  • -
  • NotImplementedException
  • +
  • NotImplementedException
  • Null
  • ObjectType
  • OderConstraint
  • @@ -228,7 +228,7 @@
  • ParameterAssumption
  • ParameterInsertTest
  • ParameterList
  • -
  • ParserError
  • +
  • ParserError
  • PlusOp
  • PositivExpr
  • PostDecExpr
  • @@ -282,7 +282,7 @@
  • TypeAssumptions
  • TypedMatrixSimpleTest
  • TypedMatrixTest
  • -
  • TypeinferenceException
  • +
  • TypeinferenceException
  • TypeinferenceResultSet
  • TypeInsertable
  • TypeInsertPoint
  • diff --git a/doc/LambdaJavadoc/de/dhbwstuttgart/core/MyCompiler.html b/doc/LambdaJavadoc/de/dhbwstuttgart/core/MyCompiler.html index 89179bc3a..3188d089f 100644 --- a/doc/LambdaJavadoc/de/dhbwstuttgart/core/MyCompiler.html +++ b/doc/LambdaJavadoc/de/dhbwstuttgart/core/MyCompiler.html @@ -567,11 +567,11 @@ implements

    parse2SyntaxTree

    private SourceFile parse2SyntaxTree(java.io.Reader fileContent)
    -                             throws ParserError
    + throws ParserError
    Parst den Inhalt einer Datei zu einem Syntaxbaum.
    Throws:
    -
    ParserError
    +
    ParserError
    @@ -582,7 +582,7 @@ implements

    parse

    public void parse(Menge<java.lang.String> filenames)
    -           throws ParserError
    + throws ParserError
    Diese Funktion nimmt einen Menge von Dateinamen. Alle diese Dateien werden zu einem SyntaxBaum geparst.
    Specified by:
    @@ -590,7 +590,7 @@ implements Parameters:
    filenames - - Eine Liste von Quellcodedateien, welche gseparst werden sollen
    Throws:
    -
    ParserError
    +
    ParserError
    diff --git a/doc/LambdaJavadoc/de/dhbwstuttgart/core/MyCompilerAPI.html b/doc/LambdaJavadoc/de/dhbwstuttgart/core/MyCompilerAPI.html index fe71ae109..e1282f742 100644 --- a/doc/LambdaJavadoc/de/dhbwstuttgart/core/MyCompilerAPI.html +++ b/doc/LambdaJavadoc/de/dhbwstuttgart/core/MyCompilerAPI.html @@ -237,7 +237,7 @@ var activeTableTab = "activeTableTab";

    typeReconstruction

    Menge<TypeinferenceResultSet> typeReconstruction()
                                               throws java.lang.NullPointerException,
    -                                                 TypeinferenceException
    + TypeinferenceException
    Author: Jörg Bäuerle
    Ruft den Typrekonstruktionsalgorithmus auf.
    @@ -247,7 +247,7 @@ var activeTableTab = "activeTableTab";
    java.lang.NullPointerException - Wenn noch kein abstrakter Syntaxbaum vorhanden ist. @throws CTypeReconstructionException Wenn ein Fehler bei der Typrekonstruktion auftritt.
    -
    TypeinferenceException
    +
    TypeinferenceException
    @@ -280,13 +280,13 @@ var activeTableTab = "activeTableTab";
  • parse

    void parse(Menge<java.lang.String> filenames)
    -    throws ParserError
    + throws ParserError
    Parst zusammenhängende JavaKlassen in verschiedenen Dateien.
    Parameters:
    filenames - - Eine Liste von Quellcodedateien, welche gseparst werden sollen
    Throws:
    -
    ParserError
    +
    ParserError
  • @@ -297,7 +297,7 @@ var activeTableTab = "activeTableTab";
  • parse

    SourceFile parse(java.lang.String sourceCode)
    -          throws ParserError
    + throws ParserError
    Parst den SourceCode einer Datei.
    Parameters:
    @@ -305,7 +305,7 @@ var activeTableTab = "activeTableTab";
    Returns:
    den aus dem sourceCode generierten Syntaxbaum
    Throws:
    -
    ParserError
    +
    ParserError
  • diff --git a/doc/LambdaJavadoc/de/dhbwstuttgart/parser/class-use/JavaParser.yyException.html b/doc/LambdaJavadoc/de/dhbwstuttgart/parser/class-use/JavaParser.yyException.html index ebb0c3990..3dca5fb64 100644 --- a/doc/LambdaJavadoc/de/dhbwstuttgart/parser/class-use/JavaParser.yyException.html +++ b/doc/LambdaJavadoc/de/dhbwstuttgart/parser/class-use/JavaParser.yyException.html @@ -91,7 +91,7 @@   -de.dhbwstuttgart.typeinference.exceptions +de.dhbwstuttgart.exceptions   @@ -160,12 +160,12 @@ -
  • +
  • -

    Uses of JavaParser.yyException in de.dhbwstuttgart.typeinference.exceptions

    +

    Uses of JavaParser.yyException in de.dhbwstuttgart.exceptions

    - + diff --git a/doc/LambdaJavadoc/de/dhbwstuttgart/parser/package-use.html b/doc/LambdaJavadoc/de/dhbwstuttgart/parser/package-use.html index 0fe646c4e..f6ca4da64 100644 --- a/doc/LambdaJavadoc/de/dhbwstuttgart/parser/package-use.html +++ b/doc/LambdaJavadoc/de/dhbwstuttgart/parser/package-use.html @@ -107,7 +107,7 @@ - + @@ -238,11 +238,11 @@
    Constructors in de.dhbwstuttgart.typeinference.exceptions with parameters of type JavaParser.yyException Constructors in de.dhbwstuttgart.exceptions with parameters of type JavaParser.yyException 
    Constructor and Description
     
    de.dhbwstuttgart.typeinference.exceptionsde.dhbwstuttgart.exceptions  
  • -
  • +
  • - + diff --git a/doc/LambdaJavadoc/de/dhbwstuttgart/syntaxtree/class-use/SyntaxTreeNode.html b/doc/LambdaJavadoc/de/dhbwstuttgart/syntaxtree/class-use/SyntaxTreeNode.html index 5cd82bb1f..8fe1aad6a 100644 --- a/doc/LambdaJavadoc/de/dhbwstuttgart/syntaxtree/class-use/SyntaxTreeNode.html +++ b/doc/LambdaJavadoc/de/dhbwstuttgart/syntaxtree/class-use/SyntaxTreeNode.html @@ -111,7 +111,7 @@ - + @@ -1296,12 +1296,12 @@
    Classes in de.dhbwstuttgart.parser used by de.dhbwstuttgart.typeinference.exceptions Classes in de.dhbwstuttgart.parser used by de.dhbwstuttgart.exceptions 
    Class and Description
     
    de.dhbwstuttgart.typeinference.exceptionsde.dhbwstuttgart.exceptions  
  • -
  • +
  • -

    Uses of SyntaxTreeNode in de.dhbwstuttgart.typeinference.exceptions

    +

    Uses of SyntaxTreeNode in de.dhbwstuttgart.exceptions

    - + diff --git a/doc/LambdaJavadoc/de/dhbwstuttgart/syntaxtree/package-use.html b/doc/LambdaJavadoc/de/dhbwstuttgart/syntaxtree/package-use.html index 8dfed61db..fd69f81de 100644 --- a/doc/LambdaJavadoc/de/dhbwstuttgart/syntaxtree/package-use.html +++ b/doc/LambdaJavadoc/de/dhbwstuttgart/syntaxtree/package-use.html @@ -115,7 +115,7 @@ - + @@ -367,11 +367,11 @@
    Constructors in de.dhbwstuttgart.typeinference.exceptions with parameters of type SyntaxTreeNode Constructors in de.dhbwstuttgart.exceptions with parameters of type SyntaxTreeNode 
    Constructor and Description
     
    de.dhbwstuttgart.typeinference.exceptionsde.dhbwstuttgart.exceptions  
  • -
  • +
  • - + diff --git a/doc/LambdaJavadoc/de/dhbwstuttgart/typeinference/exceptions/DebugException.html b/doc/LambdaJavadoc/de/dhbwstuttgart/typeinference/exceptions/DebugException.html index c9c4fa20c..b21c7b354 100644 --- a/doc/LambdaJavadoc/de/dhbwstuttgart/typeinference/exceptions/DebugException.html +++ b/doc/LambdaJavadoc/de/dhbwstuttgart/typeinference/exceptions/DebugException.html @@ -44,7 +44,7 @@
    Classes in de.dhbwstuttgart.syntaxtree used by de.dhbwstuttgart.typeinference.exceptions Classes in de.dhbwstuttgart.syntaxtree used by de.dhbwstuttgart.exceptions 
    Class and Description
    - + @@ -94,9 +93,9 @@
  • -

    Uses of ParserError in de.dhbwstuttgart.core

    +

    Uses of ParserError in de.dhbwstuttgart.core

  • Packages that use ParserError Packages that use ParserError 
    Package Description
    - + @@ -144,7 +143,7 @@
    Methods in de.dhbwstuttgart.core that throw ParserError Methods in de.dhbwstuttgart.core that throw ParserError 
    Modifier and Type Method and Description
    - + @@ -87,7 +86,7 @@ - + @@ -98,9 +97,9 @@
  • -

    Uses of TypeinferenceException in de.dhbwstuttgart.core

    +

    Uses of TypeinferenceException in de.dhbwstuttgart.core

  • Packages that use TypeinferenceException Packages that use TypeinferenceException 
    Package Description 
    de.dhbwstuttgart.typeinference.exceptionsde.dhbwstuttgart.exceptions  
    - + @@ -116,12 +115,12 @@
    Methods in de.dhbwstuttgart.core that throw TypeinferenceException Methods in de.dhbwstuttgart.core that throw TypeinferenceException 
    Modifier and Type Method and Description
  • -
  • +
  • -

    Uses of TypeinferenceException in de.dhbwstuttgart.typeinference.exceptions

    +

    Uses of TypeinferenceException in de.dhbwstuttgart.exceptions

    - + @@ -129,7 +128,7 @@ - +
    Subclasses of TypeinferenceException in de.dhbwstuttgart.typeinference.exceptions Subclasses of TypeinferenceException in de.dhbwstuttgart.exceptions 
    Modifier and Type Class and Description
    class ParserError ParserError 
    @@ -149,7 +148,7 @@