// currently allows only one argument svoid tok_mruCachedFunctions(LS tok) { pcall { if (!tok.contains("mruCached")) ret; int i = -1; while ((i = jfind(tok, i+1, "static mruCached ")) >= 0) { int iCurly = tok_findEndOfMethodHeader(tok, i); LS tok2 = subList(tok, i); S name = tok_methodName(tok2); IntRange r = tok_findArgs(tok2); LPair typesAndNames = tok_typesAndNamesOfParams(subList(tok2, r)); if (l(typesAndNames) != 1) print("mruCached function must have exactly one argument: " + name); S inputType = first(typesAndNames).b; S boxedInputType = tok_toNonPrimitiveTypes(inputType); S returnType = joinSubList(tok, i+4, bracket-3); S boxedReturnType = tok_toNonPrimitiveTypes(returnType); replaceTokens(tok2, i, bracket-1, "static \*boxedType*/ \*fName*/_cache;\n" + "static \*type*/ \*fName*/() { if (\*fName*/_cache == null) \*fName*/_cache = \*fName*/_load(); ret \*fName*/_cache; }\n\n" + "static \*boxedType*/ \*fName*/_load"); reTok(tok, i, iCurly); } }}