From 558a873e68776cc77a67a6df535807f0e7c8cfe0 Mon Sep 17 00:00:00 2001 From: Florian Steurer Date: Wed, 13 Apr 2016 11:58:33 +0200 Subject: [PATCH] commenting --- .../typeinference/unify/Unify.java | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/src/de/dhbwstuttgart/typeinference/unify/Unify.java b/src/de/dhbwstuttgart/typeinference/unify/Unify.java index 25c60984..61884a19 100644 --- a/src/de/dhbwstuttgart/typeinference/unify/Unify.java +++ b/src/de/dhbwstuttgart/typeinference/unify/Unify.java @@ -376,6 +376,9 @@ public class Unify { .filter(x -> x.size() > 0).collect(Collectors.toCollection(HashSet::new)); } + /** + * Cartesian product Case 1: (a <. Theta') + */ protected Set> unifyCase1(PlaceholderType a, UnifyType thetaPrime, IFiniteClosure fc) { Set> result = new HashSet<>(); @@ -456,6 +459,9 @@ public class Unify { return result; } + /** + * Cartesian Product Case 2: (a <.? ? ext Theta') + */ protected Set> unifyCase2(PlaceholderType a, ExtendsType extThetaPrime, IFiniteClosure fc) { Set> result = new HashSet<>(); @@ -528,6 +534,9 @@ public class Unify { // return result; } + /** + * Cartesian Product Case 3: (a <.? ? sup Theta') + */ protected Set> unifyCase3(PlaceholderType a, SuperType subThetaPrime, IFiniteClosure fc) { Set> result = new HashSet<>(); @@ -549,6 +558,9 @@ public class Unify { return result; } + /** + * Cartesian Product Case 4: (a <.? Theta') + */ protected Set> unifyCase4(PlaceholderType a, UnifyType thetaPrime, IFiniteClosure fc) { Set> result = new HashSet<>(); Set resultPrime = new HashSet<>(); @@ -558,6 +570,9 @@ public class Unify { return result; } + /** + * Cartesian Product Case 5: (Theta <. a) + */ protected Set> unifyCase5(UnifyType theta, PlaceholderType a, IFiniteClosure fc) { Set> result = new HashSet<>(); for(UnifyType thetaS : fc.greater(theta)) { @@ -576,6 +591,9 @@ public class Unify { return result; } + /** + * Cartesian Product Case 6: (? ext Theta <.? a) + */ protected Set> unifyCase6(ExtendsType extTheta, PlaceholderType a, IFiniteClosure fc) { Set> result = new HashSet<>(); //for(UnifyType thetaS : fc.smaller(extTheta.getExtendedType())) { @@ -591,6 +609,9 @@ public class Unify { return result; } + /** + * Cartesian Product Case 7: (? sup Theta <.? a) + */ protected Set> unifyCase7(SuperType supTheta, PlaceholderType a, IFiniteClosure fc) { Set> result = new HashSet<>(); @@ -658,6 +679,9 @@ public class Unify { // return result; } + /** + * Cartesian Product Case 8: (Theta <.? a) + */ protected Set> unifyCase8(UnifyType theta, PlaceholderType a, IFiniteClosure fc) { Set> result = new HashSet<>(); //for(UnifyType thetaS : fc.grArg(theta)) { @@ -680,12 +704,25 @@ public class Unify { return result; } + /** + * Takes a set of candidates for each position and computes all possible permutations. + * @param candidates The length of the list determines the number of type params. Each set + * contains the candidates for the corresponding position. + */ protected Set permuteParams(ArrayList> candidates) { Set result = new HashSet<>(); permuteParams(candidates, 0, result, new UnifyType[candidates.size()]); return result; } + /** + * Takes a set of candidates for each position and computes all possible permutations. + * @param candidates The length of the list determines the number of type params. Each set + * contains the candidates for the corresponding position. + * @param idx Idx for the current permutatiton. + * @param result Set of all permutations found so far + * @param current The permutation of type params that is currently explored + */ private void permuteParams(ArrayList> candidates, int idx, Set result, UnifyType[] current) { if(candidates.size() == idx) { result.add(new TypeParams(Arrays.copyOf(current, current.length)));