Compare commits

...

23 Commits

Author SHA1 Message Date
JanUlrich
4bee1044c2 mapFC -> pi 2019-01-20 14:04:27 +01:00
JanUlrich
0d3514cbd8 backup 2018-08-24 13:55:53 +02:00
JanUlrich
0776f128ed Merge branch 'bigRefactoring' of ssh://gohorb.ba-horb.de/bahome/projekt/git/JavaCompilerCore into sat 2018-08-21 14:03:16 +02:00
JanUlrich
dad9e58763 Fehler beheben 2018-07-17 19:56:01 +02:00
JanUlrich
d0e7ea86ed Tests bereinigen 2018-07-17 19:51:50 +02:00
JanUlrich
e9c87f6bf6 FCGenerator sortiert unnötige Paare aus 2018-07-08 21:04:24 +02:00
JanUlrich
0ae743f446 Benchmark Endgültig 2018-07-07 02:10:33 +02:00
JanUlrich
ef9f9157f3 Benchmark 2018-07-06 10:54:56 +02:00
JanUlrich
3d57a3929c Result anfügen 2018-07-05 21:15:06 +02:00
JanUlrich
a71c1f3893 Gencoy ASP Generator fertig stellen 2018-07-05 16:33:20 +02:00
JanUlrich
1f8421db27 ASP Generate Gencay 2018-07-04 12:29:02 +02:00
JanUlrich
3dfbddf693 Vector Test anpasen 2018-06-28 16:41:13 +02:00
JanUlrich
79fb15f269 MAsterarbeit 2018-06-28 16:04:12 +02:00
JanUlrich
ba63da2860 ASP Parser einführen 2018-06-15 06:15:36 +02:00
JanUlrich
fe72936737 Merge mit bigRefactoring 2018-06-13 23:54:35 +02:00
JanUlrich
a2c30f83a8 Tests anfügen 2018-05-28 15:55:29 +02:00
JanUlrich
fc9b1a6bb1 Beginnen mit ASP Generator für Unify WITH wildcards 2018-05-28 15:51:40 +02:00
JanUlrich
bf4e65caf5 Merge branch 'bigRefactoring' into sat 2018-04-12 20:08:25 +02:00
JanUlrich
b6d67a1c51 Beginnen mit Tests von UnifyWithoutWildcards 2018-04-12 19:31:32 +02:00
JanUlrich
a06f4b3349 Merge branch 'bigRefactoring' into sat 2018-04-12 18:12:19 +02:00
JanUlrich
10be0b17e9 Oder-Constraints generieren 2018-04-11 17:16:45 +02:00
JanUlrich
277dac20e7 Tests anpassen. Beginnen mit Oder Constraints 2018-04-11 14:13:15 +02:00
JanUlrich
e7e96d5943 Tests erweitern und ANTLR Grammatik parsed nur noch unifier Regeln 2018-04-09 13:00:24 +02:00
146 changed files with 13904 additions and 1393 deletions

19
asp/adaptRules.lp Normal file
View File

@ -0,0 +1,19 @@
%makeAdapt(smallerDot(CFC, DFC)) :- smallerDot(C, D), type(C, CN, CNP), type(D, DN, DNP), CNP != DNP
%, smaller(CFC, DFC), type(CFC, CN, CNP), type(DFC, DN, DNP), mapRootFC(smaller(CFC, DFC), _, _)
%.
type(pointer(smallerDot(C,D)), DN, DNP)
:- smallerDot(C, D), type(C, CN, CNP), type(D, DN, DNP), CNP != DNP
.
smallerDot(pointer(smallerDot(C,D)), D)
:- smallerDot(C, D), type(C, CN, CNP), type(D, DN, DNP), CNP != DNP
.
param(pointer(smallerDot(C,D)), P, P2)
:- smallerDot(C, D), type(C, CN, CNP), type(D, DN, DNP), CNP != DNP
, smaller(CFC, DFC), type(CFC, CN, CNP), type(DFC, DN, DNP)
, pi(CFC, DFC, P1, P2), param(C, P, P1)
.

22
asp/cartesian.lp Normal file
View File

@ -0,0 +1,22 @@
%Mit Hilfe von Quelle: https://www.cs.uni-potsdam.de/~torsten/Papers/asp4ki.pdf
%Dieser Code generiert das Karthesische Produkt der Constraints des Inputs.
%und Constraints sind einfach weiterhin equals uns smallerDot
%oder constraints:
% oder(pointer, pointer)
%constraints innerhalb des oders müssen eingepackt sein:
% constraint(pointer, eigentlicher Constraint)
% um mehrere constraints als Und-Constraint innerhalb eines Oders zu verbinden kann die list(..) verwendet werden
%Die eigentliche Oder-Verknüpfung:
cons(Cons1), cons(Cons2) :- oder(C1, C2), constraint(C1, Cons1), constraint(C2, Cons2).
%Auspacken der constraints:
equals(X,Y) :- cons(equals(X,Y)).
smallerDot(X,Y) :- cons(smallerDot(X,Y)).
oder(X,Y) :- cons(oder(X,Y)).
list(X,Y) :- cons(list(X,Y)).
equals(X,Y) :- list(equals(X,Y), _).
smallerDot(X,Y) :- list(smallerDot(X,Y), _).
list(A,B) :- list(_, list(A,B)).

70
asp/facultyTestInput.lp Normal file
View File

@ -0,0 +1,70 @@
typeVar(cRO).
smaller(cAVP,cAVQ).
type(cAVY,cjava_DOT_lang_DOT_Integer,0).
type(cAVI,cjava_DOT_lang_DOT_Integer,0).
type(cAVD,cjava_DOT_lang_DOT_Comparable,1).
type(cAVH,cjava_DOT_lang_DOT_Comparable,1).
type(cAVJ,cjava_DOT_lang_DOT_Number,0).
typeVar(cT).
equals(cQ,cRO).
smaller(cAVR,cAVS).
param(cAVZ,cYO,1).
param(cAVZ,cYP,2).
type(cAWD,cjava_DOT_lang_DOT_Integer,0).
typeVar(cO).
smaller(cAVN,cAVO).
type(cAWA,cjava_DOT_lang_DOT_Integer,0).
type(cAVF,cjava_DOT_lang_DOT_Object,0).
typeVar(cYA).
type(cAVU,cjava_DOT_lang_DOT_Integer,0).
equals(cN,cAVV).
smaller(cAVB,cAVC).
type(cAVO,cjava_DOT_lang_DOT_Object,0).
type(cAVB,cjava_DOT_io_DOT_Serializable,0).
smallerDot(cT,cM).
typeVar(cL).
smallerDot(cM,cL).
typeVar(cP).
type(cAVQ,cjava_DOT_lang_DOT_Number,0).
type(cAVR,cFaculty,0).
smallerDot(cAWD,cAWE).
typeVar(cYB).
type(cAVE,cjava_DOT_lang_DOT_Integer,0).
type(cAVN,cjava_DOT_lang_DOT_Number,0).
equals(cT,cAVT).
type(cAVV,cFaculty,0).
type(cAVC,cjava_DOT_lang_DOT_Object,0).
type(cAVM,cjava_DOT_lang_DOT_Object,0).
smaller(cAVG,cAVH).
type(cAVL,cjava_DOT_lang_DOT_Object,0).
type(cAWE,cjava_DOT_lang_DOT_Integer,0).
type(cAVG,cjava_DOT_lang_DOT_Integer,0).
param(cAVT,cAVU,2).
typeVar(cYO).
type(cAWB,cjava_DOT_lang_DOT_Integer,0).
type(cAVW,cjava_DOT_lang_DOT_Integer,0).
typeVar(cM).
param(cAVH,cAVI,1).
typeVar(cQ).
type(cAVX,cjava_DOT_lang_DOT_Integer,0).
equals(cYA,cO).
equals(cAWA,cP).
smallerDot(cM,cAVZ).
type(cAVK,cjava_DOT_io_DOT_Serializable,0).
smallerDot(cP,cQ).
smallerDot(cO,cAWB).
param(cAVD,cAVE,1).
smallerDot(cAVY,cYB).
smallerDot(cAVW,cAVX).
smaller(cAVD,cAVF).
smaller(cAVL,cAVM).
type(cAVP,cjava_DOT_lang_DOT_Integer,0).
typeVar(cYP).
typeVar(cN).
type(cAVT,cFun2,2).
param(cAVT,cRO,1).
type(cAVS,cjava_DOT_lang_DOT_Object,0).
type(cAWC,cFaculty,0).
smallerDot(cN,cAWC).
type(cAVZ,cFun2,2).
smaller(cAVJ,cAVK).

125
asp/fc.lp.backup Normal file
View File

@ -0,0 +1,125 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Anzahl Wildcards in einem Typ feststellen:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Start, am Ende der Parameterliste:
wildcard(A) :- extendsWildcard(A).
wildcard(A) :- superWildcard(A).
numWildcards(TP, Ende-1, Num) :- param(TP, Param, Ende),
numWildcards(Param, Num), type(TP,_,Ende)
, not wildcard(Param)
.
numWildcards(TP, Ende-1, Num + 1) :- param(TP, Param, Ende),
numWildcards(Param, Num), type(TP,_,Ende)
, wildcard(Param)
.
%Anschließend aufsummieren:
numWildcards(TP, ParamNum-1, NumWC1 + NumWC2 + 1) :- param(TP, Param, ParamNum),
numWildcards(Param, NumWC1), numWildcards(TP,ParamNum, NumWC2)
, wildcard(Param)
.
numWildcards(TP, ParamNum-1, NumWC1 + NumWC2) :- param(TP, Param, ParamNum),
numWildcards(Param, NumWC1), numWildcards(TP,ParamNum, NumWC2)
, not wildcard(Param)
.
numWildcards(TP, Num) :- numWildcards(TP, 0, Num), param(TP, P, 1), wildcard(P).
numWildcards(TP, Num) :- numWildcards(TP, 0, Num), param(TP, P, 1), not wildcard(P).
numWildcards(TP, 0) :- type(TP, _, 0).
numWildcards(TP, 0) :- typeVar(TP).
%%%%%%%%%%%%%%%%
% Greater
%%%%%%%%%%%%%%%%
{ greaterGen(P, A, AFC, BFC) : smaller(AFC, BFC), type(AFC, AN, ANum) } == 1 :- greaterGen(P, A), type(A, AN, ANum)
%, greaterArgGenNum(P, N), N < 100000
.
%:- greaterGen(A, _, _ , _), numWildcards(A, NW), NW >= 1.
type(P, BN, BNum) :- greaterGen(P, A, _, B), type(B, BN, BNum).
%Bei den Parametern gibt es zwei Fälle:
%% Die TPHs müssen gemapt werden, die anderen übernommen
greaterArgGen(pointer(P, Param), Param) :- greaterGen(P, A, Afc, B), param(A, Param, PNum), mapFC(smaller(Afc, B), PNum, _).
greaterArgGen(pointer(P, Param), Param) :- greaterGen(P, A, _, B), param(B, Param, PNum), type(B, _, _).
param(P, pointer(P, Param), PNum) :- greaterGen(P, A, _, B), param(B, Param, PNum)
, type(Param, _, _)
.
param(P, pointer(P, Param), PNum2) :- greaterGen(P, A, Afc, B), param(A, Param, PNum)
, mapFC(smaller(Afc,B), PNum, PNum2)
.
%TypeVars bleiben einfach TypeVars:
typeVar(Pointer) :- greaterArgGen(Pointer, T), typeVar(T).
makeGreaterGen(Pointer, T) :- greaterArgGen(Pointer, T), extendsWildcard(T).
makeSmallerGen(Pointer, T) :- greaterArgGen(Pointer, T), superWildcard(T).
makeSmallerGenG(Pointer, T),
makeGreaterGenG(Pointer, T),
makeSameGenG(Pointer, T)
:- greaterArgGen(Pointer, T), not extendsWildcard(T), not superWildcard(T), type(T, N, Num).
greaterGen(P, T) :- makeGreaterGenG(P, T).
extendsWildcard(P) :- makeGreaterGenG(P, T).
smallerGen(P, T) :- makeGreaterGenG(P, T).
superWildcard(P) :- makeSmallerGenG(P, T).
{ greaterGen(P, T, TFC, TFC) : smaller(TFC, _), type(TFC, TN, TNum) } == 1 :- makeSameGenG(P, T), type(T, TN, TNum).
greaterArgGenNum(P, 0) :- greaterArgGen(P, _), type(P, _ ,_).
greaterArgGenNum(pointer(P, P2), Num + 1) :- greaterArgGen(pointer(P, P2),_), greaterArgGenNum(P, Num).
%%%%%%%%%%%%%%%%%
% smaller
%%%%%%%%%%%%%%%%
{ smallerGen(P, A, AFC, BFC) : smaller(BFC, AFC), type(AFC, AN, ANum) } == 1 :- smallerGen(P, A), type(A, AN, ANum)
.
{ type(P, BN, BNum) : type(B,BN,BNum) } == 1 :- smallerGen(P, A, _, B).
%Bei den Parametern gibt es drei Fälle:
%% Die TPHs müssen gemapt werden, die anderen übernommen
smallerArgGen(pointer(P, Param), Param) :- smallerGen(P, A, Afc, B), param(A, Param, PNum), mapFC(smaller(B, Afc), _, PNum).
param(P, pointer(P, Param), PNum2) :- smallerGen(P, A, Afc, B), param(A, Param, PNum)
, mapFC(smaller(B,Afc), PNum2, PNum)
.
%Neue Parameter können hinzu kommen: TODO
%smallerArgGen(pointer(P, Param), Param) :- smallerGen(P, A, _, B), param(B, Param, PNum).
%param(P, pointer(P, Param), PNum) :- greaterGen(P, A, _, B), param(B, Param, PNum)
% %, type(Param, _, _) %Es ist egal ob es ein Typparameter oder eine TypeVar ist. smallerArgGen macht das richtige
% .
%Es können voraussetzungen hinzukommen:
equals(Param, PA) :- smallerGen(P, A, Afc, B), param(Afc, Param, PNum), type(Param, _, _), param(A, PA, PNum).
%TypeVars bleiben einfach TypeVars:
typeVar(Pointer) :- smallerArgGen(Pointer, T), typeVar(T).
makeSmallerGenS(Pointer, T) :- smallerArgGen(Pointer, T), extendsWildcard(T).
makeGreaterGenS(Pointer, T) :- smallerArgGen(Pointer, T), superWildcard(T).
makeSmallerGenS(Pointer, T),
makeGreaterGenS(Pointer, T),
makeSameGenS(Pointer, T)
:- smallerArgGen(Pointer, T), not extendsWildcard(T), not superWildcard(T), type(T, N, Num).
greaterGen(P, T) :- makeGreaterGenS(P, T).
extendsWildcard(P) :- makeGreaterGenS(P, T).
smallerGen(P, T) :- makeSmallerGenS(P, T).
superWildcard(P) :- makeSmallerGenS(P, T).
{ smallerGen(P, T, TFC, TFC) : smaller(TFC, _), type(TFC, TN, TNum) } == 1 :- makeSameGenS(P, T), type(T, TN, TNum).
%%%
% Grundlegende Regeln
%%%
smaller(A, A) :- smaller(A, _).
smaller(B, B) :- smaller(_, B).
%smaller(A, A) :- type(A). %Alle Typen erben von sich selber. Hätte komische Nebeneffekte
%Mapping:
mapFC(smaller(A,B), Num, Num2) :- smaller(A,B), param(A, P, Num), typeVar(P), param(B, P, Num2).
hasTypeInParameterList(A) :- type(A, _, _), param(A, P, _), type(P, _, _).
mapRootFC(smaller(A,B), Num, Num2) :- smaller(A, B), not hasTypeInParameterList(A), param(A, P, Num), typeVar(P), param(B, P, Num2).

110
asp/fc.lp.old Normal file
View File

@ -0,0 +1,110 @@
wildcard(A) :- extendsWildcard(A).
wildcard(A) :- superWildcard(A).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Anzahl der Wildcards ist 1
% Mehr benötigt man nicht verschachtelt
% Dadurch ist numWildcards unnötig, man ändert einfach die grArg auf Wildcards
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
type(P, TN, TNum) :- makeSameGen(P, T), type(T, TN, TNum).
param(P, TN, TNum) :- makeSameGen(P, T), param(T, TN, TNum).
superWildcard(P) :- makeSameGen(P, T), superWildcard(T).
extendsWildcard(P) :- makeSameGen(P, T), extendsWildcard(T).
%%%%%%%%%%%%%%%%%
% Greater
%%%%%%%%%%%%%%%%
{ greaterGen(P, A, AFC, BFC) : smaller(AFC, BFC), type(AFC, AN, ANum) } == 1 :- greaterGen(P, A), type(A, AN, ANum)
.
type(P, BN, BNum) :- greaterGen(P, A, _, B), type(B, BN, BNum).
%Bei den Parametern gibt es zwei Fälle:
%% Die TPHs müssen gemapt werden, die anderen übernommen
greaterArgGen(pointer(P, Param), Param) :- greaterGen(P, A, Afc, B), param(A, Param, PNum), mapFC(smaller(Afc, B), PNum, _).
greaterArgGen(pointer(P, Param), Param) :- greaterGen(P, A, _, B), param(B, Param, PNum), type(B, _, _).
param(P, pointer(P, Param), PNum) :- greaterGen(P, A, _, B), param(B, Param, PNum)
, type(Param, _, _)
.
param(P, pointer(P, Param), PNum2) :- greaterGen(P, A, Afc, B), param(A, Param, PNum)
, mapFC(smaller(Afc,B), PNum, PNum2)
.
%TypeVars bleiben einfach TypeVars:
typeVar(Pointer) :- greaterArgGen(Pointer, T), typeVar(T).
%makeGreaterGen(Pointer, T) :- greaterArgGen(Pointer, T), extendsWildcard(T).
%makeSmallerGen(Pointer, T) :- greaterArgGen(Pointer, T), superWildcard(T).
makeSameGen(Pointer, T) :- greaterArgGen(Pointer, T), extendsWildcard(T).
makeSameGen(Pointer, T) :- greaterArgGen(Pointer, T), superWildcard(T).
makeSmallerGenG(Pointer, T),
makeGreaterGenG(Pointer, T),
makeSameGenG(Pointer, T)
:- greaterArgGen(Pointer, T), not extendsWildcard(T), not superWildcard(T), type(T, N, Num).
greaterGen(P, T) :- makeGreaterGenG(P, T).
extendsWildcard(P) :- makeGreaterGenG(P, T).
smallerGen(P, T) :- makeGreaterGenG(P, T).
superWildcard(P) :- makeSmallerGenG(P, T).
{ greaterGen(P, T, TFC, TFC) : smaller(TFC, _), type(TFC, TN, TNum) } == 1 :- makeSameGenG(P, T), type(T, TN, TNum).
greaterArgGenNum(P, 0) :- greaterArgGen(P, _), type(P, _ ,_).
greaterArgGenNum(pointer(P, P2), Num + 1) :- greaterArgGen(pointer(P, P2),_), greaterArgGenNum(P, Num).
%%%%%%%%%%%%%%%%%
% smaller
%%%%%%%%%%%%%%%%
{ smallerGen(P, A, AFC, BFC) : smaller(BFC, AFC), type(AFC, AN, ANum) } == 1 :- smallerGen(P, A), type(A, AN, ANum)
.
{ type(P, BN, BNum) : type(B,BN,BNum) } == 1 :- smallerGen(P, A, _, B).
%Bei den Parametern gibt es drei Fälle:
%% Die TPHs müssen gemapt werden, die anderen übernommen
smallerArgGen(pointer(P, Param), Param) :- smallerGen(P, A, Afc, B), param(A, Param, PNum), mapFC(smaller(B, Afc), _, PNum).
param(P, pointer(P, Param), PNum2) :- smallerGen(P, A, Afc, B), param(A, Param, PNum)
, mapFC(smaller(B,Afc), PNum2, PNum)
.
%Neue Parameter können hinzu kommen: TODO
%smallerArgGen(pointer(P, Param), Param) :- smallerGen(P, A, _, B), param(B, Param, PNum).
%param(P, pointer(P, Param), PNum) :- greaterGen(P, A, _, B), param(B, Param, PNum)
% %, type(Param, _, _) %Es ist egal ob es ein Typparameter oder eine TypeVar ist. smallerArgGen macht das richtige
% .
%Es können voraussetzungen hinzukommen:
equals(Param, PA) :- smallerGen(P, A, Afc, B), param(Afc, Param, PNum), type(Param, _, _), param(A, PA, PNum).
%TypeVars bleiben einfach TypeVars:
typeVar(Pointer) :- smallerArgGen(Pointer, T), typeVar(T).
makeSameGen(Pointer, T) :- smallerArgGen(Pointer, T), extendsWildcard(T).
makeSameGen(Pointer, T) :- smallerArgGen(Pointer, T), superWildcard(T).
makeSmallerGenS(Pointer, T),
makeGreaterGenS(Pointer, T),
makeSameGenS(Pointer, T)
:- smallerArgGen(Pointer, T), not extendsWildcard(T), not superWildcard(T), type(T, N, Num).
greaterGen(P, T) :- makeGreaterGenS(P, T).
extendsWildcard(P) :- makeGreaterGenS(P, T).
smallerGen(P, T) :- makeSmallerGenS(P, T).
superWildcard(P) :- makeSmallerGenS(P, T).
{ smallerGen(P, T, TFC, TFC) : smaller(TFC, _), type(TFC, TN, TNum) } == 1 :- makeSameGenS(P, T), type(T, TN, TNum).
%%%
% Grundlegende Regeln
%%%
smaller(A, A) :- smaller(A, _).
smaller(B, B) :- smaller(_, B).
%smaller(A, A) :- type(A). %Alle Typen erben von sich selber. Hätte komische Nebeneffekte
%Mapping:
mapFC(smaller(A,B), Num, Num2) :- smaller(A,B), param(A, P, Num), typeVar(P), param(B, P, Num2).
hasTypeInParameterList(A) :- type(A, _, _), param(A, P, _), type(P, _, _).
mapRootFC(smaller(A,B), Num, Num2) :- smaller(A, B), not hasTypeInParameterList(A), param(A, P, Num), typeVar(P), param(B, P, Num2).

17
asp/greater.pl Normal file
View File

@ -0,0 +1,17 @@
{ fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V7,V8),greaterGen(V1,V2)) : type(V1,V10,V11), type(V7,V10,V11), type(V8,V9,V12), smaller(V7,V8) } == 1 :- greaterGen(V1,V2).
{ fun19(typeVar(V15),greaterGen(V1,V2),greaterGen(V1,V2),type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V7,V8),fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V7,V8),greaterGen(V1,V2)),param(V1,V15,V13),pi(V7,V8,V13,V14)) : typeVar(V15) ; fun20(notSuper(V15),notExtends(V15),type(V15,V16,V17),greaterGen(V1,V2),greaterGen(V1,V2),type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V7,V8),fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V7,V8),greaterGen(V1,V2)),param(V1,V15,V13),pi(V7,V8,V13,V14)) : notSuper(V15), notExtends(V15), type(V15,V16,V17) ; fun21(notSuper(V15),notExtends(V15),type(V15,V16,V17),greaterGen(V1,V2),greaterGen(V1,V2),type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V7,V8),fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V7,V8),greaterGen(V1,V2)),param(V1,V15,V13),pi(V7,V8,V13,V14)) : notSuper(V15), notExtends(V15), type(V15,V16,V17) ; fun22(notSuper(V15),extendsWildcard(V15),type(V15,V16,V17),greaterGen(V1,V2),greaterGen(V1,V2),type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V7,V8),fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V7,V8),greaterGen(V1,V2)),param(V1,V15,V13),pi(V7,V8,V13,V14)) : notSuper(V15), extendsWildcard(V15), type(V15,V16,V17) ; fun23(notSuper(V15),notExtends(V15),type(V15,V16,V17),greaterGen(V1,V2),greaterGen(V1,V2),type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V7,V8),fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V7,V8),greaterGen(V1,V2)),param(V1,V15,V13),pi(V7,V8,V13,V14)) : notSuper(V15), notExtends(V15), type(V15,V16,V17) ; fun24(superWildcard(V15),notExtends(V15),type(V15,V16,V17),greaterGen(V1,V2),greaterGen(V1,V2),type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V7,V8),fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V7,V8),greaterGen(V1,V2)),param(V1,V15,V13),pi(V7,V8,V13,V14)) : superWildcard(V15), notExtends(V15), type(V15,V16,V17) } == 1 :- greaterGen(V1,V2), greaterGen(V1,V2), type(V1,V10,V11), type(V7,V10,V11), type(V8,V9,V12), smaller(V7,V8), fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V7,V8),greaterGen(V1,V2)), param(V1,V15,V13), pi(V7,V8,V13,V14).
param(V2,V15,V14) :- greaterGen(V1,V2), greaterGen(V1,V2), type(V1,V10,V11), type(V7,V10,V11), type(V8,V9,V12), smaller(V7,V8), fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V7,V8),greaterGen(V1,V2)), param(V1,V15,V13), pi(V7,V8,V13,V14), greaterGen(V1,V2), greaterGen(V1,V2), type(V1,V10,V11), type(V7,V10,V11), type(V8,V9,V12), smaller(V7,V8), fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V7,V8),greaterGen(V1,V2)), param(V1,V15,V13), pi(V7,V8,V13,V14), typeVar(V15), fun19(typeVar(V15),greaterGen(V1,V2),greaterGen(V1,V2),type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V7,V8),fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V7,V8),greaterGen(V1,V2)),param(V1,V15,V13),pi(V7,V8,V13,V14)).
param(V2,V15,V14) :- greaterGen(V1,V2), greaterGen(V1,V2), type(V1,V10,V11), type(V7,V10,V11), type(V8,V9,V12), smaller(V7,V8), fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V7,V8),greaterGen(V1,V2)), param(V1,V15,V13), pi(V7,V8,V13,V14), greaterGen(V1,V2), greaterGen(V1,V2), type(V1,V10,V11), type(V7,V10,V11), type(V8,V9,V12), smaller(V7,V8), fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V7,V8),greaterGen(V1,V2)), param(V1,V15,V13), pi(V7,V8,V13,V14), notSuper(V15), notExtends(V15), type(V15,V16,V17), fun20(notSuper(V15),notExtends(V15),type(V15,V16,V17),greaterGen(V1,V2),greaterGen(V1,V2),type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V7,V8),fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V7,V8),greaterGen(V1,V2)),param(V1,V15,V13),pi(V7,V8,V13,V14)).
superWildcard(pointer(greaterGen(V1,V2), notSuper(V15), notExtends(V15), type(V15,V16,V17))) :- greaterGen(V1,V2), greaterGen(V1,V2), type(V1,V10,V11), type(V7,V10,V11), type(V8,V9,V12), smaller(V7,V8), fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V7,V8),greaterGen(V1,V2)), param(V1,V15,V13), pi(V7,V8,V13,V14), greaterGen(V1,V2), greaterGen(V1,V2), type(V1,V10,V11), type(V7,V10,V11), type(V8,V9,V12), smaller(V7,V8), fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V7,V8),greaterGen(V1,V2)), param(V1,V15,V13), pi(V7,V8,V13,V14), notSuper(V15), notExtends(V15), type(V15,V16,V17), fun21(notSuper(V15),notExtends(V15),type(V15,V16,V17),greaterGen(V1,V2),greaterGen(V1,V2),type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V7,V8),fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V7,V8),greaterGen(V1,V2)),param(V1,V15,V13),pi(V7,V8,V13,V14)).
param(V2,pointer(greaterGen(V1,V2), notSuper(V15), notExtends(V15), type(V15,V16,V17)),V14) :- greaterGen(V1,V2), greaterGen(V1,V2), type(V1,V10,V11), type(V7,V10,V11), type(V8,V9,V12), smaller(V7,V8), fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V7,V8),greaterGen(V1,V2)), param(V1,V15,V13), pi(V7,V8,V13,V14), greaterGen(V1,V2), greaterGen(V1,V2), type(V1,V10,V11), type(V7,V10,V11), type(V8,V9,V12), smaller(V7,V8), fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V7,V8),greaterGen(V1,V2)), param(V1,V15,V13), pi(V7,V8,V13,V14), notSuper(V15), notExtends(V15), type(V15,V16,V17), fun21(notSuper(V15),notExtends(V15),type(V15,V16,V17),greaterGen(V1,V2),greaterGen(V1,V2),type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V7,V8),fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V7,V8),greaterGen(V1,V2)),param(V1,V15,V13),pi(V7,V8,V13,V14)).
smallerGen(V15,pointer(greaterGen(V1,V2), notSuper(V15), notExtends(V15), type(V15,V16,V17))) :- greaterGen(V1,V2), greaterGen(V1,V2), type(V1,V10,V11), type(V7,V10,V11), type(V8,V9,V12), smaller(V7,V8), fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V7,V8),greaterGen(V1,V2)), param(V1,V15,V13), pi(V7,V8,V13,V14), greaterGen(V1,V2), greaterGen(V1,V2), type(V1,V10,V11), type(V7,V10,V11), type(V8,V9,V12), smaller(V7,V8), fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V7,V8),greaterGen(V1,V2)), param(V1,V15,V13), pi(V7,V8,V13,V14), notSuper(V15), notExtends(V15), type(V15,V16,V17), fun21(notSuper(V15),notExtends(V15),type(V15,V16,V17),greaterGen(V1,V2),greaterGen(V1,V2),type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V7,V8),fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V7,V8),greaterGen(V1,V2)),param(V1,V15,V13),pi(V7,V8,V13,V14)).
superWildcard(pointer(greaterGen(V1,V2), notSuper(V15), notExtends(V15), type(V15,V16,V17))) :- greaterGen(V1,V2), greaterGen(V1,V2), type(V1,V10,V11), type(V7,V10,V11), type(V8,V9,V12), smaller(V7,V8), fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V7,V8),greaterGen(V1,V2)), param(V1,V15,V13), pi(V7,V8,V13,V14), greaterGen(V1,V2), greaterGen(V1,V2), type(V1,V10,V11), type(V7,V10,V11), type(V8,V9,V12), smaller(V7,V8), fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V7,V8),greaterGen(V1,V2)), param(V1,V15,V13), pi(V7,V8,V13,V14), notSuper(V15), extendsWildcard(V15), type(V15,V16,V17), fun22(notSuper(V15),extendsWildcard(V15),type(V15,V16,V17),greaterGen(V1,V2),greaterGen(V1,V2),type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V7,V8),fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V7,V8),greaterGen(V1,V2)),param(V1,V15,V13),pi(V7,V8,V13,V14)).
param(V2,pointer(greaterGen(V1,V2), notSuper(V15), notExtends(V15), type(V15,V16,V17)),V14) :- greaterGen(V1,V2), greaterGen(V1,V2), type(V1,V10,V11), type(V7,V10,V11), type(V8,V9,V12), smaller(V7,V8), fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V7,V8),greaterGen(V1,V2)), param(V1,V15,V13), pi(V7,V8,V13,V14), greaterGen(V1,V2), greaterGen(V1,V2), type(V1,V10,V11), type(V7,V10,V11), type(V8,V9,V12), smaller(V7,V8), fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V7,V8),greaterGen(V1,V2)), param(V1,V15,V13), pi(V7,V8,V13,V14), notSuper(V15), extendsWildcard(V15), type(V15,V16,V17), fun22(notSuper(V15),extendsWildcard(V15),type(V15,V16,V17),greaterGen(V1,V2),greaterGen(V1,V2),type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V7,V8),fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V7,V8),greaterGen(V1,V2)),param(V1,V15,V13),pi(V7,V8,V13,V14)).
smallerGen(V15,pointer(greaterGen(V1,V2), notSuper(V15), notExtends(V15), type(V15,V16,V17))) :- greaterGen(V1,V2), greaterGen(V1,V2), type(V1,V10,V11), type(V7,V10,V11), type(V8,V9,V12), smaller(V7,V8), fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V7,V8),greaterGen(V1,V2)), param(V1,V15,V13), pi(V7,V8,V13,V14), greaterGen(V1,V2), greaterGen(V1,V2), type(V1,V10,V11), type(V7,V10,V11), type(V8,V9,V12), smaller(V7,V8), fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V7,V8),greaterGen(V1,V2)), param(V1,V15,V13), pi(V7,V8,V13,V14), notSuper(V15), extendsWildcard(V15), type(V15,V16,V17), fun22(notSuper(V15),extendsWildcard(V15),type(V15,V16,V17),greaterGen(V1,V2),greaterGen(V1,V2),type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V7,V8),fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V7,V8),greaterGen(V1,V2)),param(V1,V15,V13),pi(V7,V8,V13,V14)).
extendsWildcard(pointer(greaterGen(V1,V2), notSuper(V15), notExtends(V15), type(V15,V16,V17))) :- greaterGen(V1,V2), greaterGen(V1,V2), type(V1,V10,V11), type(V7,V10,V11), type(V8,V9,V12), smaller(V7,V8), fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V7,V8),greaterGen(V1,V2)), param(V1,V15,V13), pi(V7,V8,V13,V14), greaterGen(V1,V2), greaterGen(V1,V2), type(V1,V10,V11), type(V7,V10,V11), type(V8,V9,V12), smaller(V7,V8), fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V7,V8),greaterGen(V1,V2)), param(V1,V15,V13), pi(V7,V8,V13,V14), notSuper(V15), notExtends(V15), type(V15,V16,V17), fun23(notSuper(V15),notExtends(V15),type(V15,V16,V17),greaterGen(V1,V2),greaterGen(V1,V2),type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V7,V8),fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V7,V8),greaterGen(V1,V2)),param(V1,V15,V13),pi(V7,V8,V13,V14)).
param(V2,pointer(greaterGen(V1,V2), notSuper(V15), notExtends(V15), type(V15,V16,V17)),V14) :- greaterGen(V1,V2), greaterGen(V1,V2), type(V1,V10,V11), type(V7,V10,V11), type(V8,V9,V12), smaller(V7,V8), fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V7,V8),greaterGen(V1,V2)), param(V1,V15,V13), pi(V7,V8,V13,V14), greaterGen(V1,V2), greaterGen(V1,V2), type(V1,V10,V11), type(V7,V10,V11), type(V8,V9,V12), smaller(V7,V8), fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V7,V8),greaterGen(V1,V2)), param(V1,V15,V13), pi(V7,V8,V13,V14), notSuper(V15), notExtends(V15), type(V15,V16,V17), fun23(notSuper(V15),notExtends(V15),type(V15,V16,V17),greaterGen(V1,V2),greaterGen(V1,V2),type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V7,V8),fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V7,V8),greaterGen(V1,V2)),param(V1,V15,V13),pi(V7,V8,V13,V14)).
greaterGen(V15,pointer(greaterGen(V1,V2), notSuper(V15), notExtends(V15), type(V15,V16,V17))) :- greaterGen(V1,V2), greaterGen(V1,V2), type(V1,V10,V11), type(V7,V10,V11), type(V8,V9,V12), smaller(V7,V8), fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V7,V8),greaterGen(V1,V2)), param(V1,V15,V13), pi(V7,V8,V13,V14), greaterGen(V1,V2), greaterGen(V1,V2), type(V1,V10,V11), type(V7,V10,V11), type(V8,V9,V12), smaller(V7,V8), fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V7,V8),greaterGen(V1,V2)), param(V1,V15,V13), pi(V7,V8,V13,V14), notSuper(V15), notExtends(V15), type(V15,V16,V17), fun23(notSuper(V15),notExtends(V15),type(V15,V16,V17),greaterGen(V1,V2),greaterGen(V1,V2),type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V7,V8),fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V7,V8),greaterGen(V1,V2)),param(V1,V15,V13),pi(V7,V8,V13,V14)).
extendsWildcard(pointer(greaterGen(V1,V2), notSuper(V15), notExtends(V15), type(V15,V16,V17))) :- greaterGen(V1,V2), greaterGen(V1,V2), type(V1,V10,V11), type(V7,V10,V11), type(V8,V9,V12), smaller(V7,V8), fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V7,V8),greaterGen(V1,V2)), param(V1,V15,V13), pi(V7,V8,V13,V14), greaterGen(V1,V2), greaterGen(V1,V2), type(V1,V10,V11), type(V7,V10,V11), type(V8,V9,V12), smaller(V7,V8), fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V7,V8),greaterGen(V1,V2)), param(V1,V15,V13), pi(V7,V8,V13,V14), superWildcard(V15), notExtends(V15), type(V15,V16,V17), fun24(superWildcard(V15),notExtends(V15),type(V15,V16,V17),greaterGen(V1,V2),greaterGen(V1,V2),type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V7,V8),fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V7,V8),greaterGen(V1,V2)),param(V1,V15,V13),pi(V7,V8,V13,V14)).
param(V2,pointer(greaterGen(V1,V2), notSuper(V15), notExtends(V15), type(V15,V16,V17)),V14) :- greaterGen(V1,V2), greaterGen(V1,V2), type(V1,V10,V11), type(V7,V10,V11), type(V8,V9,V12), smaller(V7,V8), fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V7,V8),greaterGen(V1,V2)), param(V1,V15,V13), pi(V7,V8,V13,V14), greaterGen(V1,V2), greaterGen(V1,V2), type(V1,V10,V11), type(V7,V10,V11), type(V8,V9,V12), smaller(V7,V8), fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V7,V8),greaterGen(V1,V2)), param(V1,V15,V13), pi(V7,V8,V13,V14), superWildcard(V15), notExtends(V15), type(V15,V16,V17), fun24(superWildcard(V15),notExtends(V15),type(V15,V16,V17),greaterGen(V1,V2),greaterGen(V1,V2),type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V7,V8),fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V7,V8),greaterGen(V1,V2)),param(V1,V15,V13),pi(V7,V8,V13,V14)).
greaterGen(V15,pointer(greaterGen(V1,V2), notSuper(V15), notExtends(V15), type(V15,V16,V17))) :- greaterGen(V1,V2), greaterGen(V1,V2), type(V1,V10,V11), type(V7,V10,V11), type(V8,V9,V12), smaller(V7,V8), fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V7,V8),greaterGen(V1,V2)), param(V1,V15,V13), pi(V7,V8,V13,V14), greaterGen(V1,V2), greaterGen(V1,V2), type(V1,V10,V11), type(V7,V10,V11), type(V8,V9,V12), smaller(V7,V8), fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V7,V8),greaterGen(V1,V2)), param(V1,V15,V13), pi(V7,V8,V13,V14), superWildcard(V15), notExtends(V15), type(V15,V16,V17), fun24(superWildcard(V15),notExtends(V15),type(V15,V16,V17),greaterGen(V1,V2),greaterGen(V1,V2),type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V7,V8),fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V7,V8),greaterGen(V1,V2)),param(V1,V15,V13),pi(V7,V8,V13,V14)).
type(V2,V9,V12) :- greaterGen(V1,V2), greaterGen(V1,V2), type(V1,V10,V11), type(V7,V10,V11), type(V8,V9,V12), smaller(V7,V8), fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V7,V8),greaterGen(V1,V2)).

