* !Help - Ada/Fortran/C interface issues
@ 1997-11-21 0:00 Jeffrey A. Flachman
1997-11-21 0:00 ` Stephen Leake
0 siblings, 1 reply; 3+ messages in thread
From: Jeffrey A. Flachman @ 1997-11-21 0:00 UTC (permalink / raw)
I posted this problem yesterday but I think I did not explain it well.
I am trying to find an Ada parser to provide information about my Ada
code. I have provided a better description of my strategy and an
example.
I am working on hooking an Ada program (10's of thousands of lines of
code) into a simulation written in C and Fortran. The main requirement
(since different versions of the Ada code need to be hooked in
frequently) is that my solution cannot involve many changes to the Ada
code. The C and Fortran code will read input from a text file which can
be used to modify any of the 5000+ Ada variables in the Ada code. Also,
for restart capability, I need to be able to save and image of the state
of all the Ada variables at any time without saving all the rest of the
Ada address space.
Therefore, the solution I have found is to define a list of every Ada
(static) variable in the Ada code and to "Auto generate" some additional
interface code between the Ada and Fortran/C simulation code. Several
years ago I wrote a tool which parses the Ada code and provides all the
Ada variable names, the package/procudure they are defined in, and the
basic type. The problem is that the parse is very rudamentary and does
not provide enough insight into the type declarations of each variable.
So when hooking the Ada and Fortran/C together, some massaging of the
list is required by hand. I would like to fully automate the process
now.
The proposed plan is to generate the list of variables including an
expansion of records down to each individual "data" element. See the
following example:
--------- test_data_spec.ada
with DATA_TYPES; -- declaration of all data types
package TEST_DATA is
type RECORD_1_TYPE is record
T_BITMAP : BITMAP;
T_BIT_ARR : BITMAP_ARRAY(1..2);
T_SHORT_BIT : SHORT_BITMAP;
T_SHORT_BIT_ARR : SHORT_BITMAP_ARRAY(1..2);
T_INTEGER : INTEGER;
T_INT_ARR : INTEGER_ARRAY(1..2);
T_LONG_INT : LONG_INTEGER;
T_LONG_INT_ARR : LONG_INTEGER_ARRAY(1..2);
T_BOOLEAN : BOOLEAN;
T_BOOLEAN_ARR : BOOLEAN_ARRAY(1..2);
T_FLOAT : FLOAT;
T_FLOAT_ARR : FLOAT_ARRAY(1..2);
T_LONG_FLOAT : LONG_FLOAT;
T_LONG_FLOAT_ARR : LONG_FLOAT_ARRAY(1..2);
T_ENUM : ENUM_TYPE;
T_ENUM_ARR : ENUM_TYPE_ARRAY(1..2);
end record;
TST_BITMAP : BITMAP;
TST_BIT_ARR : BITMAP_ARRAY(1..2);
TST_SHORT_BIT : SHORT_BITMAP;
TST_SHORT_BIT_ARR : SHORT_BITMAP_ARRAY(1..2);
TST_INTEGER : INTEGER;
TST_INT_ARR : INTEGER_ARRAY(1..2);
TST_LONG_INT : LONG_INTEGER;
TST_LONG_INT_ARR : LONG_INTEGER_ARRAY(1..2);
TST_BOOLEAN : BOOLEAN;
TST_BOOLEAN_ARR : BOOLEAN_ARRAY(1..2);
TST_FLOAT : FLOAT;
TST_FLOAT_ARR : FLOAT_ARRAY(1..2);
TST_LONG_FLOAT : LONG_FLOAT;
TST_LONG_FLOAT_ARR : LONG_FLOAT_ARRAY(1..2);
TST_ENUM : ENUM_TYPE;
TST_ENUM_ARR : ENUM_TYPE_ARRAY(1..2);
TST_B_1_16 : B1_16_BITS;
TST_B_1_32 : B1_32_BITS;
-- Renamed record data
TEST : RECORD_1_TYPE;
TEST2 : RECORD_1_TYPE;
TEST_BITMAP : BITMAP renames TEST.T_BITMAP;
TEST_BIT_ARR : BITMAP_ARRAY renames TEST.T_BIT_ARR;
TEST_SHORT_BIT : SHORT_BITMAP renames TEST.T_SHORT_BIT;
TEST_SHORT_BIT_ARR : SHORT_BITMAP_ARRAY renames
TEST.T_SHORT_BIT_ARR;
TEST_INTEGER : INTEGER renames TEST.T_INTEGER;
TEST_INT_ARR : INTEGER_ARRAY renames TEST.T_INT_ARR;
TEST_LONG_INT : LONG_INTEGER renames TEST.T_LONG_INT;
TEST_LONG_INT_ARR : LONG_INTEGER_ARRAY renames
TEST.T_LONG_INT_ARR;
TEST_BOOLEAN : BOOLEAN renames TEST.T_BOOLEAN;
TEST_BOOLEAN_ARR : BOOLEAN_ARRAY renames
TEST.T_BOOLEAN_ARR;
TEST_FLOAT : FLOAT renames TEST.T_FLOAT;
TEST_FLOAT_ARR : FLOAT_ARRAY renames TEST.T_FLOAT_ARR;
TEST_LONG_FLOAT : LONG_FLOAT renames
TEST.T_LONG_FLOAT;
TEST_LONG_FLOAT_ARR : LONG_FLOAT_ARRAY renames
TEST.T_LONG_FLOAT_ARR;
TEST_ENUM : ENUM_TYPE renames TEST.T_ENUM;
TEST_ENUM_ARR : ENUM_TYPE_ARRAY renames TEST.T_ENUM_ARR;
end TEST_DATA;
The utility/tool needs to provide the following information.
Package Variable Type
------- --------------- --------------------
TEST_DATA T_BITMAP DATA_TYPES.BITMAP
TEST_DATA T_BIT_ARR DATA_TYPES.BITMAP_ARRAY(1..2)
TEST_DATA T_SHORT_BIT DATA_TYPES.SHORT_BITMAP
TEST_DATA T_SHORT_BIT_ARR DATA_TYPES.SHORT_BITMAP_ARRAY(1..2)
TEST_DATA T_INTEGER SYSTEM.INTEGER
TEST_DATA T_INT_ARR DATA_TYPES.INTEGER_ARRAY(1..2)
TEST_DATA T_LONG_INT SYSTEM.LONG_INTEGER
TEST_DATA T_LONG_INT_ARR DATA_TYPES.LONG_INTEGER_ARRAY(1..2)
TEST_DATA T_BOOLEAN SYSTEM.BOOLEAN
TEST_DATA T_BOOLEAN_ARR DATA_TYPES.BOOLEAN_ARRAY(1..2)
TEST_DATA T_FLOAT SYSTEM.FLOAT
TEST_DATA T_FLOAT_ARR DATA_TYPES.FLOAT_ARRAY(1..2)
TEST_DATA T_LONG_FLOAT SYSTEM.LONG_FLOAT
TEST_DATA T_LONG_FLOAT_ARR DATA_TYPES.LONG_FLOAT_ARRAY(1..2)
TEST_DATA T_ENUM DATA_TYPES.ENUM_TYPE
TEST_DATA T_ENUM_ARR DATA_TYPES.ENUM_TYPE_ARRAY(1..2)
TEST_DATA TST_BITMAP DATA_TYPES.BITMAP
TEST_DATA TST_BIT_ARR DATA_TYPES.BITMAP_ARRAY(1..2)
TEST_DATA TST_SHORT_BIT DATA_TYPES.SHORT_BITMAP
TEST_DATA TST_SHORT_BIT_ARR DATA_TYPES.SHORT_BITMAP_ARRAY(1..2)
TEST_DATA TST_INTEGER SYSTEM.INTEGER
TEST_DATA TST_INT_ARR DATA_TYPES.INTEGER_ARRAY(1..2)
TEST_DATA TST_LONG_INT SYSTEM.LONG_INTEGER
TEST_DATA TST_LONG_INT_ARR DATA_TYPES.LONG_INTEGER_ARRAY(1..2)
TEST_DATA TST_BOOLEAN SYSTEM.BOOLEAN
TEST_DATA TST_BOOLEAN_ARR DATA_TYPES.BOOLEAN_ARRAY(1..2)
TEST_DATA TST_FLOAT SYSTEM.FLOAT
TEST_DATA TST_FLOAT_ARR DATA_TYPES.FLOAT_ARRAY(1..2)
TEST_DATA TST_LONG_FLOAT SYSTEM.LONG_FLOAT
TEST_DATA TST_LONG_FLOAT_ARR DATA_TYPES.LONG_FLOAT_ARRAY(1..2)
TEST_DATA TST_ENUM DATA_TYPES.ENUM_TYPE
TEST_DATA TST_ENUM_ARR DATA_TYPES.ENUM_TYPE_ARRAY(1..2)
TEST_DATA TST_B_1_1 DATA_TYPES.B1_16_BITS
TEST_DATA TST_B_1_3 DATA_TYPES.B1_32_BITS
TEST_DATA TEST DATA_TYPES.RECORD_1_TYPE
TEST_DATA TEST2 DATA_TYPES.RECORD_1_TYPE
Package Variable Rename
------- --------------- --------------------
TEST_DATA TEST_BITMAP TEST_DATA.TEST.T_BITMAP
TEST_DATA TEST_BIT_ARR TEST_DATA.TEST.T_BIT_ARR
TEST_DATA TEST_SHORT_BIT TEST_DATA.TEST.T_SHORT_BIT
TEST_DATA TEST_SHORT_BIT_ARR TEST_DATA.TEST.T_SHORT_BIT_ARR
TEST_DATA TEST_INTEGER TEST_DATA.TEST.T_INTEGER
TEST_DATA TEST_INT_ARR TEST_DATA.TEST.T_INT_ARR
TEST_DATA TEST_LONG_INT TEST_DATA.TEST.T_LONG_INT
TEST_DATA TEST_LONG_INT_ARR TEST_DATA.TEST.T_LONG_INT_ARR
TEST_DATA TEST_BOOLEAN TEST_DATA.TEST.T_BOOLEAN
TEST_DATA TEST_BOOLEAN_ARR TEST_DATA.TEST.T_BOOLEAN_ARR
TEST_DATA TEST_FLOAT TEST_DATA.TEST.T_FLOAT
TEST_DATA TEST_FLOAT_ARR TEST_DATA.TEST.T_FLOAT_ARR
TEST_DATA TEST_LONG_FLOAT TEST_DATA.TEST.T_LONG_FLOAT
TEST_DATA TEST_LONG_FLOAT_ARR TEST_DATA.TEST.T_LONG_FLOAT_ARR
TEST_DATA TEST_ENUM TEST_DATA.TEST.T_ENUM
TEST_DATA TEST_ENUM_ARR TEST_DATA.TEST.T_ENUM_ARR
From this list I can then generate the following code in addition to
"type" information code in Fortran/C.
-------- test_addr_spec.ada
with TEST_DATA;
use TEST_DATA;
package TEST_ADDR is
type ADDR_ARRAY_TYPE is array (NATURAL range <>) of SYSTEM.ADDRESS;
type SIZE_ARRAY_TYPE is array (NATURAL range <>) of INTEGER;
ADDR_ARRAY : ADDR_ARRAY_TYPE(1..40);
SIZE_ARRAY : SIZE_ARRAY_TYPE(1..40);
end TEST_ADDR;
-------- test_addr_body.ada
with TEST_DATA;
use TEST_DATA;
package body TEST_ADDR is
begin
ADDR_ARRAY(1) := TST_BITMAP'ADDRESS;
SIZE_ARRAY(1) := TST_BITMAP'SIZE;
--
ADDR_ARRAY(1) := TST_BITMAP'ADDRESS;
ADDR_ARRAY(2) := TST_BIT_ARR'ADDRESS;
ADDR_ARRAY(3) := TST_SHORT_BIT'ADDRESS;
ADDR_ARRAY(4) := TST_SHORT_BIT_ARR'ADDRESS;
ADDR_ARRAY(5) := TST_INTEGER'ADDRESS;
ADDR_ARRAY(6) := TST_INT_ARR'ADDRESS;
ADDR_ARRAY(7) := TST_LONG_INT'ADDRESS;
ADDR_ARRAY(8) := TST_LONG_INT_ARR'ADDRESS;
ADDR_ARRAY(9) := TST_BOOLEAN'ADDRESS;
ADDR_ARRAY(10) := TST_BOOLEAN_ARR'ADDRESS;
ADDR_ARRAY(11) := TST_FLOAT'ADDRESS;
ADDR_ARRAY(12) := TST_FLOAT_ARR'ADDRESS;
ADDR_ARRAY(13) := TST_LONG_FLOAT'ADDRESS;
ADDR_ARRAY(14) := TST_LONG_FLOAT_ARR'ADDRESS;
ADDR_ARRAY(15) := TST_ENUM'ADDRESS;
ADDR_ARRAY(16) := TST_ENUM_ARR'ADDRESS;
ADDR_ARRAY(17) := TST_B_1_16'ADDRESS;
ADDR_ARRAY(18) := TST_B_1_32'ADDRESS;
ADDR_ARRAY(19) := TEST_BITMAP'ADDRESS;
ADDR_ARRAY(20) := TEST_BIT_ARR'ADDRESS;
ADDR_ARRAY(21) := TEST_SHORT_BIT'ADDRESS;
ADDR_ARRAY(22) := TEST_SHORT_BIT_ARR'ADDRESS;
ADDR_ARRAY(23) := TEST_INTEGER'ADDRESS;
ADDR_ARRAY(24) := TEST_INT_ARR'ADDRESS;
ADDR_ARRAY(25) := TEST_LONG_INT'ADDRESS;
ADDR_ARRAY(26) := TEST_LONG_INT_ARR'ADDRESS;
ADDR_ARRAY(27) := TEST_BOOLEAN'ADDRESS;
ADDR_ARRAY(28) := TEST_BOOLEAN_ARR'ADDRESS;
ADDR_ARRAY(29) := TEST_FLOAT'ADDRESS;
ADDR_ARRAY(30) := TEST_FLOAT_ARR'ADDRESS;
ADDR_ARRAY(31) := TEST_LONG_FLOAT'ADDRESS;
ADDR_ARRAY(32) := TEST_LONG_FLOAT_ARR'ADDRESS;
ADDR_ARRAY(33) := TEST_ENUM'ADDRESS;
ADDR_ARRAY(34) := TEST_ENUM_ARR'ADDRESS;
ADDR_ARRAY(35) := TEST'ADDRESS;
ADDR_ARRAY(36) := TEST_DATA'ADDRESS;
SIZE_ARRAY(1) := TST_BITMAP'SIZE;
SIZE_ARRAY(2) := TST_BIT_ARR'SIZE;
SIZE_ARRAY(3) := TST_SHORT_BIT'SIZE;
SIZE_ARRAY(4) := TST_SHORT_BIT_ARR'SIZE;
SIZE_ARRAY(5) := TST_INTEGER'SIZE;
SIZE_ARRAY(6) := TST_INT_ARR'SIZE;
SIZE_ARRAY(7) := TST_LONG_INT'SIZE;
SIZE_ARRAY(8) := TST_LONG_INT_ARR'SIZE;
SIZE_ARRAY(9) := TST_BOOLEAN'SIZE;
SIZE_ARRAY(10) := TST_BOOLEAN_ARR'SIZE;
SIZE_ARRAY(11) := TST_FLOAT'SIZE;
SIZE_ARRAY(12) := TST_FLOAT_ARR'SIZE;
SIZE_ARRAY(13) := TST_LONG_FLOAT'SIZE;
SIZE_ARRAY(14) := TST_LONG_FLOAT_ARR'SIZE;
SIZE_ARRAY(15) := TST_ENUM'SIZE;
SIZE_ARRAY(16) := TST_ENUM_ARR'SIZE;
SIZE_ARRAY(17) := TST_B_1_16'SIZE;
SIZE_ARRAY(18) := TST_B_1_32'SIZE;
SIZE_ARRAY(19) := TEST_BITMAP'SIZE;
SIZE_ARRAY(20) := TEST_BIT_ARR'SIZE;
SIZE_ARRAY(21) := TEST_SHORT_BIT'SIZE;
SIZE_ARRAY(22) := TEST_SHORT_BIT_ARR'SIZE;
SIZE_ARRAY(23) := TEST_INTEGER'SIZE;
SIZE_ARRAY(24) := TEST_INT_ARR'SIZE;
SIZE_ARRAY(25) := TEST_LONG_INT'SIZE;
SIZE_ARRAY(26) := TEST_LONG_INT_ARR'SIZE;
SIZE_ARRAY(27) := TEST_BOOLEAN'SIZE;
SIZE_ARRAY(28) := TEST_BOOLEAN_ARR'SIZE;
SIZE_ARRAY(29) := TEST_FLOAT'SIZE;
SIZE_ARRAY(30) := TEST_FLOAT_ARR'SIZE;
SIZE_ARRAY(31) := TEST_LONG_FLOAT'SIZE;
SIZE_ARRAY(32) := TEST_LONG_FLOAT_ARR'SIZE;
SIZE_ARRAY(33) := TEST_ENUM'SIZE;
SIZE_ARRAY(34) := TEST_ENUM_ARR'SIZE;
SIZE_ARRAY(35) := TEST'SIZE;
SIZE_ARRAY(36) := TEST_DATA'SIZE;
end TEST_ADDR;
I can then use a pragma to pass ADDR_ARRAY and SIZE_ARRAY to the
Fortran/C code. In addition, I can create some code for Fortran/C that
will provide "type" information so that the Fortran/C code will know how
to interpret the ASCII input from the initialization file and how to
store it at the Address defined by ADDR_ARRAY.
The way the process will work is to parse the Ada source code and all
the variable and type information. Then write a script which will
generate the TEST_ADDR package and the Fortran/C "type" definitions.
This additional code will be compiled into the simulation and will allow
me to provide a "compiler independent" solution which does not require
significant modification to the Ada code. We work on many systems and
do not wish to create a solution which is dependent on any one Ada
compiler. I am sure that you all know the frustration will porting Ada
from one compiler to another when it involves connections to other
languages.
If you know of any utilities or tools which will provide the information
I need about my Ada code, then please post back or email me at
<flachman@ast.lmco.com>
Right now my only solution is to hack a version of GNAT to provide the
extra symbol table information or to use lex/yacc to write my own parser
and generate the type of symbol table information I need.
Jeff Flachman <flachman@ast.lmco.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~1997-11-22 0:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-11-21 0:00 !Help - Ada/Fortran/C interface issues Jeffrey A. Flachman
1997-11-21 0:00 ` Stephen Leake
1997-11-22 0:00 ` Robert Dewar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox