de6d4f37d7d9c31783995775870378622f5edfa4
[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 }