From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,62393652a5a13a37,start X-Google-Attributes: gid103376,public From: "Joe Wisniewski" Subject: ASIS problem with generics (Long) Date: 1998/11/23 Message-ID: <0c562.3852$Z84.7368406@news.rdc1.md.home.com>#1/1 X-Deja-AN: 414675140 X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3 Organization: @Home Network NNTP-Posting-Date: Sun, 22 Nov 1998 20:07:24 PDT Newsgroups: comp.lang.ada Date: 1998-11-23T00:00:00+00:00 List-Id: I am putting together an ASIS application where I need to be able to traverse a number of types (all records of some sort). I need to traverse these types down to the base level and build up a recursive structure that keeps track of relevant information to be able to re-declare objects of these types in "generated source". The rest of the details are irrelevant to this discussion. I have been able to do what I needed to do, with some difficulty for a first-time crack at ASIS, but have run into a snag that I don't know quite how to handle. It has to do with the fact that one of the constituent types is an unconstrained array that is declared within a generic and is bounded by the generic parameter. Here is the type/package hierarchy --************************ generic type Index_Type is (<>); package uta_bit_array is type bit is new boolean; for bit use (false => 0, true => 1); for bit'size use 1; ... type kind is array (index_type) of bit; ... end uta_bit_array; --************************ package package_1 is .... type type_1 is private; ... private ... type mask_index-type is range 0..31; package mask_ops is new uta_bit_array (mask_index_type); type type_2 is new mask_ops.kind; ... type type_1 is record mask_3a : type_2; end Package_1; --************************** type Rec_Type is record is_active : boolean; Field1 : Package_1.Type_1; ..... end record; --************************** Up until now, I haven't really had any problems such as this. When I encounter a derived type, I have been using the asis_type_definitions.parent_type call to "pop" to the "parent" type. Then, among other things, I have been getting the type declaration string via asis_type_definitions.type-definition_declaration and then building up the declaration string via the asis_text.non_comment_image on the asis_text.lines call. This is where I detected a problem. Normally, when there is a problem like this (some kind of inappropriate use of an interface call), the standard inappropriate_element exception is raised. This problem is somewhat different since no exception was raised. BUT, trying to get the lines for the array returned no lines. When I "dumped" the element, the Line "value" is [ ]. I have a good idea about what is wrong here, I'm just not quite sure where to trudge next. I am assuming that something of the following is the issue. When you get into the generic, that type does not really exist. It is just a template, per se. So it seems that perhaps that when I get a derived type (or any type) whose enclosing unit is a generic, I need to somehow get to the "instantiated" type definition, not the generic version, so that asis_type_definitions.type_definition_declaration gets me the The key to this, as I now realize, is that I have to be able to extract the type declaration(s) without having to "keep track of" anything else in the generic above and beyond the type declaration. That is, I have to be able to transform this problem into a solution that takes the form of: 1. when I see type Mask_3a_type is new mask_ops.kind; 2. I need to know that mask_ops is a generic instantiation 3. grab, but don't save save the generic instantiation package mask_ops is new uta_bit_array (mask_index_type); When I say don't save, I mean that I do NOT want to get in the business of regenerating code for packages. Types is bad enough. 4. get the declaration in the generic type kind is array(index_type) of bit; 5. recursively traverse "bit" which I can already do Then I need to reconstruct the text of the array type declaration such that it compiles, that is take the text of the generic type declaration (which is what I can't get at) and then change the formal parameter name for the type (index_type) to the instantiated one (mask_index_type). I know that this is confusing, but the "system solution and requirements" dictated this. My problem is that only one individual on the project recognizes the complexity of what it is that they want done. If someone has gone through type traversal in generics, I think that you could help me with it. I'm just running out of time and need a jumpstart on this solution. BTW, after having gone through the investement of pain and suffering on this task, if you know of anyone in the DC area needing any ASIS experience, I'd love to parlay this experience on another project Thanx for the patience Joe Wisniewski 6. Somehow