5 public class ImageSetExpr extends SetExpr {
6 static final public boolean INVERSE=true;
11 public ImageSetExpr(VarDescriptor vd, RelationDescriptor rd) {
17 public String name() {
18 String name=vd.toString()+".";
25 public ImageSetExpr(boolean inverse, VarDescriptor vd, RelationDescriptor rd) {
28 this.inverse = inverse;
31 public boolean equals(Map remap, Expr e) {
32 if (e==null||!(e instanceof ImageSetExpr))
34 ImageSetExpr ise=(ImageSetExpr)e;
35 if (ise.inverse!=inverse)
39 VarDescriptor nvde=vd;
40 if (remap.containsKey(nvde))
41 nvde=(VarDescriptor)remap.get(nvde);
47 public boolean inverted() {
51 public VarDescriptor getVar() {
55 public RelationDescriptor getRelation() {
59 public Descriptor getDescriptor() {
63 public boolean usesDescriptor(Descriptor d) {
64 return (d==rd)||(d==vd);
67 public Set getInversedRelations() {
68 HashSet set = new HashSet();
75 public Set getRequiredDescriptors() {
76 HashSet v = new HashSet();
81 public void generate(CodeWriter writer, VarDescriptor dest) {
82 throw new IRException("not supported");
85 public void generate_inclusion(CodeWriter writer, VarDescriptor dest, VarDescriptor element) {
86 String hash = inverse ? "_hashinv->contains(" : "_hash->contains(" ;
87 writer.outputline("int " + dest.getSafeSymbol() + " = " + rd.getSafeSymbol() + hash + vd.getSafeSymbol() + ", " + element.getSafeSymbol() + ");");
90 public void generate_size(CodeWriter writer, VarDescriptor dest) {
94 String hash = inverse ? "_hashinv->count(" : "_hash->count(" ;
95 writer.outputline("int " + dest.getSafeSymbol() + " = " + rd.getSafeSymbol() + hash + vd.getSafeSymbol() + ");");
98 public void prettyPrint(PrettyPrinter pp) {
99 pp.output(vd.toString());
104 pp.output(rd.toString());
107 public TypeDescriptor typecheck(SemanticAnalyzer sa) {
108 throw new IRException("not supported");