public static void closeStream(Stream self) {
    { Surrogate testValue000 = Stella_Object.safePrimaryType(self);

      if (Surrogate.subtypeOfP(testValue000, Stella.SGT_STELLA_INPUT_FILE_STREAM)) {
        { InputFileStream self000 = ((InputFileStream)(self));

          InputFileStream.terminateFileInputStreamP(self000);
        }
      }
      else if (Surrogate.subtypeOfP(testValue000, Stella.SGT_STELLA_OUTPUT_FILE_STREAM)) {
        { OutputFileStream self000 = ((OutputFileStream)(self));

          OutputFileStream.terminateFileOutputStreamP(self000);
        }
      }
      else if (Surrogate.subtypeOfP(testValue000, Stella.SGT_STELLA_INPUT_STRING_STREAM)) {
        { InputStringStream self000 = ((InputStringStream)(self));

          InputStringStream.terminateStringInputStreamP(self000);
        }
      }
      else if (Surrogate.subtypeOfP(testValue000, Stella.SGT_STELLA_OUTPUT_STRING_STREAM)) {
        { OutputStringStream self000 = ((OutputStringStream)(self));

          OutputStringStream.terminateStringOutputStreamP(self000);
        }
      }
      else if (Surrogate.subtypeOfP(testValue000, Stella.SGT_STELLA_INPUT_STREAM)) {
        { InputStream self000 = ((InputStream)(self));

          InputStream.terminateInputStreamP(self000);
        }
      }
      else if (Surrogate.subtypeOfP(testValue000, Stella.SGT_STELLA_OUTPUT_STREAM)) {
        { OutputStream self000 = ((OutputStream)(self));

          OutputStream.terminateOutputStreamP(self000);
        }
      }
      else {
      }
    }
  }