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 boolean isNewObject(boolean isdomain) {
33 if (getType()==ADDTOSET) {
34 return sources.allocSource((SetDescriptor)descriptor);
35 } else if (getType()==ADDTORELATION) {
36 RelationDescriptor rd=(RelationDescriptor)descriptor;
37 return sources.relallocSource(rd,isdomain);
38 } else throw new Error(type());
41 public SetDescriptor getDomainSet() {
44 Predicate predicate=torepair.getPredicate();
45 if (!(predicate.getDescriptor() instanceof RelationDescriptor))
48 /* Have relation descriptor now */
49 if (predicate instanceof InclusionPredicate) {
50 InclusionPredicate ip=(InclusionPredicate)predicate;
52 return ip.expr.getSet();
53 else if (ip.setexpr instanceof ImageSetExpr) {
54 ImageSetExpr ise=(ImageSetExpr)ip.setexpr;
56 return ise.getImageSetExpr().getSet();
58 return ise.getVar().getSet();
60 } else if (predicate instanceof ExprPredicate) {
61 ExprPredicate ep=(ExprPredicate)predicate;
63 if (ep.inverted()&&ep.getType()==ExprPredicate.SIZE)
64 return sources.relgetSourceSet((RelationDescriptor)predicate.getDescriptor(),true);
65 else if (ep.inverted()&&ep.getType()==ExprPredicate.COMPARISON)
66 return ((OpExpr)ep.expr).right.getSet();
67 else if (!ep.inverted()) {
68 switch(ep.getType()) {
69 case ExprPredicate.SIZE:
71 SizeofExpr soe=((SizeofExpr)((OpExpr)ep.expr).left);
72 ImageSetExpr ise=(ImageSetExpr)soe.setexpr;
74 return ise.getImageSetExpr().getSet();
76 return ise.getVar().getSet();
78 case ExprPredicate.COMPARISON:
80 RelationExpr re=((RelationExpr)((OpExpr)ep.expr).left);
81 return ep.expr.getSet();
87 } else throw new Error("Unrecognized predicate");
91 public SetDescriptor getRangeSet() {
94 Predicate predicate=torepair.getPredicate();
95 if (!(predicate.getDescriptor() instanceof RelationDescriptor))
98 /* Have relation descriptor now */
99 if (predicate instanceof InclusionPredicate) {
100 InclusionPredicate ip=(InclusionPredicate)predicate;
102 return ip.expr.getSet();
103 else if (ip.setexpr instanceof ImageSetExpr) {
104 ImageSetExpr ise=(ImageSetExpr)ip.setexpr;
106 return ise.getImageSetExpr().getSet();
108 return ise.getVar().getSet();
110 } else if (predicate instanceof ExprPredicate) {
111 ExprPredicate ep=(ExprPredicate)predicate;
113 if (!ep.inverted()&&ep.getType()==ExprPredicate.SIZE)
114 return sources.relgetSourceSet((RelationDescriptor)predicate.getDescriptor(),false);
115 else if (!ep.inverted()&&ep.getType()==ExprPredicate.COMPARISON)
116 return ((OpExpr)ep.expr).right.getSet();
117 else if (ep.inverted()) {
118 switch(ep.getType()) {
119 case ExprPredicate.SIZE:
121 SizeofExpr soe=((SizeofExpr)((OpExpr)ep.expr).left);
122 ImageSetExpr ise=(ImageSetExpr)soe.setexpr;
124 return ise.getImageSetExpr().getSet();
126 return ise.getVar().getSet();
128 case ExprPredicate.COMPARISON:
130 RelationExpr re=((RelationExpr)((OpExpr)ep.expr).left);
131 return ep.expr.getSet();
137 } else throw new Error("Unrecognized predicate");
144 public int getType() {
148 public DNFPredicate getPredicate() {
152 public Descriptor getDescriptor() {
156 public AbstractRepair(DNFPredicate dp,int typ, Descriptor d, Sources s) {