* @param store
   */
  public static void doSaveModule(Module module, Stella_Object store) {
    { Object old$PrintreadablyP$000 = Stella.$PRINTREADABLYp$.get();

      try {
        Native.setBooleanSpecial(Stella.$PRINTREADABLYp$, true);
        { Object old$Module$000 = Stella.$MODULE$.get();
          Object old$Context$000 = Stella.$CONTEXT$.get();

          try {
            Native.setSpecial(Stella.$MODULE$, module);
            Native.setSpecial(Stella.$CONTEXT$, ((Module)(Stella.$MODULE$.get())));
            { Surrogate testValue000 = Stella_Object.safePrimaryType(store);

              if (Surrogate.subtypeOfP(testValue000, Logic.SGT_STELLA_OUTPUT_STREAM)) {
                { OutputStream store000 = ((OutputStream)(store));

                  Logic.printModuleFileHeader(module, store000);
                }
              }
              else if (Surrogate.subtypeOfP(testValue000, Logic.SGT_LOGIC_OBJECT_STORE)) {
                { ObjectStore store000 = ((ObjectStore)(store));

                  store000.storeModuleHeader(module);
                }
              }
              else {
                { OutputStringStream stream000 = OutputStringStream.newOutputStringStream();

                  stream000.nativeStream.print("`" + testValue000 + "' is not a valid case option");
                  throw ((StellaException)(StellaException.newStellaException(stream000.theStringReader()).fillInStackTrace()));
                }
              }
            }
            { NamedDescription description = null;
              Iterator iter000 = Logic.allNamedDescriptions(module, true);

              while (iter000.nextP()) {
                description = ((NamedDescription)(iter000.value));
                if (NamedDescription.classDescriptionP(description) &&
                    (description.nativeRelation() != null)) {
                  { Stella_Class renamed_Class = ((Stella_Class)(description.nativeRelation()));

                    Logic.saveObject(renamed_Class, store);
                    { Slot slot = null;
                      Cons iter001 = renamed_Class.classLocalSlots.theConsList;

                      for (;!(iter001 == Stella.NIL); iter001 = iter001.rest) {
                        slot = ((Slot)(iter001.value));
                        if (Logic.stellaRelationStringifiedSource(slot) != null) {
                          Logic.saveObject(slot, store);
                        }
                      }
                    }
                  }
                }
                else {
                  Logic.saveObject(description, store);
                }
              }
            }
            { MethodSlot function = null;
              Iterator iter002 = Module.allFunctions(module, true);

              while (iter002.nextP()) {
                function = ((MethodSlot)(iter002.value));
                if (Logic.stellaRelationStringifiedSource(function) != null) {
                  Logic.saveObject(function, store);
                }
              }
            }
            { Object old$Excludedpropositions$000 = Logic.$EXCLUDEDPROPOSITIONS$.get();

              try {
                Native.setSpecial(Logic.$EXCLUDEDPROPOSITIONS$, HashTable.newHashTable());
                Logic.excludeOriginatedPropositions();
                { Cons reversedpropositions = Stella.NIL;

                  { Proposition p = null;
                    Iterator iter003 = Logic.allPropositions(module, false);

                    while (iter003.nextP()) {
                      p = ((Proposition)(iter003.value));
                      if (Proposition.locallyModifiedPropositionP(p, module) &&
                          (!Proposition.excludedPropositionP(p, module))) {
                        reversedpropositions = Cons.cons(p, reversedpropositions);
                      }
                    }
                  }
                  { Stella_Object p = null;
                    Cons iter004 = reversedpropositions;

                    for (;!(iter004 == Stella.NIL); iter004 = iter004.rest) {
                      p = iter004.value;
                      Logic.saveObject(p, store);
                    }
                  }
                }

              } finally {
                Logic.$EXCLUDEDPROPOSITIONS$.set(old$Excludedpropositions$000);
              }
            }
            { Surrogate testValue001 = Stella_Object.safePrimaryType(store);

              if (Surrogate.subtypeOfP(testValue001, Logic.SGT_STELLA_OUTPUT_STREAM)) {
                { OutputStream store000 = ((OutputStream)(store));

                  Logic.printModuleFileTrailer(module, store000);
                }
              }
              else if (Surrogate.subtypeOfP(testValue001, Logic.SGT_LOGIC_OBJECT_STORE)) {
                { ObjectStore store000 = ((ObjectStore)(store));

                  store000.storeModuleTrailer(module);
                }
              }
              else {
                { OutputStringStream stream001 = OutputStringStream.newOutputStringStream();

                  stream001.nativeStream.print("`" + testValue001 + "' is not a valid case option");
                  throw ((StellaException)(StellaException.newStellaException(stream001.theStringReader()).fillInStackTrace()));
                }
              }
            }

          } finally {
            Stella.$CONTEXT$.set(old$Context$000);
            Stella.$MODULE$.set(old$Module$000);
          }
        }

      } finally {
        Stella.$PRINTREADABLYp$.set(old$PrintreadablyP$000);
      }
    }
  }