Verified Commit 536bf76c authored by Amin Bandali's avatar Amin Bandali
Browse files

Revert "Don’t add built-in signatures"

This reverts commit 12512076.

class java.lang.NullPointerException: null

I don’t know why I even try with Java…
parent 7ed802a9
......@@ -2,10 +2,6 @@ package org.aminb.alloy.catalyst;
import java.util.Map;
import java.util.HashMap;
import java.util.Set;
import java.util.HashSet;
import java.util.Arrays;
import java.util.Optional;
......@@ -33,27 +29,22 @@ import;
public class SSRVisitor extends VisitReturn {
Set<PrimSig> builtins =
new HashSet<>(Arrays.asList(Sig.UNIV, Sig.SIGINT, Sig.SEQIDX,
// if come to var that's not used in a join field access, toss out its sig?
* new plan:
* - gather list of candidate sigs in visit(Sig)
* - all but those who a field of their own or another sig refers to them
* - if in visit(ExprBinary) we detect a "field access" dot join involving
* a sig, let it remain on the list if it is
* - how about ExprQt? when to disallow those that are quantified over?
* - any other cases where it should be allowed?
* - otherwise, remove sig from candidates
Map<PrimSig, Boolean> candidates = new HashMap<>();
Optional<Boolean> putCandidate(PrimSig sig, Boolean viable) {
if (!builtins.contains(sig))
return Optional.of(candidates.put(sig, viable));
return Optional.empty();
Optional<Boolean> putCandidateIfAbsent(PrimSig sig, Boolean viable) {
if (!builtins.contains(sig))
return Optional.of(candidates.putIfAbsent(sig, viable));
return Optional.empty();
PrimSig getFirstPrimSig(Expr e) {
e.type() // :: Type
......@@ -82,7 +73,7 @@ public class SSRVisitor extends VisitReturn {
if (x.op == ExprBinary.Op.JOIN)
if (x.left instanceof ExprUnary && x.right instanceof ExprUnary)
if (!isFieldAccess(x))
putCandidate(getFirstPrimSig(x.left), false);
candidates.put(getFirstPrimSig(x.left), false);
return null;
......@@ -142,7 +133,7 @@ public class SSRVisitor extends VisitReturn {
Expr subsub = getUnarySub(getUnarySub(s));
if (subsub instanceof PrimSig)
if (((PrimSig)subsub).getFieldDecls().size() > 1)
putCandidate((PrimSig)subsub, false);
candidates.put((PrimSig)subsub, false);
else if (s instanceof PrimSig)
......@@ -199,7 +190,7 @@ public class SSRVisitor extends VisitReturn {
public Object visit(Sig x) {
// add the sig as a candidate if we haven't seen it before
if (x instanceof PrimSig)
putCandidateIfAbsent((PrimSig)x, true);
candidates.putIfAbsent((PrimSig)x, true);
return null;
......@@ -213,7 +204,7 @@ public class SSRVisitor extends VisitReturn {
// after first column
for (ProductType t : x.type())
for (int i = 1; i < t.arity(); i++)
putCandidate(t.get(i), false);
candidates.put(t.get(i), false);
// TODO: if type of field refers to another field, in this sig
// or elsewhere, if there are no multiplicity constraints then
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