From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.1 required=3.0 tests=BAYES_00,FROM_NO_USER, T_FILL_THIS_FORM_SHORT autolearn=no autolearn_force=no version=3.4.5-pre1 Date: Tue, 13 Jul 93 14:22:52 CDT From: crispen <@ada3.ca.boeing.com:crispen@eight-ball.boeing.com> Subject: Forcing default representations Message-ID: <9307131922.AA04017@eight-ball.boeing.com> List-Id: OK, just what the hell does LRM 13.1(6) mean, anyway? "certain occurrences of its name imply that the representation of the type must have been determined." Even the Annotated LRM is obscure on this point. "certain occurrences" indeed! My goal here is to put as many of my rep specs as I possibly can in a private part. In fact, I've been making some really sexy rep specs: for Trim_Max_Rate use record Aircraft_Trim_Positions at 0 range 0..Aircraft_Trim_Position_Array_Size-1; Surface_Tab_Deflections at Aircraft_Trim_Position_Array_Size/8 range 0..Surface_Tab_Deflection_Array_Size-1; end record; for Trim_Max_Rate'size use Aircraft_Trim_Position_Array_Size + Surface_Tab_Deflection_Array_Size; Where I've defined the _Size constants elsewhere, e.g.: Aircraft_Trim_Position_Array_Size : constant := Number_Of_Aircraft_Trims * Float_Size; for Aircraft_Trim_Position_Array'size use Aircraft_Trim_Position_Array_Size; Like I said, pure sex -- oh, yeah, naturally I define: Number_Of_Aircraft_Trims : constant := Aircraft_Trim'pos (Aircraft_Trim'last) - Aircraft_Trim'pos (Aircraft_Trim'first) + 1; So basically I'm going after having the best of all possible worlds: we have rep specs (essential, because we're defining objects that are going on a network between two machines of possibly different architectures), but the person who is modifying this file should be able to add or delete from the Aircraft_Trim enumeration at will, and the rep specs are generated automatically. Cool! In fact, I've tested this out on a SPARC, a 68030 board, and an SGI Indigo, and it works! Or, at any rate, when I define an object of the type and have Text_IO put out the object'size/8 it gives the same answer on all 3 machines. The problem, though, is with this declaration: type Flight_Controls_Discrete_Outputs is ( Flt_Control_System_Caution_Light, LE_Flaps_Caution_Light [...] Flight_Controls_Discrete_Outputs_Size : constant := 8; for Flight_Controls_Discrete_Outputs'size use Flight_Controls_Discrete_Outputs_Size; If I define this above the private part, and before the declaration: type Flight_Controls_Discrete_Data_Pair is record Name : Flight_Controls_Discrete_Outputs; State : Base_Types.Discrete_State; end record; no problem. If I don't, and if I define it in the private part, then I get the following error: /usr/people/crispen/generic/types/fc_if_types.a, line 372, char 5:error: RM 13. 1(6): type representation already determined by a forcing occurrence on all 3 of my Ada compilers (they're VADS, but of different vintages). But, I can define this record: for Landing_Gear_Parameters use record Position at 0 range Four_Bytes; State at 4 range One_Byte; -- 3 bytes spare Crab_Angle at 8 range Four_Bytes; end record; Landing_Gear_Parameters_Size : constant := 12 * Bytes; for Landing_Gear_Parameters'size use Landing_Gear_Parameters_Size; in the private part with no problems (and Landing_Gear_Parameters is defined as an element of another record before the private part). You'd think that if one was a problem, so would the other one be, but Nooooooo! So, is my compiler ignoring the rep specs in the private part, or what? p.s.: I know I should substitute System.Storage_Unit for "8" above, and I will. p.p.s: I've defined: type One_Byte is range 0..7; type Two_Bytes is range 0..15; type Three_Bytes is range 0..23; type Four_Bytes is range 0..31; Cute trick, eh? +-------------------------------+--------------------------------------+ | Bob Crispen | Who will babysit the babysitters? | | crispen@foxy.boeing.com +--------------------------------------+ | (205) 461-3296 |Opinions expressed here are mine alone| +-------------------------------+--------------------------------------+