You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: src/callgraph.ml
+111-27
Original file line number
Diff line number
Diff line change
@@ -17,7 +17,7 @@ let pp_index fmt x =
17
17
Format.pp_print_int fmt (int_of_index x)
18
18
19
19
(** The local result express the result of the termination checker for this symbol *)
20
-
typelocal_result = SelfLoopingof(indexlist)
20
+
typelocal_result = SelfLoopingofstringlist
21
21
22
22
(** The pretty printer for the type [local_result] *)
23
23
letpp_local_result : local_result printer =
@@ -46,57 +46,100 @@ module IMap =
46
46
end)
47
47
end
48
48
49
-
50
-
(** A call [{callee; caller; matrix; is_rec}] represents a call to the function symbol with key [callee] by the function symbole with the key [caller].
51
-
The [matrix] gives the relation between the parameters of the caller and the callee.
52
-
The coefficient [matrix.(a).(b)] give the relation between the [a]-th parameter of the caller and the [b]-th argument of the callee.
53
-
[rules] is the list of indexes of rules which lead to this call-matrix in the graph. *)
54
-
typecall =
55
-
{ callee : index;(** Key of the function symbol being called. *)
56
-
caller : index;(** Key of the calling function symbol. *)
57
-
matrix : matrix;(** Size change matrix of the call. *)
58
-
}
49
+
moduleEdgeLabel=struct
50
+
typet = (stringlist*Cmp_matrix.t) list
51
+
52
+
letpp : t printer =
53
+
funfmtl ->
54
+
Format.fprintf fmt "[%a]"
55
+
(pp_list ",@." (funfmt (a,b) -> Cmp_matrix.pp fmt b)) l
(** Compare a term and a pattern, using an int indicating under how many lambdas the comparison occurs *)
84
+
letrec comparison : int -> term -> pattern -> Cmp.t =
85
+
funnbtp ->
86
+
letrec comp_list : Cmp.t -> pattern list -> term list -> Cmp.t =
87
+
funcurlplt ->
88
+
match lp,lt with
89
+
|[], _|_, [] -> cur
90
+
|a::l1, b::l2 ->
91
+
begin
92
+
match (comparison nb b a), cur with
93
+
|_ , Infi -> assertfalse
94
+
(* We are sure, that the current state [cur] cannot contain a Infi, else the Infi would be the result of the function and no recursive call would be needed *)
95
+
|Infi, _ -> Infi
96
+
|Min1, _ -> comp_list Min1 l1 l2
97
+
|_ , Min1 -> comp_list Min1 l1 l2
98
+
|Zero, Zero -> comp_list Zero l1 l2
99
+
end
100
+
in
101
+
match p,t with
102
+
|Var (_,_,n,_), DB (_,_,m) -> if n+nb=m thenZeroelseInfi(* Two distinct variables are uncomparable *)
103
+
|Var (_,_,n,_), App(DB(_,_,m),_,_) -> if n+nb=m thenZeroelseInfi(* A variable when applied has the same size as if it was not applied *)
104
+
|Lambda(_,_,Var(_,_,n,_)), DB(_,_,m) -> if n+nb=m+1thenZeroelseInfi
105
+
|Lambda(_,_,Var(_,_,n,_)), App(DB(_,_,m),_,_) -> if n+nb=m+1thenZeroelseInfi
106
+
|Pattern (_,f,lp), App(Const(_,g),t1,lt) when (name_eq f g) ->
107
+
begin
108
+
comp_list Zero lp (t1::lt)
109
+
end
110
+
|Pattern (_,_,l),t -> Cmp.minus1 (Cmp.mini (List.map (comparison nb t) l))
111
+
|Lambda(_,_,pp),Lam(_,_,_,tt) -> comparison nb tt pp
112
+
|_ -> Infi
113
+
infunpt -> comparison 0 t p
114
+
115
+
116
+
letrn_to_string : rule_name -> string =
117
+
function
118
+
|Beta -> failwith "Beta should not occur in a rule declaration"
119
+
|Deltan -> string_of_name n
120
+
|Gamma(_, n) -> string_of_name n
121
+
end
122
+
123
+
moduleDkRules=struct
124
+
includeStudyRules(Dk)
125
+
126
+
letrec import : loc -> mident -> unit =
127
+
funlcm ->
128
+
begin
129
+
let (deps,ctx,ext) =Signature.read_dko lc (string_of_mident m) in
130
+
letsymb (id,_,ty,_) =
131
+
let cst = (string_of_mident m)^"."^(string_of_ident id) in
0 commit comments