import java.util.*;
public class RelationInclusion extends Inclusion {
-
+
Expr leftelementexpr, rightelementexpr;
RelationDescriptor relation;
public Expr getLeftExpr() {
return leftelementexpr;
}
-
+
public Expr getRightExpr() {
return rightelementexpr;
}
String check = "int " + typesafecheck + " = " ;
if (!(relation.getDomain() instanceof ReservedSetDescriptor)) {
- check += relation.getDomain().getSafeSymbol() + "_hash->contains(" + ld.getSafeSymbol() + ") && ";
+ check += "SimpleHashcontainskey("+relation.getDomain().getSafeSymbol() + "_hash, "+ld.getSafeSymbol() + ") && ";
}
if (!(relation.getRange() instanceof ReservedSetDescriptor)) {
- check += relation.getRange().getSafeSymbol() + "_hash->contains(" + rd.getSafeSymbol() + ") && ";
+ check += "SimpleHashcontainskey("+relation.getRange().getSafeSymbol() +"_hash, "+ rd.getSafeSymbol() + ") && ";
}
check += "1;"; // terminate boolean expression
}
String addeditem = (VarDescriptor.makeNew("addeditem")).getSafeSymbol();
- /* if (!Compiler.REPAIR) {
- writer.outputline("int " + addeditem + ";");
- if (relation.testUsage(RelationDescriptor.IMAGE)) {
- writer.outputline(addeditem + " = " + relation.getSafeSymbol() + "_hash->add((int)" + ld.getSafeSymbol() + ", (int)" + rd.getSafeSymbol() + ");");
- }
-
- if (relation.testUsage(RelationDescriptor.INVIMAGE)) {
- writer.outputline(addeditem + " = " + relation.getSafeSymbol() + "_hashinv->add((int)" + rd.getSafeSymbol() + ", (int)" + ld.getSafeSymbol() + ");");
- }
- } else {*/
- Repair.generate_dispatch(writer, relation, ld.getSafeSymbol(), rd.getSafeSymbol());
- // }
-
+ Repair.generate_dispatch(writer, relation, ld.getSafeSymbol(), rd.getSafeSymbol());
+
if (RelationInclusion.worklist) {
writer.outputline("if (" + addeditem + ")");
writer.startblock(); {
public boolean typecheck(SemanticAnalyzer sa) {
TypeDescriptor ld = leftelementexpr.typecheck(sa);
TypeDescriptor rd = rightelementexpr.typecheck(sa);
-
+
if (ld == null || rd == null) {
return false;
}
boolean ok = true;
- /* #ATTN#: this check makes sure that the types match up,
- a runtime check needs to made that the set relationships
+ /* #ATTN#: this check makes sure that the types match up,
+ a runtime check needs to made that the set relationships
are correct */
- if (ld != relation.getDomain().getType()) {
+ if (ld != relation.getDomain().getType()) {
sa.getErrorReporter().report(null, "Type of left element '" + ld.getSymbol() + "' must match domain type '" + relation.getDomain().getType().getSymbol() + "'");
ok = false;
}