-
Steve Baird authored
In some common cases, a reference to Some_Type'Some_Streaming_Attribute causes the needed subprogram to be generated "on demand". If there are multiple such references (e.g., two calls to Some_Type'Write) then we want to avoid generating multiple essentially-identical subprograms. This change implies that a generated streaming subprogram may now have multiple call sites, so we can no longer use the source position information from the (one and only) call site. If an exception is raised during a streaming operation, this can make a difference in the reported raise location. gcc/ada/ * exp_attr.adb (Cached_Streaming_Ops): A new package, providing maps to save previously-generated Read/Write/Input/Output procedures. (Expand_N_Attribute_Reference): When a new subprogram is generated for a Read/Write/Input/Output attribute reference, record that type/subp pair in the appropriate Cached_Streaming_Ops map. (Find_Stream_Subprogram): Check the appropriate Cached_Streaming_Ops map to see if an appropriate subprogram has already been generated. If so, then return it. The appropriateness test includes a call to a new nested subprogram, In_Available_Context. * exp_strm.ads, exp_strm.adb: Do not pass in a Loc parameter (or a source-location-bearing Nod parameter) to the 16 procedures provided for building streaming-related subprograms. Use the source location of the type instead. * exp_dist.adb, exp_ch3.adb: Adapt to Exp_Strm spec changes. For these calls the source location of the type was already being used.
Steve Baird authoredIn some common cases, a reference to Some_Type'Some_Streaming_Attribute causes the needed subprogram to be generated "on demand". If there are multiple such references (e.g., two calls to Some_Type'Write) then we want to avoid generating multiple essentially-identical subprograms. This change implies that a generated streaming subprogram may now have multiple call sites, so we can no longer use the source position information from the (one and only) call site. If an exception is raised during a streaming operation, this can make a difference in the reported raise location. gcc/ada/ * exp_attr.adb (Cached_Streaming_Ops): A new package, providing maps to save previously-generated Read/Write/Input/Output procedures. (Expand_N_Attribute_Reference): When a new subprogram is generated for a Read/Write/Input/Output attribute reference, record that type/subp pair in the appropriate Cached_Streaming_Ops map. (Find_Stream_Subprogram): Check the appropriate Cached_Streaming_Ops map to see if an appropriate subprogram has already been generated. If so, then return it. The appropriateness test includes a call to a new nested subprogram, In_Available_Context. * exp_strm.ads, exp_strm.adb: Do not pass in a Loc parameter (or a source-location-bearing Nod parameter) to the 16 procedures provided for building streaming-related subprograms. Use the source location of the type instead. * exp_dist.adb, exp_ch3.adb: Adapt to Exp_Strm spec changes. For these calls the source location of the type was already being used.