5 public class ImageSetExpr extends SetExpr {
6 static final public boolean INVERSE=true;
11 boolean isimageset=false;
13 public ImageSetExpr(boolean inverse, VarDescriptor vd, RelationDescriptor rd) {
16 this.inverse = inverse;
19 public ImageSetExpr(VarDescriptor vd, RelationDescriptor rd) {
25 public ImageSetExpr(boolean inverse, ImageSetExpr ise, RelationDescriptor rd) {
29 this.inverse = inverse;
32 public ImageSetExpr(ImageSetExpr ise, RelationDescriptor rd) {
39 public Set freeVars() {
40 HashSet hs=new HashSet();
45 public String name() {
50 name+=vd.toString()+".";
57 public boolean equals(Map remap, Expr e) {
58 if (e==null||!(e instanceof ImageSetExpr))
60 ImageSetExpr ise2=(ImageSetExpr)e;
61 if (ise2.isimageset!=isimageset)
63 if (ise2.inverse!=inverse)
69 return ise.equals(remap,ise2.ise);
71 VarDescriptor nvde=vd;
72 if (remap!=null&&remap.containsKey(nvde))
73 nvde=(VarDescriptor)remap.get(nvde);
80 public boolean inverted() {
84 public VarDescriptor getVar() {
88 public ImageSetExpr getImageSetExpr() {
92 public RelationDescriptor getRelation() {
96 public Descriptor getDescriptor() {
100 public boolean usesDescriptor(Descriptor d) {
102 return d==rd||ise.usesDescriptor(d);
103 return (d==rd)||(d==vd);
106 public Set getInversedRelations() {
107 HashSet set = new HashSet();
114 public Set getRequiredDescriptors() {
115 HashSet v = new HashSet();
120 public void generate(CodeWriter writer, VarDescriptor dest) {
121 throw new IRException("not supported");
124 public void generate_inclusion(CodeWriter writer, VarDescriptor dest, VarDescriptor element) {
125 String hash = inverse ? "_hashinv->contains(" : "_hash->contains(" ;
126 writer.outputline("int " + dest.getSafeSymbol() + " = " + rd.getSafeSymbol() + hash + vd.getSafeSymbol() + ", " + element.getSafeSymbol() + ");");
129 public void generate_size(CodeWriter writer, VarDescriptor dest) {
133 String hash = inverse ? "_hashinv->count(" : "_hash->count(" ;
134 writer.outputline("int " + dest.getSafeSymbol() + " = " + rd.getSafeSymbol() + hash + vd.getSafeSymbol() + ");");
137 public void prettyPrint(PrettyPrinter pp) {
138 pp.output(vd.toString());
143 pp.output(rd.toString());
146 public TypeDescriptor typecheck(SemanticAnalyzer sa) {
147 throw new IRException("not supported");