public static void clearLogicModuleHook(Module module) {
    { 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())));
        Logic.destroyInferenceCaches(module);
        Logic.clearInlineQueryCaches();
        { Stella_Object term = null;
          Cons iter000 = Logic.allTerms(module, true).listify().theConsList;

          for (;!(iter000 == Stella.NIL); iter000 = iter000.rest) {
            term = iter000.value;
            Logic.destroyInstance(term);
          }
        }
        { Proposition proposition = null;
          Iterator iter001 = Logic.allPropositions(module, true);

          while (iter001.nextP()) {
            proposition = ((Proposition)(iter001.value));
            Proposition.destroyProposition(proposition);
          }
        }
        Logic.cleanupStructuredObjectsIndex(module);
        Logic.locallyConceivedPropositions(module).removeDeletedMembers();
        Logic.locallyConceivedInstances(module).removeDeletedMembers();
        Logic.cleanupAllDescriptionExtensions();
        Logic.cleanupUnfinalizedObjects();
        Keyword.clearMemoizationTables(Logic.KWD_KB_UPDATE);
        Keyword.clearMemoizationTables(Logic.KWD_META_KB_UPDATE);

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