Verified Commit 86d924ca authored by Amin Bandali's avatar Amin Bandali
Browse files

Discard a few more classes of false positives

- discard meta signatures
- discard abstract signatures
- discard enum signatures and their children
- discard parents of subset signatures
- discard signatures of meta fields

TODO: make sure we’re not discarding anything useful in the non-join
else case of visit(ExprBinary).
parent d8cd05b7
......@@ -64,13 +64,29 @@ public class SSRVisitor extends VisitReturn {
public Object visit(ExprBinary x) {
// in a dot join, if it's not of form `sig.field' or `var.field' where
// `var in sig', discard candidate
if (x.op == ExprBinary.Op.JOIN)
if (x.op == ExprBinary.Op.JOIN) {
if (x.left instanceof ExprUnary && x.right instanceof ExprUnary)
if (!isFieldAccess(x)) {
PrimSig s = getFirstPrimSig(x.left);
if (!builtins.contains(s))
candidates.put(s, false);
}
}
else {
if (x.left instanceof ExprUnary && x.right instanceof ExprUnary) {
ExprUnary
l = (ExprUnary) x.left,
r = (ExprUnary) x.right;
for (ProductType t : l.type())
for (int i = 1; i < t.arity(); i++)
if (!builtins.contains(t.get(i)))
candidates.put(t.get(i), false);
for (ProductType t : r.type())
for (int i = 1; i < t.arity(); i++)
if (!builtins.contains(t.get(i)))
candidates.put(t.get(i), false);
}
}
visitThis(x.left);
visitThis(x.right);
return null;
......@@ -187,9 +203,24 @@ public class SSRVisitor extends VisitReturn {
@Override
public Object visit(Sig x) {
// add the sig as a candidate if we haven't seen it before
if (x instanceof PrimSig)
if (!builtins.contains((PrimSig)x) && !candidates.containsKey((PrimSig)x))
candidates.put((PrimSig)x, true);
if (x instanceof PrimSig) {
PrimSig px = (PrimSig)x;
if (!builtins.contains(px) && !candidates.containsKey(px))
candidates.put(px, true);
if (px.isMeta != null)
candidates.put(px, false);
if (px.isAbstract != null)
candidates.put(px, false);
if (px.parent != null && px.parent.isEnum != null) {
candidates.put(px, false);
candidates.put(px.parent, false);
}
}
else if (x instanceof Sig.SubsetSig) {
for (Sig p : ((Sig.SubsetSig)x).parents)
if (p instanceof PrimSig)
candidates.put((PrimSig)p, false);
}
return null;
}
......@@ -206,6 +237,10 @@ public class SSRVisitor extends VisitReturn {
if (!builtins.contains(t.get(i)))
candidates.put(t.get(i), false);
if (x.isMeta != null)
if (x.sig instanceof PrimSig)
candidates.put((PrimSig)x.sig, false);
// TODO: if type of field refers to another field, in this sig
// or elsewhere, if there are no multiplicity constraints then
// we're fine (we can replace the type with that sig's type).
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment