3 * implementazione dei comandi USE/USED BY
10 * implementazione dei comandi USE/USED BY
13 * alist: string list list; lista su cui eseguire il comando USE/USED BY
14 * asvar: string; nome della variabile del comando use
15 * usek: string; nome della tabella in cui ricercare le occorrenze;
16 * la distinzione fra l'esecuzione del comando USE e USED BY
17 * sta nell'utilizzo della tabella 'backPointer' per USE
18 * e 'refObj' per USED BY
20 * output: string list list; lista su cui e' stato eseguito il
24 * USE e USED BY sono identici dal punto di vista algoritmico, per questo
25 * sono stati accorpati in una sola funzione; stilisticamente, sarebbe meglio
26 * avere due implementazioni distinte...
28 let use_ex alist asvar usek =
32 let r1 = pgresult_to_string (c#exec
33 ("select att0 from property where att2='" ^ usek ^ "'"))
34 and r2 = pgresult_to_string (c#exec
35 "select att0 from property where att2='position'")
36 and r3 = pgresult_to_string (c#exec
37 "select att0 from property where att2='occurrence'")
40 "select distinct t" ^ r3 ^ ".att1, t" ^ r2 ^ ".att1 " ^
41 "from t" ^ r3 ^ ", t" ^ r2 ^ ", t" ^ r1 ^ " " ^
42 "where " ^ "t" ^ r1 ^ ".att0 = '" ^ (List.hd xres) ^ "' and t" ^ r1 ^
43 ".att1 = t" ^ r2 ^ ".att0 and t" ^ r1 ^ ".att1 = t" ^ r3 ^
48 if not (List.mem asvar (List.tl (List.hd alist))) then
50 (fun l -> [List.hd l] @ List.tl xres @ List.tl l)
57 hd::tl -> (List.hd l)::tl
65 (List.combine (List.hd alist) t)
77 (List.tl (List.hd alist))
83 xresv = "" or xresv = currv
90 if not (List.mem asvar (List.tl (List.hd alist))) then
101 let use_ex alist asvar =
102 if (List.find_all asvar (List.tl (List.hd alist))) = [] then
103 use_ex_nc alist asvar
105 use_ex_co alist asvar
112 hd::tl -> (List.hd l)::tl
115 let hash = List.combine (List.hd alist) t in
116 snd (set_assoc asvar (snd l) hash)
124 List.assoc asvar (List.combine (List.tl (List.hd alist)) (List.tl xres))
128 xresv = "" or xresv = currv