* @param typeref
   * @return Stella_Object
   */
  public static Stella_Object searchForObject(Stella_Object self, Stella_Object typeref) {
    { Surrogate classtype = null;

      if (typeref != null) {
        { Surrogate testValue000 = Stella_Object.safePrimaryType(typeref);

          if (Surrogate.subtypeOfSymbolP(testValue000)) {
            { Symbol typeref000 = ((Symbol)(typeref));

              classtype = Surrogate.lookupSurrogateInModule(typeref000.symbolName, ((Module)(typeref000.homeContext)), false);
            }
          }
          else if (Surrogate.subtypeOfSurrogateP(testValue000)) {
            { Surrogate typeref000 = ((Surrogate)(typeref));

              classtype = typeref000;
            }
          }
          else if (Surrogate.subtypeOfStringP(testValue000)) {
            { StringWrapper typeref000 = ((StringWrapper)(typeref));

              classtype = Surrogate.lookupSurrogate(typeref000.wrapperValue);
            }
          }
          else if (Surrogate.subtypeOfClassP(testValue000)) {
            { Stella_Class typeref000 = ((Stella_Class)(typeref));

              classtype = typeref000.classType;
            }
          }
          else {
            System.out.println("Invalid type reference: `" + typeref + "'");
          }
        }
        if ((classtype != null) &&
            ((classtype.surrogateValue == null) ||
             (!Stella_Object.isaP(classtype.surrogateValue, Stella.SGT_STELLA_CLASS)))) {
          System.out.println("No class exists with name: `" + classtype.symbolName + "'");
          classtype = null;
        }
      }
      { Surrogate testValue001 = Stella_Object.safePrimaryType(self);

        if (Surrogate.subtypeOfStringP(testValue001)) {
          { StringWrapper self000 = ((StringWrapper)(self));

            { String string = self000.wrapperValue;
              Stella_Object renamed_Object = Stella.stringSearchForObject(string, classtype);
              Module module = null;

              if ((renamed_Object == null) &&
                  Stella.qualifiedStellaNameP(string)) {
                { Object [] caller_MV_returnarray = new Object[1];

                  module = Stella.computeModuleAndBareName(string, caller_MV_returnarray);
                  string = ((String)(((StringWrapper)(caller_MV_returnarray[0])).wrapperValue));
                }
                renamed_Object = Stella.stringSearchForObject(string, classtype);
              }
              if (renamed_Object == null) {
                string = Native.stringUpcase(string);
                renamed_Object = Stella.stringSearchForObject(string, classtype);
              }
              return (renamed_Object);
            }
          }
        }
        else if (Surrogate.subtypeOfSymbolP(testValue001)) {
          { Symbol self000 = ((Symbol)(self));

            return (Stella_Object.searchForObject(StringWrapper.wrapString(self000.symbolName), classtype));
          }
        }
        else if (Surrogate.subtypeOfIntegerP(testValue001)) {
          { IntegerWrapper self000 = ((IntegerWrapper)(self));

            { int integer = self000.wrapperValue;
              Stella_Object renamed_Object = null;

              { CodeWrapper fn = null;
                Cons iter000 = Stella.$INTEGER_TO_OBJECT_FUNCTIONS$.theConsList;

                for (;!(iter000 == Stella.NIL); iter000 = iter000.rest) {
                  fn = ((CodeWrapper)(iter000.value));
                  if (Surrogate.subtypeOfP(Stella_Object.safePrimaryType(fn), Stella.SGT_STELLA_FUNCTION_CODE_WRAPPER)) {
                    { FunctionCodeWrapper fn000 = ((FunctionCodeWrapper)(fn));

                      renamed_Object = ((Stella_Object)(edu.isi.stella.javalib.Native.funcall(fn000.wrapperValue, null, new java.lang.Object [] {new Integer(integer)})));
                    }
                  }
                  else {
                    { OutputStringStream stream000 = OutputStringStream.newOutputStringStream();

                      stream000.nativeStream.print("`" + Stella_Object.safePrimaryType(fn) + "' is not a valid case option");
                      throw ((StellaException)(StellaException.newStellaException(stream000.theStringReader()).fillInStackTrace()));
                    }
                  }
                  if (renamed_Object != null) {
                    return (renamed_Object);
                  }
                }
              }
              return (null);
            }
          }
        }
        else if (Surrogate.subtypeOfP(testValue001, Stella.SGT_STELLA_OBJECT)) {
          { Stella_Object self000 = ((Stella_Object)(self));

            return (self000);
          }
        }
        else {
          return (null);
        }
      }
    }
  }