5 public class SetInclusion extends Inclusion {
10 static boolean worklist = true;
12 public SetInclusion(Expr elementexpr, SetDescriptor set) {
13 this.elementexpr = elementexpr;
17 public Set getTargetDescriptors() {
18 HashSet v = new HashSet();
23 public Set getRequiredDescriptors() {
24 return elementexpr.getRequiredDescriptors();
27 public void generate(CodeWriter writer) {
28 VarDescriptor vd = VarDescriptor.makeNew("element");
29 elementexpr.generate(writer, vd);
31 String addeditem = (VarDescriptor.makeNew("addeditem")).getSafeSymbol();
32 writer.outputline("int " + addeditem + ";");
34 writer.outputline(addeditem + " = " + set.getSafeSymbol() + "_hash->add((int)" + vd.getSafeSymbol()
35 + ", (int)" + vd.getSafeSymbol() + ");");
37 if (SetInclusion.worklist) {
38 writer.outputline("if (" + addeditem + ")");
39 writer.startblock(); {
40 WorkList.generate_dispatch(writer, set, vd.getSafeSymbol());
47 public boolean typecheck(SemanticAnalyzer sa) {
48 TypeDescriptor td = elementexpr.typecheck(sa);
54 TypeDescriptor settype = set.getType();
56 if (!td.equals(settype)) {
57 sa.getErrorReporter().report(null, "Type mismatch: attempting to test for types '" + td.getSymbol() + "' in set of type '" + settype.getSymbol() + "'");