public static String coerceToModuleName(Stella_Object namespec, boolean warnP) {
    { Surrogate testValue000 = Stella_Object.safePrimaryType(namespec);

      if (Surrogate.subtypeOfStringP(testValue000)) {
        { StringWrapper namespec000 = ((StringWrapper)(namespec));

          return (namespec000.wrapperValue);
        }
      }
      else if (Surrogate.subtypeOfP(testValue000, Stella.SGT_STELLA_MUTABLE_STRING_WRAPPER)) {
        { MutableStringWrapper namespec000 = ((MutableStringWrapper)(namespec));

          return ((namespec000.wrapperValue).toString());
        }
      }
      else if (Surrogate.subtypeOfKeywordP(testValue000)) {
        { Keyword namespec000 = ((Keyword)(namespec));

          return (namespec000.symbolName);
        }
      }
      else if (Surrogate.subtypeOfSymbolP(testValue000)) {
        { Symbol namespec000 = ((Symbol)(namespec));

          { Module module = ((Module)(namespec000.homeContext));

            if (module == null) {
              return (namespec000.symbolName);
            }
            else {
              return (namespec000.visibleName(false));
            }
          }
        }
      }
      else if (Surrogate.subtypeOfSurrogateP(testValue000)) {
        { Surrogate namespec000 = ((Surrogate)(namespec));

          { Module module = ((Module)(namespec000.homeContext));

            if (module == null) {
              return (namespec000.symbolName);
            }
            else {
              return (namespec000.visibleName(false));
            }
          }
        }
      }
      else {
        if (warnP) {
          Stella.STANDARD_WARNING.nativeStream.println("Warning: Illegal module name: `" + namespec + "'");
        }
        return (null);
      }
    }
  }