diff options
author | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-04-20 12:17:42 +0000 |
---|---|---|
committer | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-04-20 12:17:42 +0000 |
commit | 2f29393fcb4a0b9f4a008a6210abcfdadaf2955f (patch) | |
tree | 4bebcf3a2e3f9d1be7744405c508ced9f3c8cbad /gcc/ada/xoscons.adb | |
parent | 7f571c29f326abea0fafac50e7a9866043829377 (diff) | |
download | gcc-2f29393fcb4a0b9f4a008a6210abcfdadaf2955f.tar.gz |
2009-04-20 Robert Dewar <dewar@adacore.com>
* sinfo.ads: Minor comment fixes
* exp_disp.adb: Minor reformatting
* gnat1drv.adb: Minor reformatting
* output.adb: Minor reformatting
* s-vxwext-kernel.ads: Minor reformatting
* sem.ads: Minor reformatting
* sem.adb: Minor reformatting
* sem_elim.adb: Minor reformatting
* uname.ads: Minor reformatting
2009-04-20 Eric Botcazou <ebotcazou@adacore.com>
* init.c (__gnat_adjust_context_for_raise): On x86{-64}/Linux, add
a small dope of 4 words to the adjustment to the stack pointer.
2009-04-20 Thomas Quinot <quinot@adacore.com>
* xoscons.adb: generate C header s-oscons.h in
addition to s-oscons.ads.
* socket.c: On VMS, use s-oscons.h.
* sem_ch3.adb: Minor reformatting
* exp_ch9.adb: Minor reformatting
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@146401 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/xoscons.adb')
-rw-r--r-- | gcc/ada/xoscons.adb | 76 |
1 files changed, 56 insertions, 20 deletions
diff --git a/gcc/ada/xoscons.adb b/gcc/ada/xoscons.adb index 4f5e4a291c7..64a9e799a3f 100644 --- a/gcc/ada/xoscons.adb +++ b/gcc/ada/xoscons.adb @@ -105,11 +105,16 @@ procedure XOSCons is Table_Initial => 100, Table_Increment => 10); - Max_Constant_Name_Len : Natural := 0; + Max_Const_Name_Len : Natural := 0; Max_Constant_Value_Len : Natural := 0; -- Longest name and longest value lengths - procedure Output_Info (OFile : Sfile; Info_Index : Integer); + type Language is (Lang_Ada, Lang_C); + + procedure Output_Info + (Lang : Language; + OFile : Sfile; + Info_Index : Integer); -- Output information from the indicated asm info line procedure Parse_Asm_Line (Line : String); @@ -128,14 +133,22 @@ procedure XOSCons is function Contains_Template_Name (S : String) return Boolean is begin - return Index (Source => To_Lower (S), Pattern => Tmpl_Name) > 0; + if Index (Source => To_Lower (S), Pattern => Tmpl_Name) > 0 then + return True; + else + return False; + end if; end Contains_Template_Name; ----------------- -- Output_Info -- ----------------- - procedure Output_Info (OFile : Sfile; Info_Index : Integer) is + procedure Output_Info + (Lang : Language; + OFile : Sfile; + Info_Index : Integer) + is Info : Asm_Info renames Asm_Infos.Table (Info_Index); procedure Put (S : String); @@ -153,11 +166,17 @@ procedure XOSCons is if Info.Kind /= TXT then -- TXT case is handled by the common code below - Put (" "); - Put (Info.Constant_Name.all); - Put (Spaces (Max_Constant_Name_Len - Info.Constant_Name'Length)); + case Lang is + when Lang_Ada => + Put (" " & Info.Constant_Name.all); + Put (Spaces (Max_Const_Name_Len - Info.Constant_Name'Length)); - Put (" : constant := "); + Put (" : constant := "); + + when Lang_C => + Put ("#define " & Info.Constant_Name.all & " "); + Put (Spaces (Max_Const_Name_Len - Info.Constant_Name'Length)); + end case; if Info.Kind = CND then if not Info.Int_Value.Positive then @@ -168,15 +187,20 @@ procedure XOSCons is Put (Info.Text_Value.all); end if; - Put (";"); + if Lang = Lang_Ada then + Put (";"); - if Info.Comment'Length > 0 then - Put (Spaces (Max_Constant_Value_Len - Info.Value_Len)); - Put (" -- "); + if Info.Comment'Length > 0 then + Put (Spaces (Max_Constant_Value_Len - Info.Value_Len)); + Put (" -- "); + end if; end if; end if; - Put (Info.Comment.all); + if Lang = Lang_Ada then + Put (Info.Comment.all); + end if; + New_Line (OFile); end Output_Info; @@ -272,8 +296,8 @@ procedure XOSCons is Find_Colon (Index2); Info.Constant_Name := Field_Alloc; - if Info.Constant_Name'Length > Max_Constant_Name_Len then - Max_Constant_Name_Len := Info.Constant_Name'Length; + if Info.Constant_Name'Length > Max_Const_Name_Len then + Max_Const_Name_Len := Info.Constant_Name'Length; end if; Index1 := Index2 + 1; @@ -332,13 +356,20 @@ procedure XOSCons is -- Local declarations - Asm_File_Name : constant String := Tmpl_Name & ".s"; + -- Input files + Tmpl_File_Name : constant String := Tmpl_Name & ".i"; + Asm_File_Name : constant String := Tmpl_Name & ".s"; + + -- Output files + Ada_File_Name : constant String := Unit_Name & ".ads"; + C_File_Name : constant String := Unit_Name & ".h"; Asm_File : Ada.Text_IO.File_Type; Tmpl_File : Ada.Text_IO.File_Type; - OFile : Sfile; + Ada_OFile : Sfile; + C_OFile : Sfile; Line : String (1 .. 256); Last : Integer; @@ -368,7 +399,8 @@ begin -- Load C template and output definitions Open (Tmpl_File, In_File, Tmpl_File_Name); - Create (OFile, Out_File, Ada_File_Name); + Create (Ada_OFile, Out_File, Ada_File_Name); + Create (C_OFile, Out_File, C_File_Name); Current_Line := 0; Current_Info := Asm_Infos.First; @@ -398,16 +430,20 @@ begin elsif In_Template then if In_Comment then if Line (1 .. Last) = "*/" then + Put_Line (C_OFile, Line (1 .. Last)); In_Comment := False; else - Put_Line (OFile, Line (1 .. Last)); + Put_Line (Ada_OFile, Line (1 .. Last)); + Put_Line (C_OFile, Line (1 .. Last)); end if; elsif Line (1 .. Last) = "/*" then + Put_Line (C_OFile, Line (1 .. Last)); In_Comment := True; elsif Asm_Infos.Table (Current_Info).Line_Number = Current_Line then - Output_Info (OFile, Current_Info); + Output_Info (Lang_Ada, Ada_OFile, Current_Info); + Output_Info (Lang_C, C_OFile, Current_Info); Current_Info := Current_Info + 1; end if; Current_Line := Current_Line + 1; |