}
static <T> Class<T> compile(String file, Class<T> aClass) throws Throwable {
try (Reader in = resource(format("%s.kl", file))) {
debug("loading: %s", file);
Compiler compiler = new Compiler(null, file, cons(intern("do"), read(in)));
//noinspection RedundantCast
File compilePath = new File((String) intern("*compile-path*").value());
File classFile = new File(compilePath, file + ".class");
if (!(compilePath.mkdirs() || compilePath.isDirectory())) throw new IOException("could not make directory: " + compilePath);
try {
return compiler.load(classFile.getName().replaceAll(".class$", ".kl"), aClass);
} finally {
lines.clear();
if (compiler.bytes != null)
try (OutputStream out = new FileOutputStream(classFile)) {
out.write(compiler.bytes);