static new ThreadLocal evalJava_prep_voidMagic; // set to false to avoid looking up standard function return types static LS evalJava_prePrep(S code, EvalJavaPrep prep default new) { LS tok = javaTok(trim(code)); int idx; while ((idx = jfind(tok, "global {")) >= 0) { int j = findEndOfBracketPart(tok, idx+2); prep.global.add(joinSubList(tok, idx+3, j-1)); clearTokens_reTok(tok, idx, j+1); } // =1*2 as in Lua if (eqGet(tok, 1, "=")) tok = subList(tok, 2); // if code is something like "sclass Bla {}", just return as is if (tok_isStaticLevelCode(tok)) ret tok; if (!isFalse(evalJava_prep_voidMagic!) && tok_shouldAddReturn(tok) && eqGet(tok, 3, "(") && isIdentifier(get(tok, 1)) && isKnownVoidFunction_uncached(get(tok, 1))) tokAppend_reTok(tok, l(tok)-2, ";"); S name = null; ifdef evalJava_prePrep_debug printVars evalJava_prePrep(+tok); endifdef // just a single identifier: interpret as function call if (l(tok) == 3 && isIdentifier(name = firstToken(tok))) tokAppend_reTok(tok, 1, "()" + (isKnownVoidFunction_uncached(name) ? ";" : "")); ifdef evalJava_prePrep_debug printVars evalJava_prePrep(+name, +tok); endifdef ret tok; }