Warning: session_start(): open(/var/lib/php/sessions/sess_vi8rtk1o8rllpv0a8hag8qelat, 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
svoid tok_swappableFunctions(LS tok) {
jreplace(tok, "swappable static", "static swappable");
jreplace(tok, "pswappable ", "persistently swappable $2");
int i;
while ((i = jfind_any(tok,
"swappable (", "swappable <", "swappable .")) >= 0) {
// left-scan for modifiers
int iModEnd = i;
bool persistently = eqGet(tok, i-2, "persistently");
if (persistently) iModEnd -= 2;
int iMod = leftScanModifiers(tok, iModEnd);
S modifiers = joinSubList(tok, iMod, iModEnd);
// scan return type, find function name
int iEndOfType = tok_findEndOfType(tok, i+2);
S returnType = joinSubList(tok, i+2, iEndOfType-1);
S name = assertIdentifier(tok.get(iEndOfType));
int iArgs = iEndOfType+2;
assertEquals("(", get(tok, iArgs));
int iCurly = indexOf(tok, iEndOfType, "{");
assertEquals(")", get(tok, iCurly-2));
LS tokArgs = subList(tok, iArgs+1, iCurly-2);
LPairS args = tok_typesAndNamesOfParams(tokArgs);
S args1 = join(tokArgs);
S args2 = joinWithComma(pairsB(args));
bool isVoidMethod = eq(returnType, "void");
LS types = pairsA(args);
if (!isVoidMethod) types.add(returnType);
S typeParams = joinWithComma(map tok_toNonPrimitiveTypes(types)); // TODO: modifiers
S base = name + "_base", fallback = name + "_fallback";
S mods = modifiers + (persistently || containsJavaToken(modifiers, "static") ? "" : "transient ");
S src;
if (isVoidMethod)
if (empty(args))
// no args, returning void
src = mods + "Runnable \*name*/;\n" +
"\*modifiers*/\*returnType*/ \*name*/(\*args1*/) { if (\*name*/ != null) \*name*/.run(); else \*base*/(\*args2*/); }\n" +
"final \*modifiers*/\*returnType*/ \*fallback*/(Runnable _f, \*args1*/) { if (_f != null) _f.run(); else \*base*/(); }\n" +
"\*modifiers*/\*returnType*/ \*base*/(\*args1*/) {";
else {
// args, returning void
S varType = "IVF\*l(args)*/<\*typeParams*/>";
src = "\*mods*/ \*varType*/ \*name*/;\n" +
"\*modifiers*/\*returnType*/ \*name*/(\*args1*/) { if (\*name*/ != null) \*name*/.get(\*args2*/); else \*base*/(\*args2*/); }\n" +
"final \*modifiers*/\*returnType*/ \*fallback*/(\*varType*/ _f, \*args1*/) { if (_f != null) _f.get(\*args2*/); else \*base*/(\*args2*/); }\n" +
"\*modifiers*/\*returnType*/ \*base*/(\*args1*/) {";
}
else {
// zero or more args, not returning void
S varType = "IF\*l(args)*/<\*typeParams*/>";
src = "\*mods*/ \*varType*/ \*name*/;\n" +
"\*modifiers*/\*returnType*/ \*name*/(\*args1*/) { ret \*name*/ != null ? \*name*/.get(\*args2*/) : \*base*/(\*args2*/); }\n" +
"final \*modifiers*/\*returnType*/ \*fallback*/(\*varType*/ _f, \*args1*/) { ret _f != null ? _f.get(\*args2*/) : \*base*/(\*args2*/); }\n" +
"\*modifiers*/\*returnType*/ \*base*/(\*args1*/) {";
}
replaceTokens_reTok(tok, iMod, iCurly+1, src);
}
}