Committing changes to leftsize->rightSize, more comments, and handling
[repair.git] / Repair / RepairCompiler / MCC / IR / Sources.java
1 package MCC.IR;
2
3 import MCC.State;
4
5 public class Sources {
6     State state;
7
8     public Sources(State s) {
9         this.state=s;
10     }
11
12     public boolean setSource(SetDescriptor sd) {
13         return false;
14     }
15     public boolean allocSource(SetDescriptor sd) {
16         return true;
17     }
18     public SetDescriptor getSourceSet(SetDescriptor sd) {
19         return null;
20     }
21     public void generateSourceAlloc(CodeWriter cr,VarDescriptor vd, SetDescriptor sd) {
22         TypeDescriptor td=sd.getType();
23         Expr e=td.getSizeExpr();
24         VarDescriptor size=VarDescriptor.makeNew("size");
25         e.generate(cr, size);
26         cr.outputline(td.getGenerateType().getSafeSymbol()+" "+vd.getSafeSymbol()+"=("+td.getGenerateType().getSafeSymbol()+") malloc("+size.getSafeSymbol()+");");
27     }
28
29     public boolean relsetSource(RelationDescriptor rd, boolean domain) {
30         return false;
31     }
32     public boolean relallocSource(RelationDescriptor rd, boolean domain) {
33         return true;
34     }
35     public SetDescriptor relgetSourceSet(RelationDescriptor rd, boolean domain) {
36         return null;
37     }
38     public void relgenerateSourceAlloc(CodeWriter cr,VarDescriptor vd, RelationDescriptor rd, boolean domain) {
39         SetDescriptor sd=null;
40         if (domain)
41             sd=rd.getDomain();
42         else
43             sd=rd.getRange();
44         TypeDescriptor td=sd.getType();
45         Expr e=td.getSizeExpr();
46         VarDescriptor size=VarDescriptor.makeNew("size");
47         e.generate(cr, size);
48         cr.outputline(td.getGenerateType().getSafeSymbol()+" "+vd.getSafeSymbol()+"=("+td.getGenerateType().getSafeSymbol()+") malloc("+size.getSafeSymbol()+");");
49     }
50
51 }