/** * Given a list of functions, find a work function. If the list contains an anonymous work * function, return that; otherwise, return the first work function, or null if there are no work * functions at all. * * @param fns List of functions to search * @return Primary work function in fns */ public static Function findWork(List fns, boolean init) { Function work = null; for (Iterator iter = fns.iterator(); iter.hasNext(); ) { Function fn = (Function) iter.next(); int cls = init ? Function.FUNC_PREWORK : Function.FUNC_WORK; if (fn.getCls() == cls) { if (fn.getName() == null) work = fn; if (work == null) work = fn; } } return work; }
private void translateHelpers(List<Function> helpers, List newStmts) { for (Iterator<Function> iter = helpers.iterator(); iter.hasNext(); ) { Function helper = iter.next(); newStmts.add(new StmtIODecl(helper.getContext(), helper)); } }