6 #include <engine/list.h>
8 #include <engine/banshee.h>
11 #include <engine/bool.h>
12 #include <engine/ufind.h>
14 #include <engine/setif-sort.h>
15 #include <engine/flowrow-sort.h>
16 #include <engine/setif-sort.h>
27 typedef gen_e label_term
;
28 typedef gen_e_list label_term_list
;
30 typedef struct flowrow_field
*argterm_field
;
31 typedef flowrow_map argterm_map
;
32 typedef gen_e argterm
;
35 typedef gen_e_list aterm_list
;
38 stamp
label_term_get_stamp(gen_e arg1
);
39 bool label_term_is_var(gen_e arg1
);
40 DECLARE_OPAQUE_LIST(label_term_list
,gen_e
)
41 label_term
label_term_zero(void);
42 label_term
label_term_one(void);
43 label_term
label_term_fresh(const char *name
);
44 label_term
label_term_union(label_term_list exprs
) deletes
;
45 label_term
label_term_inter(label_term_list exprs
) deletes
;
46 label_term
label_term_constant(const char *name
) deletes
;
47 bool label_term_is_constant(label_term e
,const char *name
);
48 label_term_list
label_term_tlb(label_term e
) deletes
;
49 void label_term_inclusion(label_term e1
,label_term e2
) deletes
;
50 void label_term_unify(label_term e1
,label_term e2
) deletes
;
52 void label_term_print(FILE* arg1
,label_term arg2
) deletes
;
53 static bool label_term_res_proj(setif_var arg1
,gen_e arg2
) deletes
;
54 static void label_term_con_match(gen_e arg1
,gen_e arg2
) deletes
;
55 stamp
argterm_get_stamp(gen_e arg1
);
56 bool argterm_is_var(gen_e arg1
);
57 DECLARE_OPAQUE_LIST(argterm_map
,flowrow_field
)
58 void argterm_print(FILE *f
,argterm row
) deletes
;
59 stamp
aterm_get_stamp(gen_e arg1
);
60 bool aterm_is_var(gen_e arg1
);
61 DECLARE_OPAQUE_LIST(aterm_list
,gen_e
)
62 aterm
aterm_zero(void);
63 aterm
aterm_one(void);
64 aterm
aterm_fresh(const char *name
);
65 aterm
aterm_union(aterm_list exprs
) deletes
;
66 aterm
aterm_inter(aterm_list exprs
) deletes
;
67 aterm
aterm_constant(const char *name
) deletes
;
68 bool aterm_is_constant(aterm e
,const char *name
);
69 aterm_list
aterm_tlb(aterm e
) deletes
;
70 void aterm_inclusion(aterm e1
,aterm e2
) deletes
;
71 void aterm_unify(aterm e1
,aterm e2
) deletes
;
73 aterm
ref(label_term arg1
,aterm arg2
,aterm arg3
) deletes
;
74 struct ref_decon
ref_decon(aterm arg1
);
95 static gen_e
ref_pat0_con(gen_e arg1
) deletes
;
96 aterm
ref_pat0(label_term arg1
) deletes
;
103 static gen_e
ref_pat1_con(gen_e arg1
) deletes
;
104 aterm
ref_pat1(aterm arg1
) deletes
;
111 static gen_e
ref_pat2_con(gen_e arg1
) deletes
;
112 aterm
ref_pat2(aterm arg1
) deletes
;
113 aterm
lam(label_term arg1
,argterm arg2
,aterm arg3
) deletes
;
114 struct lam_decon
lam_decon(aterm arg1
);
135 static gen_e
lam_pat0_con(gen_e arg1
) deletes
;
136 aterm
lam_pat0(label_term arg1
) deletes
;
143 static gen_e
lam_pat1_con(gen_e arg1
) deletes
;
144 aterm
lam_pat1(argterm arg1
) deletes
;
151 static gen_e
lam_pat2_con(gen_e arg1
) deletes
;
152 aterm
lam_pat2(aterm arg1
) deletes
;
153 void aterm_print(FILE* arg1
,aterm arg2
) deletes
;
154 static bool aterm_res_proj(setif_var arg1
,gen_e arg2
) deletes
;
155 static void aterm_con_match(gen_e arg1
,gen_e arg2
) deletes
;
157 stamp
label_term_get_stamp(gen_e arg1
)
159 return setif_get_stamp((gen_e
)arg1
);
162 bool label_term_is_var(gen_e arg1
)
164 return setif_is_var((gen_e
)arg1
);
167 DEFINE_LIST(label_term_list
,gen_e
)
168 label_term
label_term_zero(void)
173 label_term
label_term_one(void)
178 label_term
label_term_fresh(const char *name
)
180 return setif_fresh(name
);
183 static label_term
label_term_fresh_small(const char *name
)
185 return setif_fresh_small(name
);
188 static label_term
label_term_fresh_large(const char *name
)
190 return setif_fresh_large(name
);
193 label_term
label_term_union(label_term_list exprs
) deletes
195 return setif_union(exprs
);
198 label_term
label_term_inter(label_term_list exprs
) deletes
200 return setif_inter(exprs
);
203 label_term
label_term_constant(const char *name
) deletes
205 return setif_constant(name
);
208 bool label_term_is_constant(label_term e
, const char *name
)
210 if (setif_is_constant(e
))
211 return (! strcmp(name
,setif_get_constant_name(e
)));
215 label_term_list
label_term_tlb(label_term e
) deletes
220 void label_term_inclusion(label_term e1
, label_term e2
) deletes
222 setif_inclusion(label_term_con_match
,label_term_res_proj
,e1
,e2
);
225 static void label_term_inclusion_contra(label_term e1
, label_term e2
) deletes
227 setif_inclusion(label_term_con_match
,label_term_res_proj
,e2
,e1
);
230 void label_term_unify(label_term e1
, label_term e2
) deletes
232 setif_inclusion(label_term_con_match
,label_term_res_proj
,e1
,e2
);
233 setif_inclusion(label_term_con_match
,label_term_res_proj
,e2
,e1
);
236 void label_term_print(FILE* arg1
,label_term arg2
) deletes
238 switch(((setif_term
)arg2
)->type
)
241 fprintf(arg1
,"%s",sv_get_name((setif_var
)arg2
));
250 fprintf(arg1
,setif_get_constant_name(arg2
));
254 gen_e_list list
= setif_get_union(arg2
);
255 gen_e_list_scanner scan
;
257 gen_e_list_scan(list
,&scan
);
258 if (gen_e_list_next(&scan
,&temp
))
259 label_term_print(arg1
,temp
);
260 while (gen_e_list_next(&scan
,&temp
))
262 fprintf(arg1
," || ");
263 label_term_print(arg1
,temp
);
270 gen_e_list list
= setif_get_inter(arg2
);
271 gen_e_list_scanner scan
;
273 gen_e_list_scan(list
,&scan
);
274 if (gen_e_list_next(&scan
,&temp
))
275 label_term_print(arg1
,temp
);
276 while (gen_e_list_next(&scan
,&temp
))
278 fprintf(arg1
," && ");
279 label_term_print(arg1
,temp
);
291 static bool label_term_res_proj(setif_var arg1
,gen_e arg2
) deletes
293 switch(((setif_term
)arg2
)->type
)
303 static void label_term_con_match(gen_e arg1
,gen_e arg2
) deletes
305 switch(((setif_term
)arg1
)->type
)
309 failure("Inconsistent system of constraints\n");
315 stamp
argterm_get_stamp(gen_e arg1
)
317 return flowrow_get_stamp((gen_e
)arg1
);
320 bool argterm_is_var(gen_e arg1
)
322 return flowrow_is_var((gen_e
)arg1
);
325 DEFINE_LIST(argterm_map
,flowrow_field
)
326 argterm_field
argterm_make_field(const char *label
, aterm expr
)
328 flowrow_field result
= ralloc(flowrow_region
, struct flowrow_field
);
329 result
->label
= rstrdup(flowrow_region
,label
);
330 result
->expr
= (gen_e
) expr
;
334 argterm
argterm_zero(void)
336 return flowrow_zero();
339 argterm
argterm_one(void)
341 return flowrow_one();
344 argterm
argterm_abs(void)
346 return flowrow_abs();
349 argterm
argterm_wild(void)
351 return flowrow_wild();
354 argterm
argterm_fresh(const char *name
)
356 return flowrow_fresh(name
);
359 static argterm
argterm_fresh_small(const char *name
)
361 return flowrow_fresh_small(name
);
364 static argterm
argterm_fresh_large(const char *name
)
366 return flowrow_fresh_large(name
);
369 argterm
argterm_row(argterm_map fields
,argterm rest
) deletes
371 return flowrow_row(aterm_get_stamp
,fields
,rest
);
374 aterm
argterm_extract_field(const char *field_name
, argterm row
)
376 return flowrow_extract_field(field_name
,row
);
379 argterm
argterm_extract_rest(argterm row
)
381 return flowrow_extract_rest(row
);
384 argterm_map
argterm_extract_fields(argterm row
)
386 return flowrow_extract_fields(row
);
389 void argterm_inclusion(argterm row1
, argterm row2
) deletes
391 flowrow_inclusion(aterm_fresh
,aterm_get_stamp
,aterm_inclusion
,aterm_zero(), row1
,row2
);
394 static void argterm_inclusion_contra(argterm row1
, argterm row2
) deletes
396 flowrow_inclusion(aterm_fresh
,aterm_get_stamp
,aterm_inclusion
,aterm_zero(), row2
,row1
);
399 void argterm_unify(argterm row1
, argterm row2
) deletes
401 argterm_inclusion(row1
,row2
);
402 argterm_inclusion(row2
,row1
);
405 void argterm_print(FILE *f
,argterm row
) deletes
407 flowrow_print(f
,aterm_get_stamp
,aterm_print
,row
);
410 stamp
aterm_get_stamp(gen_e arg1
)
412 return setif_get_stamp((gen_e
)arg1
);
415 bool aterm_is_var(gen_e arg1
)
417 return setif_is_var((gen_e
)arg1
);
420 DEFINE_LIST(aterm_list
,gen_e
)
421 aterm
aterm_zero(void)
426 aterm
aterm_one(void)
431 aterm
aterm_fresh(const char *name
)
433 return setif_fresh(name
);
436 static aterm
aterm_fresh_small(const char *name
)
438 return setif_fresh_small(name
);
441 static aterm
aterm_fresh_large(const char *name
)
443 return setif_fresh_large(name
);
446 aterm
aterm_union(aterm_list exprs
) deletes
448 return setif_union(exprs
);
451 aterm
aterm_inter(aterm_list exprs
) deletes
453 return setif_inter(exprs
);
456 aterm
aterm_constant(const char *name
) deletes
458 return setif_constant(name
);
461 bool aterm_is_constant(aterm e
, const char *name
)
463 if (setif_is_constant(e
))
464 return (! strcmp(name
,setif_get_constant_name(e
)));
468 aterm_list
aterm_tlb(aterm e
) deletes
473 void aterm_inclusion(aterm e1
, aterm e2
) deletes
475 setif_inclusion(aterm_con_match
,aterm_res_proj
,e1
,e2
);
478 static void aterm_inclusion_contra(aterm e1
, aterm e2
) deletes
480 setif_inclusion(aterm_con_match
,aterm_res_proj
,e2
,e1
);
483 void aterm_unify(aterm e1
, aterm e2
) deletes
485 setif_inclusion(aterm_con_match
,aterm_res_proj
,e1
,e2
);
486 setif_inclusion(aterm_con_match
,aterm_res_proj
,e2
,e1
);
489 bool aterm_is_ref(aterm e
)
491 return ((setif_term
)e
)->type
== 11;
494 aterm
ref(label_term arg1
,aterm arg2
,aterm arg3
) deletes
499 s
[1] = label_term_get_stamp((gen_e
)arg1
);
500 s
[2] = aterm_get_stamp((gen_e
)arg2
);
501 s
[3] = aterm_get_stamp((gen_e
)arg3
);
502 if ((ret
= (struct ref_
*)term_hash_find(setif_hash
,s
,4)) == NULL
)
504 ret
= ralloc(setif_region
,struct ref_
);
506 ret
->st
= stamp_fresh();
510 term_hash_insert(setif_hash
,(gen_e
)ret
,s
,4);
515 struct ref_decon
ref_decon(aterm arg1
)
517 if (((setif_term
)arg1
)->type
== REF_
)
519 struct ref_
* c
= (struct ref_
*)arg1
;
520 return (struct ref_decon
){c
->f0
,c
->f1
,c
->f2
};
524 return (struct ref_decon
){NULL
,NULL
,NULL
};
527 static gen_e
get_ref_proj0_arg(gen_e_list arg1
)
530 gen_e_list_scanner scan
;
531 gen_e_list_scan(arg1
,&scan
);
532 while (gen_e_list_next(&scan
,&temp
))
534 if (((setif_term
)temp
)->type
== REFPROJ0_
)
535 return (gen_e
)((struct refProj0_
* ) temp
)->f0
;
540 label_term
ref_proj0(aterm arg1
) deletes
543 if (setif_is_var(arg1
))
545 setif_var v
= (setif_var
)arg1
;
546 c
= (label_term
)sv_get_ub_proj(v
,get_ref_proj0_arg
);
553 gen_e_list_scanner scan
;
554 c
= label_term_fresh(NULL
);
557 gen_e_list_scan(sv_get_lbs(v
),&scan
);
558 while (gen_e_list_next(&scan
,&lb
))
560 setif_inclusion(aterm_con_match
,aterm_res_proj
,lb
,e
);
565 else if ( ((setif_term
)arg1
)->type
== REF_
)
566 return ((struct ref_
* )arg1
)->f0
;
567 else if ( setif_is_zero(arg1
))
568 return label_term_zero();
569 else if ( setif_is_union(arg1
))
571 c
= get_ref_proj0_arg(setif_get_proj_cache(arg1
));
577 c
= label_term_fresh(NULL
);
579 setif_set_proj_cache(arg1
,e
);
580 aterm_inclusion(arg1
,e
);
587 c
= label_term_fresh(NULL
);
589 aterm_inclusion(arg1
,e
);
594 static gen_e
ref_pat0_con(gen_e arg1
) deletes
596 return (gen_e
)ref_pat0((label_term
)arg1
);
599 aterm
ref_pat0(label_term arg1
) deletes
601 struct refProj0_
* ret
;
604 s
[1] = label_term_get_stamp((gen_e
)arg1
);
605 if ((ret
= (struct refProj0_
*)term_hash_find(setif_hash
,s
,2)) == NULL
)
607 ret
= ralloc(setif_region
,struct refProj0_
);
608 ret
->type
= REFPROJ0_
;
609 ret
->st
= stamp_fresh();
611 term_hash_insert(setif_hash
,(gen_e
)ret
,s
,2);
616 static gen_e
get_ref_proj1_arg(gen_e_list arg1
)
619 gen_e_list_scanner scan
;
620 gen_e_list_scan(arg1
,&scan
);
621 while (gen_e_list_next(&scan
,&temp
))
623 if (((setif_term
)temp
)->type
== REFPROJ1_
)
624 return (gen_e
)((struct refProj1_
* ) temp
)->f0
;
629 aterm
ref_proj1(aterm arg1
) deletes
632 if (setif_is_var(arg1
))
634 setif_var v
= (setif_var
)arg1
;
635 c
= (aterm
)sv_get_ub_proj(v
,get_ref_proj1_arg
);
642 gen_e_list_scanner scan
;
643 c
= aterm_fresh(NULL
);
646 gen_e_list_scan(sv_get_lbs(v
),&scan
);
647 while (gen_e_list_next(&scan
,&lb
))
649 setif_inclusion(aterm_con_match
,aterm_res_proj
,lb
,e
);
654 else if ( ((setif_term
)arg1
)->type
== REF_
)
655 return ((struct ref_
* )arg1
)->f1
;
656 else if ( setif_is_zero(arg1
))
658 else if ( setif_is_union(arg1
))
660 c
= get_ref_proj1_arg(setif_get_proj_cache(arg1
));
666 c
= aterm_fresh(NULL
);
668 setif_set_proj_cache(arg1
,e
);
669 aterm_inclusion(arg1
,e
);
676 c
= aterm_fresh(NULL
);
678 aterm_inclusion(arg1
,e
);
683 static gen_e
ref_pat1_con(gen_e arg1
) deletes
685 return (gen_e
)ref_pat1((aterm
)arg1
);
688 aterm
ref_pat1(aterm arg1
) deletes
690 struct refProj1_
* ret
;
693 s
[1] = aterm_get_stamp((gen_e
)arg1
);
694 if ((ret
= (struct refProj1_
*)term_hash_find(setif_hash
,s
,2)) == NULL
)
696 ret
= ralloc(setif_region
,struct refProj1_
);
697 ret
->type
= REFPROJ1_
;
698 ret
->st
= stamp_fresh();
700 term_hash_insert(setif_hash
,(gen_e
)ret
,s
,2);
705 static gen_e
get_ref_proj2_arg(gen_e_list arg1
)
708 gen_e_list_scanner scan
;
709 gen_e_list_scan(arg1
,&scan
);
710 while (gen_e_list_next(&scan
,&temp
))
712 if (((setif_term
)temp
)->type
== REFPROJ2_
)
713 return (gen_e
)((struct refProj2_
* ) temp
)->f0
;
718 aterm
ref_proj2(aterm arg1
) deletes
721 if (setif_is_var(arg1
))
723 setif_var v
= (setif_var
)arg1
;
724 c
= (aterm
)sv_get_ub_proj(v
,get_ref_proj2_arg
);
731 gen_e_list_scanner scan
;
732 c
= aterm_fresh(NULL
);
735 gen_e_list_scan(sv_get_lbs(v
),&scan
);
736 while (gen_e_list_next(&scan
,&lb
))
738 setif_inclusion(aterm_con_match
,aterm_res_proj
,lb
,e
);
743 else if ( ((setif_term
)arg1
)->type
== REF_
)
744 return ((struct ref_
* )arg1
)->f2
;
745 else if ( setif_is_zero(arg1
))
747 else if ( setif_is_union(arg1
))
749 c
= get_ref_proj2_arg(setif_get_proj_cache(arg1
));
755 c
= aterm_fresh(NULL
);
757 setif_set_proj_cache(arg1
,e
);
758 aterm_inclusion(arg1
,e
);
765 c
= aterm_fresh(NULL
);
767 aterm_inclusion(arg1
,e
);
772 static gen_e
ref_pat2_con(gen_e arg1
) deletes
774 return (gen_e
)ref_pat2((aterm
)arg1
);
777 aterm
ref_pat2(aterm arg1
) deletes
779 struct refProj2_
* ret
;
782 s
[1] = aterm_get_stamp((gen_e
)arg1
);
783 if ((ret
= (struct refProj2_
*)term_hash_find(setif_hash
,s
,2)) == NULL
)
785 ret
= ralloc(setif_region
,struct refProj2_
);
786 ret
->type
= REFPROJ2_
;
787 ret
->st
= stamp_fresh();
789 term_hash_insert(setif_hash
,(gen_e
)ret
,s
,2);
794 bool aterm_is_lam(aterm e
)
796 return ((setif_term
)e
)->type
== 15;
799 aterm
lam(label_term arg1
,argterm arg2
,aterm arg3
) deletes
804 s
[1] = label_term_get_stamp((gen_e
)arg1
);
805 s
[2] = argterm_get_stamp((gen_e
)arg2
);
806 s
[3] = aterm_get_stamp((gen_e
)arg3
);
807 if ((ret
= (struct lam_
*)term_hash_find(setif_hash
,s
,4)) == NULL
)
809 ret
= ralloc(setif_region
,struct lam_
);
811 ret
->st
= stamp_fresh();
815 term_hash_insert(setif_hash
,(gen_e
)ret
,s
,4);
820 struct lam_decon
lam_decon(aterm arg1
)
822 if (((setif_term
)arg1
)->type
== LAM_
)
824 struct lam_
* c
= (struct lam_
*)arg1
;
825 return (struct lam_decon
){c
->f0
,c
->f1
,c
->f2
};
829 return (struct lam_decon
){NULL
,NULL
,NULL
};
832 static gen_e
get_lam_proj0_arg(gen_e_list arg1
)
835 gen_e_list_scanner scan
;
836 gen_e_list_scan(arg1
,&scan
);
837 while (gen_e_list_next(&scan
,&temp
))
839 if (((setif_term
)temp
)->type
== LAMPROJ0_
)
840 return (gen_e
)((struct lamProj0_
* ) temp
)->f0
;
845 label_term
lam_proj0(aterm arg1
) deletes
848 if (setif_is_var(arg1
))
850 setif_var v
= (setif_var
)arg1
;
851 c
= (label_term
)sv_get_ub_proj(v
,get_lam_proj0_arg
);
858 gen_e_list_scanner scan
;
859 c
= label_term_fresh(NULL
);
862 gen_e_list_scan(sv_get_lbs(v
),&scan
);
863 while (gen_e_list_next(&scan
,&lb
))
865 setif_inclusion(aterm_con_match
,aterm_res_proj
,lb
,e
);
870 else if ( ((setif_term
)arg1
)->type
== LAM_
)
871 return ((struct lam_
* )arg1
)->f0
;
872 else if ( setif_is_zero(arg1
))
873 return label_term_zero();
874 else if ( setif_is_union(arg1
))
876 c
= get_lam_proj0_arg(setif_get_proj_cache(arg1
));
882 c
= label_term_fresh(NULL
);
884 setif_set_proj_cache(arg1
,e
);
885 aterm_inclusion(arg1
,e
);
892 c
= label_term_fresh(NULL
);
894 aterm_inclusion(arg1
,e
);
899 static gen_e
lam_pat0_con(gen_e arg1
) deletes
901 return (gen_e
)lam_pat0((label_term
)arg1
);
904 aterm
lam_pat0(label_term arg1
) deletes
906 struct lamProj0_
* ret
;
909 s
[1] = label_term_get_stamp((gen_e
)arg1
);
910 if ((ret
= (struct lamProj0_
*)term_hash_find(setif_hash
,s
,2)) == NULL
)
912 ret
= ralloc(setif_region
,struct lamProj0_
);
913 ret
->type
= LAMPROJ0_
;
914 ret
->st
= stamp_fresh();
916 term_hash_insert(setif_hash
,(gen_e
)ret
,s
,2);
921 static gen_e
get_lam_proj1_arg(gen_e_list arg1
)
924 gen_e_list_scanner scan
;
925 gen_e_list_scan(arg1
,&scan
);
926 while (gen_e_list_next(&scan
,&temp
))
928 if (((setif_term
)temp
)->type
== LAMPROJ1_
)
929 return (gen_e
)((struct lamProj1_
* ) temp
)->f0
;
934 argterm
lam_proj1(aterm arg1
) deletes
937 if (setif_is_var(arg1
))
939 setif_var v
= (setif_var
)arg1
;
940 c
= (argterm
)sv_get_ub_proj(v
,get_lam_proj1_arg
);
947 gen_e_list_scanner scan
;
948 c
= argterm_fresh(NULL
);
951 gen_e_list_scan(sv_get_lbs(v
),&scan
);
952 while (gen_e_list_next(&scan
,&lb
))
954 setif_inclusion(aterm_con_match
,aterm_res_proj
,lb
,e
);
959 else if ( ((setif_term
)arg1
)->type
== LAM_
)
960 return ((struct lam_
* )arg1
)->f1
;
961 else if ( setif_is_zero(arg1
))
962 return argterm_zero();
963 else if ( setif_is_union(arg1
))
965 c
= get_lam_proj1_arg(setif_get_proj_cache(arg1
));
971 c
= argterm_fresh(NULL
);
973 setif_set_proj_cache(arg1
,e
);
974 aterm_inclusion(arg1
,e
);
981 c
= argterm_fresh(NULL
);
983 aterm_inclusion(arg1
,e
);
988 static gen_e
lam_pat1_con(gen_e arg1
) deletes
990 return (gen_e
)lam_pat1((argterm
)arg1
);
993 aterm
lam_pat1(argterm arg1
) deletes
995 struct lamProj1_
* ret
;
998 s
[1] = argterm_get_stamp((gen_e
)arg1
);
999 if ((ret
= (struct lamProj1_
*)term_hash_find(setif_hash
,s
,2)) == NULL
)
1001 ret
= ralloc(setif_region
,struct lamProj1_
);
1002 ret
->type
= LAMPROJ1_
;
1003 ret
->st
= stamp_fresh();
1005 term_hash_insert(setif_hash
,(gen_e
)ret
,s
,2);
1010 static gen_e
get_lam_proj2_arg(gen_e_list arg1
)
1013 gen_e_list_scanner scan
;
1014 gen_e_list_scan(arg1
,&scan
);
1015 while (gen_e_list_next(&scan
,&temp
))
1017 if (((setif_term
)temp
)->type
== LAMPROJ2_
)
1018 return (gen_e
)((struct lamProj2_
* ) temp
)->f0
;
1023 aterm
lam_proj2(aterm arg1
) deletes
1026 if (setif_is_var(arg1
))
1028 setif_var v
= (setif_var
)arg1
;
1029 c
= (aterm
)sv_get_ub_proj(v
,get_lam_proj2_arg
);
1036 gen_e_list_scanner scan
;
1037 c
= aterm_fresh(NULL
);
1039 sv_add_ub_proj(v
,e
);
1040 gen_e_list_scan(sv_get_lbs(v
),&scan
);
1041 while (gen_e_list_next(&scan
,&lb
))
1043 setif_inclusion(aterm_con_match
,aterm_res_proj
,lb
,e
);
1048 else if ( ((setif_term
)arg1
)->type
== LAM_
)
1049 return ((struct lam_
* )arg1
)->f2
;
1050 else if ( setif_is_zero(arg1
))
1051 return aterm_zero();
1052 else if ( setif_is_union(arg1
))
1054 c
= get_lam_proj2_arg(setif_get_proj_cache(arg1
));
1060 c
= aterm_fresh(NULL
);
1062 setif_set_proj_cache(arg1
,e
);
1063 aterm_inclusion(arg1
,e
);
1070 c
= aterm_fresh(NULL
);
1072 aterm_inclusion(arg1
,e
);
1077 static gen_e
lam_pat2_con(gen_e arg1
) deletes
1079 return (gen_e
)lam_pat2((aterm
)arg1
);
1082 aterm
lam_pat2(aterm arg1
) deletes
1084 struct lamProj2_
* ret
;
1087 s
[1] = aterm_get_stamp((gen_e
)arg1
);
1088 if ((ret
= (struct lamProj2_
*)term_hash_find(setif_hash
,s
,2)) == NULL
)
1090 ret
= ralloc(setif_region
,struct lamProj2_
);
1091 ret
->type
= LAMPROJ2_
;
1092 ret
->st
= stamp_fresh();
1094 term_hash_insert(setif_hash
,(gen_e
)ret
,s
,2);
1099 void aterm_print(FILE* arg1
,aterm arg2
) deletes
1101 switch(((setif_term
)arg2
)->type
)
1104 fprintf(arg1
,"%s",sv_get_name((setif_var
)arg2
));
1113 fprintf(arg1
,setif_get_constant_name(arg2
));
1117 gen_e_list list
= setif_get_union(arg2
);
1118 gen_e_list_scanner scan
;
1120 gen_e_list_scan(list
,&scan
);
1121 if (gen_e_list_next(&scan
,&temp
))
1122 aterm_print(arg1
,temp
);
1123 while (gen_e_list_next(&scan
,&temp
))
1125 fprintf(arg1
," || ");
1126 aterm_print(arg1
,temp
);
1133 gen_e_list list
= setif_get_inter(arg2
);
1134 gen_e_list_scanner scan
;
1136 gen_e_list_scan(list
,&scan
);
1137 if (gen_e_list_next(&scan
,&temp
))
1138 aterm_print(arg1
,temp
);
1139 while (gen_e_list_next(&scan
,&temp
))
1141 fprintf(arg1
," && ");
1142 aterm_print(arg1
,temp
);
1149 fprintf(arg1
,"ref(");
1150 label_term_print(arg1
,((struct ref_
*)arg2
)->f0
);
1152 aterm_print(arg1
,((struct ref_
*)arg2
)->f1
);
1154 aterm_print(arg1
,((struct ref_
*)arg2
)->f2
);
1161 fprintf(arg1
,"lam(");
1162 label_term_print(arg1
,((struct lam_
*)arg2
)->f0
);
1164 argterm_print(arg1
,((struct lam_
*)arg2
)->f1
);
1166 aterm_print(arg1
,((struct lam_
*)arg2
)->f2
);
1173 fprintf(arg1
,"Proj[ref,0,");
1174 label_term_print(arg1
,((struct refProj0_
*)arg2
)->f0
);
1181 fprintf(arg1
,"Proj[ref,1,");
1182 aterm_print(arg1
,((struct refProj1_
*)arg2
)->f0
);
1189 fprintf(arg1
,"Proj[ref,2,");
1190 aterm_print(arg1
,((struct refProj2_
*)arg2
)->f0
);
1197 fprintf(arg1
,"Proj[lam,0,");
1198 label_term_print(arg1
,((struct lamProj0_
*)arg2
)->f0
);
1205 fprintf(arg1
,"Proj[lam,1,");
1206 argterm_print(arg1
,((struct lamProj1_
*)arg2
)->f0
);
1213 fprintf(arg1
,"Proj[lam,2,");
1214 aterm_print(arg1
,((struct lamProj2_
*)arg2
)->f0
);
1226 static bool aterm_res_proj(setif_var arg1
,gen_e arg2
) deletes
1228 switch(((setif_term
)arg2
)->type
)
1231 return setif_proj_merge(arg1
,(gen_e
)((struct refProj0_
*)arg2
)->f0
,get_ref_proj0_arg
,ref_pat0_con
,(fresh_large_fn_ptr
)label_term_fresh_large
,(incl_fn_ptr
)label_term_inclusion
,aterm_inclusion
);
1234 return setif_proj_merge(arg1
,(gen_e
)((struct refProj1_
*)arg2
)->f0
,get_ref_proj1_arg
,ref_pat1_con
,(fresh_large_fn_ptr
)aterm_fresh_large
,(incl_fn_ptr
)aterm_inclusion_contra
,aterm_inclusion
);
1237 return setif_proj_merge(arg1
,(gen_e
)((struct refProj2_
*)arg2
)->f0
,get_ref_proj2_arg
,ref_pat2_con
,(fresh_large_fn_ptr
)aterm_fresh_large
,(incl_fn_ptr
)aterm_inclusion
,aterm_inclusion
);
1240 return setif_proj_merge(arg1
,(gen_e
)((struct lamProj0_
*)arg2
)->f0
,get_lam_proj0_arg
,lam_pat0_con
,(fresh_large_fn_ptr
)label_term_fresh_large
,(incl_fn_ptr
)label_term_inclusion
,aterm_inclusion
);
1243 return setif_proj_merge(arg1
,(gen_e
)((struct lamProj1_
*)arg2
)->f0
,get_lam_proj1_arg
,lam_pat1_con
,(fresh_large_fn_ptr
)argterm_fresh_large
,(incl_fn_ptr
)argterm_inclusion_contra
,aterm_inclusion
);
1246 return setif_proj_merge(arg1
,(gen_e
)((struct lamProj2_
*)arg2
)->f0
,get_lam_proj2_arg
,lam_pat2_con
,(fresh_large_fn_ptr
)aterm_fresh_large
,(incl_fn_ptr
)aterm_inclusion
,aterm_inclusion
);
1256 static void aterm_con_match(gen_e arg1
,gen_e arg2
) deletes
1258 switch(((setif_term
)arg1
)->type
)
1261 switch(((setif_term
)arg2
)->type
)
1265 label_term_inclusion(((struct ref_
*)arg1
)->f0
,((struct ref_
*)arg2
)->f0
);
1266 aterm_inclusion_contra(((struct ref_
*)arg1
)->f1
,((struct ref_
*)arg2
)->f1
);
1267 aterm_inclusion(((struct ref_
*)arg1
)->f2
,((struct ref_
*)arg2
)->f2
);
1272 label_term_inclusion(((struct ref_
*)arg1
)->f0
,((struct refProj0_
*)arg2
)->f0
);
1275 aterm_inclusion_contra(((struct ref_
*)arg1
)->f1
,((struct refProj1_
*)arg2
)->f0
);
1278 aterm_inclusion(((struct ref_
*)arg1
)->f2
,((struct refProj2_
*)arg2
)->f0
);
1291 failure("Inconsistent system of constraints\n");
1296 switch(((setif_term
)arg2
)->type
)
1300 label_term_inclusion(((struct lam_
*)arg1
)->f0
,((struct lam_
*)arg2
)->f0
);
1301 argterm_inclusion_contra(((struct lam_
*)arg1
)->f1
,((struct lam_
*)arg2
)->f1
);
1302 aterm_inclusion(((struct lam_
*)arg1
)->f2
,((struct lam_
*)arg2
)->f2
);
1307 label_term_inclusion(((struct lam_
*)arg1
)->f0
,((struct lamProj0_
*)arg2
)->f0
);
1310 argterm_inclusion_contra(((struct lam_
*)arg1
)->f1
,((struct lamProj1_
*)arg2
)->f0
);
1313 aterm_inclusion(((struct lam_
*)arg1
)->f2
,((struct lamProj2_
*)arg2
)->f0
);
1326 failure("Inconsistent system of constraints\n");
1332 failure("Inconsistent system of constraints\n");
1338 void andersen_terms_init(void)
1346 void andersen_terms_reset(void) deletes
1354 void andersen_terms_stats(FILE * arg1
)
1359 void andersen_terms_print_graph(FILE * arg1
)
1361 print_constraint_graphs(arg1
);