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=-0.3 required=5.0 tests=BAYES_00,FREEMAIL_FROM, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,6e300d7ab3fa9943,start X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Date: Fri, 09 Sep 2005 13:27:09 -0400 From: Chi-Hua Chen Reply-To: stephaniechc-newsada@yahoo.com User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.7.5) Gecko/20041217 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: constant in instantiations in GNAT/asis Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: fw.grammatech.com Message-ID: <4321c610$1_3@newsfeed.slurp.net> X-Trace: newsfeed.slurp.net 1126286864 209.4.89.67 (9 Sep 2005 12:27:44 -0500) X-Original-NNTP-Posting-Host: 209.4.89.67 Path: g2news1.google.com!news2.google.com!newsread.com!news-xfer.newsread.com!news-out1.kabelfoon.nl!newsfeed.kabelfoon.nl!xindi.nntp.kabelfoon.nl!newsfeed.slurp.net!not-for-mail Xref: g2news1.google.com comp.lang.ada:4557 Date: 2005-09-09T13:27:09-04:00 List-Id: I am having trouble getting back the constants used in generic instantiations from asis. For example, in a call inside an instantiation that has three actuals: a variable (X1), a constant (K1), and a literal, I get only the variable and the constant when I call Function_Call_Parameters on the call. K1 is no where to be found. (However, in the assembly output, I do see the constant appears for the call.) So is there a way I can get K1 for the call (other than going back to the tree for the generic itself)? Another perhaps related problem is when I try to get the element_span_in_template (a gnat extension) for an aggregate containing a constant, I get an exception Returned_List_Length = 3 First part length = 2 Second part length = 0 Exception information: Exception name: CONSTRAINT_ERROR Message: asis-expressions.adb:1395 length check failed Below is a small program extracted from Ada.Numerics.Discrete_Random, from which I first encounter the problem, with some modifications. I am using GNAT 3.15p (20020523). Chi-Hua ========== random.ads ========== generic package Random is type Generator is limited private; procedure Reset(Gen : Generator); private K1 : constant := 94_833_359; type Generator is limited record Gen_State : Integer; end record; end Random; ========== random.adb ========== package body Random is function Square_Mod_N (X, N, Z : Integer) return Integer; type Agg is record Field1 : Integer; Field2 : Integer; Field3 : Integer; end record; procedure Reset (Gen : Generator) is X1 : Integer; X2 : Integer; A1 : Agg; begin -- Only two items show up in function_call_parameters X1 := Square_Mod_N(X1, K1, X2); -- Exceptions in element_span_in_template span A1 := (X1, K1, 1); -- This one seems fine, though X1 := K1; end Reset; function Square_Mod_N (X, N, Z : Integer) return Integer is begin return 0; end Square_Mod_N; end Random; ========== main.adb ========= with Random; procedure Main is package Ada95_Random is new Random; G: Ada95_Random.Generator; begin Ada95_Random.Reset(Gen=>G); end Main;