public void generate(CompilationUnit unit) {
   println(J2ObjC.getFileHeader(getSourceFileName()));
   List<AbstractTypeDeclaration> typesToGenerate = collectTypes(unit);
   if (!typesToGenerate.isEmpty()) {
     findBlockComments(unit, typesToGenerate);
     findInvokedConstructors(unit);
     printStart(getSourceFileName());
     printImports(unit);
     pushIgnoreDeprecatedDeclarationsPragma();
     for (AbstractTypeDeclaration type : typesToGenerate) {
       generate(type);
     }
     popIgnoreDeprecatedDeclarationsPragma();
   } else {
     // Print a dummy C function so compiled object file is valid.
     List<AbstractTypeDeclaration> types = ASTUtil.getTypes(unit);
     if (!types.isEmpty()) {
       printf("void %s_unused() {}\n", NameTable.getFullName(types.get(0)));
     }
   }
   save(unit);
 }