public static String constructSymbolConstantName(GeneralizedSymbol symbol) {
    { String prefix = null;
      String environmentname = "";

      if (((Module)(symbol.homeContext)) != null) {
        environmentname = ((Module)(symbol.homeContext)).moduleName + "-";
      }
      if (!(Stella.incrementalTranslationP() ||
          (((Keyword)(Stella.$TRANSLATOROUTPUTLANGUAGE$.get())) == Stella.KWD_JAVA))) {
        environmentname = Native.stringUpcase(((String)(Stella.$CURRENTFILE$.get()))) + "-" + environmentname;
      }
      { Surrogate testValue000 = Stella_Object.safePrimaryType(symbol);

        if (Surrogate.subtypeOfSymbolP(testValue000)) {
          { Symbol symbol000 = ((Symbol)(symbol));

            prefix = "SYM-";
          }
        }
        else if (Surrogate.subtypeOfSurrogateP(testValue000)) {
          { Surrogate symbol000 = ((Surrogate)(symbol));

            prefix = "SGT-";
          }
        }
        else if (Surrogate.subtypeOfKeywordP(testValue000)) {
          { Keyword symbol000 = ((Keyword)(symbol));

            prefix = "KWD-";
          }
        }
        else {
          { OutputStringStream stream000 = OutputStringStream.newOutputStringStream();

            stream000.nativeStream.print("`" + testValue000 + "' is not a valid case option");
            throw ((StellaException)(StellaException.newStellaException(stream000.theStringReader()).fillInStackTrace()));
          }
        }
      }
      return (prefix + environmentname + symbol.symbolName);
    }
  }