* @param type
   * @param module
   * @param localP
   * @return Stella_Object
   */
  public static Stella_Object findOrCreateInstance(String name, NamedDescription type, Module module, boolean localP) {
    { Surrogate instanceref = Surrogate.lookupSurrogateInModule(name, module, localP);
      Stella_Object value = ((instanceref != null) ? instanceref.surrogateValue : ((Stella_Object)(null)));
      Surrogate typeref = null;

      if (value != null) {
        if (Stella_Object.stellaClassP(value)) {
          return (Logic.classDgetDescription(((Stella_Class)(value))));
        }
        else {
          return (value);
        }
      }
      else if (instanceref == null) {
        instanceref = Surrogate.internSurrogateInModule(name, module, localP);
      }
      typeref = Logic.objectSurrogate(type);
      if (typeref == RDBMS.SGT_STELLA_THING) {
        typeref = null;
      }
      { Object old$Module$000 = Stella.$MODULE$.get();
        Object old$Context$000 = Stella.$CONTEXT$.get();

        try {
          Native.setSpecial(Stella.$MODULE$, module);
          Native.setSpecial(Stella.$CONTEXT$, ((Module)(Stella.$MODULE$.get())));
          return (Logic.createLogicInstance(instanceref, typeref));

        } finally {
          Stella.$CONTEXT$.set(old$Context$000);
          Stella.$MODULE$.set(old$Module$000);
        }
      }
    }
  }