diff options
author | Arnaud Charlet <charlet@adacore.com> | 2020-07-23 08:57:22 -0400 |
---|---|---|
committer | Arnaud Charlet <charlet@adacore.com> | 2020-07-23 08:57:22 -0400 |
commit | 0c111868b791a5251de7a59362e15c51cd35362b (patch) | |
tree | dba4bb4460ca9b0d833195f5a60c1648197b878e /gcc/ada | |
parent | 2949e0865723e011279a504e3fe913062c8d6e0b (diff) | |
download | gcc-0c111868b791a5251de7a59362e15c51cd35362b.zip gcc-0c111868b791a5251de7a59362e15c51cd35362b.tar.gz gcc-0c111868b791a5251de7a59362e15c51cd35362b.tar.bz2 |
[Ada] Add push/pop capability in Output
Add the capability to use the Write_* procedures in an environment where
you want to write debugging info but still use them to write to other
files (such a C source files).
gcc/ada/
* output.ads (Push_Output, Pop_Output): New procedures.
* output.adb (FD_Array, FD_Stack, FD_Stack_Idx): New type and vars.
(Push_Output, Pop_Output): New procedures.
Diffstat (limited to 'gcc/ada')
-rw-r--r-- | gcc/ada/output.adb | 29 | ||||
-rw-r--r-- | gcc/ada/output.ads | 9 |
2 files changed, 38 insertions, 0 deletions
diff --git a/gcc/ada/output.adb b/gcc/ada/output.adb index d36aac8..971819b 100644 --- a/gcc/ada/output.adb +++ b/gcc/ada/output.adb @@ -45,6 +45,13 @@ package body Output is Current_FD : File_Descriptor := Standout; -- File descriptor for current output + type FD_Array is array (Nat range 1 .. 3) of File_Descriptor; + FD_Stack : FD_Array; + FD_Stack_Idx : Nat := FD_Array'First - 1; + -- Maintain a small stack for Push_Output and Pop_Output. We'd normally + -- use Table for this and allow an unlimited depth, but we're the target + -- of a pragma Elaborate_All in Table, so we can't use it here. + Special_Output_Proc : Output_Proc := null; -- Record argument to last call to Set_Special_Output. If this is -- non-null, then we are in special output mode. @@ -228,6 +235,28 @@ package body Output is (Cur_Indentation - Indentation_Amount) mod Indentation_Limit; end Outdent; + ---------------- + -- Pop_Output -- + ---------------- + + procedure Pop_Output is + begin + pragma Assert (FD_Stack_Idx >= FD_Array'First); + Current_FD := FD_Stack (FD_Stack_Idx); + FD_Stack_Idx := FD_Stack_Idx - 1; + end Pop_Output; + + ----------------- + -- Push_Output -- + ----------------- + + procedure Push_Output is + begin + pragma Assert (FD_Stack_Idx < FD_Array'Last); + FD_Stack_Idx := FD_Stack_Idx + 1; + FD_Stack (FD_Stack_Idx) := Current_FD; + end Push_Output; + --------------------------- -- Restore_Output_Buffer -- --------------------------- diff --git a/gcc/ada/output.ads b/gcc/ada/output.ads index 4574cce..55d308a 100644 --- a/gcc/ada/output.ads +++ b/gcc/ada/output.ads @@ -95,6 +95,15 @@ package Output is -- output will appear on the given file descriptor only after special -- output has been cancelled. + procedure Push_Output; + -- Saves the current output destination on a stack, but leaves it + -- unchanged. This subprogram only supports a small stack and is normally + -- used with a depth of one. + + procedure Pop_Output; + -- Changes the current output destination to be the last output destination + -- popped using Push_Output. + procedure Indent; -- Increases the current indentation level. Whenever a line is written -- (triggered by Eol), an appropriate amount of whitespace is added to the |