From 92c284a04bc470264c3834ca4527ae29d8958bb1 Mon Sep 17 00:00:00 2001 From: JanUlrich Date: Wed, 15 Mar 2017 16:54:43 +0100 Subject: [PATCH] Constraints generieren. Fehler beheben --- src/de/dhbwstuttgart/syntaxtree/Method.java | 10 ++-------- .../dhbwstuttgart/syntaxtree/statement/MethodCall.java | 1 + src/de/dhbwstuttgart/typeinference/OderConstraint.java | 7 ++----- src/de/dhbwstuttgart/typeinference/UndConstraint.java | 7 ++----- test/javFiles/MethodsEasy.jav | 2 +- 5 files changed, 8 insertions(+), 19 deletions(-) diff --git a/src/de/dhbwstuttgart/syntaxtree/Method.java b/src/de/dhbwstuttgart/syntaxtree/Method.java index 6dae2e1d..7d18c634 100755 --- a/src/de/dhbwstuttgart/syntaxtree/Method.java +++ b/src/de/dhbwstuttgart/syntaxtree/Method.java @@ -23,18 +23,12 @@ import de.dhbwstuttgart.syntaxtree.statement.Block; public class Method extends Field implements IItemWithOffset { private Block block; - private ParameterList parameterlist = new ParameterList(null, new NullToken()); + private ParameterList parameterlist = new ParameterList(new ArrayList<>(), new NullToken()); private ExceptionList exceptionlist; - private String name; - - private List types_in_parameterlist = new ArrayList<>(); - private int modifiers; - private ParameterList parameterList; public Method(String name, RefTypeOrTPH returnType, int modifiers, ParameterList parameterList, Block block, GenericDeclarationList gtvDeclarations, Token offset) { super(name, returnType, modifiers, offset); - this.name = name; this.parameterlist = parameterList; this.block = block; } @@ -47,6 +41,6 @@ public class Method extends Field implements IItemWithOffset } public ParameterList getParameterList() { - return parameterList; + return parameterlist; } } diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/MethodCall.java b/src/de/dhbwstuttgart/syntaxtree/statement/MethodCall.java index f2537cfc..7b33f17b 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/MethodCall.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/MethodCall.java @@ -38,6 +38,7 @@ public class MethodCall extends Statement methodConstraints.addConstraint(m.getArgTypes().get(i), arglist.getArguments().get(i).getType()); } + overloading.addConstraint(methodConstraints); } ret.add(overloading); return ret; diff --git a/src/de/dhbwstuttgart/typeinference/OderConstraint.java b/src/de/dhbwstuttgart/typeinference/OderConstraint.java index 4fc1d3f2..e1709ad6 100755 --- a/src/de/dhbwstuttgart/typeinference/OderConstraint.java +++ b/src/de/dhbwstuttgart/typeinference/OderConstraint.java @@ -1,16 +1,13 @@ package de.dhbwstuttgart.typeinference; -import java.util.ArrayList; -import java.util.Set; -import java.util.TreeSet; -import java.util.Vector; +import java.util.*; public class OderConstraint extends OderMenge{ private Set oderConstraintPairs; public OderConstraint(){ - oderConstraintPairs = new TreeSet<>(); + oderConstraintPairs = new HashSet<>(); } diff --git a/src/de/dhbwstuttgart/typeinference/UndConstraint.java b/src/de/dhbwstuttgart/typeinference/UndConstraint.java index 51b3819f..d6809def 100755 --- a/src/de/dhbwstuttgart/typeinference/UndConstraint.java +++ b/src/de/dhbwstuttgart/typeinference/UndConstraint.java @@ -1,9 +1,6 @@ package de.dhbwstuttgart.typeinference; -import java.util.Collection; -import java.util.Set; -import java.util.TreeSet; -import java.util.Vector; +import java.util.*; import de.dhbwstuttgart.exceptions.DebugException; import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPH; @@ -16,7 +13,7 @@ import de.dhbwstuttgart.typeinference.unify.Unifikationsalgorithmus; */ public class UndConstraint extends UndMenge { - Set> set = new TreeSet<>(); + Set> set = new HashSet<>(); @Override public Set> getSet() { diff --git a/test/javFiles/MethodsEasy.jav b/test/javFiles/MethodsEasy.jav index 24cbd52d..36d0b4d4 100644 --- a/test/javFiles/MethodsEasy.jav +++ b/test/javFiles/MethodsEasy.jav @@ -1,6 +1,6 @@ class Methods { - mt4(a,b,c) { return a.add(b).sub(c) ; } + mt4(a,b,c) { return a.mt3(b).mt3(c) ; } mt3(a) {return a.add(); } }