4
asp/pi.pl Normal file
View File

@ -0,0 +1,4 @@
pi(V1,V2,V4,V5) :- typeVar(V3), param(V1,V3,V4), param(V2,V3,V5), type(V1,V10,V8), param(V1,V9,V7), typeVar(V9), V7 = 1 .. V8, type(V2,V14,V12), param(V2,V13,V11), typeVar(V13), V11 = 1 .. V12.
notSuper(V1) :- type(V1,_,_), not superWildcard(V1).
notExtends(V1) :- type(V1,_,_), not extendsWildcard(V1).

44
asp/reduceRules.lp Normal file
View File

@ -0,0 +1,44 @@
%%%%%%%%%%%%%%%%%%%%
% reduce1
%%%%%%%%%%%%%%%%%%%%
smallerDotWC(CP, DP)
:- smallerDot(C, D), type(C, CN, NP), type(D, DN, NP)
, type(CFC, CN, NP), type(DFC, DN, NP), smaller(CFC, DFC)
, pi(CFC, DFC, N, N2)
, param(C, CP, N), param(D, DP, N2), N = 1 .. NP
.
%%%%%%%%%%%%%%%%%%%%
% reduceExt
%%%%%%%%%%%%%%%%%%%%
%TODO
%smallerDotWC(CP, DP)
%:- smallerDotWC(C, D), type(C, CN, NP), type(D, DN, NP)
%, type(CFC, CN, NP), type(DFC, DN, NP), smaller(CFC, DFC)
%, pi(CFC, DFC, N, N2)
%, param(C, CP, N), param(D, DP, N2), N = 1 .. NP
%.
%%%%%%%%%%%%%%%%%%%%
% reduceEq
%%%%%%%%%%%%%%%%%%%%
equals(CP, DP)
:- smallerDot(C, D), type(C, CN, NP), type(D, CN, NP)
, param(C, CP, N), param(D, DP, N), N = 1 .. NP
.
%%%%%%%%%%%%%%%%%%%%
% reduce2
%%%%%%%%%%%%%%%%%%%%
equals(P1, P2) :- equals(C, D), type(C, CN, NP), type(D, CN, NP)
, param(C, P1, N), param(D, P2, N)
.
%%%%%%%%%%%%%%%%%%%%
% swap
%%%%%%%%%%%%%%%%%%%%
equals(A, B) :- equals(B, A), typeVar(A), not typeVar(B).

1
asp/result.lp Normal file
View File

@ -0,0 +1 @@
:- equals(A, B), equals(A, C), type(B,BN,_), type(C,CN,_), CN != BN.

291
asp/rule5.test Normal file
View File

@ -0,0 +1,291 @@
param(cEPQ,cAEG,1).
param(cEQX,cAEG,1).
param(cEQE,cAEG,1).
typeVar(cBFS).
type(cEON,cjava_DOT_io_DOT_Serializable,0).
constraint(cESK,list(equals(cESN,cM),list(smallerDot(cL,cESM),list(smallerDot(cESL,cQC),null)))).
type(cESM,cjava_DOT_util_DOT_ArrayList,1).
param(cERA,cDKY,1).
param(cEQM,cDKY,1).
type(cEQE,cjava_DOT_util_DOT_List,1).
type(cEQI,cjava_DOT_util_DOT_Collection,1).
type(cEPS,cjava_DOT_util_DOT_AbstractList,1).
param(cEQD,cBFS,1).
type(cEPQ,cjava_DOT_lang_DOT_Iterable,1).
type(cEOM,cjava_DOT_util_DOT_ArrayList,1).
smaller(cEOW,cEOX).
type(cEPV,cjava_DOT_lang_DOT_Object,0).
param(cERQ,cCII,1).
param(cEPY,cDKY,1).
smaller(cEPM,cEPN).
param(cEOQ,cBFS,1).
smaller(cEQC,cEQD).
type(cERM,cjava_DOT_util_DOT_Vector,1).
param(cESJ,cQF,1).
type(cESN,cjava_DOT_lang_DOT_Boolean,0).
smaller(cEPI,cEPJ).
type(cERJ,cjava_DOT_util_DOT_Collection,1).
type(cEQA,cjava_DOT_util_DOT_ArrayList,1).
type(cEOA,cjava_DOT_util_DOT_ArrayList,1).
param(cEOT,cBFS,1).
type(cEOW,cjava_DOT_util_DOT_AbstractCollection,1).
param(cEPC,cCII,1).
type(cEQB,cjava_DOT_util_DOT_AbstractList,1).
param(cENS,cCII,1).
type(cEQS,cjava_DOT_util_DOT_Collection,1).
typeVar(cDKY).
type(cEPU,cjava_DOT_util_DOT_AbstractCollection,1).
smaller(cEQG,cEQH).
type(cEQJ,cjava_DOT_lang_DOT_Object,0).
param(cEQG,cCII,1).
param(cEPN,cCII,1).
param(cESE,cDKY,1).
param(cEQZ,cBFS,1).
type(cERK,cjava_DOT_util_DOT_Vector,1).
smaller(cEPE,cEPF).
type(cEOK,cjava_DOT_util_DOT_ArrayList,1).
typeVar(cQC).
smaller(cERE,cERF).
param(cEOA,cCII,1).
type(cEQQ,cjava_DOT_lang_DOT_Iterable,1).
smaller(cEPA,cEPB).
typeVar(cM).
smaller(cERA,cERB).
type(cEPP,cjava_DOT_lang_DOT_Object,0).
param(cEPS,cCII,1).
param(cENQ,cAEG,1).
param(cEPH,cCII,1).
smaller(cERW,cERX).
type(cEOG,cjava_DOT_util_DOT_Collection,1).
type(cERE,cjava_DOT_io_DOT_Serializable,0).
param(cERG,cDKY,1).
smaller(cERS,cERT).
param(cEOF,cBFS,1).
type(cESA,cjava_DOT_util_DOT_AbstractCollection,1).
param(cERY,cDKY,1).
typeVar(cCII).
type(cEOO,cjava_DOT_util_DOT_Collection,1).
type(cERN,cjava_DOT_lang_DOT_Cloneable,0).
param(cENO,cBFS,1).
typeVar(cAEG).
type(cERB,cjava_DOT_lang_DOT_Object,0).
typeVar(cQD).
param(cEQP,cAEG,1).
param(cEOO,cAEG,1).
type(cESF,cjava_DOT_io_DOT_Serializable,0).
param(cEPE,cBFS,1).
type(cEPG,cjava_DOT_util_DOT_ArrayList,1).
type(cEPD,cjava_DOT_util_DOT_Collection,1).
type(cERC,cjava_DOT_util_DOT_AbstractCollection,1).
type(cERQ,cjava_DOT_util_DOT_ArrayList,1).
type(cENW,cjava_DOT_lang_DOT_Iterable,1).
type(cENQ,cjava_DOT_util_DOT_ArrayList,1).
smaller(cESC,cESD).
type(cEOU,cjava_DOT_util_DOT_List,1).
smaller(cENO,cENP).
smaller(cEOE,cEOF).
smaller(cERO,cERP).
type(cEPH,cjava_DOT_util_DOT_List,1).
smaller(cESE,cESF).
param(cERO,cCII,1).
param(cEOS,cBFS,1).
type(cEQX,cjava_DOT_util_DOT_List,1).
type(cEQR,cjava_DOT_lang_DOT_Object,0).
param(cEQY,cBFS,1).
smaller(cEQW,cEQX).
smaller(cEOC,cEOD).
smaller(cERM,cERN).
param(cEPT,cCII,1).
param(cEQQ,cBFS,1).
param(cERZ,cDKY,1).
type(cENV,cjava_DOT_util_DOT_AbstractCollection,1).
type(cEOZ,cjava_DOT_lang_DOT_Object,0).
param(cEQK,cAEG,1).
type(cEQO,cjava_DOT_util_DOT_AbstractList,1).
type(cEQU,cjava_DOT_util_DOT_Vector,1).
smaller(cEOK,cEOL).
type(cEQW,cjava_DOT_util_DOT_ArrayList,1).
type(cENO,cjava_DOT_util_DOT_ArrayList,1).
type(cERF,cjava_DOT_lang_DOT_Object,0).
param(cEPA,cCII,1).
type(cERV,cjava_DOT_io_DOT_Serializable,0).
smaller(cERG,cERH).
param(cEOU,cCII,1).
param(cENU,cDKY,1).
param(cESM,cQE,1).
param(cEOP,cAEG,1).
param(cEPO,cBFS,1).
param(cEOK,cBFS,1).
constraint(cESG,list(smallerDot(cL,cESJ),list(equals(cESI,cM),list(smallerDot(cESH,cQD),null)))).
type(cEPE,cjava_DOT_util_DOT_ArrayList,1).
param(cEQF,cAEG,1).
smaller(cEPY,cEPZ).
param(cESC,cDKY,1).
param(cENY,cAEG,1).
param(cEOM,cAEG,1).
smaller(cEQO,cEQP).
type(cEOR,cjava_DOT_lang_DOT_Object,0).
type(cESC,cjava_DOT_util_DOT_List,1).
type(cEOP,cjava_DOT_lang_DOT_Iterable,1).
type(cERU,cjava_DOT_util_DOT_ArrayList,1).
type(cERY,cjava_DOT_util_DOT_AbstractCollection,1).
param(cEPL,cAEG,1).
param(cEOX,cAEG,1).
type(cEQK,cjava_DOT_util_DOT_ArrayList,1).
type(cERZ,cjava_DOT_util_DOT_Collection,1).
param(cEQA,cBFS,1).
param(cERI,cDKY,1).
smaller(cEPC,cEPD).
type(cEQT,cjava_DOT_lang_DOT_Iterable,1).
type(cERT,cjava_DOT_lang_DOT_Object,0).
type(cEOY,cjava_DOT_lang_DOT_Cloneable,0).
param(cEQU,cDKY,1).
type(cEPB,cjava_DOT_util_DOT_AbstractCollection,1).
type(cESI,cjava_DOT_lang_DOT_Boolean,0).
smaller(cENU,cENV).
type(cESE,cjava_DOT_util_DOT_Vector,1).
param(cEOG,cCII,1).
type(cEOI,cjava_DOT_util_DOT_List,1).
type(cENU,cjava_DOT_util_DOT_AbstractList,1).
smaller(cERU,cERV).
type(cEPN,cjava_DOT_util_DOT_AbstractList,1).
type(cEQV,cjava_DOT_util_DOT_List,1).
type(cEPA,cjava_DOT_util_DOT_AbstractList,1).
smaller(cEPQ,cEPR).
type(cEQL,cjava_DOT_util_DOT_AbstractList,1).
param(cEQH,cCII,1).
type(cEOL,cjava_DOT_lang_DOT_Cloneable,0).
type(cEQY,cjava_DOT_util_DOT_AbstractList,1).
type(cEOF,cjava_DOT_util_DOT_AbstractCollection,1).
param(cEQT,cBFS,1).
smaller(cEOS,cEOT).
type(cENR,cjava_DOT_lang_DOT_Cloneable,0).
type(cEQD,cjava_DOT_util_DOT_Collection,1).
type(cENZ,cjava_DOT_lang_DOT_Object,0).
param(cEPG,cCII,1).
type(cEQF,cjava_DOT_util_DOT_Collection,1).
type(cEQN,cjava_DOT_util_DOT_List,1).
type(cEQH,cjava_DOT_util_DOT_Collection,1).
smaller(cEOY,cEOZ).
type(cERR,cjava_DOT_lang_DOT_Cloneable,0).
param(cERU,cCII,1).
type(cESB,cjava_DOT_lang_DOT_Object,0).
smaller(cEPO,cEPP).
param(cEPU,cDKY,1).
param(cEQI,cDKY,1).
smaller(cEQE,cEQF).
smaller(cEQA,cEQB).
type(cEPM,cjava_DOT_util_DOT_ArrayList,1).
param(cENW,cCII,1).
param(cEOE,cBFS,1).
type(cEOX,cjava_DOT_util_DOT_Collection,1).
type(cEQG,cjava_DOT_util_DOT_List,1).
param(cERH,cDKY,1).
smaller(cEQI,cEQJ).
param(cEOC,cAEG,1).
type(cEPT,cjava_DOT_util_DOT_List,1).
type(cEOT,cjava_DOT_util_DOT_Collection,1).
type(cERP,cjava_DOT_lang_DOT_Object,0).
type(cERS,cMyVector,0).
type(cESD,cjava_DOT_lang_DOT_Object,0).
type(cEOD,cjava_DOT_util_DOT_RandomAccess,0).
smaller(cEPK,cEPL).
type(cEPK,cjava_DOT_util_DOT_AbstractList,1).
param(cERM,cDKY,1).
smaller(cEPG,cEPH).
type(cEOS,cjava_DOT_util_DOT_AbstractCollection,1).
param(cEQS,cBFS,1).
param(cEQW,cAEG,1).
type(cENY,cjava_DOT_util_DOT_Collection,1).
param(cEPW,cBFS,1).
type(cEOJ,cjava_DOT_lang_DOT_Object,0).
param(cEQC,cBFS,1).
type(cENT,cjava_DOT_lang_DOT_Iterable,1).
param(cERK,cDKY,1).
type(cEPY,cjava_DOT_util_DOT_Vector,1).
type(cEQM,cjava_DOT_util_DOT_AbstractList,1).
smaller(cENW,cENX).
smaller(cEPW,cEPX).
smaller(cEOM,cEON).
smaller(cEQM,cEQN).
smaller(cEPS,cEPT).
type(cENX,cjava_DOT_lang_DOT_Object,0).
smallerDot(cL,cK).
type(cESJ,cjava_DOT_util_DOT_Vector,1).
type(cEQC,cjava_DOT_util_DOT_List,1).
type(cEOB,cjava_DOT_util_DOT_RandomAccess,0).
smaller(cEOU,cEOV).
param(cERC,cAEG,1).
smaller(cEQU,cEQV).
type(cERG,cjava_DOT_util_DOT_Collection,1).
type(cESH,cjava_DOT_lang_DOT_Object,0).
smaller(cEOQ,cEOR).
oder(cESG,cESK).
smaller(cEQQ,cEQR).
param(cEPD,cCII,1).
type(cEPZ,cjava_DOT_util_DOT_AbstractList,1).
param(cEQL,cAEG,1).
type(cEPC,cjava_DOT_util_DOT_AbstractCollection,1).
smaller(cENS,cENT).
param(cESA,cBFS,1).
type(cERA,cjava_DOT_lang_DOT_Iterable,1).
smaller(cEQY,cEQZ).
typeVar(cQE).
type(cEOE,cjava_DOT_util_DOT_AbstractList,1).
type(cESL,cjava_DOT_lang_DOT_Object,0).
type(cERX,cjava_DOT_lang_DOT_Object,0).
type(cENP,cjava_DOT_util_DOT_List,1).
type(cEPI,cjava_DOT_util_DOT_RandomAccess,0).
typeVar(cK).
smaller(cERK,cERL).
type(cERD,cjava_DOT_lang_DOT_Object,0).
type(cERI,cjava_DOT_util_DOT_List,1).
type(cEPJ,cjava_DOT_lang_DOT_Object,0).
smaller(cESA,cESB).
type(cEOC,cjava_DOT_util_DOT_ArrayList,1).
param(cEOW,cAEG,1).
param(cERJ,cDKY,1).
param(cEQB,cBFS,1).
smaller(cEOI,cEOJ).
type(cEPL,cjava_DOT_util_DOT_AbstractCollection,1).
param(cEQO,cAEG,1).
smaller(cERI,cERJ).
typeVar(cQF).
param(cEPK,cAEG,1).
param(cENP,cBFS,1).
type(cERO,cjava_DOT_util_DOT_AbstractCollection,1).
typeVar(cL).
smaller(cEOG,cEOH).
param(cEQV,cDKY,1).
type(cERW,cjava_DOT_lang_DOT_Object,0).
type(cEQZ,cjava_DOT_util_DOT_List,1).
type(cENS,cjava_DOT_util_DOT_Collection,1).
smaller(cENY,cENZ).
param(cEOI,cAEG,1).
smaller(cEOO,cEOP).
smaller(cERY,cERZ).
param(cEPZ,cDKY,1).
param(cEQN,cDKY,1).
smaller(cEQK,cEQL).
type(cEOH,cjava_DOT_lang_DOT_Object,0).
type(cEPF,cjava_DOT_util_DOT_RandomAccess,0).
smaller(cERC,cERD).
type(cEPO,cjava_DOT_util_DOT_List,1).
type(cEPR,cjava_DOT_lang_DOT_Object,0).
type(cEQP,cjava_DOT_util_DOT_List,1).
smaller(cEQS,cEQT).
type(cERL,cjava_DOT_util_DOT_RandomAccess,0).
param(cENT,cCII,1).
type(cEOQ,cjava_DOT_util_DOT_Collection,1).
type(cEPW,cjava_DOT_util_DOT_ArrayList,1).
type(cEPX,cjava_DOT_io_DOT_Serializable,0).
smaller(cEPU,cEPV).
smaller(cEOA,cEOB).
type(cEOV,cjava_DOT_lang_DOT_Object,0).
param(cEPB,cCII,1).
smaller(cENQ,cENR).
param(cEPM,cCII,1).
smaller(cERQ,cERR).
param(cENV,cDKY,1).
type(cERH,cjava_DOT_lang_DOT_Iterable,1).

15
asp/smaller.pl Normal file
View File

