[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5. Intrinsic Subprograms

5.1 Intrinsic Operators  
5.2 Enclosing_Entity  
5.3 Exception_Information  
5.4 Exception_Message  
5.5 Exception_Name  
5.6 File  
5.7 Line  
5.8 Rotate_Left  
5.9 Rotate_Right  
5.10 Shift_Left  
5.11 Shift_Right  
5.12 Shift_Right_Arithmetic  
5.13 Source_Location  

GNAT allows a user application program to write the declaration:

 
   pragma Import (Intrinsic, name);

providing that the name corresponds to one of the implemented intrinsic subprograms in GNAT, and that the parameter profile of the referenced subprogram meets the requirements. This chapter describes the set of implemented intrinsic subprograms, and the requirements on parameter profiles. Note that no body is supplied; as with other uses of pragma Import, the body is supplied elsewhere (in this case by the compiler itself). Note that any use of this feature is potentially non-portable, since the Ada standard does not require Ada compilers to implement this feature.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.1 Intrinsic Operators

All the predefined numeric operators in package Standard in pragma Import (Intrinsic,..) declarations. In the binary operator case, the operands must have the same size. The operand or operands must also be appropriate for the operator. For example, for addition, the operands must both be floating-point or both be fixed-point, and the right operand for "**" must have a root type of Standard.Integer'Base. You can use an intrinsic operator declaration as in the following example:

 
   type Int1 is new Integer;
   type Int2 is new Integer;

   function "+" (X1 : Int1; X2 : Int2) return Int1;
   function "+" (X1 : Int1; X2 : Int2) return Int2;
   pragma Import (Intrinsic, "+");

This declaration would permit "mixed mode" arithmetic on items of the differing types Int1 and Int2. It is also possible to specify such operators for private types, if the full views are appropriate arithmetic types.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.2 Enclosing_Entity

This intrinsic subprogram is used in the implementation of the library routine GNAT.Source_Info. The only useful use of the intrinsic import in this case is the one in this unit, so an application program should simply call the function GNAT.Source_Info.Enclosing_Entity to obtain the name of the current subprogram, package, task, entry, or protected subprogram.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.3 Exception_Information

This intrinsic subprogram is used in the implementation of the library routine GNAT.Current_Exception. The only useful use of the intrinsic import in this case is the one in this unit, so an application program should simply call the function GNAT.Current_Exception.Exception_Information to obtain the exception information associated with the current exception.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.4 Exception_Message

This intrinsic subprogram is used in the implementation of the library routine GNAT.Current_Exception. The only useful use of the intrinsic import in this case is the one in this unit, so an application program should simply call the function GNAT.Current_Exception.Exception_Message to obtain the message associated with the current exception.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.5 Exception_Name

This intrinsic subprogram is used in the implementation of the library routine GNAT.Current_Exception. The only useful use of the intrinsic import in this case is the one in this unit, so an application program should simply call the function GNAT.Current_Exception.Exception_Name to obtain the name of the current exception.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.6 File

This intrinsic subprogram is used in the implementation of the library routine GNAT.Source_Info. The only useful use of the intrinsic import in this case is the one in this unit, so an application program should simply call the function GNAT.Source_Info.File to obtain the name of the current file.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.7 Line

This intrinsic subprogram is used in the implementation of the library routine GNAT.Source_Info. The only useful use of the intrinsic import in this case is the one in this unit, so an application program should simply call the function GNAT.Source_Info.Line to obtain the number of the current source line.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.8 Rotate_Left

In standard Ada 95, the Rotate_Left function is available only for the predefined modular types in package Interfaces. However, in GNAT it is possible to define a Rotate_Left function for a user defined modular type or any signed integer type as in this example:

 
   function Shift_Left
     (Value  : My_Modular_Type;
      Amount : Natural)
      return   My_Modular_Type;

The requirements are that the profile be exactly as in the example above. The only modifications allowed are in the formal parameter names, and in the type of Value and the return type, which must be the same, and must be either a signed integer type, or a modular integer type with a binary modulus, and the size must be 8. 16, 32 or 64 bits.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.9 Rotate_Right

A Rotate_Right function can be defined for any user defined binary modular integer type, or signed integer type, as described above for Rotate_Left.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.10 Shift_Left

A Shift_Left function can be defined for any user defined binary modular integer type, or signed integer type, as described above for Rotate_Left.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.11 Shift_Right

A Shift_Right function can be defined for any user defined binary modular integer type, or signed integer type, as described above for Rotate_Left.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.12 Shift_Right_Arithmetic

A Shift_Right_Arithmetic function can be defined for any user defined binary modular integer type, or signed integer type, as described above for Rotate_Left.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.13 Source_Location

This intrinsic subprogram is used in the implementation of the library routine GNAT.Source_Info. The only useful use of the intrinsic import in this case is the one in this unit, so an application program should simply call the function GNAT.Source_Info.Source_Location to obtain the current source file location.


[ << ] [ >> ]           [Top] [Contents] [Index] [ ? ]

This document was generated by Mail Server on June, 15 2005 using texi2html