Warning: session_start(): open(/var/lib/php/sessions/sess_n4dt7jgouib5n0s469j6bsfofm, O_RDWR) failed: No space left on device (28) in /var/www/tb-usercake/models/config.php on line 51
Warning: session_start(): Failed to read session data: files (path: /var/lib/php/sessions) in /var/www/tb-usercake/models/config.php on line 51
!7
sbool verbose = true;
p {
makeAndroid("Compiler bot with caching!");
}
static synchronized S answer(S s) {
new Matches m;
if (match3("Please compile this JavaX snippet: *", s, m)) {
S snippetID = unquote(m.m[0]);
S transpiledSrc = getServerTranspiled(snippetID);
int i = transpiledSrc.indexOf('\n');
String libs = transpiledSrc.substring(0, Math.max(0, i));
print("Compiling snippet: " + snippetID + ". Libs: " + libs);
transpiledSrc = transpiledSrc.substring(i+1);
return compile(transpiledSrc, libs);
}
if "Please compile this Java text: *"
ret compile($1, "");
if "Please compile this Java text: * with libraries *"
ret compile($1, $2);
if (match3("Please compile this Java text: * for java version *", s, m)) {
String src = unquote(m.m[0]);
String target = unquote(m.m[1]);
return compile(src, "", target);
}
return null;
}
static synchronized S compile(S src, S libs) {
return compile(src, libs, null);
}
static synchronized S compile(S src, S dehlibs, S javaTarget) {
if (verbose)
print("Compiling " + l(src) + " chars");
S md5 = md5(src);
File jar = getJarFile(md5);
if (jar == null || jar.length() <= 22) {
// have to compile
try {
javaCompileToJar(src, dehlibs, jar);
} catch e {
ret e.getMessage();
}
} else {
print("Getting classes from cache (" + jar.getAbsolutePath() + ", " + jar.length() + " bytes)");
touchFile(jar); // so we can find the unused ones easier
}
return "ok, " + quote(jar.getAbsolutePath());
}
static File getJarFile(S md5) {
assertTrue(isMD5(md5));
ret new File(getCacheProgramDir(), md5 + ".jar");
}