public static void operateOnFile(String file, Keyword operation) {
    { String targetlanguage = ((Keyword)(Stella.$TRANSLATOROUTPUTLANGUAGE$.get())).symbolName;
      Module currentmodule = ((Module)(Stella.$MODULE$.get()));
      Context currentcontext = ((Context)(Stella.$CONTEXT$.get()));
      boolean seeninmoduleP = false;
      boolean skipP = false;

      file = Stella.translateLogicalPathname(file);
      if (operation == null) {
        operation = Stella.KWD_TRANSLATE;
      }
      { Object old$Translationphase$000 = Stella.$TRANSLATIONPHASE$.get();
        Object old$Translationerrors$000 = Stella.$TRANSLATIONERRORS$.get();
        Object old$Translationwarnings$000 = Stella.$TRANSLATIONWARNINGS$.get();
        Object old$Translationnotes$000 = Stella.$TRANSLATIONNOTES$.get();
        Object old$Currentfile$000 = Stella.$CURRENTFILE$.get();
        Object old$Module$000 = Stella.$MODULE$.get();
        Object old$Context$000 = Stella.$CONTEXT$.get();

        try {
          Native.setSpecial(Stella.$TRANSLATIONPHASE$, null);
          Native.setIntSpecial(Stella.$TRANSLATIONERRORS$, 0);
          Native.setIntSpecial(Stella.$TRANSLATIONWARNINGS$, 0);
          Native.setIntSpecial(Stella.$TRANSLATIONNOTES$, 0);
          Native.setSpecial(Stella.$CURRENTFILE$, Stella.fileBaseName(file));
          Native.setSpecial(Stella.$MODULE$, currentmodule);
          Native.setSpecial(Stella.$CONTEXT$, currentcontext);
          if (((Keyword)(Stella.$TRANSLATOROUTPUTLANGUAGE$.get())) == Stella.KWD_COMMON_LISP) {
            targetlanguage = "Common Lisp";
          }
          else if ((((Keyword)(Stella.$TRANSLATOROUTPUTLANGUAGE$.get())) == Stella.KWD_CPP) ||
              (((Keyword)(Stella.$TRANSLATOROUTPUTLANGUAGE$.get())) == Stella.KWD_CPP_STANDALONE)) {
            targetlanguage = "C++";
          }
          else if (((Keyword)(Stella.$TRANSLATOROUTPUTLANGUAGE$.get())) == Stella.KWD_IDL) {
            targetlanguage = "IDL";
          }
          else if (((Keyword)(Stella.$TRANSLATOROUTPUTLANGUAGE$.get())) == Stella.KWD_JAVA) {
            targetlanguage = "Java";
          }
          else {
          }
          if (((Integer)(Stella.$TRANSLATIONVERBOSITYLEVEL$.get())).intValue() >= 1) {
            System.out.println("Processing `" + file + "':");
            System.out.println("*** Pass 1, generating objects...");
          }
          { Object old$TransientobjectsP$000 = Stella.$TRANSIENTOBJECTSp$.get();

            try {
              Native.setBooleanSpecial(Stella.$TRANSIENTOBJECTSp$, true);
              { Stella_Object tree = null;
                SExpressionIterator iter000 = InputStream.sExpressions(InputFileStream.newInputFileStream(file));

                while (iter000.nextP()) {
                  tree = iter000.value;
                  { Object old$TransientobjectsP$001 = Stella.$TRANSIENTOBJECTSp$.get();

                    try {
                      Native.setBooleanSpecial(Stella.$TRANSIENTOBJECTSp$, false);
                      if (Stella_Object.safePrimaryType(tree) == Stella.SGT_STELLA_CONS) {
                        { Cons tree000 = ((Cons)(tree));

                          { Object [] caller_MV_returnarray = new Object[1];

                            skipP = Cons.handleInModuleTree(tree000, seeninmoduleP, true, caller_MV_returnarray);
                            seeninmoduleP = ((boolean)(((BooleanWrapper)(caller_MV_returnarray[0])).wrapperValue));
                          }
                          if (!(skipP)) {
                            { Object old$Translationphase$001 = Stella.$TRANSLATIONPHASE$.get();

                              try {
                                Native.setSpecial(Stella.$TRANSLATIONPHASE$, Stella.KWD_DEFINE);
                                Cons.walkTopLevelTree(tree000, true);

                              } finally {
                                Stella.$TRANSLATIONPHASE$.set(old$Translationphase$001);
                              }
                            }
                          }
                        }
                      }
                      else {
                      }

                    } finally {
                      Stella.$TRANSIENTOBJECTSp$.set(old$TransientobjectsP$001);
                    }
                  }
                }
              }

            } finally {
              Stella.$TRANSIENTOBJECTSp$.set(old$TransientobjectsP$000);
            }
          }
          ((List)(Stella.$TRANSLATIONUNITS$.get())).reverse();
          if (!(operation == Stella.KWD_DEFINE)) {
            if (((Integer)(Stella.$TRANSLATIONVERBOSITYLEVEL$.get())).intValue() >= 1) {
              System.out.println("*** Pass 2, finalizing objects...");
            }
            Native.setSpecial(Stella.$TRANSLATIONPHASE$, Stella.KWD_FINALIZE);
            Stella.finalizeClassesAndSlots();
            if (!(operation == Stella.KWD_FINALIZE)) {
              if (((Integer)(Stella.$TRANSLATIONVERBOSITYLEVEL$.get())).intValue() >= 1) {
                System.out.println("*** Pass 3, walking objects...");
              }
              Native.setSpecial(Stella.$TRANSLATIONPHASE$, Stella.KWD_WALK);
              if (!(Stella.useHardcodedSymbolsP() ||
                  (((Keyword)(Stella.$TRANSLATOROUTPUTLANGUAGE$.get())) == Stella.KWD_JAVA))) {
                Stella.clearSymbolRegistry();
              }
              { Object old$UserecordedsignaturesP$000 = Stella.$USERECORDEDSIGNATURESp$.get();

                try {
                  Native.setBooleanSpecial(Stella.$USERECORDEDSIGNATURESp$, Stella.$WALK_WITH_RECORDED_SIGNATURESp$);
                  Stella.walkAllPhaseOneUnits();

                } finally {
                  Stella.$USERECORDEDSIGNATURESp$.set(old$UserecordedsignaturesP$000);
                }
              }
              if (!(operation == Stella.KWD_WALK)) {
                Stella.translateAndOutputUnitsToFile(file, targetlanguage);
              }
              if (Stella.$RECORD_SIGNATURESp$) {
                System.out.println("Recording object signatures...");
                Stella.recordSignaturesOfAllUnits(file);
              }
            }
          }
          Stella.summarizeTranslationErrors();

        } finally {
          Stella.$CONTEXT$.set(old$Context$000);
          Stella.$MODULE$.set(old$Module$000);
          Stella.$CURRENTFILE$.set(old$Currentfile$000);
          Stella.$TRANSLATIONNOTES$.set(old$Translationnotes$000);
          Stella.$TRANSLATIONWARNINGS$.set(old$Translationwarnings$000);
          Stella.$TRANSLATIONERRORS$.set(old$Translationerrors$000);
          Stella.$TRANSLATIONPHASE$.set(old$Translationphase$000);
        }
      }
    }
  }