@ -0,0 +1,15 @@
{ fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V8,V7),smallerGen(V1,V2)) : type(V1,V10,V11), type(V7,V10,V11), type(V8,V9,V12), smaller(V8,V7) } == 1 :- smallerGen(V1,V2).
{ fun19(typeVar(V15),smallerGen(V1,V2),smallerGen(V1,V2),type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V8,V7),fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V8,V7),smallerGen(V1,V2)),param(V1,V15,V13),pi(V8,V7,V14,V13)) : typeVar(V15) ; fun20(notSuper(V15),notExtends(V15),type(V15,V16,V17),smallerGen(V1,V2),smallerGen(V1,V2),type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V8,V7),fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V8,V7),smallerGen(V1,V2)),param(V1,V15,V13),pi(V8,V7,V14,V13)) : notSuper(V15), notExtends(V15), type(V15,V16,V17) ; fun21(superWildcard(V15),notExtends(V15),type(V15,V16,V17),smallerGen(V1,V2),smallerGen(V1,V2),type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V8,V7),fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V8,V7),smallerGen(V1,V2)),param(V1,V15,V13),pi(V8,V7,V14,V13)) : superWildcard(V15), notExtends(V15), type(V15,V16,V17) ; fun22(superWildcard(V15),notExtends(V15),type(V15,V16,V17),smallerGen(V1,V2),smallerGen(V1,V2),type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V8,V7),fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V8,V7),smallerGen(V1,V2)),param(V1,V15,V13),pi(V8,V7,V14,V13)) : superWildcard(V15), notExtends(V15), type(V15,V16,V17) ; fun23(notSuper(V15),extendsWildcard(V15),type(V15,V16,V17),smallerGen(V1,V2),smallerGen(V1,V2),type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V8,V7),fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V8,V7),smallerGen(V1,V2)),param(V1,V15,V13),pi(V8,V7,V14,V13)) : notSuper(V15), extendsWildcard(V15), type(V15,V16,V17) ; fun24(notSuper(V15),extendsWildcard(V15),type(V15,V16,V17),smallerGen(V1,V2),smallerGen(V1,V2),type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V8,V7),fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V8,V7),smallerGen(V1,V2)),param(V1,V15,V13),pi(V8,V7,V14,V13)) : notSuper(V15), extendsWildcard(V15), type(V15,V16,V17) } == 1 :- smallerGen(V1,V2), smallerGen(V1,V2), type(V1,V10,V11), type(V7,V10,V11), type(V8,V9,V12), smaller(V8,V7), fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V8,V7),smallerGen(V1,V2)), param(V1,V15,V13), pi(V8,V7,V14,V13).
param(V2,V15,V14) :- smallerGen(V1,V2), smallerGen(V1,V2), type(V1,V10,V11), type(V7,V10,V11), type(V8,V9,V12), smaller(V8,V7), fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V8,V7),smallerGen(V1,V2)), param(V1,V15,V13), pi(V8,V7,V14,V13), smallerGen(V1,V2), smallerGen(V1,V2), type(V1,V10,V11), type(V7,V10,V11), type(V8,V9,V12), smaller(V8,V7), fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V8,V7),smallerGen(V1,V2)), param(V1,V15,V13), pi(V8,V7,V14,V13), typeVar(V15), fun19(typeVar(V15),smallerGen(V1,V2),smallerGen(V1,V2),type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V8,V7),fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V8,V7),smallerGen(V1,V2)),param(V1,V15,V13),pi(V8,V7,V14,V13)).
param(V2,V15,V14) :- smallerGen(V1,V2), smallerGen(V1,V2), type(V1,V10,V11), type(V7,V10,V11), type(V8,V9,V12), smaller(V8,V7), fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V8,V7),smallerGen(V1,V2)), param(V1,V15,V13), pi(V8,V7,V14,V13), smallerGen(V1,V2), smallerGen(V1,V2), type(V1,V10,V11), type(V7,V10,V11), type(V8,V9,V12), smaller(V8,V7), fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V8,V7),smallerGen(V1,V2)), param(V1,V15,V13), pi(V8,V7,V14,V13), notSuper(V15), notExtends(V15), type(V15,V16,V17), fun20(notSuper(V15),notExtends(V15),type(V15,V16,V17),smallerGen(V1,V2),smallerGen(V1,V2),type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V8,V7),fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V8,V7),smallerGen(V1,V2)),param(V1,V15,V13),pi(V8,V7,V14,V13)).
param(V2,pointer(smallerGen(V1,V2), notSuper(V15), notExtends(V15), type(V15,V16,V17)),V14) :- smallerGen(V1,V2), smallerGen(V1,V2), type(V1,V10,V11), type(V7,V10,V11), type(V8,V9,V12), smaller(V8,V7), fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V8,V7),smallerGen(V1,V2)), param(V1,V15,V13), pi(V8,V7,V14,V13), smallerGen(V1,V2), smallerGen(V1,V2), type(V1,V10,V11), type(V7,V10,V11), type(V8,V9,V12), smaller(V8,V7), fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V8,V7),smallerGen(V1,V2)), param(V1,V15,V13), pi(V8,V7,V14,V13), superWildcard(V15), notExtends(V15), type(V15,V16,V17), fun21(superWildcard(V15),notExtends(V15),type(V15,V16,V17),smallerGen(V1,V2),smallerGen(V1,V2),type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V8,V7),fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V8,V7),smallerGen(V1,V2)),param(V1,V15,V13),pi(V8,V7,V14,V13)).
greaterGen(V15,pointer(smallerGen(V1,V2), notSuper(V15), notExtends(V15), type(V15,V16,V17))) :- smallerGen(V1,V2), smallerGen(V1,V2), type(V1,V10,V11), type(V7,V10,V11), type(V8,V9,V12), smaller(V8,V7), fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V8,V7),smallerGen(V1,V2)), param(V1,V15,V13), pi(V8,V7,V14,V13), smallerGen(V1,V2), smallerGen(V1,V2), type(V1,V10,V11), type(V7,V10,V11), type(V8,V9,V12), smaller(V8,V7), fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V8,V7),smallerGen(V1,V2)), param(V1,V15,V13), pi(V8,V7,V14,V13), superWildcard(V15), notExtends(V15), type(V15,V16,V17), fun21(superWildcard(V15),notExtends(V15),type(V15,V16,V17),smallerGen(V1,V2),smallerGen(V1,V2),type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V8,V7),fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V8,V7),smallerGen(V1,V2)),param(V1,V15,V13),pi(V8,V7,V14,V13)).
superWildcard(pointer(smallerGen(V1,V2), notSuper(V15), notExtends(V15), type(V15,V16,V17))) :- smallerGen(V1,V2), smallerGen(V1,V2), type(V1,V10,V11), type(V7,V10,V11), type(V8,V9,V12), smaller(V8,V7), fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V8,V7),smallerGen(V1,V2)), param(V1,V15,V13), pi(V8,V7,V14,V13), smallerGen(V1,V2), smallerGen(V1,V2), type(V1,V10,V11), type(V7,V10,V11), type(V8,V9,V12), smaller(V8,V7), fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V8,V7),smallerGen(V1,V2)), param(V1,V15,V13), pi(V8,V7,V14,V13), superWildcard(V15), notExtends(V15), type(V15,V16,V17), fun22(superWildcard(V15),notExtends(V15),type(V15,V16,V17),smallerGen(V1,V2),smallerGen(V1,V2),type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V8,V7),fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V8,V7),smallerGen(V1,V2)),param(V1,V15,V13),pi(V8,V7,V14,V13)).
param(V2,pointer(smallerGen(V1,V2), notSuper(V15), notExtends(V15), type(V15,V16,V17)),V14) :- smallerGen(V1,V2), smallerGen(V1,V2), type(V1,V10,V11), type(V7,V10,V11), type(V8,V9,V12), smaller(V8,V7), fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V8,V7),smallerGen(V1,V2)), param(V1,V15,V13), pi(V8,V7,V14,V13), smallerGen(V1,V2), smallerGen(V1,V2), type(V1,V10,V11), type(V7,V10,V11), type(V8,V9,V12), smaller(V8,V7), fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V8,V7),smallerGen(V1,V2)), param(V1,V15,V13), pi(V8,V7,V14,V13), superWildcard(V15), notExtends(V15), type(V15,V16,V17), fun22(superWildcard(V15),notExtends(V15),type(V15,V16,V17),smallerGen(V1,V2),smallerGen(V1,V2),type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V8,V7),fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V8,V7),smallerGen(V1,V2)),param(V1,V15,V13),pi(V8,V7,V14,V13)).
greaterGen(V15,pointer(smallerGen(V1,V2), notSuper(V15), notExtends(V15), type(V15,V16,V17))) :- smallerGen(V1,V2), smallerGen(V1,V2), type(V1,V10,V11), type(V7,V10,V11), type(V8,V9,V12), smaller(V8,V7), fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V8,V7),smallerGen(V1,V2)), param(V1,V15,V13), pi(V8,V7,V14,V13), smallerGen(V1,V2), smallerGen(V1,V2), type(V1,V10,V11), type(V7,V10,V11), type(V8,V9,V12), smaller(V8,V7), fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V8,V7),smallerGen(V1,V2)), param(V1,V15,V13), pi(V8,V7,V14,V13), superWildcard(V15), notExtends(V15), type(V15,V16,V17), fun22(superWildcard(V15),notExtends(V15),type(V15,V16,V17),smallerGen(V1,V2),smallerGen(V1,V2),type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V8,V7),fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V8,V7),smallerGen(V1,V2)),param(V1,V15,V13),pi(V8,V7,V14,V13)).
extendsWildcard(pointer(smallerGen(V1,V2), notSuper(V15), notExtends(V15), type(V15,V16,V17))) :- smallerGen(V1,V2), smallerGen(V1,V2), type(V1,V10,V11), type(V7,V10,V11), type(V8,V9,V12), smaller(V8,V7), fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V8,V7),smallerGen(V1,V2)), param(V1,V15,V13), pi(V8,V7,V14,V13), smallerGen(V1,V2), smallerGen(V1,V2), type(V1,V10,V11), type(V7,V10,V11), type(V8,V9,V12), smaller(V8,V7), fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V8,V7),smallerGen(V1,V2)), param(V1,V15,V13), pi(V8,V7,V14,V13), notSuper(V15), extendsWildcard(V15), type(V15,V16,V17), fun23(notSuper(V15),extendsWildcard(V15),type(V15,V16,V17),smallerGen(V1,V2),smallerGen(V1,V2),type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V8,V7),fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V8,V7),smallerGen(V1,V2)),param(V1,V15,V13),pi(V8,V7,V14,V13)).
param(V2,pointer(smallerGen(V1,V2), notSuper(V15), notExtends(V15), type(V15,V16,V17)),V14) :- smallerGen(V1,V2), smallerGen(V1,V2), type(V1,V10,V11), type(V7,V10,V11), type(V8,V9,V12), smaller(V8,V7), fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V8,V7),smallerGen(V1,V2)), param(V1,V15,V13), pi(V8,V7,V14,V13), smallerGen(V1,V2), smallerGen(V1,V2), type(V1,V10,V11), type(V7,V10,V11), type(V8,V9,V12), smaller(V8,V7), fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V8,V7),smallerGen(V1,V2)), param(V1,V15,V13), pi(V8,V7,V14,V13), notSuper(V15), extendsWildcard(V15), type(V15,V16,V17), fun23(notSuper(V15),extendsWildcard(V15),type(V15,V16,V17),smallerGen(V1,V2),smallerGen(V1,V2),type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V8,V7),fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V8,V7),smallerGen(V1,V2)),param(V1,V15,V13),pi(V8,V7,V14,V13)).
smallerGen(V15,pointer(smallerGen(V1,V2), notSuper(V15), notExtends(V15), type(V15,V16,V17))) :- smallerGen(V1,V2), smallerGen(V1,V2), type(V1,V10,V11), type(V7,V10,V11), type(V8,V9,V12), smaller(V8,V7), fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V8,V7),smallerGen(V1,V2)), param(V1,V15,V13), pi(V8,V7,V14,V13), smallerGen(V1,V2), smallerGen(V1,V2), type(V1,V10,V11), type(V7,V10,V11), type(V8,V9,V12), smaller(V8,V7), fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V8,V7),smallerGen(V1,V2)), param(V1,V15,V13), pi(V8,V7,V14,V13), notSuper(V15), extendsWildcard(V15), type(V15,V16,V17), fun23(notSuper(V15),extendsWildcard(V15),type(V15,V16,V17),smallerGen(V1,V2),smallerGen(V1,V2),type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V8,V7),fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V8,V7),smallerGen(V1,V2)),param(V1,V15,V13),pi(V8,V7,V14,V13)).
param(V2,pointer(smallerGen(V1,V2), notSuper(V15), notExtends(V15), type(V15,V16,V17)),V14) :- smallerGen(V1,V2), smallerGen(V1,V2), type(V1,V10,V11), type(V7,V10,V11), type(V8,V9,V12), smaller(V8,V7), fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V8,V7),smallerGen(V1,V2)), param(V1,V15,V13), pi(V8,V7,V14,V13), smallerGen(V1,V2), smallerGen(V1,V2), type(V1,V10,V11), type(V7,V10,V11), type(V8,V9,V12), smaller(V8,V7), fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V8,V7),smallerGen(V1,V2)), param(V1,V15,V13), pi(V8,V7,V14,V13), notSuper(V15), extendsWildcard(V15), type(V15,V16,V17), fun24(notSuper(V15),extendsWildcard(V15),type(V15,V16,V17),smallerGen(V1,V2),smallerGen(V1,V2),type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V8,V7),fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V8,V7),smallerGen(V1,V2)),param(V1,V15,V13),pi(V8,V7,V14,V13)).
smallerGen(V15,pointer(smallerGen(V1,V2), notSuper(V15), notExtends(V15), type(V15,V16,V17))) :- smallerGen(V1,V2), smallerGen(V1,V2), type(V1,V10,V11), type(V7,V10,V11), type(V8,V9,V12), smaller(V8,V7), fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V8,V7),smallerGen(V1,V2)), param(V1,V15,V13), pi(V8,V7,V14,V13), smallerGen(V1,V2), smallerGen(V1,V2), type(V1,V10,V11), type(V7,V10,V11), type(V8,V9,V12), smaller(V8,V7), fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V8,V7),smallerGen(V1,V2)), param(V1,V15,V13), pi(V8,V7,V14,V13), notSuper(V15), extendsWildcard(V15), type(V15,V16,V17), fun24(notSuper(V15),extendsWildcard(V15),type(V15,V16,V17),smallerGen(V1,V2),smallerGen(V1,V2),type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V8,V7),fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V8,V7),smallerGen(V1,V2)),param(V1,V15,V13),pi(V8,V7,V14,V13)).
type(V2,V9,V12) :- smallerGen(V1,V2), smallerGen(V1,V2), type(V1,V10,V11), type(V7,V10,V11), type(V8,V9,V12), smaller(V8,V7), fun18(type(V1,V10,V11),type(V7,V10,V11),type(V8,V9,V12),smaller(V8,V7),smallerGen(V1,V2)).

116
asp/step4.lp Normal file
View File

