From 1371220249b8b1ba3354e2e01cd7dbde59eff26a Mon Sep 17 00:00:00 2001 From: JanUlrich Date: Mon, 28 Sep 2015 16:35:01 +0200 Subject: [PATCH] Fehler in TypeDeplyment behoben --- .../syntaxtree/statement/LambdaExpression.java | 2 +- .../type}/FunVoidN.java | 15 ++++----------- src/de/dhbwstuttgart/syntaxtree/type/Type.java | 4 ++++ .../syntaxtree/type/TypePlaceholder.java | 4 ++++ .../typedeployment/GenericTypeInsertPoint.java | 4 ++-- test/bytecode/Matrix_lambda2.jav | 2 +- 6 files changed, 16 insertions(+), 15 deletions(-) rename src/de/dhbwstuttgart/{typeinference => syntaxtree/type}/FunVoidN.java (71%) diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/LambdaExpression.java b/src/de/dhbwstuttgart/syntaxtree/statement/LambdaExpression.java index 4eee4c29..d52bfd17 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/LambdaExpression.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/LambdaExpression.java @@ -29,6 +29,7 @@ import de.dhbwstuttgart.syntaxtree.ParameterList; import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode; import de.dhbwstuttgart.syntaxtree.type.ExtendsWildcardType; import de.dhbwstuttgart.syntaxtree.type.FunN; +import de.dhbwstuttgart.syntaxtree.type.FunVoidN; import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar; import de.dhbwstuttgart.syntaxtree.type.ObjectType; import de.dhbwstuttgart.syntaxtree.type.RefType; @@ -37,7 +38,6 @@ import de.dhbwstuttgart.syntaxtree.type.Type; import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder; import de.dhbwstuttgart.syntaxtree.type.WildcardType; import de.dhbwstuttgart.typeinference.ConstraintsSet; -import de.dhbwstuttgart.typeinference.FunVoidN; import de.dhbwstuttgart.typeinference.JavaCodeResult; import de.dhbwstuttgart.typeinference.OderConstraint; import de.dhbwstuttgart.typeinference.ResultSet; diff --git a/src/de/dhbwstuttgart/typeinference/FunVoidN.java b/src/de/dhbwstuttgart/syntaxtree/type/FunVoidN.java similarity index 71% rename from src/de/dhbwstuttgart/typeinference/FunVoidN.java rename to src/de/dhbwstuttgart/syntaxtree/type/FunVoidN.java index 2adfd1c5..66018baf 100644 --- a/src/de/dhbwstuttgart/typeinference/FunVoidN.java +++ b/src/de/dhbwstuttgart/syntaxtree/type/FunVoidN.java @@ -1,4 +1,4 @@ -package de.dhbwstuttgart.typeinference; +package de.dhbwstuttgart.syntaxtree.type; import java.util.Iterator; @@ -7,22 +7,15 @@ import de.dhbwstuttgart.typeinference.Menge; import de.dhbwstuttgart.parser.JavaClassName; import de.dhbwstuttgart.syntaxtree.Method; import de.dhbwstuttgart.syntaxtree.ParameterList; -import de.dhbwstuttgart.syntaxtree.type.FunN; -import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar; -import de.dhbwstuttgart.syntaxtree.type.RefType; -import de.dhbwstuttgart.syntaxtree.type.Type; -import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder; import de.dhbwstuttgart.typeinference.assumptions.MethodAssumption; import de.dhbwstuttgart.typeinference.assumptions.TypeAssumptions; /** - * @see Spezifikation "Complete Typeinference in Java 8" von Martin Plümicke - * "interface FunN { R apply(T1 arg1, T2 arg2, ... , TN argN); }" + * FunVoid { + * void apply(T1 arg1, ... TN argN); + * } * @author A10023 - Andreas Stadelmeier * - * Bemerkung: - * FunN ist ein RefType. Der RefType ist nicht mit einem FunNInterface verbunden. - * */ public class FunVoidN extends FunN { diff --git a/src/de/dhbwstuttgart/syntaxtree/type/Type.java b/src/de/dhbwstuttgart/syntaxtree/type/Type.java index 2ee31e55..5c2e4d86 100755 --- a/src/de/dhbwstuttgart/syntaxtree/type/Type.java +++ b/src/de/dhbwstuttgart/syntaxtree/type/Type.java @@ -234,6 +234,10 @@ public abstract class Type extends SyntaxTreeNode implements IItemWithOffset public JavaCodeResult printJavaCode(ResultSet resultSet){ return new JavaCodeResult(this.name.toString()); } + + public JavaCodeResult printJavaCode(ResultSet resultSet, boolean resolveTPHs){ + return printJavaCode(resultSet); + } public Type applyResultSet(ResultSet result){ return this.clone(); diff --git a/src/de/dhbwstuttgart/syntaxtree/type/TypePlaceholder.java b/src/de/dhbwstuttgart/syntaxtree/type/TypePlaceholder.java index 533daf5b..831476ed 100755 --- a/src/de/dhbwstuttgart/syntaxtree/type/TypePlaceholder.java +++ b/src/de/dhbwstuttgart/syntaxtree/type/TypePlaceholder.java @@ -401,6 +401,10 @@ public class TypePlaceholder extends ObjectType return equalType.printJavaCode(resultSet); } + public JavaCodeResult printJavaCode(ResultSet resultSet, boolean resolveTPHs){ + if(resolveTPHs)return printJavaCode(resultSet); + return new JavaCodeResult(this.get_Name()); + } /** * Berechnet die InsertPoints dieses TypePlaceholders. * Alle an diesem TypePlaceholder registrierten ITypeReplacementListener werden darauf kontrolliert, diff --git a/src/de/dhbwstuttgart/typeinference/typedeployment/GenericTypeInsertPoint.java b/src/de/dhbwstuttgart/typeinference/typedeployment/GenericTypeInsertPoint.java index 5b2601db..f1be21c4 100644 --- a/src/de/dhbwstuttgart/typeinference/typedeployment/GenericTypeInsertPoint.java +++ b/src/de/dhbwstuttgart/typeinference/typedeployment/GenericTypeInsertPoint.java @@ -210,9 +210,9 @@ class GenericVarExtendsDeclarationPatch { public String getInsertString(ResultSet resultSet){ String ret = ""; if(this.genericPair != null){ - ret += this.genericPair.TA1.printJavaCode(resultSet); + ret += this.genericPair.TA1.printJavaCode(resultSet, false); ret += " extends "; - ret += this.genericPair.TA2.printJavaCode(resultSet); + ret += this.genericPair.TA2.printJavaCode(resultSet, false); } return ret; } diff --git a/test/bytecode/Matrix_lambda2.jav b/test/bytecode/Matrix_lambda2.jav index f41dec6d..aad428d4 100644 --- a/test/bytecode/Matrix_lambda2.jav +++ b/test/bytecode/Matrix_lambda2.jav @@ -1,4 +1,4 @@ class Matrix { op = (f) -> f.apply(2); -} \ No newline at end of file +} \ No newline at end of file