Change to the spec...missed a consistency property. Adding timing option.
[repair.git] / Repair / RepairCompiler / MCC / IR / RelationDescriptor.java
1 package MCC.IR;
2
3 /**
4  * RelationDescriptor
5  *
6  * represents a set in the model space
7  */
8
9 public class RelationDescriptor extends Descriptor {
10
11     SetDescriptor domain;
12     SetDescriptor range;
13     boolean bStatic;
14     public static String prefix="";
15     public static final Usage NONE = new Usage("NONE");
16     public static final Usage IMAGE = new Usage("IMAGE");
17     public static final Usage INVIMAGE = new Usage("INVIMAGE");
18     public static final Usage BOTH = new Usage("BOTH");
19
20     public static class Usage {
21         String name;
22         private Usage(String name) { this.name = name; }
23         public String toString() { return name; }
24     }
25     
26     Usage usage = NONE;
27
28     public RelationDescriptor(String name) {
29         super(name);
30         bStatic = false;
31         domain = null;
32         range = null;
33     }
34     
35     public boolean isStatic() {
36         return bStatic;
37     }
38     
39     public void isStatic(boolean newvalue) {
40         bStatic = newvalue;
41     }
42
43     public void setDomain(SetDescriptor td) {
44         domain = td;
45     }
46
47     public SetDescriptor getDomain() {
48         return domain;
49     }
50
51     public void setRange(SetDescriptor td) {
52         range = td;
53     }
54
55     public SetDescriptor getRange() {
56         return range;
57     }
58
59     public void addUsage(Usage newusage) {
60         if (newusage == null || newusage == NONE || newusage == BOTH) {
61             throw new IllegalArgumentException();
62         }
63
64         Usage oldusage = usage;
65
66         if (usage == BOTH) {
67             return;
68         } else if (usage == IMAGE && newusage == INVIMAGE) {
69             usage = BOTH;
70         } else if (usage == INVIMAGE && newusage == IMAGE) {
71             usage = BOTH;
72         } else {
73             usage = newusage;
74         }
75
76         //System.out.println(getSymbol() + " usage: " + oldusage + " + " + newusage + " => " + usage);
77     }
78
79     public boolean testUsage(Usage testusage) {
80         return (usage == BOTH) || (testusage == usage);
81     }
82
83     public String getSafeSymbol() {
84         return prefix+safename;
85     }
86
87     public String getJustSafeSymbol() {
88         return safename;
89     }
90 }