@ -0,0 +1,116 @@
wildcard(A) :- superWildcard(A).
wildcard(A) :- extendsWildcard(A).
%Problem hier: Es gibt in der FiniteClosure nun smaller Beziehungen der Art:
%%(Matrix<A> <) Vector<Vector<A>> < List<Vector<A>>
%Mit diesen funktioniert die Unifikation in Schritt 4 des Algorithmus nicht korrekt.
%Lösung: Man könnte es lösen mit:
%typeVarOnly(TP) :- type(TP, _, PN), {notTypeVarOnly(TP, A) : param(TP, A, _), type(A, _, _)} == 0.
% Die Karthesischen Produkte von Schritt 4 des Unifikationsalgorithmus
{ makeRule1(A,TP,TPFC, SmallerType) : smaller(SmallerType, TPFC), type(TPFC, TypeName, NumParams) } = 1
:- smallerDot(A, TP), type(TP, TypeName, NumParams), typeVar(A).%, smaller(_, TPFC), type(TPFC, TypeName, NumParams).
%:- makeRule1(A, B, C,_), makeRule1(A,B,D,_), D != C.
%Alle Greater Arg Paralisten des Typen C generieren
greaterArgParaList(pointer(rule1(A, TP)), TPFC) :- makeRule1(A,TP,TPFC,_).
%Es braucht greaterArg Parameter von allen Parametern des Typs:
greaterArg(pointer(P, Param), Param) :- greaterArgParaList(P, FCType), type(FCType, FCTName, FCTPN), param(FCType, Param, Num), not typeVar(Param).
%Ein neuer Typ muss angelegt werden:
type(P, FCTName, FCTPN)
:- greaterArgParaList(P, FCType), type(FCType, FCTName, FCTPN).
param(P, pointer(P, Param), N)
:- greaterArgParaList(P, FCType), type(FCType, FCTName, FCTPN)
, param(FCType, Param, N), not typeVar(Param)
.
%Typvariablen bleiben bestehen. Sie werden durch das unify ausgetauscht
param(P, Param, N)
:- greaterArgParaList(P, FCType), type(FCType, FCTName, FCTPN)
, param(FCType, Param, N), typeVar(Param)
.
%Die Unifikation vom AusgangsTyp im Constraint und dem greaterArgList gebildeten Typen
unify(pointer(rule1unify(A,TP)), pointer(rule1(A,TP)), TP)
:- makeRule1(A,TP,TPFC, _).
%Unify auf den SmallerType anwenden:
type(pointer(rule1unify(A,TP,TPFC,SmallerType)), TN, TNum)
:- makeRule1(A, TP, TPFC, SmallerType), type(SmallerType, TN, TNum).
{ param(pointer(rule1unify(A,TP,TPFC,SmallerType)), PNew, PN) : unify(pointer(rule1unify(A,TP)), P, PNew)} == 1
:- makeRule1(A, TP, TPFC, SmallerType), param(SmallerType, P, PN).
%Am Schluss davon noch das smaller bilden:
smallerGen(pointer(smallerDot(A,TP), SmallerType), pointer(rule1unify(A,TP,TPFC,SmallerType)))
:- makeRule1(A, TP, TPFC, SmallerType), type(TP, TypeName, NumParams) %Die Bedingung für Regel 1
.
smallerGen(A) :- list(smallerGen(A),_).
type(A,B,C) :- list(type(A,B,C),_).
list(A,B) :- list(_, list(A,B)).
smallerGen(A,A) :- smallerGen(A).
{ equals(A, NewType) : smallerGen(pointer(smallerDot(A,TP), SmallerType), NewType) } == 1
:- smallerDot(A, TP), type(TP, TypeName, NumParams), typeVar(A) %Das karthesische Produkt
, smaller(SmallerType, TPFC), type(pointer(smallerDot(A,TP), SmallerType), _, _)
.
%TODO: Typen welche durch Unifikation ersetzt werden auch zu Constraints machen
%%%%%%%%%%%%%%%%%%
% Regel 2
%%%%%%%%%%%%%%%%%
%{ makeRule2(A, Theta', TPFC) : smaller(SmallerType, TPFC), type(TPFC, TypeName, NumParams) } == 1
%:- smallerDotWC(A, Theta'), extendsWildcard(Theta'), typeVar(A).
%
%%Alle Greater Arg Paralisten des Typen C generieren
%greaterArgParaList(pointer(rule2(A, TP)), TPFC) :- makeRule2(A,TP,TPFC,_).
%
%unify(pointer(rule2(A,TP)), TP)
%:- makeRule2(A,TP,TPFC)
%% , type(TP, TypeName, NumParams), typeVar(A), type(TPFC, TypeName, NumParams)
%.
%
%{ list(smallerArgGen(pointer(smallerDot(A,TP), SmallerType), SmallerType),
%list(extendsWildcard(pointer(smallerDot(A,TP), SmallerType)), null))
%: smaller(SmallerType, TPFC), type(SmallerType, SmallerName, SmallerPNum) } == 1
%:- makeRule2(A, TP, TPFC) %Die Bedingung für Regel 2
%.
%
%smallerArgGen(A, B) :- list(smallerArgGen(A, B), _).
%extendsWildcard(A) :- list(extendsWildcard(A), _).
%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Regel 3
%%%%%%%%%%%%%%%%%%%%%%%%%%%
smallerArgGen(pointer(smallerDotWC(A, Theta')), Theta') :- smallerDotWC(A, Theta'), superWildcard(Theta').
equals(A, pointer(smallerDotWC(A, Theta'))) :- smallerDotWC(A, Theta'), superWildcard(Theta').
%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Regel 4
%%%%%%%%%%%%%%%%%%%%%%%%%%%
equals(A, Theta') :- smallerDotWC(A, Theta'), not wildcard(Theta').
%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Regel 5
%%%%%%%%%%%%%%%%%%%%%%%%%%%
greaterGen(pointer(smallerDot(Theta,A)), Theta) :- smallerDot(Theta, A), not wildcard(Theta), not typeVar(Theta), typeVar(A) .
equals(A, pointer(smallerDot(Theta,A))) :- smallerDot(Theta, A), not wildcard(Theta) , not typeVar(Theta), typeVar(A) .
%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Regel 6
%%%%%%%%%%%%%%%%%%%%%%%%%%%
greaterArgGen(pointer(smallerDotWC(Theta,A)), Theta) :- smallerDotWC(Theta, A), extendsWildcard(Theta) .
equals(A, pointer(smallerDot(Theta,A))) :- smallerDotWC(Theta, A), extendsWildcard(Theta) .
%TODO: Regel 7

8
asp/step4.test Normal file
View File

@ -0,0 +1,8 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Regel 5
%%%%%%%%%%%%%%%%%%%%%%%%%%%
greaterGen(pointer(smallerDot(Theta,A)), Theta) :- smallerDot(Theta, A), not wildcard(Theta), not typeVar(Theta), typeVar(A) .
equals(A, pointer(smallerDot(Theta,A))) :- smallerDot(Theta, A), not wildcard(Theta) , not typeVar(Theta), typeVar(A) .

14
asp/subst.lp Normal file
View File

@ -0,0 +1,14 @@
subst(TV,T) :- equals(TV, T), not occurs(TV, T), not typeVar(T), typeVar(TV).
equals(A, pointer(TP, subst(TV, T)))
:- equals(A, TP), subst(TV, T), not typeVar(TP), occurs(TV, TP).
type(pointer(TP, subst(TV, T)), Name, Num)
:- type(TP, Name, Num), subst(TV, T), occurs(TV, TP).
param(pointer(TP, subst(TV, T)), Param, PNum)
:- type(pointer(TP, subst(TV, T)), Name, Num), subst(TV, T), param(TP, Param, PNum), not occurs(TV, Param).
param(pointer(TP, subst(TV, T)), pointer(Param, subst(TV, T)), PNum)
:- type(pointer(TP, subst(TV, T)), Name, Num), subst(TV, T), param(TP, Param, PNum), occurs(TV, Param).

219
asp/testInput.lp Normal file
View File

@ -0,0 +1,219 @@
typeVar(a).
type(t1, cjava_DOT_util_DOT_Vector, 1).
param(t1, t2, 1).
type(t2, cjava_DOT_util_DOT_Vector, 1).
param(t2, b, 1).
typeVar(b).
smallerDot(a, t1).
typeFC(cBUF,cjava_DOT_util_DOT_Vector,1).
paramFC(cBQX,cAKH,1).
typeFC(cBRW,cjava_DOT_lang_DOT_Object,0).
typeFC(cBRF,cjava_DOT_util_DOT_Vector,1).
typeFC(cBTR,cjava_DOT_util_DOT_Vector,1).
paramFC(cBTZ,cAKH,1).
paramFC(cBUN,cAKH,1).
typeFC(cBRY,cjava_DOT_util_DOT_Vector,1).
paramFC(cBUE,cBUF,1).
paramFC(cBRL,cAKH,1).
smaller(cBSB,cBSE).
paramFC(cBTR,cBTS,1).
smaller(cBQJ,cBQK).
typeFC(cBQP,cjava_DOT_util_DOT_Vector,1).
typeFC(cBUA,cjava_DOT_util_DOT_Collection,1).
typeFC(cBSD,cjava_DOT_lang_DOT_Integer,0).
typeFC(cBUE,cjava_DOT_util_DOT_Collection,1).
typeFC(cBUK,cjava_DOT_util_DOT_Collection,1).
paramFC(cBTJ,cAKH,1).
typeFC(cBRZ,cjava_DOT_lang_DOT_Integer,0).
smaller(cBSF,cBSI).
typeFC(cBRT,cjava_DOT_lang_DOT_Integer,0).
paramFC(cBRX,cBRY,1).
typeFC(cBRJ,cjava_DOT_util_DOT_Vector,1).
paramFC(cBRF,cBRG,1).
typeFC(cBQN,cjava_DOT_lang_DOT_Integer,0).
smaller(cBRL,cBRM).
smaller(cBUH,cBUK).
smaller(cBTR,cBTU).
paramFC(cBUL,cBUM,1).
smaller(cBRH,cBRI).
typeFC(cBTV,cjava_DOT_util_DOT_Vector,1).
typeFC(cBSQ,cjava_DOT_lang_DOT_Object,0).
typeFC(cBUL,cjava_DOT_util_DOT_Vector,1).
typeFC(cBTX,cjava_DOT_lang_DOT_Object,0).
paramFC(cBSN,cAKH,1).
typeFC(cBTE,cjava_DOT_util_DOT_Vector,1).
paramFC(cBUC,cBUD,1).
smaller(cBST,cBSU).
paramFC(cBRI,cAKH,1).
typeFC(cBSR,cjava_DOT_lang_DOT_Iterable,1).
typeFC(cBRC,cjava_DOT_util_DOT_RandomAccess,0).
typeFC(cBTL,cjava_DOT_util_DOT_Collection,1).
typeFC(cBSF,cjava_DOT_util_DOT_AbstractList,1).
typeFC(cBSX,cjava_DOT_util_DOT_AbstractList,1).
paramFC(cBSI,cBSJ,1).
typeFC(cBTH,cjava_DOT_util_DOT_Collection,1).
paramFC(cBSV,cAKH,1).
paramFC(cBQZ,cBRA,1).
paramFC(cBQJ,cAKH,1).
smaller(cBRD,cBRE).
paramFC(cBRO,cBRP,1).
typeFC(cBSI,cjava_DOT_util_DOT_List,1).
typeFC(cBQX,cjava_DOT_util_DOT_Vector,1).
paramFC(cBUI,cBUJ,1).
paramFC(cBQO,cBQP,1).
typeFC(cBTA,cjava_DOT_util_DOT_AbstractCollection,1).
paramFC(cBRJ,cAKH,1).
paramFC(cBTV,cBTW,1).
typeFC(cBUO,cjava_DOT_lang_DOT_Object,0).
typeFC(cBSA,cjava_DOT_lang_DOT_Object,0).
smaller(cBUB,cBUE).
typeFC(cBUD,cjava_DOT_lang_DOT_Integer,0).
typeFC(cBQZ,cjava_DOT_util_DOT_Vector,1).
smaller(cBTL,cBTO).
typeFC(cBTU,cjava_DOT_util_DOT_AbstractList,1).
smaller(cBTZ,cBUA).
typeFC(cBRG,cjava_DOT_lang_DOT_Integer,0).
typeFC(cBSC,cjava_DOT_util_DOT_Vector,1).
typeFC(cBSK,cjava_DOT_lang_DOT_Integer,0).
typeFC(cBST,cjava_DOT_util_DOT_AbstractList,1).
paramFC(cBSY,cBSZ,1).
typeFC(cBTW,cjava_DOT_lang_DOT_Integer,0).
typeFC(cBQW,cjava_DOT_lang_DOT_Integer,0).
smaller(cBSP,cBSQ).
paramFC(cBSG,cBSH,1).
smaller(cBTD,cBTG).
typeFC(cBUG,cjava_DOT_lang_DOT_Integer,0).
typeFC(cBSW,cjava_DOT_lang_DOT_Object,0).
paramFC(cBTD,cBTE,1).
paramFC(cBSX,cBSY,1).
paramFC(cBQM,cBQN,1).
typeFC(cBRH,cjava_DOT_util_DOT_AbstractCollection,1).
smaller(cBSN,cBSO).
paramFC(cBQK,cAKH,1).
typeFC(cBTM,cjava_DOT_util_DOT_Vector,1).
paramFC(cBTU,cBTV,1).
typeFC(cBQM,cjava_DOT_util_DOT_Vector,1).
typeFC(cBRA,cjava_DOT_util_DOT_Vector,1).
smaller(cBSV,cBSW).
typeFC(cBSO,cjava_DOT_lang_DOT_Object,0).
typeFC(cBSZ,cjava_DOT_lang_DOT_Integer,0).
typeFC(cBQL,cjava_DOT_util_DOT_Vector,1).
paramFC(cBSL,cAKH,1).
typeFC(cBRB,cjava_DOT_lang_DOT_Integer,0).
typeFC(cBSY,cjava_DOT_util_DOT_Vector,1).
paramFC(cBUH,cBUI,1).
paramFC(cBTH,cAKH,1).
typeFC(cBTN,cjava_DOT_lang_DOT_Integer,0).
smaller(cBRJ,cBRK).
typeFC(cBRP,cjava_DOT_lang_DOT_Integer,0).
typeFC(cBUH,cjava_DOT_util_DOT_List,1).
paramFC(cBRE,cBRF,1).
typeFC(cBQR,cjava_DOT_util_DOT_Collection,1).
typeFC(cBTY,cjava_DOT_lang_DOT_Object,0).
paramFC(cBQS,cBQT,1).
typeFC(cBTI,cjava_DOT_lang_DOT_Iterable,1).
typeFC(cBUC,cjava_DOT_util_DOT_Vector,1).
paramFC(cBSB,cBSC,1).
typeFC(cBQS,cjava_DOT_util_DOT_Vector,1).
smaller(cBQR,cBQU).
paramFC(cBTE,cBTF,1).
paramFC(cBUB,cBUC,1).
typeFC(cBRO,cjava_DOT_util_DOT_Vector,1).
paramFC(cBST,cAKH,1).
typeFC(cBQO,cjava_DOT_util_DOT_List,1).
typeFC(cBRE,cjava_DOT_util_DOT_Vector,1).
typeFC(cBQY,cjava_DOT_io_DOT_Serializable,0).
typeFC(cBTQ,cjava_DOT_lang_DOT_Object,0).
smaller(cBSX,cBTA).
typeFC(cBRN,cjava_DOT_util_DOT_AbstractCollection,1).
typeVar(cAKH).
paramFC(cBRH,cAKH,1).
paramFC(cBQP,cBQQ,1).
typeFC(cBSE,cjava_DOT_io_DOT_Serializable,0).
smaller(cBTP,cBTQ).
paramFC(cBRN,cBRO,1).
typeFC(cBUI,cjava_DOT_util_DOT_Vector,1).
typeFC(cBRV,cjava_DOT_io_DOT_Serializable,0).
typeFC(cBSJ,cjava_DOT_util_DOT_Vector,1).
typeFC(cBTK,cjava_DOT_util_DOT_RandomAccess,0).
paramFC(cBSJ,cBSK,1).
typeFC(cBQK,cjava_DOT_util_DOT_AbstractList,1).
smaller(cBUN,cBUO).
typeFC(cBUB,cjava_DOT_util_DOT_AbstractCollection,1).
paramFC(cBSR,cAKH,1).
paramFC(cBSC,cBSD,1).
paramFC(cBRA,cBRB,1).
paramFC(cBRM,cAKH,1).
paramFC(cBQR,cBQS,1).
typeFC(cBSM,cjava_DOT_util_DOT_AbstractCollection,1).
smaller(cBTH,cBTI).
paramFC(cBTA,cBTB,1).
smaller(cBQL,cBQO).
typeFC(cBTB,cjava_DOT_util_DOT_Vector,1).
paramFC(cBUF,cBUG,1).
paramFC(cBQL,cBQM,1).
smaller(cBRN,cBRQ).
smaller(cBRR,cBRU).
smaller(cBQX,cBQY).
typeFC(cBRM,cjava_DOT_util_DOT_List,1).
typeFC(cBTZ,cjava_DOT_util_DOT_List,1).
paramFC(cBTL,cBTM,1).
typeFC(cBRI,cjava_DOT_util_DOT_Collection,1).
typeFC(cBRK,cjava_DOT_lang_DOT_Cloneable,0).
typeFC(cBTS,cjava_DOT_util_DOT_Vector,1).
typeFC(cBUN,cjava_DOT_util_DOT_Collection,1).
paramFC(cBRR,cBRS,1).
smaller(cBQZ,cBRC).
smaller(cBRV,cBRW).
smaller(cBSL,cBSM).
typeFC(cBSB,cjava_DOT_util_DOT_Vector,1).
typeFC(cBSN,cjava_DOT_util_DOT_AbstractCollection,1).
typeFC(cBTF,cjava_DOT_lang_DOT_Integer,0).
typeFC(cBTG,cjava_DOT_lang_DOT_Object,0).
paramFC(cBTI,cAKH,1).
typeFC(cBSH,cjava_DOT_lang_DOT_Integer,0).
paramFC(cBTM,cBTN,1).
paramFC(cBSM,cAKH,1).
typeFC(cBTD,cjava_DOT_util_DOT_List,1).
typeFC(cBTJ,cjava_DOT_util_DOT_Vector,1).
typeFC(cBQJ,cjava_DOT_util_DOT_Vector,1).
typeFC(cBQU,cjava_DOT_lang_DOT_Iterable,1).
paramFC(cBSF,cBSG,1).
typeFC(cBTC,cjava_DOT_lang_DOT_Integer,0).
paramFC(cBQU,cBQV,1).
typeFC(cBTT,cjava_DOT_lang_DOT_Integer,0).
paramFC(cBUK,cBUL,1).
paramFC(cBUA,cAKH,1).
typeFC(cBUM,cjava_DOT_lang_DOT_Integer,0).
typeFC(cBQT,cjava_DOT_lang_DOT_Integer,0).
typeFC(cBSL,cjava_DOT_util_DOT_AbstractList,1).
smaller(cBSR,cBSS).
typeFC(cBUJ,cjava_DOT_lang_DOT_Integer,0).
typeFC(cBQQ,cjava_DOT_lang_DOT_Integer,0).
typeFC(cBRD,casp_DOT_UnifyWithoutWildcards_DOLLAR_MatrixTest,0).
paramFC(cBSU,cAKH,1).
typeFC(cBSU,cjava_DOT_util_DOT_List,1).
typeFC(cBTP,cjava_DOT_util_DOT_RandomAccess,0).
typeFC(cBRQ,cjava_DOT_lang_DOT_Object,0).
typeFC(cBRX,cjava_DOT_lang_DOT_Iterable,1).
typeFC(cBQV,cjava_DOT_util_DOT_Vector,1).
typeFC(cBSG,cjava_DOT_util_DOT_Vector,1).
paramFC(cBRY,cBRZ,1).
typeFC(cBSV,cjava_DOT_util_DOT_List,1).
smaller(cBRX,cBSA).
typeFC(cBRS,cjava_DOT_util_DOT_Vector,1).
typeFC(cBRL,cjava_DOT_util_DOT_Vector,1).
typeFC(cBRR,cjava_DOT_util_DOT_Vector,1).
smaller(cBTJ,cBTK).
typeFC(cBRU,cjava_DOT_lang_DOT_Cloneable,0).
paramFC(cBRS,cBRT,1).
paramFC(cBTB,cBTC,1).
paramFC(cBTS,cBTT,1).
typeFC(cBSP,cjava_DOT_lang_DOT_Cloneable,0).
smaller(cBTX,cBTY).
paramFC(cBQV,cBQW,1).
typeFC(cBSS,cjava_DOT_lang_DOT_Object,0).
typeFC(cBTO,cjava_DOT_lang_DOT_Object,0).

28
asp/testReduce.lp Normal file
View File

@ -0,0 +1,28 @@
equals(t1, t2). % Map<Object, Integer> =. Map<Integer, Object>
%smallerDot(t2, t1).
type(t1, cMap, 2).
type(t2, cMap, 2).
%type(t2, cHashMap, 2).
param(t1, t3, 1).
param(t1, t4, 2).
param(t2, t6, 1).
param(t2, t5, 2).
type(t3, cObject, 0).
type(t5, cInteger, 0).
typeVar(t4).
typeVar(t6).
type(tfc1, cMap, 2).
type(tfc2, cHashMap, 2).
param(tfc1, gA, 1).
param(tfc1, gB, 2).
param(tfc2, gB, 1).
param(tfc2, gA, 2).
typeVar(gA).
typeVar(gB).
smaller(tfc2, tfc1).
smaller(tfc1, tfc1).
#show equals/2.

12
asp/testUnifikation.lp Normal file
View File

@ -0,0 +1,12 @@
type(t1, cjava_DOT_util_DOT_Vector, 1).
param(t1, t2, 1).
type(t2, cjava_DOT_util_DOT_Vector, 1).
param(t2, b, 1).
typeVar(b).
type(t3, cjava_DOT_util_DOT_Vector, 1).
param(t3, a, 1).
typeVar(a).
unify(p, t1, t3).
#show unify/3.

23
asp/unifikation.lp Normal file
View File

@ -0,0 +1,23 @@
%reduce:
unify(Pointer, Param1, Param2)
:- unify(Pointer, T1, T2), type(T1, TName, Num), type(T2, TName, Num)
, param(T1, Param1, PNum), param(T2, Param2, PNum)
.
%Ich lasse das Subst hier aus. Vector Beispiel funktioniert womöglich auch ohne
%swap:
unify(Pointer, B, A) :- unify(Pointer, A, B).
%Subst neu implementieren.
%Subst muss von hinten nach vorne durchgehen.
%Mit occurs kann man prüfen, welche unify(P, A, B) ausgetauscht werden müssen
%Diese Fälle dürfen nicht auftreten:
%TODO (möglicherweise braucht man sie nicht; Die Unifikation geht hier nie schief)
%Occurs Regeln:
occurs(A, A) :- typeVar(A).
occurs(A, T) :- type(T, _,_), param(T, B, _), occurs(A, B).

40
asp/unifikation.lp.backup Normal file
View File

@ -0,0 +1,40 @@
%reduce:
unify(Pointer, Param1, Param2)
:- unify(Pointer, T1, T2), type(T1, TName, Num), type(T2, TName, Num)
, param(T1, Param1, PNum), param(T2, Param2, PNum)
.
%swap:
unify(Pointer, B, A) :- unify(Pointer, A, B).
%subst:
%Neuen Typ erstellen, in diesem werden dann die TPHs ersetzt:
type(pointer(unify(Pointer, A, B, E)), Name, Num)
:- unify(Pointer, A, B), typeVar(A), not occurs(A, B), type(E, Name, Num)
,param(E, Param, _), occurs(A, Param), Param != A.
param(pointer(unify(Pointer, A, B, E)), pointer(unify(Pointer, A, B, Param)), ParamNum)
:- unify(Pointer, A, B), typeVar(A), not occurs(A, B), type(E, Name, Num)
,param(E, Param, ParamNum), occurs(A, Param), Param != A.
param(pointer(unify(Pointer, A, B, E)), B, ParamNum)
:- unify(Pointer, A, B), typeVar(A), not occurs(A, B), type(E, Name, Num)
,param(E, A, ParamNum).
param(pointer(unify(Pointer, A, B, E)), Param, ParamNum)
:- unify(Pointer, A, B), typeVar(A), not occurs(A, B), type(E, Name, Num)
,param(E, Param, ParamNum), not occurs(A, Param).
%Subst neu implementieren.
%Subst muss von hinten nach vorne durchgehen.
%Mit occurs kann man prüfen, welche unify(P, A, B) ausgetauscht werden müssen
%Diese Fälle dürfen nicht auftreten:
%TODO (möglicherweise braucht man sie nicht; Die Unifikation geht hier nie schief)
%Occurs Regeln:
occurs(A, A) :- typeVar(A).
occurs(A, T) :- type(T, _,_), param(T, B, _), occurs(A, B).

95
asp/vectorTestInput.lp Normal file
View File

@ -0,0 +1,95 @@
%#show smallerGen/2.
%#show smallerGen/4.
typeVar(cZW).
smallerDot(cN,cK).
smaller(cBHW,cBHX).
param(cBHW,cZW,1).
type(cBHO,cjava_DOT_util_DOT_Vector,1).
smaller(cBIM,cBIN).
type(cBIQ,cjava_DOT_util_DOT_AbstractList,1).
type(cBIB,cjava_DOT_lang_DOT_Object,0).
type(cBIC,cjava_DOT_util_DOT_List,1).
type(cBHN,cjava_DOT_lang_DOT_Object,0).
param(cBHS,cZW,1).
param(cBHT,cZW,1).
param(cBHU,cZW,1).
param(cBHV,cZW,1).
smaller(cBHY,cBHZ).
type(cBIA,cjava_DOT_lang_DOT_Cloneable,0).
type(cBIV,cjava_DOT_lang_DOT_Object,0).
typeVar(cK).
smaller(cBHU,cBHV).
smallerDot(cL,cBIY).
type(cBIM,cjava_DOT_lang_DOT_Object,0).
smaller(cBIK,cBIL).
type(cBIL,cjava_DOT_lang_DOT_Object,0).
type(cBIE,cjava_DOT_util_DOT_Vector,1).
type(cBII,cjava_DOT_util_DOT_AbstractCollection,1).
param(cBIY,cLL,1).
type(cBHZ,cjava_DOT_lang_DOT_Object,0).
typeVar(cLL).
type(cBIR,cjava_DOT_util_DOT_List,1).
param(cBID,cZW,1).
type(cBHY,cMyVector,0).
smaller(cBII,cBIJ).
param(cBIF,cZW,1).
type(cBIG,cjava_DOT_util_DOT_Collection,1).
type(cBHT,cjava_DOT_util_DOT_AbstractCollection,1).
type(cBIT,cjava_DOT_util_DOT_AbstractList,1).
param(cBHQ,cZW,1).
smaller(cBIE,cBIF).
typeVar(cL).
param(cBHO,cZW,1).
type(cBHM,cjava_DOT_io_DOT_Serializable,0).
type(cBIK,cjava_DOT_util_DOT_RandomAccess,0).
type(cBIJ,cjava_DOT_lang_DOT_Object,0).
type(cBIO,cjava_DOT_util_DOT_AbstractCollection,1).
type(cBIZ,cjava_DOT_lang_DOT_Integer,0).
type(cBHX,cjava_DOT_lang_DOT_Object,0).
type(cBIS,cjava_DOT_util_DOT_Vector,1).
smaller(cBIG,cBIH).
param(cBIW,cZW,1).
smaller(cBIW,cBIX).
smaller(cBHM,cBHN).
smaller(cBIC,cBID).
type(cBHP,cjava_DOT_util_DOT_RandomAccess,0).
param(cBIS,cZW,1).
param(cBIQ,cZW,1).
param(cBIU,cZW,1).
param(cBIR,cZW,1).
param(cBIT,cZW,1).
smaller(cBHO,cBHP).
param(cBIP,cZW,1).
type(cBIH,cjava_DOT_lang_DOT_Object,0).
typeVar(cM).
type(cBIU,cjava_DOT_lang_DOT_Iterable,1).
type(cBHR,cjava_DOT_lang_DOT_Cloneable,0).
type(cBIF,cjava_DOT_util_DOT_List,1).
smaller(cBIU,cBIV).
type(cBHV,cjava_DOT_lang_DOT_Iterable,1).
smaller(cBIA,cBIB).
equals(cLL,cN).
type(cBIP,cjava_DOT_util_DOT_Collection,1).
type(cBHS,cjava_DOT_util_DOT_AbstractList,1).
type(cBIN,cjava_DOT_lang_DOT_Object,0).
smaller(cBHS,cBHT).
param(cBIE,cZW,1).
smaller(cBIS,cBIT).
param(cBIC,cZW,1).
param(cBIG,cZW,1).
param(cBII,cZW,1).
type(cBID,cjava_DOT_util_DOT_Collection,1).
param(cBIO,cZW,1).
type(cBIW,cjava_DOT_util_DOT_Vector,1).
smallerDot(cM,cBIZ).
smaller(cBIO,cBIP).
type(cBIY,cjava_DOT_util_DOT_Vector,1).
typeVar(cN).
type(cBHW,cjava_DOT_util_DOT_List,1).
type(cBHU,cjava_DOT_util_DOT_Collection,1).
type(cBIX,cjava_DOT_io_DOT_Serializable,0).
smaller(cBHQ,cBHR).
smaller(cBIQ,cBIR).
type(cBHQ,cjava_DOT_util_DOT_Vector,1).

View File

@ -0,0 +1 @@
5da32a6f73bb3ccac5dc264606071605

View File

@ -0,0 +1 @@
bcb7e8eb537f65ec0110731a924a3d4d3bba7805

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>de.dhbwstuttgart</groupId>
<artifactId>JavaTXcompiler</artifactId>
<version>0.1</version>
</project>

View File

@ -0,0 +1 @@
a909ae513fbc19ba7c25b0cbb9871db6

View File

@ -0,0 +1 @@
4863f156f9b2754ccff7128ff372a8e1e11ee0f8

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<metadata>
<groupId>de.dhbwstuttgart</groupId>
<artifactId>JavaTXcompiler</artifactId>
<versioning>
<release>0.1</release>
<versions>
<version>0.1</version>
</versions>
<lastUpdated>20180119143709</lastUpdated>
</versioning>
</metadata>

View File

@ -0,0 +1 @@
f023e768b9a1e74695541c63858fa86c

View File

@ -0,0 +1 @@
705a6736ea0a93b18743edd577dcb3c5e6dd518e

View File

@ -53,7 +53,7 @@
<build> <build>
<directory>target</directory> <directory>target</directory>
<outputDirectory>target/classes</outputDirectory> <outputDirectory>target/classes</outputDirectory>
<finalName>${artifactId}-${version}</finalName> <finalName>${project.artifactId}-${project.version}</finalName>
<testOutputDirectory>target/test-classes</testOutputDirectory> <testOutputDirectory>target/test-classes</testOutputDirectory>
<sourceDirectory>src/</sourceDirectory> <sourceDirectory>src/</sourceDirectory>
<testSourceDirectory>test/</testSourceDirectory> <testSourceDirectory>test/</testSourceDirectory>
@ -96,7 +96,8 @@
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration> <configuration>
<source>8</source> <source>8</source>
<target>8</target> <target>8</target>

View File

@ -7,12 +7,14 @@ import de.dhbwstuttgart.parser.scope.GenericsRegistry;
import de.dhbwstuttgart.parser.SyntaxTreeGenerator.SyntaxTreeGenerator; import de.dhbwstuttgart.parser.SyntaxTreeGenerator.SyntaxTreeGenerator;
import de.dhbwstuttgart.parser.antlr.Java8Parser.CompilationUnitContext; import de.dhbwstuttgart.parser.antlr.Java8Parser.CompilationUnitContext;
import de.dhbwstuttgart.parser.scope.JavaClassName; import de.dhbwstuttgart.parser.scope.JavaClassName;
import de.dhbwstuttgart.parser.scope.JavaClassRegistry; import de.dhbwstuttgart.sat.asp.ASPUnify;
import de.dhbwstuttgart.sat.asp.parser.ASPParser;
import de.dhbwstuttgart.sat.asp.writer.ASPFactory;
import de.dhbwstuttgart.syntaxtree.ClassOrInterface; import de.dhbwstuttgart.syntaxtree.ClassOrInterface;
import de.dhbwstuttgart.syntaxtree.SourceFile; import de.dhbwstuttgart.syntaxtree.SourceFile;
import de.dhbwstuttgart.syntaxtree.factory.ASTFactory; import de.dhbwstuttgart.syntaxtree.factory.ASTFactory;
import de.dhbwstuttgart.syntaxtree.factory.UnifyTypeFactory; import de.dhbwstuttgart.syntaxtree.factory.UnifyTypeFactory;
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder; import de.dhbwstuttgart.syntaxtree.type.*;
import de.dhbwstuttgart.typeinference.constraints.Constraint; import de.dhbwstuttgart.typeinference.constraints.Constraint;
import de.dhbwstuttgart.typeinference.constraints.ConstraintSet; import de.dhbwstuttgart.typeinference.constraints.ConstraintSet;
import de.dhbwstuttgart.typeinference.constraints.Pair; import de.dhbwstuttgart.typeinference.constraints.Pair;
@ -22,8 +24,7 @@ import de.dhbwstuttgart.typeinference.unify.TypeUnify;
import de.dhbwstuttgart.typeinference.unify.model.FiniteClosure; import de.dhbwstuttgart.typeinference.unify.model.FiniteClosure;
import de.dhbwstuttgart.typeinference.unify.model.UnifyPair; import de.dhbwstuttgart.typeinference.unify.model.UnifyPair;
import java.io.File; import java.io.*;
import java.io.IOException;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -130,4 +131,73 @@ public class JavaTXCompiler {
return ret; return ret;
} }
public List<ResultSet> aspTypeInference() throws ClassNotFoundException, IOException, InterruptedException {
Collection<ClassOrInterface> allClasses = new ArrayList<>();//environment.getAllAvailableClasses();
//Alle Importierten Klassen in allen geparsten Sourcefiles kommen ins FC
for(SourceFile sf : this.sourceFiles.values()) {
allClasses.addAll(getAvailableClasses(sf));
allClasses.addAll(sf.getClasses());
}
HashMap<String, ClassOrInterface> classes = new HashMap<>();
for(ClassOrInterface cl : allClasses){
classes.put(cl.getClassName().toString(), cl);
}
allClasses = classes.values();
final ConstraintSet<Pair> cons = getConstraints();
String content = "";
content = ASPFactory.generateASP(cons, allClasses);
final String tempDirectory = "/tmp/";
PrintWriter writer = new PrintWriter(tempDirectory + "test.lp", "UTF-8");
writer.println(content);
writer.close();
ASPUnify clingo = new ASPUnify(Arrays.asList(new File(tempDirectory + "test.lp")));
String result = clingo.runClingo();
//System.out.println(result);
ResultSet resultSet = ASPParser.parse(result, getInvolvedTPHS(cons));
return Arrays.asList(resultSet);
}
private static class TPHExtractor implements TypeVisitor<List<TypePlaceholder>> {
@Override
public List<TypePlaceholder> visit(RefType refType) {
ArrayList<TypePlaceholder> ret = new ArrayList<>();
for(RefTypeOrTPHOrWildcardOrGeneric param : refType.getParaList()){
ret.addAll(param.acceptTV(this));
}
return ret;
}
@Override
public List<TypePlaceholder> visit(SuperWildcardType superWildcardType) {
return superWildcardType.getInnerType().acceptTV(this);
}
@Override
public List<TypePlaceholder> visit(TypePlaceholder typePlaceholder) {
return Arrays.asList(typePlaceholder);
}
@Override
public List<TypePlaceholder> visit(ExtendsWildcardType extendsWildcardType) {
return extendsWildcardType.getInnerType().acceptTV(this);
}
@Override
public List<TypePlaceholder> visit(GenericRefType genericRefType) {
return new ArrayList<>();
}
}
protected Collection<TypePlaceholder> getInvolvedTPHS(ConstraintSet<Pair> toTest) {
List<TypePlaceholder> ret = new ArrayList<>();
toTest.map((Pair p)-> {
ret.addAll(p.TA1.acceptTV(new TPHExtractor()));
ret.addAll(p.TA2.acceptTV(new TPHExtractor()));
return p;
});
return ret;
}
} }

View File

@ -7,6 +7,8 @@ import de.dhbwstuttgart.syntaxtree.GenericTypeVar;
import de.dhbwstuttgart.syntaxtree.factory.ASTFactory; import de.dhbwstuttgart.syntaxtree.factory.ASTFactory;
import de.dhbwstuttgart.syntaxtree.factory.UnifyTypeFactory; import de.dhbwstuttgart.syntaxtree.factory.UnifyTypeFactory;
import de.dhbwstuttgart.syntaxtree.type.*; import de.dhbwstuttgart.syntaxtree.type.*;
import de.dhbwstuttgart.syntaxtree.visual.ASTPrinter;
import de.dhbwstuttgart.syntaxtree.visual.TypePrinter;
import de.dhbwstuttgart.typeinference.constraints.Pair; import de.dhbwstuttgart.typeinference.constraints.Pair;
import de.dhbwstuttgart.typeinference.unify.model.*; import de.dhbwstuttgart.typeinference.unify.model.*;
@ -24,12 +26,28 @@ public class FCGenerator {
return toFC(availableClasses).stream().map(t -> UnifyTypeFactory.convert(t)).collect(Collectors.toSet()); return toFC(availableClasses).stream().map(t -> UnifyTypeFactory.convert(t)).collect(Collectors.toSet());
} }
public static Set<Pair> toFC(Collection<ClassOrInterface> availableClasses) throws ClassNotFoundException { /*
HashSet<Pair> pairs = new HashSet<>(); Hier entstehen unnötige Typpaare
wenn es mehrere Vererbungsketten gibt
Beispiel:
* X<B,C> < Y<B,C>
* X<D,E> < Y<D,E>
Will man dies aber rausnehmen, muss man die andere Kette umbenennen.
Schwierig/Unmöglich, dank mehrfachvererbung
* Z<B,C,D,E> < X<B,C> < Y<B,C>
* Z<B,C,D,E> < X<D,E> < Y<D,E>
*/
public static Collection<Pair> toFC(Collection<ClassOrInterface> availableClasses) throws ClassNotFoundException {
HashMap<String, Pair> pairs = new HashMap<>();
TypePrinter printer = new TypePrinter();
for(ClassOrInterface cly : availableClasses){ for(ClassOrInterface cly : availableClasses){
pairs.addAll(getSuperTypes(cly, availableClasses)); for(Pair p : getSuperTypes(cly, availableClasses)){
String hash = p.TA1.acceptTV(printer)+";"+p.TA2.acceptTV(printer);
pairs.put(hash, p);
}
} }
return pairs; return pairs.values();
} }
/** /**
@ -121,6 +139,23 @@ public class FCGenerator {
return retList; return retList;
} }
/**
* Diese Klasse sorgt dafür, dass alle TPHs den selben Namen bekommen.
* Damit lassen sich unnötige Typpaare aussortieren.
* Gibt es zwei Typpaare der Form:
* X<B,C> < Y<B,C>
* X<D,E> < Y<D,E>
* so bekommen sie hier den gleichen Namen zugewiesen und werden in der HashMap aussortiert
* X<TPH,TPH> < Y<TPH,TPH>
private static class TypePrinterExcludingTPHs extends TypePrinter{
@Override
public String visit(TypePlaceholder typePlaceholder) {
return "TPH";
}
}
*/
/** /**
* Tauscht die GTVs in einem Typ gegen die entsprechenden Typen in der übergebenen Map aus. * Tauscht die GTVs in einem Typ gegen die entsprechenden Typen in der übergebenen Map aus.
*/ */

View File

@ -0,0 +1,60 @@
package de.dhbwstuttgart.sat.asp;
import org.apache.commons.io.IOUtils;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
public class ASPUnify {
private final List<File> input;
private static final List<File> programFiles = new ArrayList<>();
private static final String aspDirectory = System.getProperty("user.dir")+"/asp/";
static{
programFiles.add(new File(aspDirectory + "fc.lp"));
programFiles.add(new File(aspDirectory + "reduceRules.lp"));
programFiles.add(new File(aspDirectory + "adaptRules.lp"));
programFiles.add(new File(aspDirectory + "step4.lp"));
programFiles.add(new File(aspDirectory + "subst.lp"));
programFiles.add(new File(aspDirectory + "unifikation.lp"));
programFiles.add(new File(aspDirectory + "cartesian.lp"));
programFiles.add(new File(aspDirectory + "result.lp"));
}
public ASPUnify(List<File> inputFiles){
this.input = inputFiles;
}
/*
TODO: Clingo per Java Wrapper https://stackoverflow.com/questions/3356200/using-java-to-wrap-over-c
*/
public String runClingo() throws IOException, InterruptedException {
String pathToClingo =
"clingo";
List<String> commands = new ArrayList<>();
commands.add(pathToClingo);
//commands.add("--outf=2"); //use JSON-Output
commands.add("--outf=1"); //use Text-Output
commands.add("-n 0"); //Compute n models
for(File file : input){
commands.add(file.getPath());
}
commands.addAll(programFiles.stream().map(f->f.getPath()).collect(Collectors.toList()));
//commands.stream().forEach(s -> System.out.print(s + " "));
//System.out.println();
Process clingo = new ProcessBuilder( commands.toArray(new String[0])).start();
InputStream output = clingo.getInputStream();
clingo.waitFor();
String result = IOUtils.toString(output, StandardCharsets.UTF_8);
System.out.println(result);
return result;
}
}

View File

@ -6,7 +6,6 @@ import org.apache.commons.io.IOUtils;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -16,12 +15,7 @@ public class Clingo {
private final List<File> input; private final List<File> input;
private static final List<File> programFiles = new ArrayList<>(); private static final List<File> programFiles = new ArrayList<>();
static{ static{
programFiles.add(new File("/home/janulrich/Sync/HiwiJob/ResearchPapers/MasterarbeitStadelmeier/asp/unifyWithoutWildcards/basis.lp"));
programFiles.add(new File("/home/janulrich/Sync/HiwiJob/ResearchPapers/MasterarbeitStadelmeier/asp/unifyWithoutWildcards/finiteclosure.lp"));
programFiles.add(new File("/home/janulrich/Sync/HiwiJob/ResearchPapers/MasterarbeitStadelmeier/asp/unifyWithoutWildcards/subst.lp"));
programFiles.add(new File("/home/janulrich/Sync/HiwiJob/ResearchPapers/MasterarbeitStadelmeier/asp/unifyWithoutWildcards/reduce.lp"));
programFiles.add(new File("/home/janulrich/Sync/HiwiJob/ResearchPapers/MasterarbeitStadelmeier/asp/unifyWithoutWildcards/unify.lp"));
programFiles.add(new File("/home/janulrich/Sync/HiwiJob/ResearchPapers/MasterarbeitStadelmeier/asp/unifyWithoutWildcards/adapt.lp"));
} }
public Clingo(List<File> inputFiles){ public Clingo(List<File> inputFiles){
@ -33,11 +27,12 @@ public class Clingo {
*/ */
public String runClingo() throws IOException, InterruptedException { public String runClingo() throws IOException, InterruptedException {
String pathToClingo = String pathToClingo =
"/home/janulrich/Sync/HiwiJob/ResearchPapers/MasterarbeitStadelmeier/asp/clingo-5.2.1-linux-x86_64/clingo"; "clingo";
List<String> commands = new ArrayList<>(); List<String> commands = new ArrayList<>();
commands.add(pathToClingo); commands.add(pathToClingo);
//commands.add("--outf=2"); //use JSON-Output //commands.add("--outf=2"); //use JSON-Output
commands.add("--outf=1"); //use JSON-Output commands.add("--outf=1"); //use Text-Output
commands.add("-n 0"); //Compute all models
for(File file : input){ for(File file : input){
commands.add(file.getPath()); commands.add(file.getPath());
} }

View File

@ -1,5 +1,7 @@
package de.dhbwstuttgart.sat.asp.model; package de.dhbwstuttgart.sat.asp.model;
import de.dhbwstuttgart.typeinference.constraints.Pair;
public enum ASPGencayRule { public enum ASPGencayRule {
ASP_PAIR_EQUALS_NAME("equals"), ASP_PAIR_EQUALS_NAME("equals"),
ASP_PAIR_SMALLER_NAME("sub"), ASP_PAIR_SMALLER_NAME("sub"),
@ -7,10 +9,13 @@ public enum ASPGencayRule {
ASP_PARAMLIST_NAME("paramEq"), ASP_PARAMLIST_NAME("paramEq"),
ASP_FC_PARAMLIST_NAME("param"), ASP_FC_PARAMLIST_NAME("param"),
ASP_PARAMLIST_END_POINTER("null"), ASP_PARAMLIST_END_POINTER("null"),
ASP_PARAMLIST_END_RULE_EQ("endParamEq"),
ASP_PARAMLIST_END_RULE_FC("endParam"),
ASP_TYPE("typeEq"), ASP_TYPE("typeEq"),
ASP_FCTYPE("type"), ASP_FCTYPE("type"),
ASP_TYPE_VAR("var"), ASP_TYPE_VAR("var"),
ASP_GENERIC_VAR("pph"), ASP_GENERIC_VAR("pph"),
ASP_WILDCARD("wildcard"),
ASP_PARAMLIST_ORDER("paramOrder"); ASP_PARAMLIST_ORDER("paramOrder");
private final String text; private final String text;

View File

@ -1,14 +1,17 @@
package de.dhbwstuttgart.sat.asp.model; package de.dhbwstuttgart.sat.asp.model;
import de.dhbwstuttgart.bytecode.signature.Signature;
public enum ASPRule { public enum ASPRule {
ASP_PAIR_EQUALS_NAME("equals"), ASP_PAIR_EQUALS_NAME("equals"),
ASP_PAIR_SMALLER_NAME("smaller"), ASP_PAIR_SMALLER_NAME("smaller"),
ASP_PAIR_SMALLER_DOT_NAME("smallerDot"), ASP_PAIR_SMALLER_DOT_NAME("smallerDot"),
ASP_PARAMLIST_NAME("param"), ASP_PARAMLIST_NAME("param"),
ASP_PARAMLIST_END_POINTER("null"),
ASP_TYPE("type"), ASP_TYPE("type"),
ASP_FCTYPE("typeFC"), ASP_TYPE_VAR("typeVar"), ASP_ODER("oder"),
ASP_TYPE_VAR("typeVar"); ASP_CONSTRAINT("constraint"),
ASP_LIST_NAME("list"),
ASP_LIST_ENDPOINTER("null");
private final String text; private final String text;

View File

@ -6,23 +6,17 @@ import de.dhbwstuttgart.parser.NullToken;
import de.dhbwstuttgart.parser.scope.JavaClassName; import de.dhbwstuttgart.parser.scope.JavaClassName;
import de.dhbwstuttgart.sat.asp.ASPStringConverter; import de.dhbwstuttgart.sat.asp.ASPStringConverter;
import de.dhbwstuttgart.sat.asp.model.ASPRule; import de.dhbwstuttgart.sat.asp.model.ASPRule;
import de.dhbwstuttgart.sat.asp.parser.antlr.UnifyResultBaseListener; import de.dhbwstuttgart.sat.asp.parser.antlr.*;
import de.dhbwstuttgart.sat.asp.parser.antlr.UnifyResultLexer;
import de.dhbwstuttgart.sat.asp.parser.antlr.UnifyResultParser;
import de.dhbwstuttgart.sat.asp.parser.model.ParsedType; import de.dhbwstuttgart.sat.asp.parser.model.ParsedType;
import de.dhbwstuttgart.syntaxtree.type.*; import de.dhbwstuttgart.syntaxtree.type.*;
import de.dhbwstuttgart.typeinference.constraints.Pair;
import de.dhbwstuttgart.typeinference.result.*; import de.dhbwstuttgart.typeinference.result.*;
import de.dhbwstuttgart.typeinference.unify.model.PairOperator;
import org.antlr.v4.runtime.CharStreams; import org.antlr.v4.runtime.CharStreams;
import org.antlr.v4.runtime.CommonTokenStream; import org.antlr.v4.runtime.CommonTokenStream;
import org.antlr.v4.runtime.tree.ParseTreeWalker; import org.antlr.v4.runtime.tree.ParseTreeWalker;
import javax.json.Json;
import javax.json.JsonArray;
import javax.json.JsonObject;
import java.io.StringReader;
import java.util.*; import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@ -33,14 +27,11 @@ import java.util.stream.Collectors;
* TODO: Überlegen welche Informationen noch nach der Unifizierung gebraucht werden * TODO: Überlegen welche Informationen noch nach der Unifizierung gebraucht werden
* -> Eigentlich nur die korrekten Namen der Typen und TPHs * -> Eigentlich nur die korrekten Namen der Typen und TPHs
*/ */
public class ASPParser extends UnifyResultBaseListener { public class ASPParser extends ASPResultBaseListener {
private Collection<TypePlaceholder> originalTPHs; private Collection<TypePlaceholder> originalTPHs;
private ResultSet resultSet; private ResultSet resultSet;
private Map<String, ParsedType> types = new HashMap<>(); private Map<String, RefTypeOrTPHOrWildcardOrGeneric> types = new HashMap();
private Set<String> tphs = new HashSet<>(); private Set<String> tphs = new HashSet<>();
private Map<String, ParameterListNode> parameterLists = new HashMap<>();
private Set<Relation> equalsRelations = new HashSet<>();
private Set<Relation> smallerRelations = new HashSet<>();
/** /**
* Parst clingo output welcher als JSON (option --outf=2) ausgibt * Parst clingo output welcher als JSON (option --outf=2) ausgibt
@ -51,13 +42,6 @@ public class ASPParser extends UnifyResultBaseListener {
return new ASPParser(toParse, oldPlaceholders).resultSet; return new ASPParser(toParse, oldPlaceholders).resultSet;
} }
@Override
public void enterParameter(UnifyResultParser.ParameterContext ctx) {
//Linked List (pointer, Type, nextPointer)
List<String> params = parseParameterList(ctx.parameterList());
parameterLists.put(params.get(0), new ParameterListNode(params.get(1), params.get(2)));
}
private static class Relation { private static class Relation {
public final String right; public final String right;
public final String left; public final String left;
@ -87,60 +71,73 @@ public class ASPParser extends UnifyResultBaseListener {
).collect(Collectors.toList()); ).collect(Collectors.toList());
} }
@Override private void getTPHs(ASPResultParser.AnswerContext answer){
public void enterEquals(UnifyResultParser.EqualsContext ctx) { for(ASPResultParser.ResultSetRuleContext e : answer.resultSetRule()){
List<String> parameterList = parseParameterList(ctx.parameterList()); if(e.NAME().getText().equals(ASPRule.ASP_TYPE_VAR.toString())){
if(parameterList.size()<2)throw new DebugException("Fehler in Equals-Regel"); String pointer = e.parameterList().value(0).getText();
String ls = parameterList.get(0); tphs.add(pointer);
String rs = parameterList.get(1); String tphName = ASPStringConverter.fromConstant(pointer);
equalsRelations.add(new Relation(ls, rs)); Optional<TypePlaceholder> oTPH = originalTPHs.stream().filter((a)->a.getName().equals(tphName)).findAny();
TypePlaceholder tph;
} if(oTPH.isPresent()){
tph = oTPH.get();
@Override }else{
public void enterSmaller(UnifyResultParser.SmallerContext ctx) { tph = TypePlaceholder.fresh(new NullToken());
List<String> parameterList = parseParameterList(ctx.parameterList()); }
if(parameterList.size()<2)throw new DebugException("Fehler in Smaller-Regel"); types.put(pointer, tph);
String ls = parameterList.get(0);
String rs = parameterList.get(1);
smallerRelations.add(new Relation(ls, rs));
}
@Override
public void enterTypeVar(UnifyResultParser.TypeVarContext ctx) {
List<String> parameterList = parseParameterList(ctx.parameterList());
if(parameterList.size()<1)throw new DebugException("Fehler in typeVar-Regel");
tphs.add(parameterList.get(0));
}
@Override
public void enterType(UnifyResultParser.TypeContext ctx){
List<String> parameterList = parseParameterList(ctx.parameterList());
if(parameterList.size()<3)throw new DebugException("Fehler in Type-Regel");
String name = parameterList.get(0);
String typeName = parameterList.get(1);
String paramPointer = parameterList.get(2);
types.put(name, new ParsedType(typeName, paramPointer));
}
/*
private List<String> parsedRule;
private List<String> parseRule(String rule){
UnifyResultLexer lexer = new UnifyResultLexer(CharStreams.fromString(rule));
UnifyResultParser.AspruleContext parseTree = new UnifyResultParser(new CommonTokenStream(lexer)).asprule();
parsedRule = new ArrayList<>();
new ParseTreeWalker().walk(this, parseTree);
return parsedRule;
}
@Override
public void enterAsprule(UnifyResultParser.AspruleContext ctx) {
super.enterAsprule(ctx);
for(int i = 0; i< ctx.getChildCount();i++){
parsedRule.add(ctx.getChild(i).getText());
} }
} }
*/ }
private void getTypes(ASPResultParser.AnswerContext answer) {
HashMap<String, String[]> rawTypes = new HashMap<>();
for(ASPResultParser.ResultSetRuleContext e : answer.resultSetRule()){
if(e.NAME().getText().equals(ASPRule.ASP_TYPE.toString())){
String pointer = e.parameterList().value(0).getText();
String name = e.parameterList().value(1).getText();
Integer numParams = Integer.parseInt(e.parameterList().value(2).getText());
String[] params = new String[numParams + 1];
params[0] = name;
rawTypes.put(pointer, params);
}
}
for(ASPResultParser.ResultSetRuleContext e : answer.resultSetRule()){
if(e.NAME().getText().equals(ASPRule.ASP_PARAMLIST_NAME.toString())){
String typePointer = e.parameterList().value(0).getText();
String paramPointer = e.parameterList().value(1).getText();
Integer paramNum = Integer.parseInt(e.parameterList().value(2).getText());
if(rawTypes.containsKey(typePointer)) {
String[] paramArray = rawTypes.get(typePointer);
paramArray[paramNum] = paramPointer;
}
}
}
for(String name : rawTypes.keySet()){
types.put(name, createType(name, rawTypes));
}
}
private RefType createType(String name, HashMap<String, String[]> rawTypes){
String[] paramArray = rawTypes.get(name);
List<RefTypeOrTPHOrWildcardOrGeneric> paramList = new ArrayList<>();
for(int i = 1; i< paramArray.length ;i++){
String paramPointer = paramArray[i];
RefTypeOrTPHOrWildcardOrGeneric param;
if(rawTypes.containsKey(paramPointer)){
param = createType(paramPointer, rawTypes);
}else if(tphs.contains(paramPointer)){
String tphName = ASPStringConverter.fromConstant(paramPointer);
param = types.get(paramPointer);
}else{
throw new DebugException("Fehler beim Einlesen der Clingo Ausgabe");
}
if(param == null)
throw new NullPointerException();
paramList.add(param);
}
return new RefType(new JavaClassName(ASPStringConverter.fromConstant(paramArray[0])), paramList, new NullToken());
}
private ASPParser(String toParse, Collection<TypePlaceholder> oldPlaceholders){ private ASPParser(String toParse, Collection<TypePlaceholder> oldPlaceholders){
//System.out.println(toParse); //System.out.println(toParse);
this.originalTPHs = oldPlaceholders; this.originalTPHs = oldPlaceholders;
@ -159,73 +156,33 @@ public class ASPParser extends UnifyResultBaseListener {
} }
System.out.println(completeResult); System.out.println(completeResult);
*/ */
UnifyResultLexer lexer = new UnifyResultLexer(CharStreams.fromString(toParse)); ASPResultLexer lexer = new ASPResultLexer(CharStreams.fromString(toParse));
UnifyResultParser.AnswerContext parseTree = new UnifyResultParser(new CommonTokenStream(lexer)).answer(); ASPResultParser.AnswerContext parseTree = new ASPResultParser(new CommonTokenStream(lexer)).answer();
new ParseTreeWalker().walk(this, parseTree); //new ParseTreeWalker().walk(this, parseTree);
/* /*
Diese Funktion läuft im folgenden mehrmals über das Result aus dem ASP Programm. Diese Funktion läuft im folgenden mehrmals über das Result aus dem ASP Programm.
Dabei werden Schritt für Schritt die Felder dieser Klasse befüllt die am Schluss das ResultSet ergeben Dabei werden Schritt für Schritt die Felder dieser Klasse befüllt die am Schluss das ResultSet ergeben
*/ */
Set<ResultPair> ret = new HashSet<>(); getTPHs(parseTree);
//Zuerst die params und typeVars: getTypes(parseTree);
//for(String paramPointer : types.values().stream().map(parsedType -> parsedType.params).collect(Collectors.toList())){ }
//Dann die Equalsdot Statements Set<ResultPair> ret = new HashSet<>();
for(Relation eq : equalsRelations){ for(ASPResultParser.ResultSetRuleContext e : parseTree.resultSetRule()){
RefTypeOrTPHOrWildcardOrGeneric lsType = this.getType(eq.left); if(e.NAME().getText().equals(ASPRule.ASP_PAIR_EQUALS_NAME.toString())){
RefTypeOrTPHOrWildcardOrGeneric rsType = this.getType(eq.right); String tp1 = e.parameterList().value(0).getText();
if(lsType instanceof TypePlaceholder && rsType instanceof RefType) String tp2 = e.parameterList().value(1).getText();
ret.add(new PairTPHequalRefTypeOrWildcardType((TypePlaceholder) lsType, rsType)); if(tphs.contains(tp1) && tphs.contains(tp2)){
else if(lsType instanceof TypePlaceholder && rsType instanceof TypePlaceholder) //Diese kann man ignorieren. Sollten eigentlich nicht auftauchen
ret.add(new PairTPHEqualTPH((TypePlaceholder)lsType, (TypePlaceholder)rsType)); //ret.add(new PairTPHEqualTPH((TypePlaceholder) types.get(tp1), (TypePlaceholder) types.get(tp2)));
else throw new NotImplementedException(); }else if(tphs.contains(tp1)){
if(types.containsKey(tp2))
ret.add(new PairTPHequalRefTypeOrWildcardType((TypePlaceholder) types.get(tp1), types.get(tp2)));
else System.out.println(tp2);
}
}
} }
this.resultSet = new ResultSet(ret); this.resultSet = new ResultSet(ret);
} }
private RefTypeOrTPHOrWildcardOrGeneric getType(String name) {
if(tphs.contains(name)){
name = ASPStringConverter.fromConstant(name);
for(TypePlaceholder tph : originalTPHs){
if(tph.getName().equals(name))return tph;
}
return TypePlaceholder.fresh(new NullToken());
}else
if(types.containsKey(name)){
List<RefTypeOrTPHOrWildcardOrGeneric> params = new ArrayList<>();
ParsedType t = types.get(name);
for(String param : getParams(t.params)){
params.add(this.getType(param));
}
return new RefType(new JavaClassName(ASPStringConverter.fromConstant(t.name)), params, new NullToken());
}else throw new DebugException("Der Typ " + name + " konnte nicht bestimmt werden");
}
private static class ParameterListNode{
final String type;
final String nextNode;
public ParameterListNode(String type, String next) {
this.type = type;
this.nextNode = next;
}
}
private List<String> getParams(String pointer) {
List<String> params = new ArrayList<>();
while(pointer != null){
if(pointer.equals(ASPRule.ASP_PARAMLIST_END_POINTER.toString()))return params;
if(!parameterLists.containsKey(pointer))
throw new DebugException("Fehler in Ergebnisparsen");
//TODO: Fehler in ASP. Die adapt Regel muss erkennen, wenn die Parameterliste auf der linken Seite kürzer ist und diese Rechtzeitig beenden
ParameterListNode param = parameterLists.get(pointer);
pointer = param.nextNode;
params.add(param.type);
}
return params;
//Optional<ASPParameterList> ret = parameterLists.stream().filter(aspParameterList -> aspParameterList.name.equals(rs)).findAny();
//return ret.get();
}
} }

View File

@ -0,0 +1,17 @@
grammar ASPResult;
answer : 'ANSWER' (resultSetRule '.')*;
resultSetRule : NAME parameterList;
parameterList : '(' value (',' value)* ')';
value : NAME
| resultSetRule ;
NAME : [a-zA-Z0-9_']+;
WS : [ \t\r\n\u000C]+ -> skip
;
LINE_COMMENT
: '%' ~[\r\n]* -> skip
;

View File

@ -0,0 +1,13 @@
T__0=1
T__1=2
T__2=3
T__3=4
T__4=5
NAME=6
WS=7
LINE_COMMENT=8
'ANSWER'=1
'.'=2
'('=3
','=4
')'=5

View File

@ -0,0 +1,87 @@
// Generated from ASPResult.g4 by ANTLR 4.7
package de.dhbwstuttgart.sat.asp.parser.antlr;
import org.antlr.v4.runtime.ParserRuleContext;
import org.antlr.v4.runtime.tree.ErrorNode;
import org.antlr.v4.runtime.tree.TerminalNode;
/**
* This class provides an empty implementation of {@link ASPResultListener},
* which can be extended to create a listener which only needs to handle a subset
* of the available methods.
*/
public class ASPResultBaseListener implements ASPResultListener {
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterAnswer(ASPResultParser.AnswerContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitAnswer(ASPResultParser.AnswerContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterResultSetRule(ASPResultParser.ResultSetRuleContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitResultSetRule(ASPResultParser.ResultSetRuleContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterParameterList(ASPResultParser.ParameterListContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitParameterList(ASPResultParser.ParameterListContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterValue(ASPResultParser.ValueContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitValue(ASPResultParser.ValueContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterEveryRule(ParserRuleContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitEveryRule(ParserRuleContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void visitTerminal(TerminalNode node) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void visitErrorNode(ErrorNode node) { }
}

View File

@ -0,0 +1,121 @@
// Generated from ASPResult.g4 by ANTLR 4.7
package de.dhbwstuttgart.sat.asp.parser.antlr;
import org.antlr.v4.runtime.Lexer;
import org.antlr.v4.runtime.CharStream;
import org.antlr.v4.runtime.Token;
import org.antlr.v4.runtime.TokenStream;
import org.antlr.v4.runtime.*;
import org.antlr.v4.runtime.atn.*;
import org.antlr.v4.runtime.dfa.DFA;
import org.antlr.v4.runtime.misc.*;
@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast"})
public class ASPResultLexer extends Lexer {
static { RuntimeMetaData.checkVersion("4.7", RuntimeMetaData.VERSION); }
protected static final DFA[] _decisionToDFA;
protected static final PredictionContextCache _sharedContextCache =
new PredictionContextCache();
public static final int
T__0=1, T__1=2, T__2=3, T__3=4, T__4=5, NAME=6, WS=7, LINE_COMMENT=8;
public static String[] channelNames = {
"DEFAULT_TOKEN_CHANNEL", "HIDDEN"
};
public static String[] modeNames = {
"DEFAULT_MODE"
};
public static final String[] ruleNames = {
"T__0", "T__1", "T__2", "T__3", "T__4", "NAME", "WS", "LINE_COMMENT"
};
private static final String[] _LITERAL_NAMES = {
null, "'ANSWER'", "'.'", "'('", "','", "')'"
};
private static final String[] _SYMBOLIC_NAMES = {
null, null, null, null, null, null, "NAME", "WS", "LINE_COMMENT"
};
public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES);
/**
* @deprecated Use {@link #VOCABULARY} instead.
*/
@Deprecated
public static final String[] tokenNames;
static {
tokenNames = new String[_SYMBOLIC_NAMES.length];
for (int i = 0; i < tokenNames.length; i++) {
tokenNames[i] = VOCABULARY.getLiteralName(i);
if (tokenNames[i] == null) {
tokenNames[i] = VOCABULARY.getSymbolicName(i);
}
if (tokenNames[i] == null) {
tokenNames[i] = "<INVALID>";
}
}
}
@Override
@Deprecated
public String[] getTokenNames() {
return tokenNames;
}
@Override
public Vocabulary getVocabulary() {
return VOCABULARY;
}
public ASPResultLexer(CharStream input) {
super(input);
_interp = new LexerATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache);
}
@Override
public String getGrammarFileName() { return "ASPResult.g4"; }
@Override
public String[] getRuleNames() { return ruleNames; }
@Override
public String getSerializedATN() { return _serializedATN; }
@Override
public String[] getChannelNames() { return channelNames; }
@Override
public String[] getModeNames() { return modeNames; }
@Override
public ATN getATN() { return _ATN; }
public static final String _serializedATN =
"\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\2\n\67\b\1\4\2\t\2"+
"\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b\t\b\4\t\t\t\3\2\3\2\3\2\3"+
"\2\3\2\3\2\3\2\3\3\3\3\3\4\3\4\3\5\3\5\3\6\3\6\3\7\6\7$\n\7\r\7\16\7%"+
"\3\b\6\b)\n\b\r\b\16\b*\3\b\3\b\3\t\3\t\7\t\61\n\t\f\t\16\t\64\13\t\3"+
"\t\3\t\2\2\n\3\3\5\4\7\5\t\6\13\7\r\b\17\t\21\n\3\2\5\7\2))\62;C\\aac"+
"|\5\2\13\f\16\17\"\"\4\2\f\f\17\17\29\2\3\3\2\2\2\2\5\3\2\2\2\2\7\3\2"+
"\2\2\2\t\3\2\2\2\2\13\3\2\2\2\2\r\3\2\2\2\2\17\3\2\2\2\2\21\3\2\2\2\3"+
"\23\3\2\2\2\5\32\3\2\2\2\7\34\3\2\2\2\t\36\3\2\2\2\13 \3\2\2\2\r#\3\2"+
"\2\2\17(\3\2\2\2\21.\3\2\2\2\23\24\7C\2\2\24\25\7P\2\2\25\26\7U\2\2\26"+
"\27\7Y\2\2\27\30\7G\2\2\30\31\7T\2\2\31\4\3\2\2\2\32\33\7\60\2\2\33\6"+
"\3\2\2\2\34\35\7*\2\2\35\b\3\2\2\2\36\37\7.\2\2\37\n\3\2\2\2 !\7+\2\2"+
"!\f\3\2\2\2\"$\t\2\2\2#\"\3\2\2\2$%\3\2\2\2%#\3\2\2\2%&\3\2\2\2&\16\3"+
"\2\2\2\')\t\3\2\2(\'\3\2\2\2)*\3\2\2\2*(\3\2\2\2*+\3\2\2\2+,\3\2\2\2,"+
"-\b\b\2\2-\20\3\2\2\2.\62\7\'\2\2/\61\n\4\2\2\60/\3\2\2\2\61\64\3\2\2"+
"\2\62\60\3\2\2\2\62\63\3\2\2\2\63\65\3\2\2\2\64\62\3\2\2\2\65\66\b\t\2"+
"\2\66\22\3\2\2\2\6\2%*\62\3\b\2\2";
public static final ATN _ATN =
new ATNDeserializer().deserialize(_serializedATN.toCharArray());
static {
_decisionToDFA = new DFA[_ATN.getNumberOfDecisions()];
for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) {
_decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i);
}
}
}

View File

@ -0,0 +1,13 @@
T__0=1
T__1=2
T__2=3
T__3=4
T__4=5
NAME=6
WS=7
LINE_COMMENT=8
'ANSWER'=1
'.'=2
'('=3
','=4
')'=5

View File

@ -0,0 +1,50 @@
// Generated from ASPResult.g4 by ANTLR 4.7
package de.dhbwstuttgart.sat.asp.parser.antlr;
import org.antlr.v4.runtime.tree.ParseTreeListener;
/**
* This interface defines a complete listener for a parse tree produced by
* {@link ASPResultParser}.
*/
public interface ASPResultListener extends ParseTreeListener {
/**
* Enter a parse tree produced by {@link ASPResultParser#answer}.
* @param ctx the parse tree
*/
void enterAnswer(ASPResultParser.AnswerContext ctx);
/**
* Exit a parse tree produced by {@link ASPResultParser#answer}.
* @param ctx the parse tree
*/
void exitAnswer(ASPResultParser.AnswerContext ctx);
/**
* Enter a parse tree produced by {@link ASPResultParser#resultSetRule}.
* @param ctx the parse tree
*/
void enterResultSetRule(ASPResultParser.ResultSetRuleContext ctx);
/**
* Exit a parse tree produced by {@link ASPResultParser#resultSetRule}.
* @param ctx the parse tree
*/
void exitResultSetRule(ASPResultParser.ResultSetRuleContext ctx);
/**
* Enter a parse tree produced by {@link ASPResultParser#parameterList}.
* @param ctx the parse tree
*/
void enterParameterList(ASPResultParser.ParameterListContext ctx);
/**
* Exit a parse tree produced by {@link ASPResultParser#parameterList}.
* @param ctx the parse tree
*/
void exitParameterList(ASPResultParser.ParameterListContext ctx);
/**
* Enter a parse tree produced by {@link ASPResultParser#value}.
* @param ctx the parse tree
*/
void enterValue(ASPResultParser.ValueContext ctx);
/**
* Exit a parse tree produced by {@link ASPResultParser#value}.
* @param ctx the parse tree
*/
void exitValue(ASPResultParser.ValueContext ctx);
}

View File

@ -0,0 +1,318 @@
// Generated from ASPResult.g4 by ANTLR 4.7
package de.dhbwstuttgart.sat.asp.parser.antlr;
import org.antlr.v4.runtime.atn.*;
import org.antlr.v4.runtime.dfa.DFA;
import org.antlr.v4.runtime.*;
import org.antlr.v4.runtime.misc.*;
import org.antlr.v4.runtime.tree.*;
import java.util.List;
import java.util.Iterator;
import java.util.ArrayList;
@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast"})
public class ASPResultParser extends Parser {
static { RuntimeMetaData.checkVersion("4.7", RuntimeMetaData.VERSION); }
protected static final DFA[] _decisionToDFA;
protected static final PredictionContextCache _sharedContextCache =
new PredictionContextCache();
public static final int
T__0=1, T__1=2, T__2=3, T__3=4, T__4=5, NAME=6, WS=7, LINE_COMMENT=8;
public static final int
RULE_answer = 0, RULE_resultSetRule = 1, RULE_parameterList = 2, RULE_value = 3;
public static final String[] ruleNames = {
"answer", "resultSetRule", "parameterList", "value"
};
private static final String[] _LITERAL_NAMES = {
null, "'ANSWER'", "'.'", "'('", "','", "')'"
};
private static final String[] _SYMBOLIC_NAMES = {
null, null, null, null, null, null, "NAME", "WS", "LINE_COMMENT"
};
public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES);
/**
* @deprecated Use {@link #VOCABULARY} instead.
*/
@Deprecated
public static final String[] tokenNames;
static {
tokenNames = new String[_SYMBOLIC_NAMES.length];
for (int i = 0; i < tokenNames.length; i++) {
tokenNames[i] = VOCABULARY.getLiteralName(i);
if (tokenNames[i] == null) {
tokenNames[i] = VOCABULARY.getSymbolicName(i);
}
if (tokenNames[i] == null) {
tokenNames[i] = "<INVALID>";
}
}
}
@Override
@Deprecated
public String[] getTokenNames() {
return tokenNames;
}
@Override
public Vocabulary getVocabulary() {
return VOCABULARY;
}
@Override
public String getGrammarFileName() { return "ASPResult.g4"; }
@Override
public String[] getRuleNames() { return ruleNames; }
@Override
public String getSerializedATN() { return _serializedATN; }
@Override
public ATN getATN() { return _ATN; }
public ASPResultParser(TokenStream input) {
super(input);
_interp = new ParserATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache);
}
public static class AnswerContext extends ParserRuleContext {
public List<ResultSetRuleContext> resultSetRule() {
return getRuleContexts(ResultSetRuleContext.class);
}
public ResultSetRuleContext resultSetRule(int i) {
return getRuleContext(ResultSetRuleContext.class,i);
}
public AnswerContext(ParserRuleContext parent, int invokingState) {
super(parent, invokingState);
}
@Override public int getRuleIndex() { return RULE_answer; }
@Override
public void enterRule(ParseTreeListener listener) {
if ( listener instanceof ASPResultListener ) ((ASPResultListener)listener).enterAnswer(this);
}
@Override
public void exitRule(ParseTreeListener listener) {
if ( listener instanceof ASPResultListener ) ((ASPResultListener)listener).exitAnswer(this);
}
}
public final AnswerContext answer() throws RecognitionException {
AnswerContext _localctx = new AnswerContext(_ctx, getState());
enterRule(_localctx, 0, RULE_answer);
int _la;
try {
enterOuterAlt(_localctx, 1);
{
setState(8);
match(T__0);
setState(14);
_errHandler.sync(this);
_la = _input.LA(1);
while (_la==NAME) {
{
{
setState(9);
resultSetRule();
setState(10);
match(T__1);
}
}
setState(16);
_errHandler.sync(this);
_la = _input.LA(1);
}
}
}
catch (RecognitionException re) {
_localctx.exception = re;
_errHandler.reportError(this, re);
_errHandler.recover(this, re);
}
finally {
exitRule();
}
return _localctx;
}
public static class ResultSetRuleContext extends ParserRuleContext {
public TerminalNode NAME() { return getToken(ASPResultParser.NAME, 0); }
public ParameterListContext parameterList() {
return getRuleContext(ParameterListContext.class,0);
}
public ResultSetRuleContext(ParserRuleContext parent, int invokingState) {
super(parent, invokingState);
}
@Override public int getRuleIndex() { return RULE_resultSetRule; }
@Override
public void enterRule(ParseTreeListener listener) {
if ( listener instanceof ASPResultListener ) ((ASPResultListener)listener).enterResultSetRule(this);
}
@Override
public void exitRule(ParseTreeListener listener) {
if ( listener instanceof ASPResultListener ) ((ASPResultListener)listener).exitResultSetRule(this);
}
}
public final ResultSetRuleContext resultSetRule() throws RecognitionException {
ResultSetRuleContext _localctx = new ResultSetRuleContext(_ctx, getState());
enterRule(_localctx, 2, RULE_resultSetRule);
try {
enterOuterAlt(_localctx, 1);
{
setState(17);
match(NAME);
setState(18);
parameterList();
}
}
catch (RecognitionException re) {
_localctx.exception = re;
_errHandler.reportError(this, re);
_errHandler.recover(this, re);
}
finally {
exitRule();
}
return _localctx;
}
public static class ParameterListContext extends ParserRuleContext {
public List<ValueContext> value() {
return getRuleContexts(ValueContext.class);
}
public ValueContext value(int i) {
return getRuleContext(ValueContext.class,i);
}
public ParameterListContext(ParserRuleContext parent, int invokingState) {
super(parent, invokingState);
}
@Override public int getRuleIndex() { return RULE_parameterList; }
@Override
public void enterRule(ParseTreeListener listener) {
if ( listener instanceof ASPResultListener ) ((ASPResultListener)listener).enterParameterList(this);
}
@Override
public void exitRule(ParseTreeListener listener) {
if ( listener instanceof ASPResultListener ) ((ASPResultListener)listener).exitParameterList(this);
}
}
public final ParameterListContext parameterList() throws RecognitionException {
ParameterListContext _localctx = new ParameterListContext(_ctx, getState());
enterRule(_localctx, 4, RULE_parameterList);
int _la;
try {
enterOuterAlt(_localctx, 1);
{
setState(20);
match(T__2);
setState(21);
value();
setState(26);
_errHandler.sync(this);
_la = _input.LA(1);
while (_la==T__3) {
{
{
setState(22);
match(T__3);
setState(23);
value();
}
}
setState(28);
_errHandler.sync(this);
_la = _input.LA(1);
}
setState(29);
match(T__4);
}
}
catch (RecognitionException re) {
_localctx.exception = re;
_errHandler.reportError(this, re);
_errHandler.recover(this, re);
}
finally {
exitRule();
}
return _localctx;
}
public static class ValueContext extends ParserRuleContext {
public TerminalNode NAME() { return getToken(ASPResultParser.NAME, 0); }
public ResultSetRuleContext resultSetRule() {
return getRuleContext(ResultSetRuleContext.class,0);
}
public ValueContext(ParserRuleContext parent, int invokingState) {
super(parent, invokingState);
}
@Override public int getRuleIndex() { return RULE_value; }
@Override
public void enterRule(ParseTreeListener listener) {
if ( listener instanceof ASPResultListener ) ((ASPResultListener)listener).enterValue(this);
}
@Override
public void exitRule(ParseTreeListener listener) {
if ( listener instanceof ASPResultListener ) ((ASPResultListener)listener).exitValue(this);
}
}
public final ValueContext value() throws RecognitionException {
ValueContext _localctx = new ValueContext(_ctx, getState());
enterRule(_localctx, 6, RULE_value);
try {
setState(33);
_errHandler.sync(this);
switch ( getInterpreter().adaptivePredict(_input,2,_ctx) ) {
case 1:
enterOuterAlt(_localctx, 1);
{
setState(31);
match(NAME);
}
break;
case 2:
enterOuterAlt(_localctx, 2);
{
setState(32);
resultSetRule();
}
break;
}
}
catch (RecognitionException re) {
_localctx.exception = re;
_errHandler.reportError(this, re);
_errHandler.recover(this, re);
}
finally {
exitRule();
}
return _localctx;
}
public static final String _serializedATN =
"\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\3\n&\4\2\t\2\4\3\t"+
"\3\4\4\t\4\4\5\t\5\3\2\3\2\3\2\3\2\7\2\17\n\2\f\2\16\2\22\13\2\3\3\3\3"+
"\3\3\3\4\3\4\3\4\3\4\7\4\33\n\4\f\4\16\4\36\13\4\3\4\3\4\3\5\3\5\5\5$"+
"\n\5\3\5\2\2\6\2\4\6\b\2\2\2$\2\n\3\2\2\2\4\23\3\2\2\2\6\26\3\2\2\2\b"+
"#\3\2\2\2\n\20\7\3\2\2\13\f\5\4\3\2\f\r\7\4\2\2\r\17\3\2\2\2\16\13\3\2"+
"\2\2\17\22\3\2\2\2\20\16\3\2\2\2\20\21\3\2\2\2\21\3\3\2\2\2\22\20\3\2"+
"\2\2\23\24\7\b\2\2\24\25\5\6\4\2\25\5\3\2\2\2\26\27\7\5\2\2\27\34\5\b"+
"\5\2\30\31\7\6\2\2\31\33\5\b\5\2\32\30\3\2\2\2\33\36\3\2\2\2\34\32\3\2"+
"\2\2\34\35\3\2\2\2\35\37\3\2\2\2\36\34\3\2\2\2\37 \7\7\2\2 \7\3\2\2\2"+
"!$\7\b\2\2\"$\5\4\3\2#!\3\2\2\2#\"\3\2\2\2$\t\3\2\2\2\5\20\34#";
public static final ATN _ATN =
new ATNDeserializer().deserialize(_serializedATN.toCharArray());
static {
_decisionToDFA = new DFA[_ATN.getNumberOfDecisions()];
for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) {
_decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i);
}
}
}

View File

@ -8,6 +8,7 @@ resultSetRule :
| smaller | smaller
| typeVar | typeVar
| type | type
| unifier
| otherRule | otherRule
; ;
@ -17,6 +18,7 @@ value : NAME
parameter : PARAMLIST_NAME parameterList; parameter : PARAMLIST_NAME parameterList;
equals : EQUALS_NAME parameterList; equals : EQUALS_NAME parameterList;
unifier : UNIFIER_NAME parameterList;
smaller : SMALLER_NAME parameterList; smaller : SMALLER_NAME parameterList;
typeVar : TYPEVAR_NAME parameterList; typeVar : TYPEVAR_NAME parameterList;
type : TYPE_NAME parameterList; type : TYPE_NAME parameterList;
@ -24,6 +26,7 @@ otherRule : NAME parameterList;
//TODO: Es sollte Regeln für das Result set geben, welche sich nicht mit den anderen überdecken, dann auch nur diese im Result ausgeben //TODO: Es sollte Regeln für das Result set geben, welche sich nicht mit den anderen überdecken, dann auch nur diese im Result ausgeben
PARAMLIST_NAME : 'param'; PARAMLIST_NAME : 'param';
UNIFIER_NAME : 'unifier';
EQUALS_NAME : 'equals'; EQUALS_NAME : 'equals';
SMALLER_NAME : 'smaller'; SMALLER_NAME : 'smaller';
TYPEVAR_NAME : 'typeVar'; TYPEVAR_NAME : 'typeVar';
@ -35,3 +38,4 @@ WS : [ \t\r\n\u000C]+ -> skip
LINE_COMMENT LINE_COMMENT
: '%' ~[\r\n]* -> skip : '%' ~[\r\n]* -> skip
; ;

View File

@ -4,20 +4,22 @@ T__2=3
T__3=4 T__3=4
T__4=5 T__4=5
PARAMLIST_NAME=6 PARAMLIST_NAME=6
EQUALS_NAME=7 UNIFIER_NAME=7
SMALLER_NAME=8 EQUALS_NAME=8
TYPEVAR_NAME=9 SMALLER_NAME=9
TYPE_NAME=10 TYPEVAR_NAME=10
NAME=11 TYPE_NAME=11
WS=12 NAME=12
LINE_COMMENT=13 WS=13
LINE_COMMENT=14
'ANSWER'=1 'ANSWER'=1
'.'=2 '.'=2
'('=3 '('=3
','=4 ','=4
')'=5 ')'=5
'param'=6 'param'=6
'equals'=7 'unifier'=7
'smaller'=8 'equals'=8
'typeVar'=9 'smaller'=9
'type'=10 'typeVar'=10
'type'=11

View File

@ -83,6 +83,18 @@ public class UnifyResultBaseListener implements UnifyResultListener {
* <p>The default implementation does nothing.</p> * <p>The default implementation does nothing.</p>
*/ */
@Override public void exitEquals(UnifyResultParser.EqualsContext ctx) { } @Override public void exitEquals(UnifyResultParser.EqualsContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterUnifier(UnifyResultParser.UnifierContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitUnifier(UnifyResultParser.UnifierContext ctx) { }
/** /**
* {@inheritDoc} * {@inheritDoc}
* *

View File

@ -17,8 +17,9 @@ public class UnifyResultLexer extends Lexer {
protected static final PredictionContextCache _sharedContextCache = protected static final PredictionContextCache _sharedContextCache =
new PredictionContextCache(); new PredictionContextCache();
public static final int public static final int
T__0=1, T__1=2, T__2=3, T__3=4, T__4=5, PARAMLIST_NAME=6, EQUALS_NAME=7, T__0=1, T__1=2, T__2=3, T__3=4, T__4=5, PARAMLIST_NAME=6, UNIFIER_NAME=7,
SMALLER_NAME=8, TYPEVAR_NAME=9, TYPE_NAME=10, NAME=11, WS=12, LINE_COMMENT=13; EQUALS_NAME=8, SMALLER_NAME=9, TYPEVAR_NAME=10, TYPE_NAME=11, NAME=12,
WS=13, LINE_COMMENT=14;
public static String[] channelNames = { public static String[] channelNames = {
"DEFAULT_TOKEN_CHANNEL", "HIDDEN" "DEFAULT_TOKEN_CHANNEL", "HIDDEN"
}; };
@ -28,17 +29,19 @@ public class UnifyResultLexer extends Lexer {
}; };
public static final String[] ruleNames = { public static final String[] ruleNames = {
"T__0", "T__1", "T__2", "T__3", "T__4", "PARAMLIST_NAME", "EQUALS_NAME", "T__0", "T__1", "T__2", "T__3", "T__4", "PARAMLIST_NAME", "UNIFIER_NAME",
"SMALLER_NAME", "TYPEVAR_NAME", "TYPE_NAME", "NAME", "WS", "LINE_COMMENT" "EQUALS_NAME", "SMALLER_NAME", "TYPEVAR_NAME", "TYPE_NAME", "NAME", "WS",
"LINE_COMMENT"
}; };
private static final String[] _LITERAL_NAMES = { private static final String[] _LITERAL_NAMES = {
null, "'ANSWER'", "'.'", "'('", "','", "')'", "'param'", "'equals'", "'smaller'", null, "'ANSWER'", "'.'", "'('", "','", "')'", "'param'", "'unifier'",
"'typeVar'", "'type'" "'equals'", "'smaller'", "'typeVar'", "'type'"
}; };
private static final String[] _SYMBOLIC_NAMES = { private static final String[] _SYMBOLIC_NAMES = {
null, null, null, null, null, null, "PARAMLIST_NAME", "EQUALS_NAME", "SMALLER_NAME", null, null, null, null, null, null, "PARAMLIST_NAME", "UNIFIER_NAME",
"TYPEVAR_NAME", "TYPE_NAME", "NAME", "WS", "LINE_COMMENT" "EQUALS_NAME", "SMALLER_NAME", "TYPEVAR_NAME", "TYPE_NAME", "NAME", "WS",
"LINE_COMMENT"
}; };
public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES); public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES);
@ -98,31 +101,33 @@ public class UnifyResultLexer extends Lexer {
public ATN getATN() { return _ATN; } public ATN getATN() { return _ATN; }
public static final String _serializedATN = public static final String _serializedATN =
"\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\2\17c\b\1\4\2\t\2\4"+ "\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\2\20m\b\1\4\2\t\2\4"+
"\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b\t\b\4\t\t\t\4\n\t\n\4\13\t"+ "\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b\t\b\4\t\t\t\4\n\t\n\4\13\t"+
"\13\4\f\t\f\4\r\t\r\4\16\t\16\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3\3\3\3\3\4"+ "\13\4\f\t\f\4\r\t\r\4\16\t\16\4\17\t\17\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3"+
"\3\4\3\5\3\5\3\6\3\6\3\7\3\7\3\7\3\7\3\7\3\7\3\b\3\b\3\b\3\b\3\b\3\b\3"+ "\3\3\3\3\4\3\4\3\5\3\5\3\6\3\6\3\7\3\7\3\7\3\7\3\7\3\7\3\b\3\b\3\b\3\b"+
"\b\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\n\3\n\3\n\3\n\3\n\3\n\3\n\3\n\3\13"+ "\3\b\3\b\3\b\3\b\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\n\3\n\3\n\3\n\3\n\3\n\3"+
"\3\13\3\13\3\13\3\13\3\f\6\fP\n\f\r\f\16\fQ\3\r\6\rU\n\r\r\r\16\rV\3\r"+ "\n\3\n\3\13\3\13\3\13\3\13\3\13\3\13\3\13\3\13\3\f\3\f\3\f\3\f\3\f\3\r"+
"\3\r\3\16\3\16\7\16]\n\16\f\16\16\16`\13\16\3\16\3\16\2\2\17\3\3\5\4\7"+ "\6\rZ\n\r\r\r\16\r[\3\16\6\16_\n\16\r\16\16\16`\3\16\3\16\3\17\3\17\7"+
"\5\t\6\13\7\r\b\17\t\21\n\23\13\25\f\27\r\31\16\33\17\3\2\5\6\2\62;C\\"+ "\17g\n\17\f\17\16\17j\13\17\3\17\3\17\2\2\20\3\3\5\4\7\5\t\6\13\7\r\b"+
"aac|\5\2\13\f\16\17\"\"\4\2\f\f\17\17\2e\2\3\3\2\2\2\2\5\3\2\2\2\2\7\3"+ "\17\t\21\n\23\13\25\f\27\r\31\16\33\17\35\20\3\2\5\6\2\62;C\\aac|\5\2"+
"\2\2\2\2\t\3\2\2\2\2\13\3\2\2\2\2\r\3\2\2\2\2\17\3\2\2\2\2\21\3\2\2\2"+ "\13\f\16\17\"\"\4\2\f\f\17\17\2o\2\3\3\2\2\2\2\5\3\2\2\2\2\7\3\2\2\2\2"+
"\2\23\3\2\2\2\2\25\3\2\2\2\2\27\3\2\2\2\2\31\3\2\2\2\2\33\3\2\2\2\3\35"+ "\t\3\2\2\2\2\13\3\2\2\2\2\r\3\2\2\2\2\17\3\2\2\2\2\21\3\2\2\2\2\23\3\2"+
"\3\2\2\2\5$\3\2\2\2\7&\3\2\2\2\t(\3\2\2\2\13*\3\2\2\2\r,\3\2\2\2\17\62"+ "\2\2\2\25\3\2\2\2\2\27\3\2\2\2\2\31\3\2\2\2\2\33\3\2\2\2\2\35\3\2\2\2"+
"\3\2\2\2\219\3\2\2\2\23A\3\2\2\2\25I\3\2\2\2\27O\3\2\2\2\31T\3\2\2\2\33"+ "\3\37\3\2\2\2\5&\3\2\2\2\7(\3\2\2\2\t*\3\2\2\2\13,\3\2\2\2\r.\3\2\2\2"+
"Z\3\2\2\2\35\36\7C\2\2\36\37\7P\2\2\37 \7U\2\2 !\7Y\2\2!\"\7G\2\2\"#\7"+ "\17\64\3\2\2\2\21<\3\2\2\2\23C\3\2\2\2\25K\3\2\2\2\27S\3\2\2\2\31Y\3\2"+
"T\2\2#\4\3\2\2\2$%\7\60\2\2%\6\3\2\2\2&\'\7*\2\2\'\b\3\2\2\2()\7.\2\2"+ "\2\2\33^\3\2\2\2\35d\3\2\2\2\37 \7C\2\2 !\7P\2\2!\"\7U\2\2\"#\7Y\2\2#"+
")\n\3\2\2\2*+\7+\2\2+\f\3\2\2\2,-\7r\2\2-.\7c\2\2./\7t\2\2/\60\7c\2\2"+ "$\7G\2\2$%\7T\2\2%\4\3\2\2\2&\'\7\60\2\2\'\6\3\2\2\2()\7*\2\2)\b\3\2\2"+
"\60\61\7o\2\2\61\16\3\2\2\2\62\63\7g\2\2\63\64\7s\2\2\64\65\7w\2\2\65"+ "\2*+\7.\2\2+\n\3\2\2\2,-\7+\2\2-\f\3\2\2\2./\7r\2\2/\60\7c\2\2\60\61\7"+
"\66\7c\2\2\66\67\7n\2\2\678\7u\2\28\20\3\2\2\29:\7u\2\2:;\7o\2\2;<\7c"+ "t\2\2\61\62\7c\2\2\62\63\7o\2\2\63\16\3\2\2\2\64\65\7w\2\2\65\66\7p\2"+
"\2\2<=\7n\2\2=>\7n\2\2>?\7g\2\2?@\7t\2\2@\22\3\2\2\2AB\7v\2\2BC\7{\2\2"+ "\2\66\67\7k\2\2\678\7h\2\289\7k\2\29:\7g\2\2:;\7t\2\2;\20\3\2\2\2<=\7"+
"CD\7r\2\2DE\7g\2\2EF\7X\2\2FG\7c\2\2GH\7t\2\2H\24\3\2\2\2IJ\7v\2\2JK\7"+ "g\2\2=>\7s\2\2>?\7w\2\2?@\7c\2\2@A\7n\2\2AB\7u\2\2B\22\3\2\2\2CD\7u\2"+
"{\2\2KL\7r\2\2LM\7g\2\2M\26\3\2\2\2NP\t\2\2\2ON\3\2\2\2PQ\3\2\2\2QO\3"+ "\2DE\7o\2\2EF\7c\2\2FG\7n\2\2GH\7n\2\2HI\7g\2\2IJ\7t\2\2J\24\3\2\2\2K"+
"\2\2\2QR\3\2\2\2R\30\3\2\2\2SU\t\3\2\2TS\3\2\2\2UV\3\2\2\2VT\3\2\2\2V"+ "L\7v\2\2LM\7{\2\2MN\7r\2\2NO\7g\2\2OP\7X\2\2PQ\7c\2\2QR\7t\2\2R\26\3\2"+
"W\3\2\2\2WX\3\2\2\2XY\b\r\2\2Y\32\3\2\2\2Z^\7\'\2\2[]\n\4\2\2\\[\3\2\2"+ "\2\2ST\7v\2\2TU\7{\2\2UV\7r\2\2VW\7g\2\2W\30\3\2\2\2XZ\t\2\2\2YX\3\2\2"+
"\2]`\3\2\2\2^\\\3\2\2\2^_\3\2\2\2_a\3\2\2\2`^\3\2\2\2ab\b\16\2\2b\34\3"+ "\2Z[\3\2\2\2[Y\3\2\2\2[\\\3\2\2\2\\\32\3\2\2\2]_\t\3\2\2^]\3\2\2\2_`\3"+
"\2\2\2\6\2QV^\3\b\2\2"; "\2\2\2`^\3\2\2\2`a\3\2\2\2ab\3\2\2\2bc\b\16\2\2c\34\3\2\2\2dh\7\'\2\2"+
"eg\n\4\2\2fe\3\2\2\2gj\3\2\2\2hf\3\2\2\2hi\3\2\2\2ik\3\2\2\2jh\3\2\2\2"+
"kl\b\17\2\2l\36\3\2\2\2\6\2[`h\3\b\2\2";
public static final ATN _ATN = public static final ATN _ATN =
new ATNDeserializer().deserialize(_serializedATN.toCharArray()); new ATNDeserializer().deserialize(_serializedATN.toCharArray());
static { static {

View File

@ -4,20 +4,22 @@ T__2=3
T__3=4 T__3=4
T__4=5 T__4=5
PARAMLIST_NAME=6 PARAMLIST_NAME=6
EQUALS_NAME=7 UNIFIER_NAME=7
SMALLER_NAME=8 EQUALS_NAME=8
TYPEVAR_NAME=9 SMALLER_NAME=9
TYPE_NAME=10 TYPEVAR_NAME=10
NAME=11 TYPE_NAME=11
WS=12 NAME=12
LINE_COMMENT=13 WS=13
LINE_COMMENT=14
'ANSWER'=1 'ANSWER'=1
'.'=2 '.'=2
'('=3 '('=3
','=4 ','=4
')'=5 ')'=5
'param'=6 'param'=6
'equals'=7 'unifier'=7
'smaller'=8 'equals'=8
'typeVar'=9 'smaller'=9
'type'=10 'typeVar'=10
'type'=11

View File

@ -67,6 +67,16 @@ public interface UnifyResultListener extends ParseTreeListener {
* @param ctx the parse tree * @param ctx the parse tree
*/ */
void exitEquals(UnifyResultParser.EqualsContext ctx); void exitEquals(UnifyResultParser.EqualsContext ctx);
/**
* Enter a parse tree produced by {@link UnifyResultParser#unifier}.
* @param ctx the parse tree
*/
void enterUnifier(UnifyResultParser.UnifierContext ctx);
/**
* Exit a parse tree produced by {@link UnifyResultParser#unifier}.
* @param ctx the parse tree
*/
void exitUnifier(UnifyResultParser.UnifierContext ctx);
/** /**
* Enter a parse tree produced by {@link UnifyResultParser#smaller}. * Enter a parse tree produced by {@link UnifyResultParser#smaller}.
* @param ctx the parse tree * @param ctx the parse tree

View File

@ -17,24 +17,26 @@ public class UnifyResultParser extends Parser {
protected static final PredictionContextCache _sharedContextCache = protected static final PredictionContextCache _sharedContextCache =
new PredictionContextCache(); new PredictionContextCache();
public static final int public static final int
T__0=1, T__1=2, T__2=3, T__3=4, T__4=5, PARAMLIST_NAME=6, EQUALS_NAME=7, T__0=1, T__1=2, T__2=3, T__3=4, T__4=5, PARAMLIST_NAME=6, UNIFIER_NAME=7,
SMALLER_NAME=8, TYPEVAR_NAME=9, TYPE_NAME=10, NAME=11, WS=12, LINE_COMMENT=13; EQUALS_NAME=8, SMALLER_NAME=9, TYPEVAR_NAME=10, TYPE_NAME=11, NAME=12,
WS=13, LINE_COMMENT=14;
public static final int public static final int
RULE_answer = 0, RULE_resultSetRule = 1, RULE_parameterList = 2, RULE_value = 3, RULE_answer = 0, RULE_resultSetRule = 1, RULE_parameterList = 2, RULE_value = 3,
RULE_parameter = 4, RULE_equals = 5, RULE_smaller = 6, RULE_typeVar = 7, RULE_parameter = 4, RULE_equals = 5, RULE_unifier = 6, RULE_smaller = 7,
RULE_type = 8, RULE_otherRule = 9; RULE_typeVar = 8, RULE_type = 9, RULE_otherRule = 10;
public static final String[] ruleNames = { public static final String[] ruleNames = {
"answer", "resultSetRule", "parameterList", "value", "parameter", "equals", "answer", "resultSetRule", "parameterList", "value", "parameter", "equals",
"smaller", "typeVar", "type", "otherRule" "unifier", "smaller", "typeVar", "type", "otherRule"
}; };
private static final String[] _LITERAL_NAMES = { private static final String[] _LITERAL_NAMES = {
null, "'ANSWER'", "'.'", "'('", "','", "')'", "'param'", "'equals'", "'smaller'", null, "'ANSWER'", "'.'", "'('", "','", "')'", "'param'", "'unifier'",
"'typeVar'", "'type'" "'equals'", "'smaller'", "'typeVar'", "'type'"
}; };
private static final String[] _SYMBOLIC_NAMES = { private static final String[] _SYMBOLIC_NAMES = {
null, null, null, null, null, null, "PARAMLIST_NAME", "EQUALS_NAME", "SMALLER_NAME", null, null, null, null, null, null, "PARAMLIST_NAME", "UNIFIER_NAME",
"TYPEVAR_NAME", "TYPE_NAME", "NAME", "WS", "LINE_COMMENT" "EQUALS_NAME", "SMALLER_NAME", "TYPEVAR_NAME", "TYPE_NAME", "NAME", "WS",
"LINE_COMMENT"
}; };
public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES); public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES);
@ -113,21 +115,21 @@ public class UnifyResultParser extends Parser {
try { try {
enterOuterAlt(_localctx, 1); enterOuterAlt(_localctx, 1);
{ {
setState(20); setState(22);
match(T__0); match(T__0);
setState(26); setState(28);
_errHandler.sync(this); _errHandler.sync(this);
_la = _input.LA(1); _la = _input.LA(1);
while ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << PARAMLIST_NAME) | (1L << EQUALS_NAME) | (1L << SMALLER_NAME) | (1L << TYPEVAR_NAME) | (1L << TYPE_NAME) | (1L << NAME))) != 0)) { while ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << PARAMLIST_NAME) | (1L << UNIFIER_NAME) | (1L << EQUALS_NAME) | (1L << SMALLER_NAME) | (1L << TYPEVAR_NAME) | (1L << TYPE_NAME) | (1L << NAME))) != 0)) {
{ {
{ {
setState(21); setState(23);
resultSetRule(); resultSetRule();
setState(22); setState(24);
match(T__1); match(T__1);
} }
} }
setState(28); setState(30);
_errHandler.sync(this); _errHandler.sync(this);
_la = _input.LA(1); _la = _input.LA(1);
} }
@ -160,6 +162,9 @@ public class UnifyResultParser extends Parser {
public TypeContext type() { public TypeContext type() {
return getRuleContext(TypeContext.class,0); return getRuleContext(TypeContext.class,0);
} }
public UnifierContext unifier() {
return getRuleContext(UnifierContext.class,0);
}
public OtherRuleContext otherRule() { public OtherRuleContext otherRule() {
return getRuleContext(OtherRuleContext.class,0); return getRuleContext(OtherRuleContext.class,0);
} }
@ -181,48 +186,55 @@ public class UnifyResultParser extends Parser {
ResultSetRuleContext _localctx = new ResultSetRuleContext(_ctx, getState()); ResultSetRuleContext _localctx = new ResultSetRuleContext(_ctx, getState());
enterRule(_localctx, 2, RULE_resultSetRule); enterRule(_localctx, 2, RULE_resultSetRule);
try { try {
setState(35); setState(38);
_errHandler.sync(this); _errHandler.sync(this);
switch (_input.LA(1)) { switch (_input.LA(1)) {
case PARAMLIST_NAME: case PARAMLIST_NAME:
enterOuterAlt(_localctx, 1); enterOuterAlt(_localctx, 1);
{ {
setState(29); setState(31);
parameter(); parameter();
} }
break; break;
case EQUALS_NAME: case EQUALS_NAME:
enterOuterAlt(_localctx, 2); enterOuterAlt(_localctx, 2);
{ {
setState(30); setState(32);
equals(); equals();
} }
break; break;
case SMALLER_NAME: case SMALLER_NAME:
enterOuterAlt(_localctx, 3); enterOuterAlt(_localctx, 3);
{ {
setState(31); setState(33);
smaller(); smaller();
} }
break; break;
case TYPEVAR_NAME: case TYPEVAR_NAME:
enterOuterAlt(_localctx, 4); enterOuterAlt(_localctx, 4);
{ {
setState(32); setState(34);
typeVar(); typeVar();
} }
break; break;
case TYPE_NAME: case TYPE_NAME:
enterOuterAlt(_localctx, 5); enterOuterAlt(_localctx, 5);
{ {
setState(33); setState(35);
type(); type();
} }
break; break;
case NAME: case UNIFIER_NAME:
enterOuterAlt(_localctx, 6); enterOuterAlt(_localctx, 6);
{ {
setState(34); setState(36);
unifier();
}
break;
case NAME:
enterOuterAlt(_localctx, 7);
{
setState(37);
otherRule(); otherRule();
} }
break; break;
@ -269,27 +281,27 @@ public class UnifyResultParser extends Parser {
try { try {
enterOuterAlt(_localctx, 1); enterOuterAlt(_localctx, 1);
{ {
setState(37); setState(40);
match(T__2); match(T__2);
setState(38); setState(41);
value(); value();
setState(43); setState(46);
_errHandler.sync(this); _errHandler.sync(this);
_la = _input.LA(1); _la = _input.LA(1);
while (_la==T__3) { while (_la==T__3) {
{ {
{ {
setState(39); setState(42);
match(T__3); match(T__3);
setState(40); setState(43);
value(); value();
} }
} }
setState(45); setState(48);
_errHandler.sync(this); _errHandler.sync(this);
_la = _input.LA(1); _la = _input.LA(1);
} }
setState(46); setState(49);
match(T__4); match(T__4);
} }
} }
@ -327,20 +339,20 @@ public class UnifyResultParser extends Parser {
ValueContext _localctx = new ValueContext(_ctx, getState()); ValueContext _localctx = new ValueContext(_ctx, getState());
enterRule(_localctx, 6, RULE_value); enterRule(_localctx, 6, RULE_value);
try { try {
setState(50); setState(53);
_errHandler.sync(this); _errHandler.sync(this);
switch ( getInterpreter().adaptivePredict(_input,3,_ctx) ) { switch ( getInterpreter().adaptivePredict(_input,3,_ctx) ) {
case 1: case 1:
enterOuterAlt(_localctx, 1); enterOuterAlt(_localctx, 1);
{ {
setState(48); setState(51);
match(NAME); match(NAME);
} }
break; break;
case 2: case 2:
enterOuterAlt(_localctx, 2); enterOuterAlt(_localctx, 2);
{ {
setState(49); setState(52);
resultSetRule(); resultSetRule();
} }
break; break;
@ -382,9 +394,9 @@ public class UnifyResultParser extends Parser {
try { try {
enterOuterAlt(_localctx, 1); enterOuterAlt(_localctx, 1);
{ {
setState(52); setState(55);
match(PARAMLIST_NAME); match(PARAMLIST_NAME);
setState(53); setState(56);
parameterList(); parameterList();
} }
} }
@ -424,9 +436,51 @@ public class UnifyResultParser extends Parser {
try { try {
enterOuterAlt(_localctx, 1); enterOuterAlt(_localctx, 1);
{ {
setState(55); setState(58);
match(EQUALS_NAME); match(EQUALS_NAME);
setState(56); setState(59);
parameterList();
}
}
catch (RecognitionException re) {
_localctx.exception = re;
_errHandler.reportError(this, re);
_errHandler.recover(this, re);
}
finally {
exitRule();
}
return _localctx;
}
public static class UnifierContext extends ParserRuleContext {
public TerminalNode UNIFIER_NAME() { return getToken(UnifyResultParser.UNIFIER_NAME, 0); }
public ParameterListContext parameterList() {
return getRuleContext(ParameterListContext.class,0);
}
public UnifierContext(ParserRuleContext parent, int invokingState) {
super(parent, invokingState);
}
@Override public int getRuleIndex() { return RULE_unifier; }
@Override
public void enterRule(ParseTreeListener listener) {
if ( listener instanceof UnifyResultListener ) ((UnifyResultListener)listener).enterUnifier(this);
}
@Override
public void exitRule(ParseTreeListener listener) {
if ( listener instanceof UnifyResultListener ) ((UnifyResultListener)listener).exitUnifier(this);
}
}
public final UnifierContext unifier() throws RecognitionException {
UnifierContext _localctx = new UnifierContext(_ctx, getState());
enterRule(_localctx, 12, RULE_unifier);
try {
enterOuterAlt(_localctx, 1);
{
setState(61);
match(UNIFIER_NAME);
setState(62);
parameterList(); parameterList();
} }
} }
@ -462,13 +516,13 @@ public class UnifyResultParser extends Parser {
public final SmallerContext smaller() throws RecognitionException { public final SmallerContext smaller() throws RecognitionException {
SmallerContext _localctx = new SmallerContext(_ctx, getState()); SmallerContext _localctx = new SmallerContext(_ctx, getState());
enterRule(_localctx, 12, RULE_smaller); enterRule(_localctx, 14, RULE_smaller);
try { try {
enterOuterAlt(_localctx, 1); enterOuterAlt(_localctx, 1);
{ {
setState(58); setState(64);
match(SMALLER_NAME); match(SMALLER_NAME);
setState(59); setState(65);
parameterList(); parameterList();
} }
} }
@ -504,13 +558,13 @@ public class UnifyResultParser extends Parser {
public final TypeVarContext typeVar() throws RecognitionException { public final TypeVarContext typeVar() throws RecognitionException {
TypeVarContext _localctx = new TypeVarContext(_ctx, getState()); TypeVarContext _localctx = new TypeVarContext(_ctx, getState());
enterRule(_localctx, 14, RULE_typeVar); enterRule(_localctx, 16, RULE_typeVar);
try { try {
enterOuterAlt(_localctx, 1); enterOuterAlt(_localctx, 1);
{ {
setState(61); setState(67);
match(TYPEVAR_NAME); match(TYPEVAR_NAME);
setState(62); setState(68);
parameterList(); parameterList();
} }
} }
@ -546,13 +600,13 @@ public class UnifyResultParser extends Parser {
public final TypeContext type() throws RecognitionException { public final TypeContext type() throws RecognitionException {
TypeContext _localctx = new TypeContext(_ctx, getState()); TypeContext _localctx = new TypeContext(_ctx, getState());
enterRule(_localctx, 16, RULE_type); enterRule(_localctx, 18, RULE_type);
try { try {
enterOuterAlt(_localctx, 1); enterOuterAlt(_localctx, 1);
{ {
setState(64); setState(70);
match(TYPE_NAME); match(TYPE_NAME);
setState(65); setState(71);
parameterList(); parameterList();
} }
} }
@ -588,13 +642,13 @@ public class UnifyResultParser extends Parser {
public final OtherRuleContext otherRule() throws RecognitionException { public final OtherRuleContext otherRule() throws RecognitionException {
OtherRuleContext _localctx = new OtherRuleContext(_ctx, getState()); OtherRuleContext _localctx = new OtherRuleContext(_ctx, getState());
enterRule(_localctx, 18, RULE_otherRule); enterRule(_localctx, 20, RULE_otherRule);
try { try {
enterOuterAlt(_localctx, 1); enterOuterAlt(_localctx, 1);
{ {
setState(67); setState(73);
match(NAME); match(NAME);
setState(68); setState(74);
parameterList(); parameterList();
} }
} }
@ -610,24 +664,25 @@ public class UnifyResultParser extends Parser {
} }
public static final String _serializedATN = public static final String _serializedATN =
"\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\3\17I\4\2\t\2\4\3\t"+ "\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\3\20O\4\2\t\2\4\3\t"+
"\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b\t\b\4\t\t\t\4\n\t\n\4\13\t\13\3"+ "\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b\t\b\4\t\t\t\4\n\t\n\4\13\t\13\4"+
"\2\3\2\3\2\3\2\7\2\33\n\2\f\2\16\2\36\13\2\3\3\3\3\3\3\3\3\3\3\3\3\5\3"+ "\f\t\f\3\2\3\2\3\2\3\2\7\2\35\n\2\f\2\16\2 \13\2\3\3\3\3\3\3\3\3\3\3\3"+
"&\n\3\3\4\3\4\3\4\3\4\7\4,\n\4\f\4\16\4/\13\4\3\4\3\4\3\5\3\5\5\5\65\n"+ "\3\3\3\5\3)\n\3\3\4\3\4\3\4\3\4\7\4/\n\4\f\4\16\4\62\13\4\3\4\3\4\3\5"+
"\5\3\6\3\6\3\6\3\7\3\7\3\7\3\b\3\b\3\b\3\t\3\t\3\t\3\n\3\n\3\n\3\13\3"+ "\3\5\5\58\n\5\3\6\3\6\3\6\3\7\3\7\3\7\3\b\3\b\3\b\3\t\3\t\3\t\3\n\3\n"+
"\13\3\13\3\13\2\2\f\2\4\6\b\n\f\16\20\22\24\2\2\2F\2\26\3\2\2\2\4%\3\2"+ "\3\n\3\13\3\13\3\13\3\f\3\f\3\f\3\f\2\2\r\2\4\6\b\n\f\16\20\22\24\26\2"+
"\2\2\6\'\3\2\2\2\b\64\3\2\2\2\n\66\3\2\2\2\f9\3\2\2\2\16<\3\2\2\2\20?"+ "\2\2L\2\30\3\2\2\2\4(\3\2\2\2\6*\3\2\2\2\b\67\3\2\2\2\n9\3\2\2\2\f<\3"+
"\3\2\2\2\22B\3\2\2\2\24E\3\2\2\2\26\34\7\3\2\2\27\30\5\4\3\2\30\31\7\4"+ "\2\2\2\16?\3\2\2\2\20B\3\2\2\2\22E\3\2\2\2\24H\3\2\2\2\26K\3\2\2\2\30"+
"\2\2\31\33\3\2\2\2\32\27\3\2\2\2\33\36\3\2\2\2\34\32\3\2\2\2\34\35\3\2"+ "\36\7\3\2\2\31\32\5\4\3\2\32\33\7\4\2\2\33\35\3\2\2\2\34\31\3\2\2\2\35"+
"\2\2\35\3\3\2\2\2\36\34\3\2\2\2\37&\5\n\6\2 &\5\f\7\2!&\5\16\b\2\"&\5"+ " \3\2\2\2\36\34\3\2\2\2\36\37\3\2\2\2\37\3\3\2\2\2 \36\3\2\2\2!)\5\n\6"+
"\20\t\2#&\5\22\n\2$&\5\24\13\2%\37\3\2\2\2% \3\2\2\2%!\3\2\2\2%\"\3\2"+ "\2\")\5\f\7\2#)\5\20\t\2$)\5\22\n\2%)\5\24\13\2&)\5\16\b\2\')\5\26\f\2"+
"\2\2%#\3\2\2\2%$\3\2\2\2&\5\3\2\2\2\'(\7\5\2\2(-\5\b\5\2)*\7\6\2\2*,\5"+ "(!\3\2\2\2(\"\3\2\2\2(#\3\2\2\2($\3\2\2\2(%\3\2\2\2(&\3\2\2\2(\'\3\2\2"+
"\b\5\2+)\3\2\2\2,/\3\2\2\2-+\3\2\2\2-.\3\2\2\2.\60\3\2\2\2/-\3\2\2\2\60"+ "\2)\5\3\2\2\2*+\7\5\2\2+\60\5\b\5\2,-\7\6\2\2-/\5\b\5\2.,\3\2\2\2/\62"+
"\61\7\7\2\2\61\7\3\2\2\2\62\65\7\r\2\2\63\65\5\4\3\2\64\62\3\2\2\2\64"+ "\3\2\2\2\60.\3\2\2\2\60\61\3\2\2\2\61\63\3\2\2\2\62\60\3\2\2\2\63\64\7"+
"\63\3\2\2\2\65\t\3\2\2\2\66\67\7\b\2\2\678\5\6\4\28\13\3\2\2\29:\7\t\2"+ "\7\2\2\64\7\3\2\2\2\658\7\16\2\2\668\5\4\3\2\67\65\3\2\2\2\67\66\3\2\2"+
"\2:;\5\6\4\2;\r\3\2\2\2<=\7\n\2\2=>\5\6\4\2>\17\3\2\2\2?@\7\13\2\2@A\5"+ "\28\t\3\2\2\29:\7\b\2\2:;\5\6\4\2;\13\3\2\2\2<=\7\n\2\2=>\5\6\4\2>\r\3"+
"\6\4\2A\21\3\2\2\2BC\7\f\2\2CD\5\6\4\2D\23\3\2\2\2EF\7\r\2\2FG\5\6\4\2"+ "\2\2\2?@\7\t\2\2@A\5\6\4\2A\17\3\2\2\2BC\7\13\2\2CD\5\6\4\2D\21\3\2\2"+
"G\25\3\2\2\2\6\34%-\64"; "\2EF\7\f\2\2FG\5\6\4\2G\23\3\2\2\2HI\7\r\2\2IJ\5\6\4\2J\25\3\2\2\2KL\7"+
"\16\2\2LM\5\6\4\2M\27\3\2\2\2\6\36(\60\67";
public static final ATN _ATN = public static final ATN _ATN =
new ATNDeserializer().deserialize(_serializedATN.toCharArray()); new ATNDeserializer().deserialize(_serializedATN.toCharArray());
static { static {

View File

@ -1,17 +1,22 @@
package de.dhbwstuttgart.sat.asp.writer; package de.dhbwstuttgart.sat.asp.writer;
import de.dhbwstuttgart.exceptions.NotImplementedException; import de.dhbwstuttgart.exceptions.NotImplementedException;
import de.dhbwstuttgart.parser.NullToken;
import de.dhbwstuttgart.parser.SyntaxTreeGenerator.FCGenerator; import de.dhbwstuttgart.parser.SyntaxTreeGenerator.FCGenerator;
import de.dhbwstuttgart.sat.asp.ASPStringConverter; import de.dhbwstuttgart.sat.asp.ASPStringConverter;
import de.dhbwstuttgart.sat.asp.model.ASPRule; import de.dhbwstuttgart.sat.asp.model.ASPRule;
import de.dhbwstuttgart.syntaxtree.ClassOrInterface; import de.dhbwstuttgart.syntaxtree.ClassOrInterface;
import de.dhbwstuttgart.syntaxtree.GenericTypeVar;
import de.dhbwstuttgart.syntaxtree.factory.NameGenerator; import de.dhbwstuttgart.syntaxtree.factory.NameGenerator;
import de.dhbwstuttgart.syntaxtree.type.*; import de.dhbwstuttgart.syntaxtree.type.*;
import de.dhbwstuttgart.syntaxtree.visual.ASTPrinter;
import de.dhbwstuttgart.syntaxtree.visual.OutputGenerator;
import de.dhbwstuttgart.typeinference.constraints.Constraint; import de.dhbwstuttgart.typeinference.constraints.Constraint;
import de.dhbwstuttgart.typeinference.constraints.ConstraintSet; import de.dhbwstuttgart.typeinference.constraints.ConstraintSet;
import de.dhbwstuttgart.typeinference.constraints.Pair; import de.dhbwstuttgart.typeinference.constraints.Pair;
import de.dhbwstuttgart.typeinference.unify.model.PairOperator; import de.dhbwstuttgart.typeinference.unify.model.PairOperator;
import javax.management.Notification;
import java.util.*; import java.util.*;
public class ASPFactory implements TypeVisitor<String>{ public class ASPFactory implements TypeVisitor<String>{
@ -19,29 +24,112 @@ public class ASPFactory implements TypeVisitor<String>{
public static String generateASP(ConstraintSet<Pair> constraints, Collection<ClassOrInterface> fcClasses) throws ClassNotFoundException{ public static String generateASP(ConstraintSet<Pair> constraints, Collection<ClassOrInterface> fcClasses) throws ClassNotFoundException{
ASPFactory factory = new ASPFactory(); ASPFactory factory = new ASPFactory();
factory.convertFC(fcClasses); factory.convertFC(fcClasses);
List<Constraint<Pair>> constraints1 = constraints.cartesianProduct().iterator().next(); //List<Constraint<Pair>> constraints1 = constraints.cartesianProduct().iterator().next();
for(Constraint<Pair> constraint : constraints1){ for(Pair p : constraints.getUndConstraints()){
for(Pair p : constraint){ factory.convertPair(p);
factory.convertPair(p); }
} for(Set<Constraint<Pair>> oder : constraints.getOderConstraints()){
factory.convertOderConstraint(oder);
} }
return factory.writer.getASPFile(); return factory.writer.getASPFile();
} }
ASPWriter writer = new ASPWriter(); /**
boolean isFCType = false; * Wandelt eine Reihe von Constraints zu einem Und-Constraint - also einer Liste - um.
* Dieser kann dann in Oder-Constraints verwendet werden.
private void convertFC(Collection<ClassOrInterface> classes) throws ClassNotFoundException { * @param undCons - Eine Liste von Constraints. Bsp: equals(..), smallerDot(..)
Set<Pair> fc = FCGenerator.toFC(classes); * @return - list(equals, list(smallerDot(..., null)
isFCType = true; */
for(Pair fcp : fc){ protected ASPStatement convertListToUndConstraint(List<ASPStatement> undCons) {
convertPair(fcp); if(undCons.size() == 0)throw new NullPointerException();
if(undCons.size() == 1){
return undCons.get(0);
} }
isFCType = false; ASPStatement list = new ASPStatement(ASPRule.ASP_LIST_ENDPOINTER.toString());
for(ASPStatement con : undCons){
list = makeStatement(ASPRule.ASP_LIST_NAME.toString(), con.getASP(), list.getASP());
}
return list;
} }
private void convertPair(Pair p){ protected ASPStatement convertListToUndConstraint(Constraint<Pair> undCons) {
List<ASPStatement> convert = new ArrayList<>();
for(Pair p : undCons){
convert.add(generatePairStmt(p));
}
return convertListToUndConstraint(convert);
}
protected void convertOderConstraint(Set<Constraint<Pair>> oder) {
if(oder.size() < 2){//Oder-Setgröße darf nicht null sein. Sonst gibt es sowieso kein Ergebnis:
for(Pair p : oder.iterator().next()){
this.convertPair(p); //Einfach als und Constraints behandeln, wenn es nur einen Oder-Zweig gibt
}
return;
}
List<ASPStatement> ret = new ArrayList<>();
Iterator<Constraint<Pair>> it = oder.iterator();
String pointer1 = ASPStringConverter.toConstant(NameGenerator.makeNewName());
ASPStatement stmt = makeStatement(ASPRule.ASP_CONSTRAINT.toString(), pointer1,
convertListToUndConstraint(it.next()).getASP());
ret.add(stmt);
while(it.hasNext()){
String pointer2 = ASPStringConverter.toConstant(NameGenerator.makeNewName());
Constraint<Pair> cons = it.next();
stmt = makeStatement(ASPRule.ASP_CONSTRAINT.toString(), pointer2,
convertListToUndConstraint(cons).getASP());
ret.add(stmt);
ASPStatement oderStmt = makeStatement(ASPRule.ASP_ODER.toString(), pointer1, pointer2);
if(it.hasNext()){
String oderPointer = ASPStringConverter.toConstant(NameGenerator.makeNewName());
stmt = makeStatement(ASPRule.ASP_CONSTRAINT.toString(), oderPointer, oderStmt.getASP());
ret.add(stmt);
pointer1 = oderPointer;
}else{
ret.add(oderStmt);
}
}
//Alle erstellten Constraints schreiben:
writer.addAll(ret);
}
protected ASPWriter writer = new ASPWriter();
protected void convertFC(Collection<ClassOrInterface> classes) throws ClassNotFoundException {
Collection<Pair> fc = FCGenerator.toFC(classes);
HashMap<String, Pair> set = new HashMap<>();
for(Pair fcp : fc){
StringBuilder output = new StringBuilder();
OutputGenerator generator = new OutputGenerator(output);
fcp.TA1.accept(generator);
output.append("<");
fcp.TA2.accept(generator);
set.put(output.toString(), fcp);
}
for(Pair fcp : set.values()){
convertPair(fcp);
}
for(ClassOrInterface cl : classes){
RefType t = fromClassOrInterface(cl);
convertPair(new Pair(t,t,PairOperator.SMALLER));
}
}
private RefType fromClassOrInterface(ClassOrInterface cl){
List<RefTypeOrTPHOrWildcardOrGeneric> params = new ArrayList<>();
for(GenericTypeVar gtv : cl.getGenerics()){
params.add(TypePlaceholder.fresh(new NullToken()));
}
return new RefType(cl.getClassName(), params, new NullToken());
}
protected void convertPair(Pair p){
ASPStatement pairStmt = generatePairStmt(p);
writer.add(pairStmt);
}
protected ASPStatement generatePairStmt(Pair p) {
String ls = p.TA1.acceptTV(this); String ls = p.TA1.acceptTV(this);
String rs = p.TA2.acceptTV(this); String rs = p.TA2.acceptTV(this);
ASPStatement pairStmt = null; ASPStatement pairStmt = null;
@ -52,40 +140,32 @@ public class ASPFactory implements TypeVisitor<String>{
}else if(p.GetOperator().equals(PairOperator.SMALLER)){ }else if(p.GetOperator().equals(PairOperator.SMALLER)){
pairStmt = makeStatement(ASPRule.ASP_PAIR_SMALLER_NAME.toString(), ls, rs); pairStmt = makeStatement(ASPRule.ASP_PAIR_SMALLER_NAME.toString(), ls, rs);
}else throw new NotImplementedException(); }else throw new NotImplementedException();
writer.add(pairStmt); return pairStmt;
} }
private ASPStatement makeStatement(String rule, String... params){ protected ASPStatement makeStatement(String rule, String... params){
String stmt = rule + "("; String stmt = rule + "(";
for(String param : params){ Iterator<String> it = Arrays.asList(params).iterator();
stmt += param + ","; while(it.hasNext()){
String param = it.next();
stmt += param;
if(it.hasNext())stmt+=",";
} }
stmt = stmt.substring(0,stmt.length()-1);
stmt += ")"; stmt += ")";
return new ASPStatement(stmt); return new ASPStatement(stmt);
} }
private String convertParameterlist(List<String> pointers){ protected void convertParameterlist(String pointer, List<String> pointers){
String pointer = ASPStringConverter.toConstant(NameGenerator.makeNewName());
Iterator<String> it = pointers.iterator(); Iterator<String> it = pointers.iterator();
String p = pointer; Integer i = 1;
if(!it.hasNext()){ String ruleName = ASPRule.ASP_PARAMLIST_NAME.toString();
return ASPRule.ASP_PARAMLIST_END_POINTER.toString();
}
while (it.hasNext()){ while (it.hasNext()){
ASPStatement stmt; ASPStatement stmt;
String type = it.next(); String type = it.next();
String nextP = ASPStringConverter.toConstant(NameGenerator.makeNewName()); stmt = makeStatement(ruleName, pointer, type, i.toString());
if(it.hasNext()){
stmt = makeStatement(ASPRule.ASP_PARAMLIST_NAME.toString(), p, type, nextP);
}else{
stmt = makeStatement(ASPRule.ASP_PARAMLIST_NAME.toString(), p, type,
ASPRule.ASP_PARAMLIST_END_POINTER.toString());
}
p = nextP;
writer.add(stmt); writer.add(stmt);
i++;
} }
return pointer;
} }
@Override @Override
@ -96,8 +176,9 @@ public class ASPFactory implements TypeVisitor<String>{
params.add(param.acceptTV(this)); params.add(param.acceptTV(this));
} }
String typeName = ASPStringConverter.toConstant(refType.getName()); String typeName = ASPStringConverter.toConstant(refType.getName());
String ruleName = isFCType?ASPRule.ASP_FCTYPE.toString():ASPRule.ASP_TYPE.toString(); String ruleName = ASPRule.ASP_TYPE.toString();
ASPStatement stmt = makeStatement(ruleName, pointer, typeName, convertParameterlist(params)); convertParameterlist(pointer, params);
ASPStatement stmt = makeStatement(ruleName, pointer, typeName, Integer.toString(params.size()));
writer.add(stmt); writer.add(stmt);
return pointer; return pointer;
} }
@ -122,6 +203,12 @@ public class ASPFactory implements TypeVisitor<String>{
@Override @Override
public String visit(GenericRefType genericRefType) { public String visit(GenericRefType genericRefType) {
throw new NotImplementedException(); //Kann eigentlich wie ein normaler RefType behandelt werden
String pointer = ASPStringConverter.toConstant(NameGenerator.makeNewName());
String typeName = ASPStringConverter.toConstant(genericRefType.getParsedName());
String ruleName = ASPRule.ASP_TYPE.toString();
ASPStatement stmt = makeStatement(ruleName, pointer, typeName, ASPRule.ASP_LIST_ENDPOINTER.toString());
writer.add(stmt);
return pointer;
} }
} }

View File

@ -15,7 +15,7 @@ import de.dhbwstuttgart.typeinference.unify.model.PairOperator;
import java.util.*; import java.util.*;
public class ASPGencayFactory implements TypeVisitor<String> { public class ASPFactoryAlternative implements TypeVisitor<String> {
/* TODO: /* TODO:
* Alle TPHs müssen als var(tph) definiert sein * Alle TPHs müssen als var(tph) definiert sein
* Wenn es eine Variable ist, dann direkt in die type-Regel schreiben: type(p, type, tph) * Wenn es eine Variable ist, dann direkt in die type-Regel schreiben: type(p, type, tph)
@ -56,7 +56,7 @@ public class ASPGencayFactory implements TypeVisitor<String> {
} }
public static String generateASP(ConstraintSet<Pair> constraints, Collection<ClassOrInterface> fcClasses) throws ClassNotFoundException{ public static String generateASP(ConstraintSet<Pair> constraints, Collection<ClassOrInterface> fcClasses) throws ClassNotFoundException{
ASPGencayFactory factory = new ASPGencayFactory(); ASPFactoryAlternative factory = new ASPFactoryAlternative();
factory.convertFC(fcClasses); factory.convertFC(fcClasses);
List<Constraint<Pair>> constraints1 = constraints.cartesianProduct().iterator().next(); List<Constraint<Pair>> constraints1 = constraints.cartesianProduct().iterator().next();
for(Constraint<Pair> constraint : constraints1){ for(Constraint<Pair> constraint : constraints1){
@ -70,7 +70,7 @@ public class ASPGencayFactory implements TypeVisitor<String> {
} }
private void convertFC(Collection<ClassOrInterface> classes) throws ClassNotFoundException { private void convertFC(Collection<ClassOrInterface> classes) throws ClassNotFoundException {
Set<Pair> fc = FCGenerator.toFC(classes); Collection<Pair> fc = FCGenerator.toFC(classes);
isFCType = true; isFCType = true;
for(Pair fcp : fc){ for(Pair fcp : fc){
generateTheta((RefType) fcp.TA1); generateTheta((RefType) fcp.TA1);
@ -130,6 +130,11 @@ public class ASPGencayFactory implements TypeVisitor<String> {
stmt = makeStatement(paramname, p, type, stmt = makeStatement(paramname, p, type,
ASPGencayRule.ASP_PARAMLIST_END_POINTER.toString()); ASPGencayRule.ASP_PARAMLIST_END_POINTER.toString());
} }
if(!it.hasNext()){ //Falls es der letzte Pointer ist
String endRule = isFCType?ASPGencayRule.ASP_PARAMLIST_END_RULE_FC.toString():ASPGencayRule.ASP_PARAMLIST_END_RULE_EQ.toString();
writer.add(makeStatement(endRule, p,
ASPGencayRule.ASP_PARAMLIST_END_POINTER.toString()));
}
p = nextP; p = nextP;
writer.add(stmt); writer.add(stmt);
} }
@ -143,11 +148,11 @@ public class ASPGencayFactory implements TypeVisitor<String> {
String pointer = ASPStringConverter.toConstant(NameGenerator.makeNewName()); String pointer = ASPStringConverter.toConstant(NameGenerator.makeNewName());
currentFCTypePointer = pointer; currentFCTypePointer = pointer;
String paramPointer = ASPGencayRule.ASP_PARAMLIST_END_POINTER.toString(); String paramPointer = ASPGencayRule.ASP_PARAMLIST_END_POINTER.toString();
if(refType.getParaList().size() == 1 ){ if(refType.getParaList().size() == 1
if(refType.getParaList().get(0) instanceof TypePlaceholder){ && (refType.getParaList().get(0) instanceof TypePlaceholder
TypePlaceholder typePlaceholder = (TypePlaceholder) refType.getParaList().get(0); || refType.getParaList().get(0) instanceof WildcardType)){
paramPointer = typePlaceholder.acceptTV(this); RefTypeOrTPHOrWildcardOrGeneric typePlaceholder = refType.getParaList().get(0);
} paramPointer = typePlaceholder.acceptTV(this);
}else{ }else{
List<String> params = null; List<String> params = null;
params = generateParameter(refType); params = generateParameter(refType);
@ -194,6 +199,8 @@ public class ASPGencayFactory implements TypeVisitor<String> {
ret.addAll(generateParameter((RefType) param)); ret.addAll(generateParameter((RefType) param));
}else if(param instanceof TypePlaceholder){ }else if(param instanceof TypePlaceholder){
ret.add(param.acceptTV(this)); ret.add(param.acceptTV(this));
}else if(param instanceof WildcardType){
ret.add(param.acceptTV(this));
}else throw new NotImplementedException(); }else throw new NotImplementedException();
} }
return ret; return ret;
@ -201,7 +208,10 @@ public class ASPGencayFactory implements TypeVisitor<String> {
@Override @Override
public String visit(SuperWildcardType superWildcardType) { public String visit(SuperWildcardType superWildcardType) {
throw new NotImplementedException(); String pointer = ASPStringConverter.toConstant(NameGenerator.makeNewName());
writer.add(makeStatement(ASPGencayRule.ASP_WILDCARD.toString(),
pointer, "super", superWildcardType.getInnerType().acceptTV(this)));
return pointer;
} }
@Override @Override
@ -222,7 +232,10 @@ public class ASPGencayFactory implements TypeVisitor<String> {
@Override @Override
public String visit(ExtendsWildcardType extendsWildcardType) { public String visit(ExtendsWildcardType extendsWildcardType) {
throw new NotImplementedException(); String pointer = ASPStringConverter.toConstant(NameGenerator.makeNewName());
writer.add(makeStatement(ASPGencayRule.ASP_WILDCARD.toString(),
pointer, "extends", extendsWildcardType.getInnerType().acceptTV(this)));
return pointer;
} }
@Override @Override

View File

@ -1,5 +1,6 @@
package de.dhbwstuttgart.sat.asp.writer; package de.dhbwstuttgart.sat.asp.writer;
import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;

View File

@ -0,0 +1,30 @@
package de.dhbwstuttgart.syntaxtree.visual;
import de.dhbwstuttgart.syntaxtree.type.*;
public class TypePrinter implements TypeVisitor<String> {
@Override
public String visit(RefType refType) {
return refType.toString();
}
@Override
public String visit(SuperWildcardType superWildcardType) {
return "? super " + superWildcardType.getInnerType().acceptTV(this);
}
@Override
public String visit(TypePlaceholder typePlaceholder) {
return "TPH " + typePlaceholder.getName();
}
@Override
public String visit(ExtendsWildcardType extendsWildcardType) {
return "? extends " + extendsWildcardType.getInnerType().acceptTV(this);
}
@Override
public String visit(GenericRefType genericRefType) {
return genericRefType.getParsedName();
}
}

View File

@ -52,4 +52,12 @@ public class ConstraintSet<A> {
ret.oderConstraints = newOder; ret.oderConstraints = newOder;
return ret; return ret;
} }
public Constraint<A> getUndConstraints() {
return undConstraints;
}
public List<Set<Constraint<A>>> getOderConstraints() {
return oderConstraints;
}
} }

View File

@ -1,9 +1,9 @@
package asp; package asp;
import de.dhbwstuttgart.parser.NullToken; import de.dhbwstuttgart.parser.NullToken;
import de.dhbwstuttgart.sat.asp.ASPUnify;
import de.dhbwstuttgart.sat.asp.parser.ASPParser; import de.dhbwstuttgart.sat.asp.parser.ASPParser;
import de.dhbwstuttgart.sat.asp.writer.ASPFactory; import de.dhbwstuttgart.sat.asp.writer.ASPFactory;
import de.dhbwstuttgart.sat.asp.Clingo;
import de.dhbwstuttgart.syntaxtree.ClassOrInterface; import de.dhbwstuttgart.syntaxtree.ClassOrInterface;
import de.dhbwstuttgart.syntaxtree.factory.ASTFactory; import de.dhbwstuttgart.syntaxtree.factory.ASTFactory;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric; import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
@ -14,8 +14,6 @@ import de.dhbwstuttgart.typeinference.result.ResultSet;
import de.dhbwstuttgart.typeinference.unify.model.PairOperator; import de.dhbwstuttgart.typeinference.unify.model.PairOperator;
import org.junit.Test; import org.junit.Test;
import javax.json.Json;
import javax.json.JsonObject;
import java.io.*; import java.io.*;
import java.util.*; import java.util.*;
@ -31,7 +29,7 @@ public class ClingoTest {
writer.println(content); writer.println(content);
writer.close(); writer.close();
Clingo clingo = new Clingo(Arrays.asList(new File(tempDirectory + "test.lp"))); ASPUnify clingo = new ASPUnify(Arrays.asList(new File(tempDirectory + "test.lp")));
String result = clingo.runClingo(); String result = clingo.runClingo();
System.out.println(result); System.out.println(result);
ResultSet resultSet = ASPParser.parse(result, Arrays.asList(testType)); ResultSet resultSet = ASPParser.parse(result, Arrays.asList(testType));

View File

@ -1,103 +0,0 @@
package asp;
import de.dhbwstuttgart.parser.NullToken;
import de.dhbwstuttgart.parser.scope.JavaClassName;
import de.dhbwstuttgart.sat.asp.Clingo;
import de.dhbwstuttgart.sat.asp.parser.ASPParser;
import de.dhbwstuttgart.sat.asp.writer.ASPFactory;
import de.dhbwstuttgart.syntaxtree.ClassOrInterface;
import de.dhbwstuttgart.syntaxtree.factory.ASTFactory;
import de.dhbwstuttgart.syntaxtree.type.*;
import de.dhbwstuttgart.syntaxtree.visual.ResultSetPrinter;
import de.dhbwstuttgart.typeinference.constraints.ConstraintSet;
import de.dhbwstuttgart.typeinference.constraints.Pair;
import de.dhbwstuttgart.typeinference.result.ResultSet;
import de.dhbwstuttgart.typeinference.unify.model.PairOperator;
import org.junit.Test;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Ref;
import java.util.*;
public class UnifyWithoutWildcards {
public static final String tempDirectory = "/tmp/";
@Test
public void adapt() throws InterruptedException, IOException, ClassNotFoundException {
ConstraintSet<Pair> testSet = new ConstraintSet<>();
List<RefTypeOrTPHOrWildcardOrGeneric> list1 = Arrays.asList(TypePlaceholder.fresh(new NullToken()));
List<RefTypeOrTPHOrWildcardOrGeneric> list2 = Arrays.asList(TypePlaceholder.fresh(new NullToken()),TypePlaceholder.fresh(new NullToken()));
RefType t1 = new RefType(new JavaClassName("asp.UnifyWithoutWildcards$Matrix"), list1, new NullToken());
RefType t2 = new RefType(new JavaClassName("java.util.HashMap"), list2, new NullToken());
testSet.addUndConstraint(new Pair(t1, t2, PairOperator.SMALLERDOT));
ResultSet resultSet = run(testSet);
System.out.println(ResultSetPrinter.print(resultSet));
assert resultSet.results.size() > 0;
}
public ResultSet run(ConstraintSet<Pair> toTest) throws IOException, InterruptedException, ClassNotFoundException {
String content = "";
content = ASPFactory.generateASP(toTest, this.getFC());
PrintWriter writer = new PrintWriter(tempDirectory + "test.lp", "UTF-8");
writer.println(content);
writer.close();
Clingo clingo = new Clingo(Arrays.asList(new File(tempDirectory + "test.lp")));
String result = clingo.runClingo();
ResultSet resultSet = ASPParser.parse(result, getInvolvedTPHS(toTest));
return resultSet;
}
private static class TPHExtractor implements TypeVisitor<List<TypePlaceholder>>{
@Override
public List<TypePlaceholder> visit(RefType refType) {
ArrayList<TypePlaceholder> ret = new ArrayList<>();
for(RefTypeOrTPHOrWildcardOrGeneric param : refType.getParaList()){
ret.addAll(param.acceptTV(this));
}
return ret;
}
@Override
public List<TypePlaceholder> visit(SuperWildcardType superWildcardType) {
return superWildcardType.getInnerType().acceptTV(this);
}
@Override
public List<TypePlaceholder> visit(TypePlaceholder typePlaceholder) {
return Arrays.asList(typePlaceholder);
}
@Override
public List<TypePlaceholder> visit(ExtendsWildcardType extendsWildcardType) {
return extendsWildcardType.getInnerType().acceptTV(this);
}
@Override
public List<TypePlaceholder> visit(GenericRefType genericRefType) {
return new ArrayList<>();
}
}
protected Collection<TypePlaceholder> getInvolvedTPHS(ConstraintSet<Pair> toTest) {
List<TypePlaceholder> ret = new ArrayList<>();
toTest.map((Pair p)-> {
ret.addAll(p.TA1.acceptTV(new TPHExtractor()));
ret.addAll(p.TA2.acceptTV(new TPHExtractor()));
return p;
});
return ret;
}
private Collection<ClassOrInterface> getFC() {
Set<ClassOrInterface> ret = new HashSet<>();
ret.add(ASTFactory.createClass(Matrix.class));
//ret.add(ASTFactory.createObjectClass());
//ret.add(ASTFactory.createClass(java.util.List.class));
return ret;
}
private class Matrix<A> extends HashMap<A,Map<Integer, A>>{}
}

View File

@ -1,31 +1,22 @@
package asp.gencay; package asp.gencay;
import asp.UnifyWithoutWildcards;
import de.dhbwstuttgart.parser.NullToken; import de.dhbwstuttgart.parser.NullToken;
import de.dhbwstuttgart.parser.scope.JavaClassName; import de.dhbwstuttgart.parser.scope.JavaClassName;
import de.dhbwstuttgart.sat.asp.Clingo; import de.dhbwstuttgart.sat.asp.writer.ASPFactoryAlternative;
import de.dhbwstuttgart.sat.asp.parser.ASPParser;
import de.dhbwstuttgart.sat.asp.writer.ASPFactory;
import de.dhbwstuttgart.sat.asp.writer.ASPGencayFactory;
import de.dhbwstuttgart.syntaxtree.ClassOrInterface; import de.dhbwstuttgart.syntaxtree.ClassOrInterface;
import de.dhbwstuttgart.syntaxtree.factory.ASTFactory; import de.dhbwstuttgart.syntaxtree.factory.ASTFactory;
import de.dhbwstuttgart.syntaxtree.type.ExtendsWildcardType;
import de.dhbwstuttgart.syntaxtree.type.RefType; import de.dhbwstuttgart.syntaxtree.type.RefType;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric; import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder; import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
import de.dhbwstuttgart.syntaxtree.visual.ResultSetPrinter;
import de.dhbwstuttgart.typeinference.constraints.ConstraintSet; import de.dhbwstuttgart.typeinference.constraints.ConstraintSet;
import de.dhbwstuttgart.typeinference.constraints.Pair; import de.dhbwstuttgart.typeinference.constraints.Pair;
import de.dhbwstuttgart.typeinference.result.ResultSet;
import de.dhbwstuttgart.typeinference.unify.model.PairOperator; import de.dhbwstuttgart.typeinference.unify.model.PairOperator;
import org.junit.Test; import org.junit.Test;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.*; import java.util.*;
import java.util.concurrent.ArrayBlockingQueue;
public class GeneratorTest extends UnifyWithoutWildcards{ public class GeneratorTest {
@Test @Test
public void simple() throws ClassNotFoundException { public void simple() throws ClassNotFoundException {
ConstraintSet<Pair> testSet = new ConstraintSet<>(); ConstraintSet<Pair> testSet = new ConstraintSet<>();
@ -34,7 +25,7 @@ public class GeneratorTest extends UnifyWithoutWildcards{
RefType t1 = new RefType(new JavaClassName("java.util.List"), list1, new NullToken()); RefType t1 = new RefType(new JavaClassName("java.util.List"), list1, new NullToken());
RefType t2 = new RefType(new JavaClassName("java.util.List"), list2, new NullToken()); RefType t2 = new RefType(new JavaClassName("java.util.List"), list2, new NullToken());
testSet.addUndConstraint(new Pair(t1, t2, PairOperator.SMALLERDOT)); testSet.addUndConstraint(new Pair(t1, t2, PairOperator.SMALLERDOT));
String resultSet = ASPGencayFactory.generateASP(testSet, String resultSet = ASPFactoryAlternative.generateASP(testSet,
new HashSet<>(Arrays.asList(ASTFactory.createClass(List.class)))); new HashSet<>(Arrays.asList(ASTFactory.createClass(List.class))));
System.out.println(resultSet); System.out.println(resultSet);
} }
@ -47,13 +38,73 @@ public class GeneratorTest extends UnifyWithoutWildcards{
RefType t1 = new RefType(new JavaClassName("asp.UnifyWithoutWildcards$Matrix"), list1, new NullToken()); RefType t1 = new RefType(new JavaClassName("asp.UnifyWithoutWildcards$Matrix"), list1, new NullToken());
RefType t2 = new RefType(new JavaClassName("java.util.HashMap"), list2, new NullToken()); RefType t2 = new RefType(new JavaClassName("java.util.HashMap"), list2, new NullToken());
testSet.addUndConstraint(new Pair(t1, t2, PairOperator.SMALLERDOT)); testSet.addUndConstraint(new Pair(t1, t2, PairOperator.SMALLERDOT));
String resultSet = ASPGencayFactory.generateASP(testSet, this.getFC()); String resultSet = ASPFactoryAlternative.generateASP(testSet, this.getFC());
System.out.println(resultSet);
}
@Test
public void wildcardExample() throws ClassNotFoundException { //Das Beispiel aus dem Paper
ConstraintSet<Pair> testSet = new ConstraintSet<>();
TypePlaceholder tphA = TypePlaceholder.fresh(new NullToken());
RefType number = new RefType(new JavaClassName(Number.class.getName()), new ArrayList<>(), new NullToken());
ExtendsWildcardType extendsNumber = new ExtendsWildcardType(number, new NullToken());
List<RefTypeOrTPHOrWildcardOrGeneric> list1 = Arrays.asList(tphA);
List<RefTypeOrTPHOrWildcardOrGeneric> list2 = Arrays.asList(extendsNumber);
RefType stack = new RefType(new JavaClassName(Stack.class.getName()), list1, new NullToken());
RefType vector = new RefType(new JavaClassName(Vector.class.getName()), list2, new NullToken());
testSet.addUndConstraint(new Pair(stack, vector, PairOperator.SMALLERDOT));
Set<ClassOrInterface> fc = new HashSet<>();
fc.add(ASTFactory.createClass(Stack.class));
fc.add(ASTFactory.createClass(AbstractList.class));
fc.add(ASTFactory.createClass(Integer.class));
String resultSet = ASPFactoryAlternative.generateASP(testSet, fc);
System.out.println(resultSet);
}
@Test
public void example5() throws ClassNotFoundException { //Das Beispiel aus dem Paper
ConstraintSet<Pair> testSet = new ConstraintSet<>();
TypePlaceholder tphA = TypePlaceholder.fresh(new NullToken());
RefType number = new RefType(new JavaClassName(Number.class.getName()), new ArrayList<>(), new NullToken());
ExtendsWildcardType extendsNumber = new ExtendsWildcardType(number, new NullToken());
List<RefTypeOrTPHOrWildcardOrGeneric> list1 = Arrays.asList(tphA);
List<RefTypeOrTPHOrWildcardOrGeneric> list2 = Arrays.asList(extendsNumber);
RefType stack = new RefType(new JavaClassName(Stack.class.getName()), list1, new NullToken());
RefType vector = new RefType(new JavaClassName(Vector.class.getName()), list2, new NullToken());
testSet.addUndConstraint(new Pair(stack, vector, PairOperator.SMALLERDOT));
RefType integer = new RefType(new JavaClassName(Integer.class.getName()), new ArrayList<>(), new NullToken());
List<RefTypeOrTPHOrWildcardOrGeneric> list3 = Arrays.asList(integer);
List<RefTypeOrTPHOrWildcardOrGeneric> list4 = Arrays.asList(tphA);
RefType abstractList = new RefType(new JavaClassName(AbstractList.class.getName()), list3, new NullToken());
RefType list = new RefType(new JavaClassName(List.class.getName()), list4, new NullToken());
testSet.addUndConstraint(new Pair(abstractList, list, PairOperator.SMALLERDOT));
Set<ClassOrInterface> fc = new HashSet<>();
fc.add(ASTFactory.createClass(Stack.class));
fc.add(ASTFactory.createClass(Vector.class));
fc.add(ASTFactory.createClass(AbstractList.class));
fc.add(ASTFactory.createClass(List.class));
fc.add(ASTFactory.createClass(Integer.class));
fc.add(ASTFactory.createClass(Number.class));
String resultSet = ASPFactoryAlternative.generateASP(testSet, fc);
//String resultSet = ASPFactoryAlternative.generateASP(testSet, new HashSet<>());
System.out.println(resultSet); System.out.println(resultSet);
} }
private Collection<ClassOrInterface> getFC() { private Collection<ClassOrInterface> getFC() {
Set<ClassOrInterface> ret = new HashSet<>(); Set<ClassOrInterface> ret = new HashSet<>();
ret.add(ASTFactory.createClass(Matrix.class)); ret.add(ASTFactory.createClass(Matrix.class));
ret.add(ASTFactory.createClass(Stack.class));
ret.add(ASTFactory.createClass(AbstractList.class));
//ret.add(ASTFactory.createObjectClass()); //ret.add(ASTFactory.createObjectClass());
//ret.add(ASTFactory.createClass(java.util.List.class)); //ret.add(ASTFactory.createClass(java.util.List.class));
return ret; return ret;

View File

@ -1,10 +0,0 @@
package asp.unifywithoutwildcards;
import org.junit.Test;
public class ASPTests {
@Test
public void test(){
}
}

View File

@ -0,0 +1,125 @@
package asp.withWildcards;
import de.dhbwstuttgart.core.JavaTXCompiler;
import de.dhbwstuttgart.sat.asp.writer.ASPFactory;
import de.dhbwstuttgart.syntaxtree.ClassOrInterface;
import de.dhbwstuttgart.syntaxtree.SourceFile;
import de.dhbwstuttgart.syntaxtree.visual.ASTPrinter;
import de.dhbwstuttgart.syntaxtree.visual.ASTTypePrinter;
import de.dhbwstuttgart.syntaxtree.visual.ResultSetPrinter;
import de.dhbwstuttgart.typedeployment.TypeInsert;
import de.dhbwstuttgart.typedeployment.TypeInsertFactory;
import de.dhbwstuttgart.typeinference.constraints.ConstraintSet;
import de.dhbwstuttgart.typeinference.constraints.Pair;
import de.dhbwstuttgart.typeinference.result.ResultSet;
import org.junit.Test;
import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
public class InputGenerator {
public static final String rootDirectory = System.getProperty("user.dir")+"/test/javFiles/";
@Test
public void finiteClosure() throws IOException, ClassNotFoundException, InterruptedException {
execute(new File(rootDirectory+"fc.jav"));
}
@Test
public void lambda() throws IOException, ClassNotFoundException, InterruptedException {
execute(new File(rootDirectory+"Lambda.jav"));
}
@Test
public void lambda2() throws IOException, ClassNotFoundException, InterruptedException {
execute(new File(rootDirectory+"Lambda2.jav"));
}
@Test
public void lambda3() throws IOException, ClassNotFoundException, InterruptedException {
execute(new File(rootDirectory+"Lambda3.jav"));
}
@Test
public void mathStruc() throws IOException, ClassNotFoundException, InterruptedException {
execute(new File(rootDirectory+"mathStruc.jav"));
}
@Test
public void generics() throws IOException, ClassNotFoundException, InterruptedException {
execute(new File(rootDirectory+"Generics.jav"));
}
@Test
public void genericsMethodCall() throws IOException, ClassNotFoundException, InterruptedException {
execute(new File(rootDirectory+"MethodCallGenerics.jav"));
//TODO: Hier sollte der Rückgabetyp der Methode String sein
}
@Test
public void faculty() throws IOException, ClassNotFoundException, InterruptedException {
execute(new File(rootDirectory+"Faculty.jav"));
}
@Test
public void facultyTyped() throws IOException, ClassNotFoundException, InterruptedException {
execute(new File(rootDirectory+"FacultyTyped.jav"));
}
@Test
public void matrix() throws IOException, ClassNotFoundException, InterruptedException {
execute(new File(rootDirectory+"Matrix.jav"));
}
@Test
public void packageTests() throws IOException, ClassNotFoundException, InterruptedException {
execute(new File(rootDirectory+"Package.jav"));
}
@Test
public void vector() throws IOException, ClassNotFoundException, InterruptedException {
execute(new File(rootDirectory+"Vector.jav"));
}
@Test
public void lambdaRunnable() throws IOException, ClassNotFoundException, InterruptedException {
execute(new File(rootDirectory+"LambdaRunnable.jav"));
}
@Test
public void expressions() throws IOException, ClassNotFoundException, InterruptedException {
execute(new File(rootDirectory+"Expressions.jav"));
}
@Test
public void addLong() throws IOException, ClassNotFoundException, InterruptedException {
execute(new File(rootDirectory+"AddLong.jav"));
}
private static class TestResultSet{
}
public void execute(File fileToTest) throws IOException, ClassNotFoundException, InterruptedException {
JavaTXCompiler compiler = new JavaTXCompiler(fileToTest);
//List<ResultSet> results = compiler.aspTypeInference();
List<ClassOrInterface> allClasses = new ArrayList<>();//environment.getAllAvailableClasses();
//Alle Importierten Klassen in allen geparsten Sourcefiles kommen ins FC
for(SourceFile sf : compiler.sourceFiles.values()) {
allClasses.addAll(compiler.getAvailableClasses(sf));
allClasses.addAll(sf.getClasses());
}
final ConstraintSet<Pair> cons = compiler.getConstraints();
String content = "";
content = ASPFactory.generateASP(cons, allClasses);
System.out.println(cons);
System.out.println(content);
}
static String readFile(String path, Charset encoding)
throws IOException
{
byte[] encoded = Files.readAllBytes(Paths.get(path));
return new String(encoded, encoding);
}
}

View File

@ -1,9 +1,10 @@
package typeinference; package asp.withWildcards;
import de.dhbwstuttgart.core.JavaTXCompiler; import de.dhbwstuttgart.core.JavaTXCompiler;
import de.dhbwstuttgart.syntaxtree.SourceFile; import de.dhbwstuttgart.syntaxtree.SourceFile;
import de.dhbwstuttgart.syntaxtree.visual.ASTPrinter; import de.dhbwstuttgart.syntaxtree.visual.ASTPrinter;
import de.dhbwstuttgart.syntaxtree.visual.ASTTypePrinter; import de.dhbwstuttgart.syntaxtree.visual.ASTTypePrinter;
import de.dhbwstuttgart.syntaxtree.visual.ResultSetPrinter;
import de.dhbwstuttgart.typedeployment.TypeInsert; import de.dhbwstuttgart.typedeployment.TypeInsert;
import de.dhbwstuttgart.typedeployment.TypeInsertFactory; import de.dhbwstuttgart.typedeployment.TypeInsertFactory;
import de.dhbwstuttgart.typeinference.result.ResultSet; import de.dhbwstuttgart.typeinference.result.ResultSet;
@ -15,97 +16,87 @@ import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
public class JavaTXCompilerTest { public class JavaTXCompilerASPTest {
public static final String rootDirectory = System.getProperty("user.dir")+"/test/javFiles/"; public static final String rootDirectory = System.getProperty("user.dir")+"/test/javFiles/";
/*
@Test @Test
public void finiteClosure() throws IOException, ClassNotFoundException { public void finiteClosure() throws IOException, ClassNotFoundException, InterruptedException {
execute(new File(rootDirectory+"fc.jav")); execute(new File(rootDirectory+"fc.jav"));
} }
@Test @Test
public void lambda() throws IOException, ClassNotFoundException { public void lambda() throws IOException, ClassNotFoundException, InterruptedException {
execute(new File(rootDirectory+"Lambda.jav")); execute(new File(rootDirectory+"Lambda.jav"));
} }
@Test @Test
public void lambda2() throws IOException, ClassNotFoundException { public void lambda2() throws IOException, ClassNotFoundException, InterruptedException {
execute(new File(rootDirectory+"Lambda2.jav")); execute(new File(rootDirectory+"Lambda2.jav"));
} }
@Test @Test
public void lambda3() throws IOException, ClassNotFoundException { public void lambda3() throws IOException, ClassNotFoundException, InterruptedException {
execute(new File(rootDirectory+"Lambda3.jav")); execute(new File(rootDirectory+"Lambda3.jav"));
} }
@Test @Test
public void mathStruc() throws IOException, ClassNotFoundException { public void mathStruc() throws IOException, ClassNotFoundException, InterruptedException {
execute(new File(rootDirectory+"mathStruc.jav")); execute(new File(rootDirectory+"mathStruc.jav"));
} }
@Test @Test
public void generics() throws IOException, ClassNotFoundException { public void generics() throws IOException, ClassNotFoundException, InterruptedException {
execute(new File(rootDirectory+"Generics.jav")); execute(new File(rootDirectory+"Generics.jav"));
} }
@Test @Test
public void genericsMethodCall() throws IOException, ClassNotFoundException { public void genericsMethodCall() throws IOException, ClassNotFoundException, InterruptedException {
TestResultSet result = execute(new File(rootDirectory+"MethodCallGenerics.jav")); TestResultSet result = execute(new File(rootDirectory+"MethodCallGenerics.jav"));
//TODO: Hier sollte der Rückgabetyp der Methode String sein //TODO: Hier sollte der Rückgabetyp der Methode String sein
} }
@Test @Test
public void faculty() throws IOException, ClassNotFoundException { public void faculty() throws IOException, ClassNotFoundException, InterruptedException {
execute(new File(rootDirectory+"Faculty.jav")); execute(new File(rootDirectory+"Faculty.jav"));
} }
@Test @Test
public void facultyTyped() throws IOException, ClassNotFoundException { public void facultyTyped() throws IOException, ClassNotFoundException, InterruptedException {
execute(new File(rootDirectory+"FacultyTyped.jav")); execute(new File(rootDirectory+"FacultyTyped.jav"));
} }
@Test @Test
public void matrix() throws IOException, ClassNotFoundException { public void matrix() throws IOException, ClassNotFoundException, InterruptedException {
execute(new File(rootDirectory+"Matrix.jav")); execute(new File(rootDirectory+"Matrix.jav"));
} }
@Test @Test
public void packageTests() throws IOException, ClassNotFoundException { public void packageTests() throws IOException, ClassNotFoundException, InterruptedException {
execute(new File(rootDirectory+"Package.jav")); execute(new File(rootDirectory+"Package.jav"));
} }
*/
@Test @Test
public void vector() throws IOException, ClassNotFoundException { public void vector() throws IOException, ClassNotFoundException, InterruptedException {
execute(new File(rootDirectory+"Vector.jav")); execute(new File(rootDirectory+"Vector.jav"));
} }
/*
@Test @Test
public void lambdaRunnable() throws IOException, ClassNotFoundException { public void lambdaRunnable() throws IOException, ClassNotFoundException, InterruptedException {
execute(new File(rootDirectory+"LambdaRunnable.jav")); execute(new File(rootDirectory+"LambdaRunnable.jav"));
} }
@Test @Test
public void expressions() throws IOException, ClassNotFoundException { public void expressions() throws IOException, ClassNotFoundException, InterruptedException {
execute(new File(rootDirectory+"Expressions.jav")); execute(new File(rootDirectory+"Expressions.jav"));
} }
@Test @Test
public void addLong() throws IOException, ClassNotFoundException { public void addLong() throws IOException, ClassNotFoundException, InterruptedException {
execute(new File(rootDirectory+"AddLong.jav")); execute(new File(rootDirectory+"AddLong.jav"));
} }
*/
private static class TestResultSet{ private static class TestResultSet{
} }
public TestResultSet execute(File fileToTest) throws IOException, ClassNotFoundException { public TestResultSet execute(File fileToTest) throws IOException, ClassNotFoundException, InterruptedException {
//filesToTest.add(new File(rootDirectory+"fc.jav"));
//filesToTest.add(new File(rootDirectory+"Lambda.jav"));
//filesToTest.add(new File(rootDirectory+"Lambda2.jav"));
//filesToTest.add(new File(rootDirectory+"Lambda3.jav"));
//filesToTest.add(new File(rootDirectory+"Vector.jav"));
//filesToTest.add(new File(rootDirectory+"Generics.jav"));
//filesToTest.add(new File(rootDirectory+"MethodsEasy.jav"));
//filesToTest.add(new File(rootDirectory+"Matrix.jav"));
//filesToTest.add(new File(rootDirectory+"Import.jav"));
// //filesToTest.add(new File(rootDirectory+"Faculty.jav"));
// //filesToTest.add(new File(rootDirectory+"mathStruc.jav"));
// //filesToTest.add(new File(rootDirectory+"test.jav"));
JavaTXCompiler compiler = new JavaTXCompiler(fileToTest); JavaTXCompiler compiler = new JavaTXCompiler(fileToTest);
List<ResultSet> results = compiler.typeInference(); List<ResultSet> results = compiler.aspTypeInference();
for(File f : compiler.sourceFiles.keySet()){ for(File f : compiler.sourceFiles.keySet()){
SourceFile sf = compiler.sourceFiles.get(f); SourceFile sf = compiler.sourceFiles.get(f);
@ -113,6 +104,7 @@ public class JavaTXCompilerTest {
System.out.println(ASTPrinter.print(sf)); System.out.println(ASTPrinter.print(sf));
//List<ResultSet> results = compiler.typeInference(); PL 2017-10-03 vor die For-Schleife gezogen //List<ResultSet> results = compiler.typeInference(); PL 2017-10-03 vor die For-Schleife gezogen
assert results.size()>0; assert results.size()>0;
System.out.println(ResultSetPrinter.print(results.get(0)));
Set<String> insertedTypes = new HashSet<>(); Set<String> insertedTypes = new HashSet<>();
for(ResultSet resultSet : results){ for(ResultSet resultSet : results){
Set<TypeInsert> result = TypeInsertFactory.createTypeInsertPoints(sf, resultSet); Set<TypeInsert> result = TypeInsertFactory.createTypeInsertPoints(sf, resultSet);

View File

@ -0,0 +1,42 @@
package asp.withWildcards;
import de.dhbwstuttgart.sat.asp.Clingo;
import de.dhbwstuttgart.sat.asp.writer.ASPFactory;
import de.dhbwstuttgart.syntaxtree.ClassOrInterface;
import de.dhbwstuttgart.syntaxtree.factory.ASTFactory;
import org.junit.Test;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
public class ProduceFC extends ASPFactory{
public static final String tempDirectory = "/tmp/";
@Test
public void testInteger() throws InterruptedException, IOException, ClassNotFoundException {
Collection<ClassOrInterface> fc = new ArrayList<>();
fc.add(ASTFactory.createClass(Integer.class));
System.out.println(run(fc));
}
public String run(Collection<ClassOrInterface> fc) throws IOException, InterruptedException, ClassNotFoundException {
String content = "";
this.convertFC(fc);
content = writer.getASPFile();
PrintWriter writer = new PrintWriter(tempDirectory + "test.lp", "UTF-8");
writer.println(content);
writer.close();
Clingo clingo = new Clingo(
Arrays.asList(new File(tempDirectory + "test.lp"),
new File("/home/janulrich/Sync/HiwiJob/ResearchPapers/MasterarbeitStadelmeier/asp/finiteClosure/fc.pl")));
String result = clingo.runClingo();
return result;
}
}

View File

@ -0,0 +1,42 @@
package asp.withWildcards;
import de.dhbwstuttgart.sat.asp.Clingo;
import de.dhbwstuttgart.syntaxtree.ClassOrInterface;
import de.dhbwstuttgart.syntaxtree.factory.ASTFactory;
import org.junit.Test;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
public class TestFC {
public static final String tempDirectory = "/tmp/";
@Test
public void testInteger() throws InterruptedException, IOException, ClassNotFoundException {
Collection<ClassOrInterface> fc = new ArrayList<>();
fc.add(ASTFactory.createClass(Integer.class));
System.out.println(run(fc));
//TODO Hier noch Constraint Integer <. a anfügen
}
public String run(Collection<ClassOrInterface> fc) throws IOException, InterruptedException, ClassNotFoundException {
String content = "";
//this.convertFC(fc);
//content = writer.getASPFile();
PrintWriter writer = new PrintWriter(tempDirectory + "test.lp", "UTF-8");
writer.println(content);
writer.close();
Clingo clingo = new Clingo(
Arrays.asList(new File(tempDirectory + "test.lp"),
new File("/home/janulrich/Sync/HiwiJob/ResearchPapers/MasterarbeitStadelmeier/asp/finiteClosure/fc.pl")));
String result = clingo.runClingo();
return result;
}
}

View File

@ -1,34 +0,0 @@
package astfactory;
//import javafx.collections.ObservableList;
import de.dhbwstuttgart.syntaxtree.ClassOrInterface;
import de.dhbwstuttgart.syntaxtree.factory.ASTFactory;
import de.dhbwstuttgart.syntaxtree.type.GenericRefType;
import org.junit.Test;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.lang.reflect.TypeVariable;
import java.util.Arrays;
import java.util.HashMap;
import static org.junit.Assert.*;
public class ASTFactoryTest<A> extends HashMap<String, A>{
@Test
public void test(){
System.out.println((this.getClass().getGenericSuperclass()));
Type[] arguments = ((ParameterizedType) this.getClass().getGenericSuperclass()).getActualTypeArguments();
System.out.println(Arrays.toString(arguments));
System.out.println(((TypeVariable)arguments[1]).getGenericDeclaration());
}
public static class GenericFieldTest<G>{
public G testField;
}
@Test
public void genericFieldTest(){
ClassOrInterface test = ASTFactory.createClass(GenericFieldTest.class);
assertTrue(test.getFieldDecl().get(0).getType() instanceof GenericRefType);
}
}

View File

@ -1,8 +0,0 @@
package bytecode;
public class ATest extends JavaTXCompilerTest {
public ATest() {
fileName = "Example";
}
}

View File

@ -1,30 +0,0 @@
import java.lang.Integer;
import java.lang.Boolean;
import java.lang.String;
import java.lang.Byte;
import java.lang.Short;
import java.lang.Long;
import java.lang.Float;
import java.lang.Double;
import java.lang.Character;
class AssignToLit {
void m(){
// String s = "Test";
// Boolean b = false;
// Byte byte1 = 5;
// Byte byte2 = 55;
// Short short1 = 5;
// Short short2 = 55;
// Integer int1 = 5;
// Integer int2 = 8888888;
// Long long1 = 1;
// Long long2 = 5;
// Long long3 = 89989898;
// Float float1 = 1;
// Float float2 = 55;
// Double d1 = 1;
// Double d2 = 55;
Character c = 'A';
}
}

View File

@ -1,7 +0,0 @@
package bytecode;
public class AssignToLitTest extends JavaTXCompilerTest {
public AssignToLitTest() {
this.fileName = "AssignToLit";
}
}

View File

@ -1,11 +0,0 @@
public class DuMethod{
method(a){
return a+a;
}
method(a){
return a;
}
}

View File

@ -1,7 +0,0 @@
package bytecode;
public class DuMethodTest extends JavaTXCompilerTest{
public DuMethodTest() {
this.fileName = "DuMethod";
}
}

View File

@ -1,8 +0,0 @@
public class EmptyMethod{
public void m1(){
System.out.println("test");
}
public void m2(){}
}

View File

@ -1,9 +0,0 @@
import java.lang.String;
public class Example {
public m() {
String x = "X";
return x;
}
}

View File

@ -1,3 +0,0 @@
public class Exceptions {
// m(Integer i) throws
}

View File

@ -1,14 +0,0 @@
class Faculty {
Integer mul(Integer x, Integer y) {
return x;
}
m () {
var fact = (Integer x) -> {
return mul(x, x);
};
return fact;
}
}

View File

@ -1,10 +0,0 @@
class Faculty2 {
m () {
var fact = (Integer x) -> {
return x;
};
return fact;
}
}

View File

@ -1,30 +0,0 @@
import java.lang.Integer;
import java.lang.Boolean;
class For{
Integer m(Integer x){
var c = x + 2;
// Boolean b = true;
// c = 5;
// c++;
// ++c;
// c--;
// --c;
// while(x<2){
// x = x +1;
// b = false;
// }
return c;
// for(int i = 0;i<10;i++) {
// x = x + 5;
// }
}
// m2(Integer x){
// if(x<2) {
// return 1;
// }else {
// return 2;
// }
// }
}

View File

@ -1,11 +0,0 @@
package bytecode;
import org.objectweb.asm.Opcodes;
public class ForTest extends JavaTXCompilerTest {
public ForTest() {
this.fileName = "For";
}
}

View File

@ -1,5 +0,0 @@
public class Gen{
Vector<Integer> m(Vector<Integer> v){
return v;
}
}

View File

@ -1,17 +0,0 @@
class Generics<B> {
Generics(B b){
}
B mt1(B b){
return mt1(b);
}
}
/*
Problem:
auto test = new List<String>();
auto test2 = new List<Integer>();
... //code, welcher möglicherweise test und test2 vertauscht
test.add("hallo");
*/

View File

@ -1,6 +0,0 @@
class Generics2<B extends String>{
<B extends Integer> B m1(B b){
return b;
}
}

View File

@ -1,7 +0,0 @@
package bytecode;
public class Generics2Test extends JavaTXCompilerTest{
public Generics2Test() {
this.fileName = "Generics2";
}
}

View File

@ -1,7 +0,0 @@
package bytecode;
public class GenericsTest extends JavaTXCompilerTest {
public GenericsTest() {
this.fileName = "Generics";
}
}

View File

@ -1,10 +0,0 @@
public class IfTest{
Integer m1(Boolean b) {
Integer i;
if(b) {
return i;
}
return i;
}
}

View File

@ -1,8 +0,0 @@
import java.util.Vector;
class Import {
void methode(){
Vector v = new Vector<>();
v.add("X");
}
}

View File

@ -1,7 +0,0 @@
package bytecode;
public class ImportTest extends JavaTXCompilerTest{
public ImportTest() {
this.fileName = "Import";
}
}

View File

@ -1,3 +0,0 @@
public interface Interface1{
public void test();
}

View File

@ -1,7 +0,0 @@
package bytecode;
public class InterfaceTest extends JavaTXCompilerTest{
public InterfaceTest() {
this.fileName = "Interface1";
}
}

View File

@ -1,90 +0,0 @@
package bytecode;
import de.dhbwstuttgart.bytecode.BytecodeGen;
import de.dhbwstuttgart.core.JavaTXCompiler;
import de.dhbwstuttgart.syntaxtree.SourceFile;
import de.dhbwstuttgart.typeinference.result.ResultPair;
import de.dhbwstuttgart.typeinference.result.ResultSet;
import org.junit.Test;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import static org.junit.Assert.*;
public class JavaTXCompilerTest {
private static final String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/";
private static final List<File> filesToTest = new ArrayList<>();
protected String fileName = "";
@Test
public void test() throws IOException, java.lang.ClassNotFoundException {
System.out.println(rootDirectory);
filesToTest.add(new File(rootDirectory+fileName+".jav"));
System.out.println(rootDirectory+fileName+".jav");
JavaTXCompiler compiler = new JavaTXCompiler(filesToTest);
for(File f : filesToTest){
String content = readFile(f.getPath(), StandardCharsets.UTF_8);
List<ResultSet> typeinferenceResult = compiler.typeInference();
HashMap<String,byte[]> bytecode = this.getBytecode(compiler.sourceFiles.get(f), typeinferenceResult.get(0));
// for(ResultPair ep : typeinferenceResult.get(0).results) {
// System.out.println(ep.getLeft() + " ->" + ep.getRight());
// }
String name;
int pos = f.getName().lastIndexOf(".");
if(pos != -1) {
name = f.getName().substring(0, pos);
}
this.writeClassFile(bytecode);
}
}
public HashMap<String,byte[]> getBytecode(SourceFile sf, ResultSet resultSet) {
HashMap<String,byte[]> classFiles = new HashMap<>();
BytecodeGen bytecodeGen = new BytecodeGen(classFiles,resultSet);
bytecodeGen.visit(sf);
return bytecodeGen.getClassFiles();
}
public void writeClassFile(HashMap<String,byte[]> classFiles) {
FileOutputStream output;
for(String name : classFiles.keySet()) {
byte[] bytecode = classFiles.get(name);
try {
System.out.println("generating "+name+ ".class file ...");
output = new FileOutputStream(new File(System.getProperty("user.dir") + "/testBytecode/generatedBC/" +name+".class"));
output.write(bytecode);
output.close();
System.out.println(name+".class file generated");
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
static String readFile(String path, Charset encoding)
throws IOException
{
byte[] encoded = Files.readAllBytes(Paths.get(path));
return new String(encoded, encoding);
}
}

View File

@ -1,15 +0,0 @@
import java.lang.Integer;
class LamAssign {
m () {
var lam1 = (Integer x) -> {
return x;
};
return lam1;
}
}
interface Fun1<A,B>{
public A apply(B b);
}

View File

@ -1,7 +0,0 @@
package bytecode;
public class LamAssignTest extends JavaTXCompilerTest{
public LamAssignTest() {
this.fileName = "LamAssign";
}
}

View File

@ -1,9 +0,0 @@
public class LamRunnable{
public LamRunnable(){
Runnable lam = () -> {System.out.println("lambda");};
lam.run();
}
}

View File

@ -1,18 +0,0 @@
class Lambda{
methode(){
return ((f) -> f);
}
}
/*
interface Fun0<A>{
A apply();
}
interface Fun1<A,B>{
A apply(B b);
}
*/
interface Fun2<A,B,C>{
A apply(B b, C c);
}

View File

@ -1,32 +0,0 @@
public class Lambda2
{
public static void main(List<String> args){
var listOfStrings = new List<String>();
var listOfObjects;
listOfObjects = map(listOfStrings, (a) -> a);
}
public map(a , b){
b.apply(a);
return a;
}
/*
public static <I,O> List<O> map(List<I> input, Function<I,O> func) {
List<O> output;
output = new List<O>();
output.add(func.apply(input.get()));
return output;
}
*/
}
class List<A>{
A get();
void add(A);
}
class Function<A,B>{
B apply(A a);
}

View File

@ -1,23 +0,0 @@
public class Lambda2
{
/*
public static <A> List<A> map(List<? extends A> input,
Function<? super A, ? extends A> func){
input.add(func.apply(input.get()));
}
*/
public map(input,func){
input.add(func.apply(input.get()));
return map(new List<String>(), func);
}
}
class List<A>{
A get();
void add(A);
}
class Function<A,B>{
B apply(A a);
}

View File

@ -1,14 +0,0 @@
import java.lang.Integer;
class Methods {
m(a,b){
var c=a+b;
return c;
}
method2(x){
Integer i = this.m(x,2);
return i;
}
}

View File

@ -1,7 +0,0 @@
package bytecode;
public class MethodsTest extends JavaTXCompilerTest {
public MethodsTest() {
this.fileName = "Methods";
}
}

View File

@ -1,12 +0,0 @@
import java.lang.Integer;
class Op {
m(Integer a, Integer b) {
Integer c = a+b;
// d = a-b;
// e = a*b;
// f = a/b;
return c;
}
}

View File

@ -1,7 +0,0 @@
package bytecode;
public class OpTest extends JavaTXCompilerTest {
public OpTest() {
this.fileName = "Op";
}
}

View File

@ -1,11 +0,0 @@
import java.util.Vector;
class OverlaodGen {
void method(Vector<Integer> v) {
// Integer i = v.get(0);
}
void method(Vector<String> v) {
// String s = v.get(0);
}
}

View File

@ -1,7 +0,0 @@
package bytecode;
public class OverlaodGenTest extends JavaTXCompilerTest {
public OverlaodGenTest() {
this.fileName = "OverlaodGen";
}
}

View File

@ -1,5 +0,0 @@
public class RecursiveMeth{
public Integer test(){
return this.test();
}
}

Some files were not shown because too many files have changed in this diff Show More