Verified Commit 87256879 authored by Amin Bandali's avatar Amin Bandali
Browse files

Simplify builtin sig check

Sig already has a builtin field that I’d somehow missed.
parent c3eb0b17
......@@ -21,10 +21,8 @@
package org.shemshak.alloy.catalyst;
import java.util.Arrays;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
import edu.mit.csail.sdg.alloy4.Pos;
import edu.mit.csail.sdg.ast.Decl;
......@@ -53,10 +51,6 @@ import edu.mit.csail.sdg.ast.VisitReturn;
public class SSRVisitor extends VisitReturn<Object> {
Set<PrimSig> builtins =
new HashSet<>(Arrays.asList(Sig.UNIV, Sig.SIGINT, Sig.SEQIDX,
Sig.STRING, Sig.NONE, Sig.GHOST));
Map<PrimSig, Boolean> candidates = new LinkedHashMap<>();
PrimSig getFirstPrimSig(Expr e) {
......@@ -88,7 +82,7 @@ public class SSRVisitor extends VisitReturn<Object> {
if (x.left instanceof ExprUnary && x.right instanceof ExprUnary)
if (isFieldAccess(x)) {
PrimSig s = getFirstPrimSig(x.left);
if (!builtins.contains(s))
if (!s.builtin)
candidates.put(s, true);
}
}
......@@ -99,11 +93,11 @@ public class SSRVisitor extends VisitReturn<Object> {
r = (ExprUnary) x.right;
for (ProductType t : l.type())
for (int i = 1; i < t.arity(); i++)
if (!builtins.contains(t.get(i)))
if (!t.get(i).builtin)
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)))
if (!t.get(i).builtin)
candidates.put(t.get(i), false);
}
}
......@@ -166,13 +160,13 @@ public class SSRVisitor extends VisitReturn<Object> {
Expr subsub = getUnarySub(getUnarySub(s));
if (subsub instanceof PrimSig)
if (((PrimSig)subsub).getFieldDecls().size() > 1)
if (!builtins.contains(subsub))
if (!((PrimSig)subsub).builtin)
candidates.put((PrimSig)subsub, false);
}
}
else if (s instanceof PrimSig) {
if (((PrimSig)s).getFieldDecls().size() > 1)
if (!builtins.contains(s))
if (!((PrimSig)s).builtin)
candidates.put((PrimSig)s, false);
}
/**
......@@ -234,7 +228,7 @@ public class SSRVisitor extends VisitReturn<Object> {
if (x instanceof PrimSig) {
PrimSig px = (PrimSig)x;
/*
if (!builtins.contains(px) && !candidates.containsKey(px))
if (!px.builtin && !candidates.containsKey(px))
candidates.put(px, true);
*/
if (px.isMeta != null)
......@@ -264,7 +258,7 @@ public class SSRVisitor extends VisitReturn<Object> {
// after first column
for (ProductType t : x.type())
for (int i = 1; i < t.arity(); i++)
if (!builtins.contains(t.get(i)))
if (!t.get(i).builtin)
candidates.put(t.get(i), false);
if (x.isMeta != null)
......
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