------------------------------------------------------- ------------------------- -- -- -- OCARINA COMPONENTS -- -- -- -- T Y P E S -- -- -- -- S p e c -- -- -- -- Copyright (C) 2007, GET-Telecom Paris. -- -- -- -- Ocarina is free software; you can redistribute it and/or modify -- -- it under terms of the GNU General Public License as published by the -- -- Free Software Foundation; either version 2, or (at your option) any -- -- later version. Ocarina is distributed in the hope that it will be -- -- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General -- -- Public License for more details. You should have received a copy of the -- -- GNU General Public License distributed with Ocarina; see file COPYING. -- -- If not, write to the Free Software Foundation, 51 Franklin Street, Fifth -- -- Floor, Boston, MA 02111-1301, USA. -- -- -- -- As a special exception, if other files instantiate generics from this -- -- unit, or you link this unit with other files to produce an executable, -- -- this unit does not by itself cause the resulting executable to be -- -- covered by the GNU General Public License. This exception does not -- -- however invalidate any other reasons why the executable file might be -- -- covered by the GNU Public License. -- -- -- -- Ocarina is maintained by the Ocarina team -- -- (ocarina-users@listes.enst.fr) -- -- -- ------------------------------------------------------------------------------ with Unchecked_Deallocation; package Types is pragma preelaborate (Types); -- This package contains host independent type definitions which are used -- in more than one unit in the compiler. They are gathered here for easy -- reference, though in some cases the full description is found in the -- relevant module which implements the definition. The main reason that -- they are not in their "natural" specs is that this would cause a lot of -- inter-spec dependencies, and in particular some awkward circular -- dependencies would have to be dealt with. ------------------------------- -- General Use Integer Types -- ------------------------------- type int is range -2**31 .. +2**31 - 1; -- Signed 32-bit integer type dint is range -2**63 .. +2**63 - 1; -- Double length (64-bit) integer subtype nat is int range 0 .. int'last; -- Non-negative Int values subtype dnat is dint range 0 .. dint'last; subtype pos is int range 1 .. int'last; -- Positive Int values type word is mod 2**32; -- Unsigned 32-bit integer type byte is mod 2**8; for byte'size use 8; -- 8-bit unsigned integer type size_t is mod 2**Standard'address_size; -- Memory size value, for use in calls to C routines -------------------------------------- -- 8-Bit Character and String Types -- -------------------------------------- -- We use Standard.Character and Standard.String freely, since we are -- compiling ourselves, and we properly implement the required 8-bit -- character code as required in Ada 95. This section defines a few -- general use constants and subtypes. EOF : constant Character := ASCII.SUB; -- The character SUB (16#1A#) is used in DOS and other systems derived -- from DOS (OS/2, NT etc) to signal the end of a text file. Internally -- all source files are ended by an EOF character, even on Unix systems. -- An EOF character acts as the end of file only as the last character -- of a source buffer, in any other position, it is treated as a blank -- if it appears between tokens, and as an illegal character otherwise. -- This makes life easier dealing with files that originated from DOS, -- including concatenated files with interspersed EOF characters. subtype graphic_character is Character range ' ' .. '~'; -- Graphic characters, as defined in ARM subtype line_terminator is Character range ASCII.LF .. ASCII.CR; -- Line terminator characters (LF, VT, FF, CR) subtype upper_half_character is Character range Character'val (16#80#) .. Character'val (16#FF#); -- Characters with the upper bit set type character_ptr is access all Character; type string_ptr is access all String; -- Standard character and string pointers procedure Free is new Unchecked_Deallocation (String, string_ptr); -- Procedure for freeing dynamically allocated String values ----------------------------------------- -- Types Used for Text Buffer Handling -- ----------------------------------------- -- We can't use type String for text buffers, since we must use the -- standard 32-bit integer as an index value, since we count on all -- index values being the same size. type text_ptr is new int; -- Type used for subscripts in text buffer type text_buffer is array (text_ptr range <>) of Character; -- Text buffer used to hold source file or library information file type text_buffer_ptr is access all text_buffer; -- Text buffers for input files are allocated dynamically and this type -- is used to reference these text buffers. procedure Free is new Unchecked_Deallocation (text_buffer, text_buffer_ptr); -- Procedure for freeing dynamically allocated text buffers ------------------------------------------ -- Types Used for Source Input Handling -- ------------------------------------------ type logical_line_number is range 0 .. int'last; for logical_line_number'size use 32; -- Line number type, used for storing logical line numbers (i.e. line -- numbers that include effects of any Source_Reference pragmas in the -- source file). The value zero indicates a line containing a source -- reference pragma. No_Line_Number : constant logical_line_number := 0; -- Special value used to indicate no line number type physical_line_number is range 1 .. int'last; for physical_line_number'size use 32; -- Line number type, used for storing physical line numbers (i.e. -- line numbers in the physical file being compiled, unaffected by -- the presence of source reference pragmas. type column_number is range 0 .. 32767; for column_number'size use 16; -- Column number (assume that 2**15 is large enough, see declaration -- of Hostparm.Max_Line_Length) No_Column_Number : constant column_number := 0; -- Special value used to indicate no column number ----------------------------- -- Types for Namet Package -- ----------------------------- -- Name_Id values are used to identify entries in the names table. Except -- for the special values No_Name, and Error_Name, they are subscript -- values for the Names table defined in package Namet. -- Note that with only a few exceptions, which are clearly documented, the -- type Name_Id should be regarded as a private type. In particular it is -- never appropriate to perform arithmetic operations using this type. names_low_bound : constant := 300_000_000; -- Low bound for name Id values names_high_bound : constant := 399_999_999; -- Maximum number of names that can be allocated is 100 million, which is -- in practice infinite and there is no need to check the range. type name_id is range names_low_bound .. names_high_bound; for name_id'size use 32; -- Type used to identify entries in the names table No_Str : constant String := ""; No_Name : constant name_id := names_low_bound; -- The special Name_Id value No_Name is used in the parser to indicate -- a situation where no name is present (e.g. on a loop or block). First_Name_Id : constant name_id := names_low_bound + 2; -- Subscript of first entry in names table type node_id is new int; No_Node : constant node_id := 0; function Present (E : node_id) return Boolean; -- Return true when E is not No_Node function No (E : node_id) return Boolean; -- Return true when E is No_Node procedure Dummy (E : node_id); function Safe_XOR (Right : Boolean; Left : Boolean) return Boolean; -- This function performs a safe xor operation with respect to the -- No_Direct_Boolean_Operators restriction. type list_id is new node_id; No_List : constant list_id := 0; type operator_id is new byte; type value_id is new int; mode_in : constant := 0; mode_inout : constant := 1; mode_out : constant := 2; type mode_id is new byte range mode_in .. mode_out; pragma_id : constant := 0; pragma_prefix : constant := 1; pragma_version : constant := 2; pragma_unrecognized : constant := 3; type pragma_type is new byte range pragma_id .. pragma_unrecognized; type base_type is new node_id; type short_short is range -2**7 .. 2**7 - 1; for short_short'size use 8; type short is range -2**15 .. 2**15 - 1; for short'size use 16; type long is range -2**31 .. 2**31 - 1; for long'size use 32; type long_long is range -2**63 .. 2**63 - 1; for long_long'size use 64; type octet is mod 2**8; for octet'size use 8; type unsigned_short_short is mod 2**8; for unsigned_short_short'size use 8; type unsigned_short is mod 2**16; for unsigned_short'size use 16; type unsigned_long is mod 2**32; for unsigned_long'size use 32; type unsigned_long_long is mod 2**64; for unsigned_long_long'size use 64; -- Floating point types. We assume that we are on an IEEE machine, and -- that the types Short_Float and Long_Float in Standard refer to the -- 32-bit short and 64-bit long IEEE forms. Furthermore, if there is -- an extended float, we assume that it is available as Long_Long_Float. -- Note: it is harmless, and explicitly permitted, to include additional -- types in interfaces, so it is not wrong to have IEEE_Extended_Float -- defined even if the extended format is not available. type float is new Short_Float; type double is new Long_Float; type long_double is new Long_Long_Float; fss : constant := short_short'first; lss : constant := short_short'last; fs : constant := short'first; ls : constant := short'last; fl : constant := long'first; ll : constant := long'last; fll : constant := long_long'first; lll : constant := long_long'last; fo : constant := octet'first; lo : constant := octet'last; fuss : constant := unsigned_short_short'first; luss : constant := unsigned_short_short'last; fus : constant := unsigned_short'first; lus : constant := unsigned_short'last; ful : constant := unsigned_long'first; lul : constant := unsigned_long'last; full : constant := unsigned_long_long'first; lull : constant := unsigned_long_long'last; function Shift_Left (Value : unsigned_long_long; Amount : Natural) return unsigned_long_long; function Shift_Right (Value : unsigned_long_long; Amount : Natural) return unsigned_long_long; pragma import (Intrinsic, Shift_Left); pragma import (Intrinsic, Shift_Right); end Types;