public static Stella_Object nativeValueOf(Stella_Object self) {
    { Surrogate testValue000 = Stella_Object.safePrimaryType(self);

      if (Surrogate.subtypeOfP(testValue000, Logic.SGT_LOGIC_PATTERN_VARIABLE)) {
        { PatternVariable self000 = ((PatternVariable)(self));

          { Stella_Object value = Logic.groundValueOf(self000);

            if (value != null) {
              return (Logic.nativeValueOf(value));
            }
            else {
              return (null);
            }
          }
        }
      }
      else if (Surrogate.subtypeOfP(testValue000, Logic.SGT_LOGIC_SKOLEM)) {
        { Skolem self000 = ((Skolem)(self));

          { Stella_Object value = ((Stella_Object)(Stella_Object.accessInContext(self000.variableValue, self000.homeContext, false)));

            if (value != null) {
              return (Logic.nativeValueOf(value));
            }
            else {
              return (null);
            }
          }
        }
      }
      else if (Surrogate.subtypeOfP(testValue000, Logic.SGT_LOGIC_LOGIC_OBJECT)) {
        { LogicObject self000 = ((LogicObject)(self));

          return (null);
        }
      }
      else if (Surrogate.subtypeOfSurrogateP(testValue000)) {
        { Surrogate self000 = ((Surrogate)(self));

          { Stella_Object value = self000.surrogateValue;

            if (value != null) {
              return (Logic.nativeValueOf(value));
            }
            else {
              return (null);
            }
          }
        }
      }
      else {
        return (self);
      }
    }
  }