Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 88db5f9eb7 | |||
| 8c5228f8c5 | |||
| 3a9a2576a2 | |||
| 5dccbffebd | |||
| 76f2048797 | |||
| a1195b689d | |||
| 3cd61778d6 | |||
| 021d3e1b27 | |||
| c90f01d5db | |||
| 8b3b018ea9 | |||
| 210adaa493 |
Binary file not shown.
@@ -0,0 +1,19 @@
|
||||
import java.util.stream.Stream;
|
||||
import Pair;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class Kombinatoren_After {
|
||||
|
||||
|
||||
after (fst, snd) { //System.out.println("after2");
|
||||
|
||||
return () -> Stream.of(
|
||||
toks -> {
|
||||
return fst.apply().flatMap(x ->
|
||||
x.apply(toks).flatMap(p1 ->
|
||||
snd.apply().flatMap(y -> y.apply(p1.snd()).map(p2 ->
|
||||
new Pair<>(new Pair<>(p1.fst(), p2.fst()), p2.snd()))))); } );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
import java.util.stream.Stream;
|
||||
import Pair;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class Kombinatoren_After_Lazy {
|
||||
|
||||
|
||||
afterP (fst, snd) {
|
||||
return toks -> {
|
||||
return fst.apply(toks).flatMap(p1 ->
|
||||
snd.apply(p1.snd()).map(p2 ->
|
||||
new Pair<>(new Pair<>(p1.fst(), p2.fst()), p2.snd())));
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
import java.util.stream.Stream;
|
||||
import Pair;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class Kombinatoren_Or {
|
||||
|
||||
|
||||
orP (p1, p2) {
|
||||
return ()-> Stream.concat(p1.apply(), p2.apply());
|
||||
}
|
||||
|
||||
/*
|
||||
after (fst, snd) { //System.out.println("after2");
|
||||
|
||||
return () -> Stream.of(
|
||||
toks -> {
|
||||
return fst.apply().flatMap(x ->
|
||||
x.apply(toks).flatMap(p1 ->
|
||||
snd.apply().flatMap(y -> y.apply(p1.snd()).map(p2 ->
|
||||
new Pair<>(new Pair<>(p1.fst(), p2.fst()), p2.snd()))))); } );
|
||||
}
|
||||
|
||||
|
||||
trans (p, f) {
|
||||
return () -> p.apply().map(x -> (toks -> x.apply(toks).map(pr -> new Pair<>(f.apply(pr.fst()), pr.snd() ) ) ) );
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
import java.util.stream.Stream;
|
||||
//import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
import java.io.PrintStream;
|
||||
import java.lang.System;
|
||||
|
||||
//import java.lang.String;
|
||||
import java.lang.Boolean;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
import Pair;
|
||||
import Kombinatoren_failure;
|
||||
|
||||
public class Kombinatoren_Satisfy {
|
||||
|
||||
kb = new Kombinatoren_failure();
|
||||
|
||||
satisfy(cond) {
|
||||
// return () -> Stream.of (newToks -> new Kombinatoren_failure().failure().apply().map(x -> x.apply(newToks)));
|
||||
//}
|
||||
return () -> Stream.of (toks -> {
|
||||
if(toks.isEmpty()) {
|
||||
return new ArrayList<>().stream();
|
||||
}
|
||||
else
|
||||
{
|
||||
var fst = toks.getFirst();
|
||||
if (cond.apply(fst))
|
||||
{
|
||||
//var newToks = List.copyOf(toks.subList(1, toks.size()));
|
||||
var newToks = new ArrayList<>(toks);
|
||||
return newToks.removeFirst();
|
||||
kb.getContent(
|
||||
kb.succeed(fst).apply().map(x -> x.apply(newToks))
|
||||
);
|
||||
// ;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
);
|
||||
}
|
||||
/* () -> Stream.of (toks -> {
|
||||
//System.out.println(toks);
|
||||
if(toks.isEmpty())
|
||||
{
|
||||
return new ArrayList<>().stream();
|
||||
}
|
||||
else {
|
||||
var fst = toks.getFirst();
|
||||
if (cond.apply(fst))
|
||||
{
|
||||
var newToks = List.copyOf(toks.subList(1, toks.size()));
|
||||
//System.out.println("satisfy ok " + fst.toString());
|
||||
//return get(succeed(fst).apply().map(x -> x.apply(newToks)));
|
||||
}
|
||||
else {
|
||||
//System.out.println("satisfy failure " + fst.toString());
|
||||
//return get(failure().apply()).apply(toks);
|
||||
}
|
||||
return new ArrayList<>().stream();
|
||||
} } ) ;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
import java.util.stream.Stream;
|
||||
import Pair;
|
||||
//import java.util.function.Function;
|
||||
|
||||
public class Kombinatoren_Trans {
|
||||
|
||||
|
||||
trans (p, f) {
|
||||
return () -> p.apply().map(x -> (toks -> x.apply(toks).map(pr -> new Pair<>(f.apply(pr.fst()), pr.snd() ) ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
import java.util.stream.Stream;
|
||||
import java.util.stream.IntStream;
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
import java.io.PrintStream;
|
||||
import java.lang.System;
|
||||
import java.util.Optional;
|
||||
|
||||
import java.lang.String;
|
||||
import java.lang.Boolean;
|
||||
import java.util.function.Function;
|
||||
|
||||
import Pair;
|
||||
|
||||
|
||||
public class Kombinatoren_failure {
|
||||
public getContent(s) {
|
||||
return s.toList().getFirst();
|
||||
}
|
||||
|
||||
public failure() {
|
||||
return () -> Stream.of(
|
||||
toks -> new ArrayList<>().stream());
|
||||
}
|
||||
public succeed( value) {
|
||||
return () -> Stream.of(toks -> {
|
||||
//System.out.println("succeed");
|
||||
var al = new ArrayList<>();
|
||||
al.add(new Pair<>(value, toks));
|
||||
//al.forEach(x -> { System.out.println(x.toString());});
|
||||
return al.stream();});
|
||||
}
|
||||
|
||||
parser(p, inp) {
|
||||
return p.map(y -> y.apply(
|
||||
inp.chars().mapToObj(c -> (char) c)
|
||||
.collect(Collectors.toList())))
|
||||
.flatMap(x -> x)
|
||||
.filter(x -> x.snd().isEmpty())
|
||||
.findFirst()
|
||||
.get()
|
||||
.fst();
|
||||
}
|
||||
|
||||
}
|
||||
/*
|
||||
|
||||
satisfy(cond) {
|
||||
return newToks -> failure().apply().map(x -> x.apply(newToks));
|
||||
/*
|
||||
return () -> Stream.of (toks -> {
|
||||
if(toks.isEmpty()) {
|
||||
return new ArrayList<>().stream();
|
||||
}
|
||||
else {
|
||||
var fst = toks.getFirst();
|
||||
if (cond.apply(fst)) {
|
||||
var newToks = List.copyOf(toks.subList(1, toks.size()));
|
||||
this.getContent(
|
||||
succeed(fst)
|
||||
.apply().map(x -> x.apply(newToks))
|
||||
)
|
||||
;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
);
|
||||
*/
|
||||
}
|
||||
}
|
||||
*/
|
||||
@@ -1,36 +1,24 @@
|
||||
import java.util.Vector;
|
||||
|
||||
import java.lang.Boolean;
|
||||
import java.lang.Object;
|
||||
|
||||
class Pair<U, T> {
|
||||
U a;
|
||||
T b;
|
||||
import java.util.List;
|
||||
|
||||
make(x) {
|
||||
var ret = new Pair<>();
|
||||
ret.a = x.elementAt(0);
|
||||
ret.b = x.elementAt(1);
|
||||
return ret;
|
||||
class Pair<T, U> {
|
||||
T a;
|
||||
U b;
|
||||
|
||||
public Pair() { }
|
||||
public Pair(T a, U b) {
|
||||
this.a = a;
|
||||
this.b = b;
|
||||
}
|
||||
|
||||
|
||||
eq(a, b) {
|
||||
b = a;
|
||||
return a == b;
|
||||
public T fst () {
|
||||
return a;
|
||||
}
|
||||
|
||||
|
||||
compare( p) {
|
||||
return eq(p.a, p.b);
|
||||
//return p.a == p.b;
|
||||
public U snd () {
|
||||
return b;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
void m(Pair<?, ?> p, Vector<?> b)
|
||||
{
|
||||
//this.compare(p); //1, type incorrect
|
||||
this.compare(this.make(b)); //2, OK
|
||||
}
|
||||
*/
|
||||
}
|
||||
Executable
+27
@@ -0,0 +1,27 @@
|
||||
import java.util.*;
|
||||
|
||||
public class Pair<T, U> {
|
||||
T a;
|
||||
U b;
|
||||
|
||||
public Pair() { }
|
||||
public Pair(T a, U b) {
|
||||
System.out.println("Pair a; " + a + " b: " + b);
|
||||
this.a = a;
|
||||
this.b = b;
|
||||
}
|
||||
|
||||
public T fst () {
|
||||
return a;
|
||||
}
|
||||
|
||||
public U snd () {
|
||||
System.out.println("snd b: " + b);
|
||||
return b;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "Pair<"+a.toString()+","+b.toString()+">";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
import java.util.stream.Stream;
|
||||
//import java.util.stream.IntStream;
|
||||
//import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
import java.io.PrintStream;
|
||||
import java.lang.System;
|
||||
import java.util.Optional;
|
||||
import java.lang.Character;
|
||||
import java.lang.String;
|
||||
import java.lang.Boolean;
|
||||
import java.lang.Integer;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Predicate;
|
||||
//import java.util.function.IntFunction;
|
||||
|
||||
import Pair;
|
||||
|
||||
|
||||
public class Parser {
|
||||
|
||||
|
||||
strToList(s) {
|
||||
var al;
|
||||
al = new ArrayList<>();
|
||||
var i = 0;
|
||||
while (i < s.length()) {
|
||||
al.add(s.charAt(i));
|
||||
i=i+1;
|
||||
}
|
||||
return al;
|
||||
}
|
||||
/*
|
||||
|
||||
parser(p, inp) {
|
||||
return p.map(y -> y.apply(
|
||||
strToList(inp)//chars().mapToObj(c -> (Character) c)
|
||||
//.toList()
|
||||
))
|
||||
|
||||
//.flatMap(x -> x)
|
||||
|
||||
//.filter(x -> x.snd().isEmpty())
|
||||
;
|
||||
/*
|
||||
.findFirst()
|
||||
.get()
|
||||
.fst()
|
||||
|
||||
;
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
satisfy(cond) {
|
||||
return newToks -> failure().apply().map(x -> x.apply(newToks));
|
||||
/*
|
||||
return () -> Stream.of (toks -> {
|
||||
if(toks.isEmpty()) {
|
||||
return new ArrayList<>().stream();
|
||||
}
|
||||
else {
|
||||
var fst = toks.getFirst();
|
||||
if (cond.apply(fst)) {
|
||||
var newToks = List.copyOf(toks.subList(1, toks.size()));
|
||||
this.getContent(
|
||||
succeed(fst)
|
||||
.apply().map(x -> x.apply(newToks))
|
||||
)
|
||||
;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
);
|
||||
*/
|
||||
}
|
||||
}
|
||||
*/
|
||||
@@ -736,12 +736,12 @@ public class TYPEStmt implements StatementVisitor {
|
||||
|
||||
for (int i = 0; i < foMethod.arglist.getArguments().size(); i++) {
|
||||
// Zuordnung von MethoCall.signature (Argumenttypen) zu der Argumenttypen der ausgewaehlten Methode (assumption.params)
|
||||
ret.add(new Pair(foMethod.signature.get(i), assumption.getArgTypes().get(i), PairOperator.EQUALSDOT));
|
||||
ret.add(new Pair(resolver.resolve(foMethod.signature.get(i)), resolver.resolve(assumption.getArgTypes().get(i)), PairOperator.EQUALSDOT));
|
||||
|
||||
}
|
||||
|
||||
// Zuordnung von MethodCall.signature(ReturnType) zu dem ReturnType der ausgewaehlten Methode (assumption.returnType)
|
||||
ret.add(new Pair(foMethod.signature.getLast(), assumption.getReturnType(), PairOperator.EQUALSDOT));
|
||||
ret.add(new Pair(resolver.resolve(foMethod.signature.getLast()), resolver.resolve(assumption.getReturnType()), PairOperator.EQUALSDOT));
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -755,7 +755,7 @@ public class RuleSet implements IRuleSet{
|
||||
|
||||
UnifyType lhsType = pair.getLhsType();
|
||||
UnifyType rhsType = pair.getRhsType();
|
||||
if(!(lhsType instanceof ReferenceType) || !(rhsType instanceof ExtendsType))
|
||||
if((!(lhsType instanceof ReferenceType) && !(lhsType instanceof FunNType)) || !(rhsType instanceof ExtendsType))
|
||||
return Optional.empty();
|
||||
|
||||
return Optional.of(new UnifyPair(lhsType, ((ExtendsType) rhsType).getExtendedType(), PairOperator.SMALLERDOT, pair.getSubstitution(), pair.getBasePair()));
|
||||
@@ -781,7 +781,7 @@ public class RuleSet implements IRuleSet{
|
||||
|
||||
UnifyType lhsType = pair.getLhsType();
|
||||
UnifyType rhsType = pair.getRhsType();
|
||||
if(!(lhsType instanceof ReferenceType) || !(rhsType instanceof SuperType))
|
||||
if((!(lhsType instanceof ReferenceType) && !(lhsType instanceof FunNType)) || !(rhsType instanceof SuperType))
|
||||
return Optional.empty();
|
||||
|
||||
return Optional.of(new UnifyPair(((SuperType) rhsType).getSuperedType(), lhsType, PairOperator.SMALLERDOTWC, pair.getSubstitution(), pair.getBasePair()));
|
||||
@@ -904,7 +904,7 @@ public class RuleSet implements IRuleSet{
|
||||
|
||||
var fiArgs = intf.getFunctionalInterfaceTypeArguments(refType);
|
||||
var retType = fiArgs.getFirst();
|
||||
var lhsArgs = intf.getFunctionalInterfaceTypeArguments(lhsType);
|
||||
var lhsArgs = intf.getFunctionalInterfaceTypeArguments(lhsType); //FALSCHRUM????
|
||||
var lhsRet = lhsArgs.getFirst();
|
||||
|
||||
Set<UnifyPair> result = new HashSet<>();
|
||||
@@ -972,16 +972,66 @@ public class RuleSet implements IRuleSet{
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Set<UnifyPair>> smallerFunN(UnifyPair pair) {
|
||||
public Optional<Set<UnifyPair>> smallerFunN(UnifyPair pair, IFiniteClosure fc) {
|
||||
if(pair.getPairOp() != PairOperator.SMALLERDOT)
|
||||
return Optional.empty();
|
||||
|
||||
UnifyType lhsType = pair.getLhsType();
|
||||
UnifyType rhsType = pair.getRhsType();
|
||||
|
||||
if(!(lhsType instanceof PlaceholderType) || !(rhsType instanceof FunNType))
|
||||
if(!(rhsType instanceof FunNType))
|
||||
return Optional.empty();
|
||||
|
||||
/* muss nach angepasst werden */
|
||||
//FunN$$<...> <. FunctinalInterface<...> wird umgewandelt in FunN$$<...> <. FunN$$<... args aus FuntionalInterface ...>
|
||||
if (lhsType instanceof ReferenceType) {
|
||||
UnifyType typeFI = pair.getLhsType();
|
||||
|
||||
Optional<UnifyType> opt = fc.getRightHandedFunctionalInterfaceType(typeFI.getName());
|
||||
if(!opt.isPresent())
|
||||
return Optional.empty();
|
||||
|
||||
if (!(typeFI instanceof ReferenceType refType) || !(refType instanceof FunInterfaceType intf))
|
||||
return Optional.empty();
|
||||
|
||||
var fiArgs = intf.getFunctionalInterfaceTypeArguments(refType);
|
||||
var retType = fiArgs.getFirst();
|
||||
var rhsArgs = intf.getFunctionalInterfaceTypeArguments(rhsType);
|
||||
var rhsRet = rhsArgs.getFirst();
|
||||
|
||||
Set<UnifyPair> result = new HashSet<>();
|
||||
//if (retType instanceof ExtendsType) {
|
||||
result.add(new UnifyPair(retType, rhsRet, PairOperator.SMALLER));
|
||||
//} else if (retType instanceof SuperType) {
|
||||
// return Optional.empty();
|
||||
//} else {
|
||||
// result.add(new UnifyPair(lhsRet, retType, PairOperator.EQUALSDOT));
|
||||
//}
|
||||
|
||||
for (var i = 1; i < fiArgs.size(); i++) {
|
||||
var rh = rhsArgs.get(i);
|
||||
var lh = fiArgs.get(i);
|
||||
|
||||
//if (rh instanceof SuperType) {
|
||||
result.add(new UnifyPair(rh, lh, PairOperator.SMALLER));
|
||||
//} else if (rh instanceof ExtendsType) {
|
||||
// return Optional.empty();
|
||||
//} else {
|
||||
// result.add(new UnifyPair(lh, rh, PairOperator.EQUALSDOT));
|
||||
//}
|
||||
}
|
||||
|
||||
return Optional.of(result);
|
||||
}
|
||||
|
||||
else {
|
||||
if(!(lhsType instanceof PlaceholderType))
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
FunNType funNRhsType = (FunNType) rhsType;
|
||||
|
||||
Set<UnifyPair> result = new HashSet<UnifyPair>();
|
||||
@@ -1018,6 +1068,121 @@ public class RuleSet implements IRuleSet{
|
||||
return Optional.of(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Set<UnifyPair>> reduceFIFunN(UnifyPair pair, IFiniteClosure fc) {
|
||||
if(pair.getPairOp() != PairOperator.EQUALSDOT)
|
||||
return Optional.empty();
|
||||
|
||||
UnifyType lhsType = pair.getLhsType();
|
||||
UnifyType rhsType = pair.getRhsType();
|
||||
|
||||
if(!(rhsType instanceof FunNType))
|
||||
return Optional.empty();
|
||||
|
||||
/* muss nach angepasst werden */
|
||||
//FunN$$<...> <. FunctinalInterface<...> wird umgewandelt in FunN$$<...> <. FunN$$<... args aus FuntionalInterface ...>
|
||||
if (lhsType instanceof ReferenceType) {
|
||||
UnifyType typeFI = pair.getLhsType();
|
||||
|
||||
Optional<UnifyType> opt = fc.getRightHandedFunctionalInterfaceType(typeFI.getName());
|
||||
if(!opt.isPresent())
|
||||
return Optional.empty();
|
||||
|
||||
if (!(typeFI instanceof ReferenceType refType) || !(refType instanceof FunInterfaceType intf))
|
||||
return Optional.empty();
|
||||
|
||||
var fiArgs = intf.getFunctionalInterfaceTypeArguments(refType);
|
||||
var retType = fiArgs.getFirst();
|
||||
var rhsArgs = intf.getFunctionalInterfaceTypeArguments(rhsType);
|
||||
var rhsRet = rhsArgs.getFirst();
|
||||
|
||||
Set<UnifyPair> result = new HashSet<>();
|
||||
//if (retType instanceof ExtendsType) {
|
||||
result.add(new UnifyPair(retType, rhsRet, PairOperator.EQUALSDOT));
|
||||
//} else if (retType instanceof SuperType) {
|
||||
// return Optional.empty();
|
||||
//} else {
|
||||
// result.add(new UnifyPair(lhsRet, retType, PairOperator.EQUALSDOT));
|
||||
//}
|
||||
|
||||
for (var i = 1; i < fiArgs.size(); i++) {
|
||||
var rh = rhsArgs.get(i);
|
||||
var lh = fiArgs.get(i);
|
||||
|
||||
//if (rh instanceof SuperType) {
|
||||
result.add(new UnifyPair(rh, lh, PairOperator.EQUALSDOT));
|
||||
//} else if (rh instanceof ExtendsType) {
|
||||
// return Optional.empty();
|
||||
//} else {
|
||||
// result.add(new UnifyPair(lh, rh, PairOperator.EQUALSDOT));
|
||||
//}
|
||||
}
|
||||
|
||||
return Optional.of(result);
|
||||
}
|
||||
else {
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Set<UnifyPair>> reduceFunNFi(UnifyPair pair, IFiniteClosure fc) {
|
||||
if(pair.getPairOp() != PairOperator.EQUALSDOT)
|
||||
return Optional.empty();
|
||||
|
||||
UnifyType lhsType = pair.getLhsType();
|
||||
UnifyType rhsType = pair.getRhsType();
|
||||
|
||||
if(!(lhsType instanceof FunNType))
|
||||
return Optional.empty();
|
||||
|
||||
//FunN$$<...> <. FunctinalInterface<...> wird umgewandelt in FunN$$<...> <. FunN$$<... args aus FuntionalInterface ...>
|
||||
if (rhsType instanceof ReferenceType) {
|
||||
UnifyType typeFI = pair.getRhsType();
|
||||
|
||||
Optional<UnifyType> opt = fc.getRightHandedFunctionalInterfaceType(typeFI.getName());
|
||||
if(!opt.isPresent())
|
||||
return Optional.empty();
|
||||
|
||||
if (!(typeFI instanceof ReferenceType refType) || !(refType instanceof FunInterfaceType intf))
|
||||
return Optional.empty();
|
||||
|
||||
var fiArgs = intf.getFunctionalInterfaceTypeArguments(refType);
|
||||
var retType = fiArgs.getFirst();
|
||||
var lhsArgs = intf.getFunctionalInterfaceTypeArguments(lhsType);
|
||||
var lhsRet = lhsArgs.getFirst();
|
||||
|
||||
Set<UnifyPair> result = new HashSet<>();
|
||||
//if (retType instanceof ExtendsType) {
|
||||
// result.add(new UnifyPair(lhsRet, retType, PairOperator.SMALLERDOTWC));
|
||||
//} else if (retType instanceof SuperType) {
|
||||
// return Optional.empty();
|
||||
//} else {
|
||||
result.add(new UnifyPair(lhsRet, retType, PairOperator.EQUALSDOT));
|
||||
//}
|
||||
|
||||
for (var i = 1; i < fiArgs.size(); i++) {
|
||||
var lh = lhsArgs.get(i);
|
||||
var rh = fiArgs.get(i);
|
||||
|
||||
//if (rh instanceof SuperType) {
|
||||
// result.add(new UnifyPair(lh, rh, PairOperator.SMALLERDOTWC));
|
||||
//} else if (rh instanceof ExtendsType) {
|
||||
// return Optional.empty();
|
||||
//} else {
|
||||
result.add(new UnifyPair(lh, rh, PairOperator.EQUALSDOT));
|
||||
//}
|
||||
}
|
||||
|
||||
return Optional.of(result);
|
||||
}
|
||||
|
||||
else {
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Optional<UnifyPair> reduceTph(UnifyPair pair) {
|
||||
if(pair.getPairOp() != PairOperator.SMALLERDOTWC)
|
||||
@@ -1025,7 +1190,7 @@ public class RuleSet implements IRuleSet{
|
||||
|
||||
UnifyType lhsType = pair.getLhsType();
|
||||
UnifyType rhsType = pair.getRhsType();
|
||||
if(!(lhsType instanceof PlaceholderType) || !(rhsType instanceof ReferenceType))
|
||||
if(!(lhsType instanceof PlaceholderType) || (!(rhsType instanceof ReferenceType) && !(rhsType instanceof FunNType)))
|
||||
return Optional.empty();
|
||||
|
||||
return Optional.of(new UnifyPair(lhsType, rhsType, PairOperator.EQUALSDOT, pair.getSubstitution(), pair.getBasePair()));
|
||||
|
||||
@@ -1239,7 +1239,7 @@ public class TypeUnifyTask extends CancellableTask<CompletableFuture<Set<Set<Uni
|
||||
// FunN Rules
|
||||
optSet = optSet.isPresent() ? optSet : rules.reduceFunN(pair);
|
||||
optSet = optSet.isPresent() ? optSet : rules.greaterFunN(pair, fc);
|
||||
optSet = optSet.isPresent() ? optSet : rules.smallerFunN(pair);
|
||||
optSet = optSet.isPresent() ? optSet : rules.smallerFunN(pair, fc);
|
||||
|
||||
// One of the rules has been applied
|
||||
if (optSet.isPresent()) {
|
||||
|
||||
@@ -39,7 +39,8 @@ public class UnifyResultModel {
|
||||
public void notify(Set<Set<UnifyPair>> eqPrimePrimeSet, UnifyContext context) {
|
||||
Set<Set<UnifyPair>> eqPrimePrimeSetRet = eqPrimePrimeSet.stream().map(x -> {
|
||||
Optional<Set<UnifyPair>> res = new RuleSet(context.placeholderRegistry()).subst(x.stream().map(y -> {
|
||||
if (y.getPairOp() == PairOperator.SMALLERDOTWC) y.setPairOp(PairOperator.EQUALSDOT);
|
||||
if (y.getPairOp() == PairOperator.SMALLERDOTWC)
|
||||
y.setPairOp(PairOperator.EQUALSDOT);
|
||||
return y; //alle Paare a <.? b erden durch a =. b ersetzt
|
||||
}).collect(Collectors.toCollection(HashSet::new)));
|
||||
if (res.isPresent()) {//wenn subst ein Erg liefert wurde was veraendert
|
||||
|
||||
@@ -61,7 +61,9 @@ public interface IRuleSet {
|
||||
*/
|
||||
public Optional<Set<UnifyPair>> reduceFunN(UnifyPair pair);
|
||||
public Optional<Set<UnifyPair>> greaterFunN(UnifyPair pair, IFiniteClosure fc);
|
||||
public Optional<Set<UnifyPair>> smallerFunN(UnifyPair pair);
|
||||
public Optional<Set<UnifyPair>> smallerFunN(UnifyPair pair, IFiniteClosure fc);
|
||||
public Optional<Set<UnifyPair>> reduceFIFunN(UnifyPair pair, IFiniteClosure fc);
|
||||
public Optional<Set<UnifyPair>> reduceFunNFi(UnifyPair pair, IFiniteClosure fc);
|
||||
|
||||
/**
|
||||
* Checks whether the erase1-Rule applies to the pair.
|
||||
|
||||
@@ -685,6 +685,7 @@ public class FiniteClosure //extends Ordering<UnifyType> //entfernt PL 2018-12-1
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Set<UnifyType> getAncestors(UnifyType t) {
|
||||
if (!inheritanceGraph.containsKey(t))
|
||||
|
||||
@@ -14,7 +14,9 @@ import org.junit.jupiter.api.Test;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import de.dhbwstuttgart.core.ConsoleInterface;
|
||||
import de.dhbwstuttgart.core.JavaTXCompiler;
|
||||
import de.dhbwstuttgart.util.Logger.LogLevel;
|
||||
|
||||
public class AllgemeinTest {
|
||||
|
||||
@@ -29,6 +31,7 @@ public class AllgemeinTest {
|
||||
|
||||
@Test
|
||||
public void test() throws Exception {
|
||||
ConsoleInterface.logLevel = LogLevel.DEBUG;
|
||||
//String className = "GenTest";
|
||||
//String className = "Overloading_Generics";
|
||||
//String className = "Generics";
|
||||
@@ -55,6 +58,7 @@ public class AllgemeinTest {
|
||||
//String className = "WildcardCaptureConversionTest";
|
||||
//String className = "CaptureConversion";
|
||||
//String className = "Pair";
|
||||
//String className = "DublicateWildcard";
|
||||
//String className = "UseWildcardPair";
|
||||
//String className = "Assign";
|
||||
//String className = "StreamTest";
|
||||
@@ -63,11 +67,14 @@ public class AllgemeinTest {
|
||||
//String className = "Cycle";
|
||||
//String className = "TripleTest";
|
||||
//String className = "WildcardList";
|
||||
String className = "List";
|
||||
//String className = "List";
|
||||
//String className = "Box";
|
||||
//String className = "GenBox";
|
||||
//String className = "InnerInf";
|
||||
//String className = "Foo";
|
||||
//String className = "Kombinatoren_failure";
|
||||
String className = "Kombinatoren_After_Lazy";
|
||||
//String className = "Parser";
|
||||
//PL 2019-10-24: genutzt fuer unterschiedliche Tests
|
||||
path = System.getProperty("user.dir")+"/resources/AllgemeinTest/" + className + ".jav";
|
||||
//path = System.getProperty("user.dir")+"/src/test/resources/AllgemeinTest/Overloading_Generics.jav";
|
||||
@@ -76,7 +83,7 @@ public class AllgemeinTest {
|
||||
///*
|
||||
compiler = new JavaTXCompiler(
|
||||
Lists.newArrayList(new File(path)),
|
||||
Lists.newArrayList(new File(System.getProperty("user.dir")+"/resources/bytecode/classFiles/")),
|
||||
Lists.newArrayList(new File(System.getProperty("user.dir")+"/resources/AllgemeinTest/")),
|
||||
new File(System.getProperty("user.dir")+"/resources/bytecode/classFiles/"), true);
|
||||
//*/
|
||||
compiler.generateBytecode();
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
|
||||
import de.dhbwstuttgart.core.ConsoleInterface;
|
||||
import de.dhbwstuttgart.util.Logger;
|
||||
import de.dhbwstuttgart.util.Logger.LogLevel;
|
||||
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@@ -1416,6 +1418,7 @@ public class TestComplete {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled("too slow")
|
||||
public void testBug325() throws Exception {
|
||||
var classFiles = generateClassFiles(createClassLoader(), "Bug325.jav");
|
||||
var clazz = classFiles.get("Bug325");
|
||||
|
||||
Reference in New Issue
Block a user