comp.lang.ada
 help / color / mirror / Atom feed
* ASIS problem with generics (Long)
@ 1998-11-23  0:00 Joe Wisniewski
  0 siblings, 0 replies; only message in thread
From: Joe Wisniewski @ 1998-11-23  0:00 UTC (permalink / raw)


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






^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1998-11-23  0:00 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-11-23  0:00 ASIS problem with generics (Long) Joe Wisniewski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox