if (label.equals(STRING.label)) { id2sig.put(id, STRING); return STRING; }
throw new IOException("Unknown builtin sig: "+label+" (id="+id+")");
}
if (depth > nmap.size()) throw new IOException("Sig "+label+" (id="+id+") is in a cyclic inheritance relationship.");
List<Sig> parents = null;
TupleSet ts = factory.noneOf(1);
for(XMLNode sub:node) {
if (sub.is("atom")) { ts.add(factory.tuple(sub.getAttribute("label"))); continue; }
if (!sub.is("type")) continue;
Sig parent = parseSig(sub.getAttribute("ID"), depth+1);
if (parents==null) parents = new ArrayList<Sig>();
parents.add(parent);
}
if (parents==null) {
String parentID = node.getAttribute("parentID");
Sig parent = parseSig(parentID, depth+1);
if (!(parent instanceof PrimSig)) throw new IOException("Parent of sig "+label+" (id="+id+") must not be a subset sig.");
for(Expr choice: choices)
if (choice instanceof PrimSig && parent==((PrimSig)choice).parent && ((Sig)choice).label.equals(label))
{ ans=(Sig)choice; choices.remove(choice); break; }
if (ans==null) {
ans = new PrimSig(label, (PrimSig)parent, isAbstract, isLone, isOne, isSome, isPrivate, isMeta, isEnum);
allsigs.add(ans);
}
} else {
for(Expr choice:choices)
if (choice instanceof SubsetSig && ((Sig)choice).label.equals(label) && sameset(parents, ((SubsetSig)choice).parents))
{ ans=(Sig)choice; choices.remove(choice); break; }
if (ans==null) {
ans = new SubsetSig(label, parents, isExact, isLone, isOne, isSome, isPrivate, isMeta);
allsigs.add(ans);
}
}
id2sig.put(id, ans);
expr2ts.put(ans, ts);
if (ans instanceof PrimSig) {
// Add the atoms in this SIG into all parent sigs
for(PrimSig ans2 = ((PrimSig)ans).parent; ans2!=null && !ans2.builtin; ans2 = ans2.parent) {
TupleSet ts2 = expr2ts.get(ans2);
if (ts2==null) ts2 = ts.clone(); else { ts2 = ts2.clone(); ts2.addAll(ts); }
expr2ts.put(ans2, ts2);
}
}
return ans;
}