A BinaryWriter will write types to a binary output stream. The types should be read back from the stream using BinaryReader .
BinaryWriter
BinaryReader
NOTE: Under-the-hood, this class is essentially a wrapper for BinaryAutomataWriter.
BinaryAutomataWriter
375137523753375437553756375737583759
@Test public void test_3719() { checkNotSubtype("{int f2}|int","{null f2}|null"); } @Test public void test_3720() { checkNotSubtype("{int f2}|int","{int f1}|int"); } @Test public void test_3721() { checkIsSubtype("{int f2}|int","{int f2}|int"); } private void checkIsSubtype(String from, String to) { Type ft = Type.fromString(from); Type tt = Type.fromString(to); assertTrue(Type.isSubtype(ft,tt)); }
375637573758375937603761376237633764
Type ft = Type.fromString(from); Type tt = Type.fromString(to); assertTrue(Type.isSubtype(ft,tt)); } private void checkNotSubtype(String from, String to) { Type ft = Type.fromString(from); Type tt = Type.fromString(to); assertFalse(Type.isSubtype(ft,tt)); }
511512513514515516517518519520521
public ArrayList<Nominal> elements() { ArrayList<Nominal> r = new ArrayList<Nominal>(); java.util.List<Type> rawElements = raw.elements(); java.util.List<Type> nominalElements = nominal.elements(); for(int i=0;i!=rawElements.size();++i) { Type nominalElement = nominalElements.get(i); Type rawElement = rawElements.get(i); r.add(construct(nominalElement,rawElement)); } return r; }
569570571572573574575576577578579
public HashMap<String,Nominal> fields() { HashMap<String,Nominal> r = new HashMap<String,Nominal>(); HashMap<String,Type> nominalFields = nominal.fields(); for(java.util.Map.Entry<String, Type> e : raw.fields().entrySet()) { String key = e.getKey(); Type rawField = e.getValue(); Type nominalField = nominalFields.get(key); r.put(e.getKey(), Nominal.construct(nominalField,rawField)); } return r; }
577578579580581582583584585586587
} return r; } public Nominal field(String field) { Type rawField = raw.fields().get(field); if(rawField == null) { return null; } else { return construct(nominal.fields().get(field),rawField); }
836837838839840841842843844845846
844845846847848849850851852853854
949950951952953954955956957958959
public java.util.List<Nominal> params() { ArrayList<Nominal> r = new ArrayList<Nominal>(); java.util.List<Type> rawElements = raw.params(); java.util.List<Type> nominalElements = nominal.params(); for(int i=0;i!=rawElements.size();++i) { Type nominalElement = nominalElements.get(i); Type rawElement = rawElements.get(i); r.add(construct(nominalElement,rawElement)); } return r; }
995996997998999100010011002100310041005
162163164165166167168169170171172173174
// No child subsumes type. So construct its child set. ArrayList<Node> nchildren = new ArrayList<Node>(); for(int i=0;i!=children.size();) { Node n = children.get(i); Type nType = n.type; if(Type.isSubtype(type,nType)) { if(nType.equals(type)) { if(n.constraint != null) { String nextLabel = CodeUtils.freshLabel(); Code.Block blk = chainBlock(nextLabel, n.constraint); blk.add(Codes.Label(nextLabel)); blk.addAll(constraint);