fork download
  1. with Ada.Integer_Text_IO;
  2. with Ada.Text_IO;
  3. with Ada.Unchecked_Conversion;
  4. with Interfaces;
  5.  
  6. procedure Main_Test is
  7.  
  8. use Interfaces;
  9. use Ada.Text_IO;
  10. use Ada.Integer_Text_IO;
  11.  
  12. function One_Bit (Index : Natural) return Unsigned_32 is (Shift_Left (1, Index));
  13.  
  14. type Bit_Array_32_Index is range 0 .. 31;
  15. type Bit_Array_17_Index is range 0 .. 16;
  16. type Bit_Array_32 is array (Bit_Array_32_Index) of Boolean with Component_Size => 1, Size => 32;
  17. type Bit_Array_17 is array (Bit_Array_17_Index) of Boolean with Component_Size => 1, Size => 17;
  18.  
  19. -- For every new array type instantiate a convert function.
  20. function Convert is new Ada.Unchecked_Conversion (Unsigned_32, Bit_Array_32);
  21. function Convert is new Ada.Unchecked_Conversion (Unsigned_32, Bit_Array_17);
  22.  
  23. B32 : Bit_Array_32 with Volatile;
  24. B17 : Bit_Array_17 with Volatile;
  25.  
  26. begin
  27.  
  28. B17 := Convert (One_Bit (2)) or Convert (One_Bit (5));
  29. B32 := Convert (One_Bit (2) or One_Bit (5));
  30.  
  31. for E of B17 loop
  32. Put (Boolean'Pos (E), 1);
  33. end loop;
  34.  
  35. New_Line;
  36.  
  37. for E of B32 loop
  38. Put (Boolean'Pos (E), 1);
  39. end loop;
  40.  
  41. end;
Success #stdin #stdout 0s 5760KB
stdin
Standard input is empty
stdout
00100100000000000
00100100000000000000000000000000