5 public class ImageSetExpr extends SetExpr {
6 static final public boolean INVERSE=true;
11 public ImageSetExpr(VarDescriptor vd, RelationDescriptor rd) {
17 public Set freeVars() {
18 HashSet hs=new HashSet();
23 public String name() {
24 String name=vd.toString()+".";
31 public ImageSetExpr(boolean inverse, VarDescriptor vd, RelationDescriptor rd) {
34 this.inverse = inverse;
37 public boolean equals(Map remap, Expr e) {
38 if (e==null||!(e instanceof ImageSetExpr))
40 ImageSetExpr ise=(ImageSetExpr)e;
41 if (ise.inverse!=inverse)
45 VarDescriptor nvde=vd;
46 if (remap.containsKey(nvde))
47 nvde=(VarDescriptor)remap.get(nvde);
53 public boolean inverted() {
57 public VarDescriptor getVar() {
61 public RelationDescriptor getRelation() {
65 public Descriptor getDescriptor() {
69 public boolean usesDescriptor(Descriptor d) {
70 return (d==rd)||(d==vd);
73 public Set getInversedRelations() {
74 HashSet set = new HashSet();
81 public Set getRequiredDescriptors() {
82 HashSet v = new HashSet();
87 public void generate(CodeWriter writer, VarDescriptor dest) {
88 throw new IRException("not supported");
91 public void generate_inclusion(CodeWriter writer, VarDescriptor dest, VarDescriptor element) {
92 String hash = inverse ? "_hashinv->contains(" : "_hash->contains(" ;
93 writer.outputline("int " + dest.getSafeSymbol() + " = " + rd.getSafeSymbol() + hash + vd.getSafeSymbol() + ", " + element.getSafeSymbol() + ");");
96 public void generate_size(CodeWriter writer, VarDescriptor dest) {
100 String hash = inverse ? "_hashinv->count(" : "_hash->count(" ;
101 writer.outputline("int " + dest.getSafeSymbol() + " = " + rd.getSafeSymbol() + hash + vd.getSafeSymbol() + ");");
104 public void prettyPrint(PrettyPrinter pp) {
105 pp.output(vd.toString());
110 pp.output(rd.toString());
113 public TypeDescriptor typecheck(SemanticAnalyzer sa) {
114 throw new IRException("not supported");