home *** CD-ROM | disk | FTP | other *** search
/ RISC DISC 1 / RISC_DISC_1.iso / pd_share / code / ada / !Ada / doc / adaed next >
Encoding:
Text File  |  1994-08-28  |  16.2 KB  |  505 lines

  1. ADAED - 4 August 1992, NYU Ada Group, Unix Programmer's Manual
  2.  
  3. NAME
  4.  
  5. adaed - NYU translator and interpreter for the Ada programming language
  6.  
  7. SYNOPSIS
  8.  
  9.  adacomp [ option ] ... `file'
  10.  adabind [ option ]
  11.  adaexec [ option ]
  12.  adalib  [ -l `library' ]
  13.  
  14. DESCRIPTION
  15.  
  16. Adaed is a translator/interpreter for the Ada programming language
  17. that is intended primarily for educational use. 
  18.  
  19. Adacomp compiles an Ada program; it invokes in succession the two
  20. compilation phases: parsing and semantic analysis (the front end), and code
  21. generation. The `file' argument refers to the source file; if it contains no
  22. suffix the Ada source is assumed to be in `file.ada'. It may be a full path
  23. name. The output of the compiler is an instruction stream for an abstract
  24. Ada machine, which is subsequently interpreted.
  25.  
  26. Adabind binds a given `library' with the specified `main_unit' to form an
  27. executable program.
  28.  
  29. Adaexec invokes the Ada machine interpreter for the bound program given in
  30. the specified library.
  31.  
  32. Adalib is a utility that enables the user to examine the contents of the
  33. specified library.
  34.  
  35. Note: all options must precede the file name for `adacomp' and must be in
  36. lower case.
  37.  
  38. LIBRARY
  39.  
  40. All compilations require a library.
  41.  
  42. A library is a subdirectory, which is created or reinitialized when the user
  43. invokes a command containing `-n' option, such as:
  44.  
  45.     adacomp -n -l libname adafile
  46.  
  47. Intermediate files appear in subdirectory `libname'. 
  48.  
  49. This directory is created by the command if it does not already exist. Only
  50. the listing files are created in the directory from which `adacomp' is
  51. invoked. 
  52.  
  53. The `libname' directory should be used to hold files created by the `adaed'
  54. commands only (i.e. those produced by the Ada/Ed system); confusion and
  55. grief may result if you attempt to use a library directory to hold other
  56. files. The `libname' argument may be a full path name.
  57.  
  58. If the environment variable ADALIB is defined, its value is used as a
  59. default library and the `-l' option (including its `libname' argument) to
  60. `adacomp, adabind, adaexec,' and `Iadalib' can be omitted.
  61.  
  62. A given utility library, UL (e.g. one that contains mathematical functions)
  63. may be used by several unrelated programs. It may then be convenient to
  64. create independent libraries for each program, and initialize each library 
  65. with the contents of UL. This can be done simply by creating directories for
  66. each library, and copying the contents of UL into each of these.
  67.  
  68. OPTIONS
  69.  
  70. The options for `adacomp' are as follows:
  71.  
  72.  -a Generates instructions for use by the interpreter (`adaexec' command) to
  73.     trace the Ada source lines. Used in conjunction with the `-t a' option of
  74.     `adaexec'.
  75.  
  76.  -b Indicates that the binding of the library is to be performed if the
  77.     current compilation is completed without errors.
  78.  
  79.  -g Specifies that the compiler is to produce a listing of the generated 
  80.     instructions for the Ada machine (of little interest to most users).
  81.  
  82.  -i x
  83.     This is an option to the binder and is relevant only if the `-b' option
  84.     is used.
  85.  
  86. See options for `adabind' below.
  87.  
  88.  -l library
  89.     Uses the specified library to satisfy references to compilation units
  90.     not present in the file being compiled. If the compilation is successful,
  91.     the units defined in the file are added to the library. If this option
  92.     is not specified explicitly, a default library is implicitly defined by
  93.     the ADALIB environment variable.
  94.  
  95.  -m unit_name
  96.     This is an option to the binder and is relevant only if the `-b' option
  97.     is used.
  98.  
  99. See options for `adabind' below.
  100.  
  101.  -n Indicates that a new library is to be created for this compilation. The
  102.     name of the library is indicated by the `-l' option or through the
  103.     ADALIB environment variable. The `-n' option must be specified if the
  104.     library referenced by the `-l' option (or the ADALIB environment variable)
  105.     does not already exist or must be reinitialized.
  106.  
  107.  -s Produces a listing of the source file. The name of the listing file is 
  108.     the input file name prefix with suffix `.lis'. By default, no listing
  109.     file is generated unless there are warnings, errors or informational
  110.     messages to report.
  111.  
  112.  -v Gives a (verbose) descriptive trace showing the subsidiary programs
  113.     invoked by the `adacomp' command, the options and arguments passed to them,     and their exit status. This is used primarily for system checkout.
  114.  
  115. The options for `adabind' are as follows:
  116.  
  117.  -l library
  118.     Specifies the library which together with the main unit will produce a
  119.     bound program which can be executed by `adaexec'. If this option is not
  120.     specified explicitly, a default library is implicitly defined by the
  121.     ADALIB environment variable.
  122.  
  123.  -m unit_name
  124.     Specifies the name of the unit which is to serve as a main program. When
  125.     the library contains only one main program (which must be a parameterless
  126.     procedure) this option is not needed.
  127.  
  128.  -i x
  129.     To be used for programs that use `pragma' INTERFACE. `x' designates the
  130.     non-Ada interfaced procedures and may be
  131.  
  132.     a) the name of an object file, created by the user, of the form
  133.        `filename.o' (that appears in the same directory as the Ada program);
  134.   or
  135.  
  136.     b) an abbreviation for the library '/lib/lib`x'.a'. If that does not exist
  137.        then '/usr/lib/lib`x'.a' is searched. This library is unrelated to the
  138.        Ada program library referenced by the various `adaed' commands, and
  139.        generally refers to a standard library provided for another programming
  140.        language. This option may be used as many times as necessary, providing
  141.        that each use represents only a single file or library. Thus, 
  142.        `adabind -i a.o -i b.o -i lib ...' is acceptable, while
  143.        `adabind -i a.o b.o lib ...' is not. To use this option, the environment
  144.        variable INT must be set to point to the directory containing the file
  145.        `adaint' (see the Setup file or your system manager). Usage examples
  146.        appear below.
  147.  
  148. The options for `adaexec' are as follows:
  149.  
  150.  -l library
  151.     Specifies the library which contains the bound program to be executed.
  152.     If this option is not specified explicitly, a default library is
  153.     implicitly defined by the ADALIB environment variable.
  154.  
  155.  -m bound_main_unit
  156.     Specifies the name of the bound main unit, i.e. the main unit
  157.     that was specified to `adabind', or `adacomp'. Note that a given
  158.     library may have been bound several times with different main units.
  159.     When the library has been bound with only one main unit, this option
  160.     is not needed.
  161.  
  162.  -h heap_size
  163.     Specify the size of the heap increment in kilowords, by which the heap is
  164.     expanded when the elaboration of a new entity requires it. The heap expands
  165.     to fill available memory. The default increment is 128. This parameter
  166.     limits the size of the largest object that can be created in a program.
  167.  
  168.  
  169.  -p p_size
  170.     Specifies the size in bytes of the program stack size for the main task.
  171.     The default is 10000. Argument values in the range 1..31 are multiplied
  172.     by 1024 to obtain the stack size in bytes. The maximum value is 32767.
  173.  
  174.  -s t_size
  175.     Specifies the size in bytes of the stack size for each new task. The
  176.     default is 10000. Argument values in the range 1..31 are multiplied by
  177.     1024 to obtain the stack size in bytes. Use of small stack sizes may be
  178.     appropriate when executing programs with many tasks, each of which can
  179.     run with a small stack. The maximum value is 32767.
  180.  
  181.  -r number_of_stmts (an integer)
  182.     Invoke a 'round-robin' scheduling policy instead of the 'run-until-block'
  183.     default scheduling policy and specify the maximum number of interpreted
  184.     statements that a given task can execute before switching to another
  185.     task (the minimum value is 1).
  186.  
  187.  -t trace_options
  188.     Specify one or more of the following letters indicating the kind of
  189.     trace(s) requested for the execution of the program.
  190.  
  191.     a    (Ada line)
  192.          Display the source line numbers. This requires that the program be
  193.          compiled with the `-a' option.
  194.  
  195.     c    (calls) 
  196.          Display the name of each subprogram as it is entered and exited.
  197.  
  198.     e    (exceptions)
  199.          Display the name of each exception as it is raised.
  200.  
  201.     r    (rendezvous)
  202.          Trace each rendezvous.
  203.  
  204.     s    (switches)
  205.          Display context switches between tasks.
  206.  
  207.     t    (tasks)
  208.          Display task creation, activation, and termination.
  209.  
  210.  
  211. EXAMPLES
  212.  
  213. The following examples show typical usage:
  214.  
  215. 1) Compile t1.ada into a new library called testlib and bind the library;
  216.    then execute it.The listing is written to t1.lis. Note that `-s' is used
  217.    to force a listing file to be created.
  218.  
  219.     adacomp -s -nl testlib -b t1
  220.  
  221.     adaexec -l testlib
  222.  
  223. 2) Compile a package specification in p.spc and corresponding body in p.bod
  224.    into a new library called tstlib. Then compile t2.ada into the same
  225.    library, bind the main program, and execute it
  226.  
  227.     adacomp -nl tstlib p.spc
  228.  
  229.     adacomp -l tstlib p.bod
  230.  
  231.     adacomp -l tstlib -b t2
  232.  
  233.     adaexec -l tstlib
  234.  
  235. 3) In the example above, the binding could be done in a separate phase. This
  236.    is achieved by replacing the third command above with:
  237.  
  238.     adacomp -l tstlib t2
  239.  
  240.     adabind -l tstlib
  241.  
  242. 4) Example 2 above could be done without explicitly specifying the library
  243.    by setting the environment variable ADALIB, as follows:
  244.  
  245.     setenv ADALIB my_default_directory
  246.  
  247.     adacomp -n p.spc
  248.  
  249.     adacomp p.bod
  250.  
  251.     adacomp -b t2
  252.  
  253.     adaexec
  254.  
  255. 5) Compile a program with line numbers included in the generated code.
  256.    Execute it displaying Ada source line numbers as they are encountered.
  257.  
  258.     adacomp -a -nl libname -b t1
  259.  
  260.     adaexec -t a -l libname 
  261.  
  262. 6) Compile a program with two parameterless procedures (potential main
  263.    programs) which are named MAIN1 and MAIN2 in files p1.ada and p2.ada
  264.    respectively, and bind the library tstlib using MAIN1 as the main
  265.    program.
  266.  
  267.     adacomp -nl tstlib p1
  268.  
  269.     adacomp -l tstlib p2
  270.  
  271.     adabind -m main1 -l tstlib
  272.  
  273.     adaexec -l tstlib
  274.  
  275. 7) Suppose we wish to add another program to the library tstlib (created in 
  276.    Example 6) whose main program unit is named MAIN3 and appears in file
  277.    p3.ada. The following commands will compile and execute MAIN3. As tstlib
  278.    was previously bound with MAIN1 as a main unit, it is now necessary to
  279.    use the `-m' option to adaexec in order to select the desired bound main
  280.    unit.
  281.  
  282.     adacomp -l tstlib p3
  283.  
  284.     adabind -m main3 -l tstlib
  285.  
  286.     adaexec -m main3 -l tstlib
  287.  
  288. 8) The contents of the library above can be examined by:
  289.  
  290.     adalib -l tstlib
  291.  
  292. Adalib writes the name, type and compilation date of each unit in the
  293. specified library to standard output. In addition, it writes the current
  294. status (active or obsolete) of each unit. Units which may be main programs
  295. are noted by "(Main)"; if there is more than one such unit, the `-m' option to
  296. adabind must be specified during binding. Libraries that have been bound
  297. will contain at least one unit labeled "binding unit". If several of these
  298. are active, the `-m' option must be specified for adaexec.
  299.  
  300.  
  301. PRAGMA INTERFACE
  302.  
  303. Pragma interface (LRM 13.9) is currently supported for interfacing to
  304. subprograms written in FORTRAN or C.
  305.  
  306. Arguments to interfaced procedures must be one of the following types:
  307.  
  308. For C: integer, float, access, array, record, and enumeration types.
  309. For FORTRAN: integer, float and array.
  310.  
  311. The return types available are integer and float.
  312.  
  313. Following are sample Ada programs that are interfaced to subprograms coded
  314. in FORTRAN and C, together with the code for the interfaced subprograms:
  315.  
  316. 1) Interface to FORTRAN
  317.  
  318.  
  319.  This is a source file called `func.f' which contains two functions to be used
  320.  in an Ada program with pragma INTERFACE.
  321.  
  322.      function sqr(x)
  323.      sqr = x*x
  324.      return
  325.      end
  326.  
  327.      function cube(x)
  328.      cube = x*x*x
  329.      return
  330.      end
  331.  
  332.  -- Assume that the following are the contents of file `fortlib.ada'. 
  333.  -- It contains a compilation unit that defines two functions which are 
  334.  -- interfaced to the above routines.
  335.  
  336.  package FORTRAN_LIB is
  337.      function SQR(X:FLOAT) return FLOAT;
  338.      function CUBE(X:FLOAT) return FLOAT;
  339.  private
  340.      pragma INTERFACE(FORTRAN, SQR);
  341.      pragma INTERFACE(FORTRAN, CUBE);
  342.  end FORTRAN_LIB;
  343.  
  344.  with FORTRAN_LIB, TEXT_IO; use FORTRAN_LIB, TEXT_IO;
  345.  procedure TEST is
  346.     function SQRT(X : FLOAT) return FLOAT;
  347.     pragma INTERFACE(C,SQRT);
  348.     package MY_FLOAT_IO is new FLOAT_IO(FLOAT); use MY_FLOAT_IO;
  349.  begin
  350.      PUT(SQR(2.0));
  351.      NEW_LINE;
  352.      PUT(CUBE(2.0));
  353.      NEW_LINE;
  354.      PUT(SQRT(2.0));
  355.      NEW_LINE;
  356.  end TEST;
  357.  
  358. To compile and execute, enter the following commands:
  359.  
  360.     f77 -c func.f
  361.  
  362.     adacomp -nl testlib -b -i func.o fortlib
  363.  
  364.     adaexec -l testlib
  365.  
  366. The output will be:
  367.  4.00000E+00
  368.  8.00000E+00
  369.  1.41421E+00
  370.  
  371. One of the demo programs illustrates how one can use pragma interface
  372. to build a library of mathematical functions from those provided by the
  373. system.
  374.  
  375. 2) Interface to C
  376.  
  377.  
  378. /*
  379.  * Source file proc.c contains procedures PRINTA and PRINTS1 called by
  380.  * the Ada program above.
  381.  */
  382.  printa(ara)
  383.  int ara[];
  384.  {
  385.     int i;
  386.     for (i=0;i<10;i++) {
  387.        printf("%d ",ara[i]);
  388.     }
  389.     printf("\\n");
  390.  }
  391.  
  392. prints1(ara,len)
  393.  int ara[];
  394.  int len;
  395.  {
  396.     int i;
  397.     for (i=0;i<len;i++) {
  398.         printf("%c",ara[i]);
  399.     }
  400.     printf("\\n");
  401.  }
  402.  
  403. -- Assume that file `test_interface.ada' contains the following program:
  404.  procedure C_INTERFACES is
  405.      type ARA10 is array(1..10) of INTEGER;
  406.      A10: ARA10 := (1,2,3,4,5,6,7,8,9,10);
  407.  
  408.      procedure PRINTA(A:ARA10);
  409.      -- PRINTA prints an array of 10 elements of type INTEGER
  410.      pragma INTERFACE(C, PRINTA);
  411.  
  412.      procedure PRINTS1(A:STRING; LEN: INTEGER);
  413.      -- PRINTS1 prints an array of LEN elements of type CHARACTER
  414.      pragma INTERFACE(C, PRINTS1);
  415.  
  416.      procedure PRINTS(A:STRING) is
  417.      -- This routine prints a string by passing the string and its length
  418.      -- to the routine PRINTS1 which is written in C.
  419.      begin
  420.          PRINTS1(A, A'length);
  421.      end;
  422.  
  423.  begin
  424.     PRINTA(A10);
  425.     PRINTS("this is any string");
  426.  end;
  427.  
  428.  
  429. To compile and execute, enter the following:
  430.  
  431.     cc -c proc.c
  432.  
  433.     adacomp -i proc.o -nl testlib -b test_interface
  434.  
  435.     adaexec -l testlib 
  436.  
  437. The resulting output is as follows:
  438.  
  439.  1 2 3 4 5 6 7 8 9 10
  440.  this is any string
  441.  
  442.  
  443. ENVIRONMENT
  444.  
  445. The environment variable ADALIB contains the name of the library used if
  446. none is specified on the command line.
  447.  
  448. Normally the executables called by adacomp and the predefined libraries are
  449. in a directory built into the system. The directory containing these can be
  450. specified by the environment variable ADAED which overrides the built in
  451. directory name.
  452.  
  453. The location of individual components called by adacomp or the location of
  454. the predefined libraries can be overridden with the following environment
  455. variables:
  456.  
  457.   ADAFRONT    - For the front end, adafront;
  458.   GEN         - For the code generator, adagen;
  459.   BND         - For the binder, adabind;  and
  460.   ADAEDPREDEF - For the predefined libraries." 
  461.  
  462. FILES
  463.  
  464. file.ada    Ada source file
  465. adaint        partially built interpreter (used for pragma interface)
  466. predef.axq    symbol table for predef
  467. predef.trc    tree file for predef
  468. predef.lib    library for predef
  469.  
  470. DIAGNOSTICS
  471.  
  472. Adaed commands return an exit code of 0 in the case of success, and nonzero
  473. otherwise. An error code of 1 indicates errors in usage of the Ada language,
  474. 2 is returned if there is an internal Adaed system error, and 3 denotes some
  475. invalid usage of the Adaed system. Error messages regarding invalid system
  476. usage are directed to the standard error file. Ada language related messages
  477. detected at compilation are written to the listing file, while those
  478. detected by adabind or adaexec appear on standard output.
  479.  
  480. Note, that an error in a given compilation unit may cause subsequent
  481. compilation units (within the same compilation) not to be recognized.
  482.  
  483. AUTHORS
  484.  
  485. Ada/Ed-C was written by the following members of the NYU Ada Project:
  486. Bernard Banner, Jerome Chiabaut, Robert Dewar, Anne Dinning, Alain Lauque,
  487. Gail Schenker Morgulis, Brett Porter, Jean-Pierre Rosen, Edmond Schonberg,
  488. David Shields, Brian Siritzky, Franck Triplet.
  489.  
  490. BUGS
  491.  
  492. We give absolutley no warranty as to the correctness of the system. It was
  493. designed strictly for teaching purposes. Currently it is unvalidated although 
  494. we hope to put it in a validatable shape in the near future.
  495.  
  496. Any compilation or execution that terminates abnormally with mention of 
  497. "internal error" has uncovered a bug that should be reported to the NYU Ada
  498. group.
  499.  
  500. NYUADA project
  501. New York University
  502. 251 Mercer Street
  503. New York, N.Y. 10012
  504. (212) 998 \- 3480
  505.