public void generateFunctionIndex() {
    for (String s : methods.keySet()) {
      int index = 0;
      LinkedHashMap<Signature, LinkedList<Operation>> funcs = methods.get(s);
      for (Signature sig : funcs.keySet()) {
        LinkedList<Operation> sameFuncs = funcs.get(sig);

        // If we have only one function, we need no function indices.
        // However, we still mus go through the loop to check for dangling forward-declarations.
        if (sameFuncs.size() == 1 && funcs.size() == 1) {
          index = 0;
        }
        for (Operation f : sameFuncs) {
          if (f.hasBody()) {
            f.setIndex(index++);
          }
        }
      }
    }
  }