JavaClassDecl terminalsDecl = StreamSupport.stream(jcd.getDecls().getDeclIterator().spliterator(), false)
.filter(decl -> decl instanceof JavaClassDecl)
.<JavaClassDecl>map(decl -> (JavaClassDecl) decl)
.filter(decl -> decl.getName().equals("Terminals"))
.findFirst().orElseThrow(() -> new RuntimeException("Cannot find terminals class"));
Type terminalClassType = terminalsDecl
.extend(Environment.getEmptyEnvironment(), Environment.getEmptyEnvironment())
.lookup("Terminals").getType();
Type terminalObjType = terminalsDecl
.extend(Environment.getEmptyEnvironment(), Environment.getEmptyEnvironment())
.lookupType("Terminals").getType();
splicers.forEach(splicer -> splicer.accept(terminalClassType,terminalObjType));
AtomicInteger cdIdx = new AtomicInteger();
TypedAST[] classDecls = new TypedAST[toGen.size() + toGenDefs.size() + 1];
toGen.entrySet().stream().forEach(entry->classDecls[cdIdx.getAndIncrement()]
= new ValDeclaration(entry.getKey(), DefDeclaration.getMethodType(entry.getValue().second().getArgBindings(), entry.getValue().first()), entry.getValue().second(), unkLoc));
toGenDefs.entrySet().stream().forEach(entry->classDecls[cdIdx.getAndIncrement()]
= new DefDeclaration(entry.getKey(), new Arrow(Unit.getInstance(), Unit.getInstance()), new LinkedList<>(), entry.getValue(), false));
classDecls[cdIdx.getAndIncrement()] = new DefDeclaration("create", new Arrow(Unit.getInstance(),
new UnresolvedType(wyvClassName)),
Arrays.asList(),
new New(new DeclSequence(), unkLoc), true);
ArrayList<TypedAST> pairedObjDecls = new ArrayList<>();
pairedObjDecls.addAll(Arrays.asList(classDecls));
TypedAST pairedObj = new ClassDeclaration(wyvClassName, "", "", new DeclSequence(pairedObjDecls), unkLoc);
Type parseBufferType = Util.javaToWyvType(ParseBuffer.class);
Type javaClassType = Util.javaToWyvType(javaClass);
TypedAST bufGet = new Application(
new Invocation(new Variable(new NameBindingImpl("buf", null), unkLoc), "getSrcString", null, unkLoc),
UnitVal.getInstance(unkLoc),
unkLoc);
ClassType emptyType =