Created
December 10, 2019 19:50
-
-
Save saiema/913ead10a14011d5828bc6166010e61c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private Type appendTypes(Type atype, Type btype) { | |
if (atype.is_bool || atype.is_int()) | |
return Type.EMPTY; | |
if (btype.is_bool || btype.is_int()) | |
return Type.EMPTY; | |
List<ProductType> rtypes = new LinkedList<>(); | |
AtomicInteger arities = new AtomicInteger(0); | |
Iterator<ProductType> atypesIt = atype.iterator(); | |
Iterator<ProductType> btypesIt = btype.iterator(); | |
atypesIt.forEachRemaining(at -> { | |
rtypes.add(at); | |
arities.addAndGet(at.arity()); | |
}); | |
btypesIt.forEachRemaining(bt -> { | |
rtypes.add(bt); | |
arities.addAndGet(bt.arity()); | |
}); | |
List<PrimSig> primSigs = new LinkedList<>(); | |
rtypes.forEach(prodType -> { | |
for (PrimSig s : prodType.getAll()) | |
primSigs.add(s); | |
}); | |
List<ProductType> rProductTypes = Arrays.asList(new ProductType(primSigs.toArray(new PrimSig[primSigs.size()]))); | |
ConstList<ProductType> rtypesConstList = ConstList.make(rProductTypes); | |
return new Type(false, rtypesConstList, arities.get()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment