+ -- Stream attributes for strings are expanded into library calls. The
+ -- following checks are disabled when the run-time is not available or
+ -- when compiling predefined types due to bootstrap issues. As a result,
+ -- the compiler will generate in-place stream routines for string types
+ -- that appear in GNAT's library, but will generate calls via rtsfind
+ -- to library routines for user code.
+
+ -- ??? For now, disable this code for JVM, since this generates a
+ -- VerifyError exception at run time on e.g. c330001.
+
+ -- This is disabled for AAMP, to avoid creating dependences on files not
+ -- supported in the AAMP library (such as s-fileio.adb).
+
+ -- Note: In the case of using a configurable run time, it is very likely
+ -- that stream routines for string types are not present (they require
+ -- file system support). In this case, the specific stream routines for
+ -- strings are not used, relying on the regular stream mechanism
+ -- instead. That is why we include the test Is_Available when dealing
+ -- with these cases.
+
+ if VM_Target /= JVM_Target
+ and then not AAMP_On_Target
+ and then
+ not Is_Predefined_File_Name (Unit_File_Name (Current_Sem_Unit))
+ then
+ -- String as defined in package Ada
+
+ if Base_Typ = Standard_String then
+ if Restriction_Active (No_Stream_Optimizations) then
+ if Nam = TSS_Stream_Input
+ and then Is_Available (RE_String_Input)
+ then
+ return RTE (RE_String_Input);
+
+ elsif Nam = TSS_Stream_Output
+ and then Is_Available (RE_String_Output)
+ then
+ return RTE (RE_String_Output);
+
+ elsif Nam = TSS_Stream_Read
+ and then Is_Available (RE_String_Read)
+ then
+ return RTE (RE_String_Read);
+
+ elsif Nam = TSS_Stream_Write
+ and then Is_Available (RE_String_Write)
+ then
+ return RTE (RE_String_Write);
+
+ elsif Nam /= TSS_Stream_Input and then
+ Nam /= TSS_Stream_Output and then
+ Nam /= TSS_Stream_Read and then
+ Nam /= TSS_Stream_Write
+ then
+ raise Program_Error;
+ end if;
+
+ else
+ if Nam = TSS_Stream_Input
+ and then Is_Available (RE_String_Input_Blk_IO)
+ then
+ return RTE (RE_String_Input_Blk_IO);
+
+ elsif Nam = TSS_Stream_Output
+ and then Is_Available (RE_String_Output_Blk_IO)
+ then
+ return RTE (RE_String_Output_Blk_IO);
+
+ elsif Nam = TSS_Stream_Read
+ and then Is_Available (RE_String_Read_Blk_IO)
+ then
+ return RTE (RE_String_Read_Blk_IO);
+
+ elsif Nam = TSS_Stream_Write
+ and then Is_Available (RE_String_Write_Blk_IO)
+ then
+ return RTE (RE_String_Write_Blk_IO);
+
+ elsif Nam /= TSS_Stream_Input and then
+ Nam /= TSS_Stream_Output and then
+ Nam /= TSS_Stream_Read and then
+ Nam /= TSS_Stream_Write
+ then
+ raise Program_Error;
+ end if;
+ end if;
+
+ -- Wide_String as defined in package Ada
+
+ elsif Base_Typ = Standard_Wide_String then
+ if Restriction_Active (No_Stream_Optimizations) then
+ if Nam = TSS_Stream_Input
+ and then Is_Available (RE_Wide_String_Input)
+ then
+ return RTE (RE_Wide_String_Input);
+
+ elsif Nam = TSS_Stream_Output
+ and then Is_Available (RE_Wide_String_Output)
+ then
+ return RTE (RE_Wide_String_Output);
+
+ elsif Nam = TSS_Stream_Read
+ and then Is_Available (RE_Wide_String_Read)
+ then
+ return RTE (RE_Wide_String_Read);
+
+ elsif Nam = TSS_Stream_Write
+ and then Is_Available (RE_Wide_String_Write)
+ then
+ return RTE (RE_Wide_String_Write);
+
+ elsif Nam /= TSS_Stream_Input and then
+ Nam /= TSS_Stream_Output and then
+ Nam /= TSS_Stream_Read and then
+ Nam /= TSS_Stream_Write
+ then
+ raise Program_Error;
+ end if;
+
+ else
+ if Nam = TSS_Stream_Input
+ and then Is_Available (RE_Wide_String_Input_Blk_IO)
+ then
+ return RTE (RE_Wide_String_Input_Blk_IO);
+
+ elsif Nam = TSS_Stream_Output
+ and then Is_Available (RE_Wide_String_Output_Blk_IO)
+ then
+ return RTE (RE_Wide_String_Output_Blk_IO);
+
+ elsif Nam = TSS_Stream_Read
+ and then Is_Available (RE_Wide_String_Read_Blk_IO)
+ then
+ return RTE (RE_Wide_String_Read_Blk_IO);
+
+ elsif Nam = TSS_Stream_Write
+ and then Is_Available (RE_Wide_String_Write_Blk_IO)
+ then
+ return RTE (RE_Wide_String_Write_Blk_IO);
+
+ elsif Nam /= TSS_Stream_Input and then
+ Nam /= TSS_Stream_Output and then
+ Nam /= TSS_Stream_Read and then
+ Nam /= TSS_Stream_Write
+ then
+ raise Program_Error;
+ end if;
+ end if;
+
+ -- Wide_Wide_String as defined in package Ada
+
+ elsif Base_Typ = Standard_Wide_Wide_String then
+ if Restriction_Active (No_Stream_Optimizations) then
+ if Nam = TSS_Stream_Input
+ and then Is_Available (RE_Wide_Wide_String_Input)
+ then
+ return RTE (RE_Wide_Wide_String_Input);
+
+ elsif Nam = TSS_Stream_Output
+ and then Is_Available (RE_Wide_Wide_String_Output)
+ then
+ return RTE (RE_Wide_Wide_String_Output);
+
+ elsif Nam = TSS_Stream_Read
+ and then Is_Available (RE_Wide_Wide_String_Read)
+ then
+ return RTE (RE_Wide_Wide_String_Read);
+
+ elsif Nam = TSS_Stream_Write
+ and then Is_Available (RE_Wide_Wide_String_Write)
+ then
+ return RTE (RE_Wide_Wide_String_Write);
+
+ elsif Nam /= TSS_Stream_Input and then
+ Nam /= TSS_Stream_Output and then
+ Nam /= TSS_Stream_Read and then
+ Nam /= TSS_Stream_Write
+ then
+ raise Program_Error;
+ end if;
+
+ else
+ if Nam = TSS_Stream_Input
+ and then Is_Available (RE_Wide_Wide_String_Input_Blk_IO)
+ then
+ return RTE (RE_Wide_Wide_String_Input_Blk_IO);
+
+ elsif Nam = TSS_Stream_Output
+ and then Is_Available (RE_Wide_Wide_String_Output_Blk_IO)
+ then
+ return RTE (RE_Wide_Wide_String_Output_Blk_IO);
+
+ elsif Nam = TSS_Stream_Read
+ and then Is_Available (RE_Wide_Wide_String_Read_Blk_IO)
+ then
+ return RTE (RE_Wide_Wide_String_Read_Blk_IO);
+
+ elsif Nam = TSS_Stream_Write
+ and then Is_Available (RE_Wide_Wide_String_Write_Blk_IO)
+ then
+ return RTE (RE_Wide_Wide_String_Write_Blk_IO);
+
+ elsif Nam /= TSS_Stream_Input and then
+ Nam /= TSS_Stream_Output and then
+ Nam /= TSS_Stream_Read and then
+ Nam /= TSS_Stream_Write
+ then
+ raise Program_Error;
+ end if;
+ end if;
+ end if;
+ end if;
+