diff mbox

[Ada] Add procedure to print out the predefined floating point types

Message ID 20110801131805.GA5566@adacore.com
State New
Headers show

Commit Message

Arnaud Charlet Aug. 1, 2011, 1:18 p.m. UTC
This new procedure is a clean up that replaces explicit references
of constants such as Standard_Long_Float_Size by calls to attribute
functions in Einfo. This will allow eventual removal of explicit
constants for each predefined type.

No functional change.

Tested on x86_64-pc-linux-gnu, committed on trunk

2011-08-01  Geert Bosch  <bosch@adacore.com>

	* cstand.adb (P_Float_Type): New procedure to print the definition of
	predefined fpt types.
	(P_Mixed_Name): New procedure to print a name using mixed case
	(Print_Standard): Use P_Float_Type for printing floating point types
	* einfo.adb (Machine_Emax_Value): Add preliminary support for quad
	precision IEEE float.
diff mbox

Patch

Index: cstand.adb
===================================================================
--- cstand.adb	(revision 177026)
+++ cstand.adb	(working copy)
@@ -1673,6 +1673,12 @@ 
       procedure P_Float_Range (Id : Entity_Id);
       --  Prints the bounds range for the given float type entity
 
+      procedure P_Float_Type (Id : Entity_Id);
+      --  Prints the type declaration of the given float type entity
+
+      procedure P_Mixed_Name (Id : Name_Id);
+      --  Prints Id in mixed case
+
       -------------------
       -- P_Float_Range --
       -------------------
@@ -1687,6 +1693,26 @@ 
          Write_Eol;
       end P_Float_Range;
 
+      ------------------
+      -- P_Float_Type --
+      ------------------
+
+      procedure P_Float_Type (Id : Entity_Id) is
+      begin
+         Write_Str ("   type ");
+         P_Mixed_Name (Chars (Id));
+         Write_Str (" is digits ");
+         Write_Int (UI_To_Int (Digits_Value (Id)));
+         Write_Eol;
+         P_Float_Range (Id);
+         Write_Str ("   for ");
+         P_Mixed_Name (Chars (Id));
+         Write_Str ("'Size use ");
+         Write_Int (UI_To_Int (RM_Size (Id)));
+         Write_Line (";");
+         Write_Eol;
+      end P_Float_Type;
+
       -----------------
       -- P_Int_Range --
       -----------------
@@ -1702,6 +1728,23 @@ 
          Write_Eol;
       end P_Int_Range;
 
+      ------------------
+      -- P_Mixed_Name --
+      ------------------
+
+      procedure P_Mixed_Name (Id : Name_Id) is
+      begin
+         Get_Name_String (Id);
+
+         for J in 1 .. Name_Len loop
+            if J = 1 or else Name_Buffer (J - 1) = '_' then
+               Name_Buffer (J) := Fold_Upper (Name_Buffer (J));
+            end if;
+         end loop;
+
+         Write_Str (Name_Buffer (1 .. Name_Len));
+      end P_Mixed_Name;
+
    --  Start of processing for Print_Standard
 
    begin
@@ -1764,42 +1807,11 @@ 
 
       --  Floating point types
 
-      Write_Str ("   type Short_Float is digits ");
-      Write_Int (Standard_Short_Float_Digits);
-      Write_Eol;
-      P_Float_Range (Standard_Short_Float);
-      Write_Str ("   for Short_Float'Size use ");
-      Write_Int (Standard_Short_Float_Size);
-      P (";");
-      Write_Eol;
+      P_Float_Type (Standard_Short_Float);
+      P_Float_Type (Standard_Float);
+      P_Float_Type (Standard_Long_Float);
+      P_Float_Type (Standard_Long_Long_Float);
 
-      Write_Str ("   type Float is digits ");
-      Write_Int (Standard_Float_Digits);
-      Write_Eol;
-      P_Float_Range (Standard_Float);
-      Write_Str ("   for Float'Size use ");
-      Write_Int (Standard_Float_Size);
-      P (";");
-      Write_Eol;
-
-      Write_Str ("   type Long_Float is digits ");
-      Write_Int (Standard_Long_Float_Digits);
-      Write_Eol;
-      P_Float_Range (Standard_Long_Float);
-      Write_Str ("   for Long_Float'Size use ");
-      Write_Int (Standard_Long_Float_Size);
-      P (";");
-      Write_Eol;
-
-      Write_Str ("   type Long_Long_Float is digits ");
-      Write_Int (Standard_Long_Long_Float_Digits);
-      Write_Eol;
-      P_Float_Range (Standard_Long_Long_Float);
-      Write_Str ("   for Long_Long_Float'Size use ");
-      Write_Int (Standard_Long_Long_Float_Size);
-      P (";");
-      Write_Eol;
-
       P ("   type Character is (...)");
       Write_Str ("   for Character'Size use ");
       Write_Int (Standard_Character_Size);
Index: einfo.adb
===================================================================
--- einfo.adb	(revision 177026)
+++ einfo.adb	(working copy)
@@ -6518,7 +6518,7 @@ 
             case Digs is
                when  1 ..  6 => return Uint_128;
                when  7 .. 15 => return 2**10;
-               when 16 .. 18 => return 2**14;
+               when 16 .. 33 => return 2**14;
                when others => return No_Uint;
             end case;