home *** CD-ROM | disk | FTP | other *** search
/ Solo Programadores 22 / SOLO_22.iso / docs / misc / old / progress.d92 < prev    next >
Encoding:
Text File  |  1996-04-29  |  23.0 KB  |  721 lines

  1.  
  2.                          GNAT Project
  3.                     GNU-NYU Ada Translator.
  4.  
  5.                     GNAT Report 0002-921221
  6.  
  7.                       December 21, 1992
  8.  
  9. The short and the long of it.
  10. =============================
  11.  
  12. The GNAT system can now run programs through the front-end,
  13. semantic analyzer, tree transformer, GCC, and onto execution, An
  14. example follows, showing that basic control structures, arithmetic
  15. expressions, subprograms and the pragma interface all work. However
  16. gratifying this may be, we have no illusions about what a minuscule
  17. part of the work ahead this is! 
  18.  
  19. I. Briefly...
  20. =============
  21.  
  22. procedure PI (PRECISION: FLOAT) is
  23.   -- the simplest and worst algorithm for computing pi:
  24.   -- pi = 4(1 - 1/3 + 1/5 ...)
  25.  
  26.   procedure PRINT (J:FLOAT);
  27.   pragma INTERFACE (C, PRINT);
  28.  
  29.   ONE  : constant FLOAT := 0.1e1;
  30.   TWO  : constant FLOAT := ONE + ONE;
  31.   THREE: constant FLOAT := TWO + ONE;
  32.   FOUR : constant FLOAT := TWO + TWO;
  33.  
  34.   VALUE: FLOAT := TWO/THREE;
  35.   DENOM: FLOAT := FOUR + ONE;
  36.   SIGN : FLOAT := ONE;
  37.   TERM : FLOAT;
  38.  
  39. begin
  40.   while (ONE/DENOM >= PRECISION) loop
  41.     TERM  := ONE/DENOM;
  42.     VALUE := VALUE + SIGN * TERM;
  43.     SIGN  := - SIGN;
  44.     DENOM := DENOM + TWO;
  45.   end loop;
  46.  
  47.   PRINT (FOUR * VALUE);
  48. end PI;
  49.  
  50. ----------------------------------
  51. The output (it IS a lousy algorithm, and the I/O is from C):
  52.  
  53. pi = 3.141392653591791
  54. ----------------------------------
  55.  
  56.  
  57. II. In detail...
  58. ================
  59.  
  60. The syntax tree produced by the front-end is conventional, and it includes
  61. a few encodings to economize on storage. For example, parameter modes are
  62. represented as flags attached to the name of the formal, parenthesized
  63. expressions are also indicated by a flag in the expression rather than by
  64. a separate node, etc. Nodes carry their source location (as a byte offset
  65. from the beginning of the file) which is sufficient to reconstruct the
  66. source, except for comments. The subsequent semantic pass does not modify
  67. the tree, except for the addition of nodes for implicit entities. We are
  68. confident that all the information needed to implement an ASIS interface
  69. is present. The AST for the program PI follows.  
  70.  
  71.  
  72.  
  73. NYU GNAT Compiler Version 1.13
  74. (C)NYU, 1992, All Rights Reserved
  75.  
  76. Compiling: pi.ada
  77.  
  78. Tree created for compiled program
  79. ---------------------------------
  80.  
  81. Node list #1 Id = -616 (Parent = Empty)
  82. |
  83. Node #2 Id = 618 Compilation_Unit
  84.  Context_Items = Node list #3
  85.  Private_Present = False
  86.  Unit = Node #4
  87.  
  88.    Node list #3 Id = -617 (Parent = Node #2)
  89.    (Empty list)
  90.  
  91.    Node #4 Id = 629 Subprogram_Body (Parent = Node #2)
  92.     Sloc = 0 (Line number 1)
  93.     Subprogram_Specification = Node #5
  94.     Declarations = Node list #12
  95.     Handled_Statement_Sequence = Node #76
  96.     Bad_Is_Detected = False
  97.     
  98.       Node #5 Id = 628 Procedure_Specification (Parent = Node #4)
  99.        Sloc = 0 (Line number 1)
  100.        Defining_Unit_Name = Node #6
  101.        Parameter_Specifications = Node list #7
  102.        
  103.          Node #6 Id = 620/621 Defining_Identifier (Parent = Node #5)
  104.           Sloc = 10 (Line number 1)
  105.           Chars = PI
  106.           
  107.          Node list #7 Id = -623 (Parent = Node #5)
  108.          |
  109.          Node #8 Id = 624 Parameter_Specification
  110.           Defining_Identifiers = Node list #9
  111.           Parameter_Type = Node #11
  112.           Expression = Empty
  113.           In_Present = False
  114.           Out_Present = False
  115.           
  116.             Node list #9 Id = -625 (Parent = Node #8)
  117.             |
  118.             Node #10 Id = 622/626 Defining_Identifier
  119.              Sloc = 14 (Line number 1)
  120.              Chars = PRECISION
  121.              
  122.             Node #11 Id = 627 Identifier (Parent = Node #8)
  123.              Sloc = 25 (Line number 1)
  124.              Chars = FLOAT
  125.              Parens = False
  126.              
  127.       Node list #12 Id = -630 (Parent = Node #4)
  128.       |
  129.       Node #13 Id = 639 Procedure_Specification
  130.       |Sloc = 125 (Line number 5)
  131.       |Defining_Unit_Name = Node #14
  132.       |Parameter_Specifications = Node list #15
  133.       |
  134.       |  Node #14 Id = 631/632 Defining_Identifier (Parent = Node #13)
  135.       |   Sloc = 135 (Line number 5)
  136.       |   Chars = PRINT
  137.       |   
  138.       |  Node list #15 Id = -634 (Parent = Node #13)
  139.       |  |
  140.       |  Node #16 Id = 635 Parameter_Specification
  141.       |   Defining_Identifiers = Node list #17
  142.       |   Parameter_Type = Node #19
  143.       |   Expression = Empty
  144.       |   In_Present = False
  145.       |   Out_Present = False
  146.       |   
  147.       |     Node list #17 Id = -636 (Parent = Node #16)
  148.       |     |
  149.       |     Node #18 Id = 633/637 Defining_Identifier
  150.       |      Sloc = 142 (Line number 5)
  151.       |      Chars = J
  152.       |      
  153.       |     Node #19 Id = 638 Identifier (Parent = Node #16)
  154.       |      Sloc = 144 (Line number 5)
  155.       |      Chars = FLOAT
  156.       |      Parens = False
  157.       |      
  158.       Node #20 Id = 640 Pragma
  159.       |Sloc = 154 (Line number 6)
  160.       |Identifier = Node #21
  161.       |Pragma_Argument_Associations = Node list #22
  162.       |
  163.       |  Node #21 Id = 641 Identifier (Parent = Node #20)
  164.       |   Sloc = 161 (Line number 6)
  165.       |   Chars = INTERFACE
  166.       |   Parens = False
  167.       |   
  168.       |  Node list #22 Id = -642 (Parent = Node #20)
  169.       |  |
  170.       |  Node #23 Id = 644 Pragma_Argument_Association
  171.       |  |Identifier = Empty
  172.       |  |Expression = Node #24
  173.       |  |
  174.       |  |  Node #24 Id = 643 Identifier (Parent = Node #23)
  175.       |  |   Sloc = 172 (Line number 6)
  176.       |  |   Chars = C
  177.       |  |   Parens = False
  178.       |  |   
  179.       |  Node #25 Id = 646 Pragma_Argument_Association
  180.       |   Identifier = Empty
  181.       |   Expression = Node #26
  182.       |   
  183.       |     Node #26 Id = 645 Identifier (Parent = Node #25)
  184.       |      Sloc = 175 (Line number 6)
  185.       |      Chars = PRINT
  186.       |      Parens = False
  187.       |      
  188.       Node #27 Id = 651 Full_Constant_Declaration
  189.       |Sloc = 193 (Line number 8)
  190.       |Defining_Identifiers = Node list #28
  191.       |Object_Definition = Node #30
  192.       |Expression = Node #31
  193.       |Aliased_Present = False
  194.       |
  195.       |  Node list #28 Id = -648 (Parent = Node #27)
  196.       |  |
  197.       |  Node #29 Id = 647/649 Defining_Identifier
  198.       |   Sloc = 186 (Line number 8)
  199.       |   Chars = ONE
  200.       |   
  201.       |  Node #30 Id = 650 Identifier (Parent = Node #27)
  202.       |   Sloc = 202 (Line number 8)
  203.       |   Chars = FLOAT
  204.       |   Parens = False
  205.       |   
  206.       |  Node #31 Id = 652 Real_Literal (Parent = Node #27)
  207.       |   Sloc = 211 (Line number 8)
  208.       |   Numerator = 1
  209.       |   Denominator = 1
  210.       |   Parens = False
  211.       |   Decimal = True
  212.       |   
  213.       Node #32 Id = 657 Full_Constant_Declaration
  214.       |Sloc = 227 (Line number 9)
  215.       |Defining_Identifiers = Node list #33
  216.       |Object_Definition = Node #35
  217.       |Expression = Node #36
  218.       |Aliased_Present = False
  219.       |
  220.       |  Node list #33 Id = -654 (Parent = Node #32)
  221.       |  |
  222.       |  Node #34 Id = 653/655 Defining_Identifier
  223.       |   Sloc = 220 (Line number 9)
  224.       |   Chars = TWO
  225.       |   
  226.       |  Node #35 Id = 656 Identifier (Parent = Node #32)
  227.       |   Sloc = 236 (Line number 9)
  228.       |   Chars = FLOAT
  229.       |   Parens = False
  230.       |   
  231.       |  Node #36 Id = 659 Op_Add (Parent = Node #32)
  232.       |   Sloc = 249 (Line number 9)
  233.       |   Left_Opnd = Node #37
  234.       |   Right_Opnd = Node #38
  235.       |   Parens = False
  236.       |   
  237.       |     Node #37 Id = 658 Identifier (Parent = Node #36)
  238.       |      Sloc = 245 (Line number 9)
  239.       |      Chars = ONE
  240.       |      Parens = False
  241.       |      
  242.       |     Node #38 Id = 660 Identifier (Parent = Node #36)
  243.       |      Sloc = 251 (Line number 9)
  244.       |      Chars = ONE
  245.       |      Parens = False
  246.       |      
  247.       Node #39 Id = 665 Full_Constant_Declaration
  248.       |Sloc = 265 (Line number 10)
  249.       |Defining_Identifiers = Node list #40
  250.       |Object_Definition = Node #42
  251.       |Expression = Node #43
  252.       |Aliased_Present = False
  253.       |
  254.       |  Node list #40 Id = -662 (Parent = Node #39)
  255.       |  |
  256.       |  Node #41 Id = 661/663 Defining_Identifier
  257.       |   Sloc = 258 (Line number 10)
  258.       |   Chars = THREE
  259.       |   
  260.       |  Node #42 Id = 664 Identifier (Parent = Node #39)
  261.       |   Sloc = 274 (Line number 10)
  262.       |   Chars = FLOAT
  263.       |   Parens = False
  264.       |   
  265.       |  Node #43 Id = 667 Op_Add (Parent = Node #39)
  266.       |   Sloc = 287 (Line number 10)
  267.       |   Left_Opnd = Node #44
  268.       |   Right_Opnd = Node #45
  269.       |   Parens = False
  270.       |   
  271.       |     Node #44 Id = 666 Identifier (Parent = Node #43)
  272.       |      Sloc = 283 (Line number 10)
  273.       |      Chars = TWO
  274.       |      Parens = False
  275.       |      
  276.       |     Node #45 Id = 668 Identifier (Parent = Node #43)
  277.       |      Sloc = 289 (Line number 10)
  278.       |      Chars = ONE
  279.       |      Parens = False
  280.       |      
  281.       Node #46 Id = 673 Full_Constant_Declaration
  282.       |Sloc = 303 (Line number 11)
  283.       |Defining_Identifiers = Node list #47
  284.       |Object_Definition = Node #49
  285.       |Expression = Node #50
  286.       |Aliased_Present = False
  287.       |
  288.       |  Node list #47 Id = -670 (Parent = Node #46)
  289.       |  |
  290.       |  Node #48 Id = 669/671 Defining_Identifier
  291.       |   Sloc = 296 (Line number 11)
  292.       |   Chars = FOUR
  293.       |   
  294.       |  Node #49 Id = 672 Identifier (Parent = Node #46)
  295.       |   Sloc = 312 (Line number 11)
  296.       |   Chars = FLOAT
  297.       |   Parens = False
  298.       |   
  299.       |  Node #50 Id = 675 Op_Add (Parent = Node #46)
  300.       |   Sloc = 325 (Line number 11)
  301.       |   Left_Opnd = Node #51
  302.       |   Right_Opnd = Node #52
  303.       |   Parens = False
  304.       |   
  305.       |     Node #51 Id = 674 Identifier (Parent = Node #50)
  306.       |      Sloc = 321 (Line number 11)
  307.       |      Chars = TWO
  308.       |      Parens = False
  309.       |      
  310.       |     Node #52 Id = 676 Identifier (Parent = Node #50)
  311.       |      Sloc = 327 (Line number 11)
  312.       |      Chars = TWO
  313.       |      Parens = False
  314.       |      
  315.       Node #53 Id = 681 Variable_Declaration
  316.       |Defining_Identifiers = Node list #54
  317.       |Object_Definition = Node #56
  318.       |Expression = Node #57
  319.       |Aliased_Present = False
  320.       |
  321.       |  Node list #54 Id = -678 (Parent = Node #53)
  322.       |  |
  323.       |  Node #55 Id = 677/679 Defining_Identifier
  324.       |   Sloc = 335 (Line number 13)
  325.       |   Chars = VALUE
  326.       |   
  327.       |  Node #56 Id = 680 Identifier (Parent = Node #53)
  328.       |   Sloc = 342 (Line number 13)
  329.       |   Chars = FLOAT
  330.       |   Parens = False
  331.       |   
  332.       |  Node #57 Id = 683 Op_Divide (Parent = Node #53)
  333.       |   Sloc = 354 (Line number 13)
  334.       |   Left_Opnd = Node #58
  335.       |   Right_Opnd = Node #59
  336.       |   Parens = False
  337.       |   
  338.       |     Node #58 Id = 682 Identifier (Parent = Node #57)
  339.       |      Sloc = 351 (Line number 13)
  340.       |      Chars = TWO
  341.       |      Parens = False
  342.       |      
  343.       |     Node #59 Id = 684 Identifier (Parent = Node #57)
  344.       |      Sloc = 355 (Line number 13)
  345.       |      Chars = THREE
  346.       |      Parens = False
  347.       |      
  348.       Node #60 Id = 689 Variable_Declaration
  349.       |Defining_Identifiers = Node list #61
  350.       |Object_Definition = Node #63
  351.       |Expression = Node #64
  352.       |Aliased_Present = False
  353.       |
  354.       |  Node list #61 Id = -686 (Parent = Node #60)
  355.       |  |
  356.       |  Node #62 Id = 685/687 Defining_Identifier
  357.       |   Sloc = 364 (Line number 14)
  358.       |   Chars = DENOM
  359.       |   
  360.       |  Node #63 Id = 688 Identifier (Parent = Node #60)
  361.       |   Sloc = 371 (Line number 14)
  362.       |   Chars = FLOAT
  363.       |   Parens = False
  364.       |   
  365.       |  Node #64 Id = 691 Op_Add (Parent = Node #60)
  366.       |   Sloc = 385 (Line number 14)
  367.       |   Left_Opnd = Node #65
  368.       |   Right_Opnd = Node #66
  369.       |   Parens = False
  370.       |   
  371.       |     Node #65 Id = 690 Identifier (Parent = Node #64)
  372.       |      Sloc = 380 (Line number 14)
  373.       |      Chars = FOUR
  374.       |      Parens = False
  375.       |      
  376.       |     Node #66 Id = 692 Identifier (Parent = Node #64)
  377.       |      Sloc = 387 (Line number 14)
  378.       |      Chars = ONE
  379.       |      Parens = False
  380.       |      
  381.       Node #67 Id = 697 Variable_Declaration
  382.       |Defining_Identifiers = Node list #68
  383.       |Object_Definition = Node #70
  384.       |Expression = Node #71
  385.       |Aliased_Present = False
  386.       |
  387.       |  Node list #68 Id = -694 (Parent = Node #67)
  388.       |  |
  389.       |  Node #69 Id = 693/695 Defining_Identifier
  390.       |   Sloc = 394 (Line number 15)
  391.       |   Chars = SIGN
  392.       |   
  393.       |  Node #70 Id = 696 Identifier (Parent = Node #67)
  394.       |   Sloc = 401 (Line number 15)
  395.       |   Chars = FLOAT
  396.       |   Parens = False
  397.       |   
  398.       |  Node #71 Id = 698 Identifier (Parent = Node #67)
  399.       |   Sloc = 410 (Line number 15)
  400.       |   Chars = ONE
  401.       |   Parens = False
  402.       |   
  403.       Node #72 Id = 703 Variable_Declaration
  404.        Defining_Identifiers = Node list #73
  405.        Object_Definition = Node #75
  406.        Expression = Empty
  407.        Aliased_Present = False
  408.        
  409.          Node list #73 Id = -700 (Parent = Node #72)
  410.          |
  411.          Node #74 Id = 699/701 Defining_Identifier
  412.           Sloc = 417 (Line number 16)
  413.           Chars = TERM
  414.           
  415.          Node #75 Id = 702 Identifier (Parent = Node #72)
  416.           Sloc = 424 (Line number 16)
  417.           Chars = FLOAT
  418.           Parens = False
  419.           
  420.       Node #76 Id = 704 Handled_Sequence_Of_Statements (Parent = Node #4)
  421.        Statements = Node list #77
  422.        Exception_Handlers = Empty
  423.        
  424.          Node list #77 Id = -705 (Parent = Node #76)
  425.          |
  426.          Node #78 Id = 712 Loop_Statement
  427.          |Sloc = 471 (Line number 19)
  428.          |Identifier = Empty
  429.          |Iteration_Scheme = Node #79
  430.          |Statements = Node list #85
  431.          |
  432.          |  Node #79 Id = 706 Iteration_Scheme (Parent = Node #78)
  433.          |   Sloc = 440 (Line number 19)
  434.          |   Condition = Node #80
  435.          |   Loop_Parameter_Specification = Empty
  436.          |   
  437.          |     Node #80 Id = 711 Op_Ge (Parent = Node #79)
  438.          |      Sloc = 457 (Line number 19)
  439.          |      Left_Opnd = Node #81
  440.          |      Right_Opnd = Node #84
  441.          |      Parens = True
  442.          |      
  443.          |        Node #81 Id = 708 Op_Divide (Parent = Node #80)
  444.          |         Sloc = 450 (Line number 19)
  445.          |         Left_Opnd = Node #82
  446.          |         Right_Opnd = Node #83
  447.          |         Parens = False
  448.          |         
  449.          |           Node #82 Id = 707 Identifier (Parent = Node #81)
  450.          |            Sloc = 447 (Line number 19)
  451.          |            Chars = ONE
  452.          |            Parens = False
  453.          |            
  454.          |           Node #83 Id = 709 Identifier (Parent = Node #81)
  455.          |            Sloc = 451 (Line number 19)
  456.          |            Chars = DENOM
  457.          |            Parens = False
  458.          |            
  459.          |        Node #84 Id = 710 Identifier (Parent = Node #80)
  460.          |         Sloc = 460 (Line number 19)
  461.          |         Chars = PRECISION
  462.          |         Parens = False
  463.          |         
  464.          |  Node list #85 Id = -714 (Parent = Node #78)
  465.          |  |
  466.          |  Node #86 Id = 715 Assignment_Statement
  467.          |  |Sloc = 486 (Line number 20)
  468.          |  |Name = Node #87
  469.          |  |Expression = Node #88
  470.          |  |
  471.          |  |  Node #87 Id = 713 Identifier (Parent = Node #86)
  472.          |  |   Sloc = 480 (Line number 20)
  473.          |  |   Chars = TERM
  474.          |  |   Parens = False
  475.          |  |   
  476.          |  |  Node #88 Id = 717 Op_Divide (Parent = Node #86)
  477.          |  |   Sloc = 492 (Line number 20)
  478.          |  |   Left_Opnd = Node #89
  479.          |  |   Right_Opnd = Node #90
  480.          |  |   Parens = False
  481.          |  |   
  482.          |  |     Node #89 Id = 716 Identifier (Parent = Node #88)
  483.          |  |      Sloc = 489 (Line number 20)
  484.          |  |      Chars = ONE
  485.          |  |      Parens = False
  486.          |  |      
  487.          |  |     Node #90 Id = 718 Identifier (Parent = Node #88)
  488.          |  |      Sloc = 493 (Line number 20)
  489.          |  |      Chars = DENOM
  490.          |  |      Parens = False
  491.          |  |      
  492.          |  Node #91 Id = 720 Assignment_Statement
  493.          |  |Sloc = 510 (Line number 21)
  494.          |  |Name = Node #92
  495.          |  |Expression = Node #93
  496.          |  |
  497.          |  |  Node #92 Id = 719 Identifier (Parent = Node #91)
  498.          |  |   Sloc = 504 (Line number 21)
  499.          |  |   Chars = VALUE
  500.          |  |   Parens = False
  501.          |  |   
  502.          |  |  Node #93 Id = 722 Op_Add (Parent = Node #91)
  503.          |  |   Sloc = 519 (Line number 21)
  504.          |  |   Left_Opnd = Node #94
  505.          |  |   Right_Opnd = Node #95
  506.          |  |   Parens = False
  507.          |  |   
  508.          |  |     Node #94 Id = 721 Identifier (Parent = Node #93)
  509.          |  |      Sloc = 513 (Line number 21)
  510.          |  |      Chars = VALUE
  511.          |  |      Parens = False
  512.          |  |      
  513.          |  |     Node #95 Id = 724 Op_Multiply (Parent = Node #93)
  514.          |  |      Sloc = 526 (Line number 21)
  515.          |  |      Left_Opnd = Node #96
  516.          |  |      Right_Opnd = Node #97
  517.          |  |      Parens = False
  518.          |  |      
  519.          |  |        Node #96 Id = 723 Identifier (Parent = Node #95)
  520.          |  |         Sloc = 521 (Line number 21)
  521.          |  |         Chars = SIGN
  522.          |  |         Parens = False
  523.          |  |         
  524.          |  |        Node #97 Id = 725 Identifier (Parent = Node #95)
  525.          |  |         Sloc = 528 (Line number 21)
  526.          |  |         Chars = TERM
  527.          |  |         Parens = False
  528.          |  |         
  529.          |  Node #98 Id = 727 Assignment_Statement
  530.          |  |Sloc = 544 (Line number 22)
  531.          |  |Name = Node #99
  532.          |  |Expression = Node #100
  533.          |  |
  534.          |  |  Node #99 Id = 726 Identifier (Parent = Node #98)
  535.          |  |   Sloc = 538 (Line number 22)
  536.          |  |   Chars = SIGN
  537.          |  |   Parens = False
  538.          |  |   
  539.          |  |  Node #100 Id = 728 Op_Minus (Parent = Node #98)
  540.          |  |   Sloc = 547 (Line number 22)
  541.          |  |   Right_Opnd = Node #101
  542.          |  |   Parens = False
  543.          |  |   
  544.          |  |     Node #101 Id = 729 Identifier (Parent = Node #100)
  545.          |  |      Sloc = 549 (Line number 22)
  546.          |  |      Chars = SIGN
  547.          |  |      Parens = False
  548.          |  |      
  549.          |  Node #102 Id = 731 Assignment_Statement
  550.          |   Sloc = 565 (Line number 23)
  551.          |   Name = Node #103
  552.          |   Expression = Node #104
  553.          |   
  554.          |     Node #103 Id = 730 Identifier (Parent = Node #102)
  555.          |      Sloc = 559 (Line number 23)
  556.          |      Chars = DENOM
  557.          |      Parens = False
  558.          |      
  559.          |     Node #104 Id = 733 Op_Add (Parent = Node #102)
  560.          |      Sloc = 574 (Line number 23)
  561.          |      Left_Opnd = Node #105
  562.          |      Right_Opnd = Node #106
  563.          |      Parens = False
  564.          |      
  565.          |        Node #105 Id = 732 Identifier (Parent = Node #104)
  566.          |         Sloc = 568 (Line number 23)
  567.          |         Chars = DENOM
  568.          |         Parens = False
  569.          |         
  570.          |        Node #106 Id = 734 Identifier (Parent = Node #104)
  571.          |         Sloc = 576 (Line number 23)
  572.          |         Chars = TWO
  573.          |         Parens = False
  574.          |         
  575.          Node #107 Id = 740 Procedure_Call_Statement
  576.           Name = Node #108
  577.           Parameter_Associations = Node list #109
  578.           
  579.             Node #108 Id = 735 Identifier (Parent = Node #107)
  580.              Sloc = 596 (Line number 26)
  581.              Chars = PRINT
  582.              Parens = False
  583.              
  584.             Node list #109 Id = -739 (Parent = Node #107)
  585.             |
  586.             Node #110 Id = 737 Op_Multiply
  587.              Sloc = 608 (Line number 26)
  588.              Left_Opnd = Node #111
  589.              Right_Opnd = Node #112
  590.              Parens = False
  591.              
  592.                Node #111 Id = 736 Identifier (Parent = Node #110)
  593.                 Sloc = 603 (Line number 26)
  594.                 Chars = FOUR
  595.                 Parens = False
  596.                 
  597.                Node #112 Id = 738 Identifier (Parent = Node #110)
  598.                 Sloc = 610 (Line number 26)
  599.                 Chars = VALUE
  600.                 Parens = False
  601.                 
  602.  
  603.  27 lines: No errors detected
  604.  
  605.  
  606. Semantics and Translation.
  607. ==========================
  608.  
  609. The semantic analysis phase performs name resolution, type checking and
  610. overload resolution, and annotates the tree with type information and
  611. links between derived and defining occurrences of identifiers. The decorated
  612. tree is then processed by the GNAT-to-GNU converter. This processing traverses
  613. the AST and invokes tree-building routines to construct tree fragments that
  614. are immediately compiled by GCC. The result of the compilation (optimization
  615. enabled) follows. We do not yet generate constraint checks.
  616.  
  617.  
  618. The generated assembler for the SPARC.
  619. ======================================
  620. gcc2_compiled.:
  621. .data
  622.         .align 8
  623. LC0:
  624.         .double 0r1
  625. .text
  626.         .align 4
  627.         .global _PI
  628.         .proc 1
  629. _PI:
  630.         !#PROLOGUE# 0
  631.         save %sp,-176,%sp
  632.         !#PROLOGUE# 1
  633.         st %i0,[%fp+68]
  634.         st %i1,[%fp+72]
  635.         sethi %hi(LC0),%o0
  636.         ld [%o0+%lo(LC0)],%o2
  637.         ld [%o0+%lo(LC0+4)],%o3
  638.         std %o2,[%fp-24]
  639.         ldd [%fp-24],%f0
  640.         ldd [%fp-24],%f2
  641.         faddd %f0,%f2,%f0
  642.         std %f0,[%fp-32]
  643.         ldd [%fp-32],%f0
  644.         ldd [%fp-24],%f2
  645.         faddd %f0,%f2,%f0
  646.         std %f0,[%fp-40]
  647.         ldd [%fp-32],%f0
  648.         ldd [%fp-32],%f2
  649.         faddd %f0,%f2,%f0
  650.         std %f0,[%fp-48]
  651.         ldd [%fp-32],%f0
  652.         ldd [%fp-40],%f2
  653.         fdivd %f0,%f2,%f0
  654.         std %f0,[%fp-56]
  655.         ldd [%fp-48],%f0
  656.         ldd [%fp-24],%f2
  657.         faddd %f0,%f2,%f0
  658.         std %f0,[%fp-64]
  659.         ldd [%fp-24],%o0
  660.         std %o0,[%fp-72]
  661. L2:
  662.         ldd [%fp-24],%f0
  663.         ldd [%fp-64],%f2
  664.         fdivd %f0,%f2,%f0
  665.         ld [%fp+68],%f2
  666.         ld [%fp+72],%f3
  667.         fcmped %f0,%f2
  668.         nop
  669.         fbul L3
  670.         nop
  671.         ldd [%fp-24],%f0
  672.         ldd [%fp-64],%f2
  673.         fdivd %f0,%f2,%f0
  674.         std %f0,[%fp-80]
  675.         ldd [%fp-72],%f0
  676.         ldd [%fp-80],%f2
  677.         fmuld %f0,%f2,%f0
  678.         ldd [%fp-56],%f2
  679.         faddd %f2,%f0,%f0
  680.         std %f0,[%fp-56]
  681.         ldd [%fp-72],%f0
  682.         fnegs %f0,%f2
  683.         fmovs %f1,%f3
  684.         std %f2,[%fp-72]
  685.         ldd [%fp-64],%f0
  686.         ldd [%fp-32],%f2
  687.         faddd %f0,%f2,%f0
  688.         std %f0,[%fp-64]
  689.         b,a L2
  690. L3:
  691.         ldd [%fp-48],%f0
  692.         ldd [%fp-56],%f2
  693.         fmuld %f0,%f2,%f0
  694.         std %f0,[%fp-8]
  695.         ldd [%fp-8],%o0
  696.         call _PRINT,0
  697.         nop
  698. L1:
  699.         ret
  700.         restore
  701.  
  702. The C driver program.
  703. =====================
  704.  
  705. For now, the compiled Ada program is invoked from a C routine, which is
  706. also used to transmit scalar parameters to the program.
  707.  
  708. #include <stdio.h>
  709. main ()
  710. {
  711.   PI(0.0001);
  712. }
  713.  
  714. PRINT (double x)
  715. {
  716.   printf ("pi = %.15f \n", x);
  717. }
  718.  
  719.  
  720.  
  721.