public static void idlOutputAllUnitsToFile(String sourcefile) {
    { String codeoutputfile = Stella.idlMakeCodeOutputFileName(sourcefile);
      OutputFileStream codeoutputstream = OutputFileStream.newOutputFileStream(codeoutputfile);
      Cons globals = Stella.NIL;
      Cons methods = Stella.NIL;
      Cons verbatimstatements = Stella.NIL;
      Cons forms = Stella.NIL;

      { Object old$CurrentStream$000 = Stella.$CURRENT_STREAM$.get();

        try {
          Native.setSpecial(Stella.$CURRENT_STREAM$, codeoutputstream);
          Native.setSpecial(Stella.$TRANSLATIONUNITS$, ((List)(Stella.$TRANSLATIONUNITS$.get())).reverse());
          { TranslationUnit unit = null;
            Cons iter000 = ((List)(Stella.$TRANSLATIONUNITS$.get())).theConsList;

            for (;!(iter000 == Stella.NIL); iter000 = iter000.rest) {
              unit = ((TranslationUnit)(iter000.value));
              { Symbol testValue000 = unit.category;

                if ((testValue000 == Stella.SYM_STELLA_METHOD) ||
                    ((testValue000 == Stella.SYM_STELLA_PRINT_METHOD) ||
                     (testValue000 == Stella.SYM_STELLA_MACRO))) {
                  methods = Cons.cons(unit.translation, methods);
                }
                else if (testValue000 == Stella.SYM_STELLA_VERBATIM) {
                  verbatimstatements = Cons.cons(unit.translation, verbatimstatements);
                }
                else if (testValue000 == Stella.SYM_STELLA_GLOBAL_VARIABLE) {
                  globals = Cons.cons(unit.translation, globals);
                }
                else {
                  forms = Cons.cons(unit.translation, forms);
                }
              }
            }
          }
          System.out.println("Writing `" + codeoutputfile + "'...");
          {
            ((OutputStream)(Stella.$CURRENT_STREAM$.get())).nativeStream.println("// " + codeoutputfile);
            ((OutputStream)(Stella.$CURRENT_STREAM$.get())).nativeStream.println();
          }
;
          if (Stella.translateWithCopyrightHeaderP()) {
            OutputStream.outputCopyrightHeader(((OutputStream)(Stella.$CURRENT_STREAM$.get())));
          }
          { Stella_Object form = null;
            Cons iter001 = forms;

            for (;!(iter001 == Stella.NIL); iter001 = iter001.rest) {
              form = iter001.value;
              Stella_Object.idlOutputStatement(((Cons)(form)));
            }
          }
          codeoutputstream.free();

        } finally {
          Stella.$CURRENT_STREAM$.set(old$CurrentStream$000);
        }
      }
    }
  }