public static Stella_Object generateTerm(Stella_Object self) {
    if (self == null) {
      return (null);
    }
    { Surrogate testValue000 = Stella_Object.safePrimaryType(self);

      if (Surrogate.subtypeOfP(testValue000, Logic.SGT_LOGIC_PROPOSITION)) {
        { Proposition self000 = ((Proposition)(self));

          return (Proposition.generateProposition(self000));
        }
      }
      else if (Surrogate.subtypeOfP(testValue000, Logic.SGT_STELLA_LITERAL_WRAPPER)) {
        { LiteralWrapper self000 = ((LiteralWrapper)(self));

          return (self000);
        }
      }
      else if (Surrogate.subtypeOfP(testValue000, Logic.SGT_LOGIC_DESCRIPTION)) {
        { Description self000 = ((Description)(self));

          return (Description.generateDescription(self000));
        }
      }
      else if (Surrogate.subtypeOfP(testValue000, Logic.SGT_LOGIC_PATTERN_VARIABLE)) {
        { PatternVariable self000 = ((PatternVariable)(self));

          return (PatternVariable.generateOneVariable(self000, false));
        }
      }
      else if (Surrogate.subtypeOfP(testValue000, Logic.SGT_LOGIC_SKOLEM)) {
        { Skolem self000 = ((Skolem)(self));

          return (Skolem.generateSkolem(self000));
        }
      }
      else if (Surrogate.subtypeOfP(testValue000, Logic.SGT_LOGIC_LOGIC_OBJECT)) {
        { LogicObject self000 = ((LogicObject)(self));

          if (self000.surrogateValueInverse != null) {
            return (Symbol.internSymbolInModule(self000.surrogateValueInverse.symbolName, ((Module)(self000.surrogateValueInverse.homeContext)), false));
          }
          else {
            return (Logic.SYM_LOGIC_UNNAMED_OBJECT);
          }
        }
      }
      else if (Surrogate.subtypeOfSurrogateP(testValue000)) {
        { Surrogate self000 = ((Surrogate)(self));

          return (Symbol.internSymbolInModule(self000.symbolName, ((Module)(self000.homeContext)), false));
        }
      }
      else if (Surrogate.subtypeOfKeywordP(testValue000)) {
        { Keyword self000 = ((Keyword)(self));

          return (self000);
        }
      }
      else if (Surrogate.subtypeOfP(testValue000, Logic.SGT_STELLA_COLLECTION)) {
        { Collection self000 = ((Collection)(self));

          return (Logic.generateStellaCollection(self000));
        }
      }
      else if (Surrogate.subtypeOfP(testValue000, Logic.SGT_LOGIC_LOGIC_THING)) {
        { LogicThing self000 = ((LogicThing)(self));

          return (self000.generateSpecializedTerm());
        }
      }
      else if (Surrogate.subtypeOfP(testValue000, Logic.SGT_STELLA_THING)) {
        { Thing self000 = ((Thing)(self));

          if (self000.surrogateValueInverse != null) {
            return (self000.surrogateValueInverse);
          }
          else {
            throw ((TermGenerationException)(TermGenerationException.newTermGenerationException(self000, "DON'T KNOW HOW TO GENERATE EXPRESSION FOR THE THING: " + Native.stringify(self000)).fillInStackTrace()));
          }
        }
      }
      else {
        {
          Stella.STANDARD_WARNING.nativeStream.println("Warning: Illegal logical form: `" + self + "'");
          Stella.STANDARD_WARNING.nativeStream.println();
        }
;
        return (Logic.SYM_LOGIC_ILLEGAL_TERM);
      }
    }
  }