4 public final static int ADDTOSET=1;
5 public final static int REMOVEFROMSET=2;
6 public final static int ADDTORELATION=3;
7 public final static int REMOVEFROMRELATION=4;
8 public final static int MODIFYRELATION=5;
10 DNFPredicate torepair;
12 Descriptor descriptor;
15 public String type() {
22 return "AddToRelation";
23 case REMOVEFROMRELATION:
24 return "RemoveFromRelation";
26 return "ModifyRelation";
32 public SetDescriptor getDomainSet() {
35 Predicate predicate=torepair.getPredicate();
36 if (!(predicate.getDescriptor() instanceof RelationDescriptor))
39 /* Have relation descriptor now */
40 if (predicate instanceof InclusionPredicate) {
41 InclusionPredicate ip=(InclusionPredicate)predicate;
43 return ip.expr.getSet();
44 else if (ip.setexpr instanceof ImageSetExpr) {
45 ImageSetExpr ise=(ImageSetExpr)ip.setexpr;
47 return ise.getImageSetExpr().getSet();
49 return ise.getVar().getSet();
51 } else if (predicate instanceof ExprPredicate) {
52 ExprPredicate ep=(ExprPredicate)predicate;
54 if (ep.inverted()&&ep.getType()==ExprPredicate.SIZE)
55 return sources.relgetSourceSet((RelationDescriptor)predicate.getDescriptor(),true);
56 else if (ep.inverted()&&ep.getType()==ExprPredicate.COMPARISON)
57 return ((OpExpr)ep.expr).right.getSet();
58 else if (!ep.inverted()) {
59 switch(ep.getType()) {
60 case ExprPredicate.SIZE:
62 SizeofExpr soe=((SizeofExpr)((OpExpr)ep.expr).left);
63 ImageSetExpr ise=(ImageSetExpr)soe.setexpr;
65 return ise.getImageSetExpr().getSet();
67 return ise.getVar().getSet();
69 case ExprPredicate.COMPARISON:
71 RelationExpr re=((RelationExpr)((OpExpr)ep.expr).left);
72 return ep.expr.getSet();
78 } else throw new Error("Unrecognized predicate");
82 public SetDescriptor getRangeSet() {
85 Predicate predicate=torepair.getPredicate();
86 if (!(predicate.getDescriptor() instanceof RelationDescriptor))
89 /* Have relation descriptor now */
90 if (predicate instanceof InclusionPredicate) {
91 InclusionPredicate ip=(InclusionPredicate)predicate;
93 return ip.expr.getSet();
94 else if (ip.setexpr instanceof ImageSetExpr) {
95 ImageSetExpr ise=(ImageSetExpr)ip.setexpr;
97 return ise.getImageSetExpr().getSet();
99 return ise.getVar().getSet();
101 } else if (predicate instanceof ExprPredicate) {
102 ExprPredicate ep=(ExprPredicate)predicate;
104 if (!ep.inverted()&&ep.getType()==ExprPredicate.SIZE)
105 return sources.relgetSourceSet((RelationDescriptor)predicate.getDescriptor(),false);
106 else if (!ep.inverted()&&ep.getType()==ExprPredicate.COMPARISON)
107 return ((OpExpr)ep.expr).right.getSet();
108 else if (ep.inverted()) {
109 switch(ep.getType()) {
110 case ExprPredicate.SIZE:
112 SizeofExpr soe=((SizeofExpr)((OpExpr)ep.expr).left);
113 ImageSetExpr ise=(ImageSetExpr)soe.setexpr;
115 return ise.getImageSetExpr().getSet();
117 return ise.getVar().getSet();
119 case ExprPredicate.COMPARISON:
121 RelationExpr re=((RelationExpr)((OpExpr)ep.expr).left);
122 return ep.expr.getSet();
128 } else throw new Error("Unrecognized predicate");
135 public int getType() {
139 public DNFPredicate getPredicate() {
143 public Descriptor getDescriptor() {
147 public AbstractRepair(DNFPredicate dp,int typ, Descriptor d, Sources s) {