GNAT: the GNU Ada Compiler

GNAT: the GNU Ada Compiler

GNAT: The GNU Ada Compiler June, 2004 Copyright (C) Javier Miranda and Edmond Schonberg [email protected], [email protected] Applied Microelectronics Research Institute University of Las Palmas de Gran Canaria Canary Islands Spain Computer Science Department New York University U.S.A. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any latter published by the Free Software Foundation; with the Invariant Sections being “GNU General Public Documentation License”, the Front-Cover text being “GNAT: The GNU Ada Compiler”, and the Back-Cover text being “Copies published by the Free Software Foundation raise funds for GNU development.” ii Contents I First Part: Introduction 7 1 The GNAT Project 9 1.1 GCC . 10 1.2 The GNAT Compiler . 10 1.3 Compilation Model . 12 1.3.1 Traditional Compilation Model . 13 1.3.2 GNAT Compilation Model . 13 1.4 Summary . 17 2 Overview of the Front-end Architecture 19 2.1 The Scanner . 19 2.2 The Parser . 20 2.2.1 The Abstract Syntax Tree . 22 2.3 The Semantic Analyzer . 24 2.4 The Expander . 27 2.5 Summary . 28 3 Error Recovery 31 3.1 Scanner Error Recovery . 31 3.1.1 Use of the Casing of Identifiers . 32 iii iv CONTENTS 3.2 Parser Error Recovery . 32 3.2.1 The Parser Scope-Stack . 33 3.2.2 Example 1: Use of indentation . 34 3.2.3 Example 2: Handling Semicolon Used in Place of 'is' . 34 3.2.4 Example 3: Handling 'is' Used in Place of Semicolon . 36 3.3 Summary . 37 II Second Part: Semantic Analysis 39 4 Scopes and Visibility 41 4.1 Flags and Data Structures . 41 4.2 Analysis of Records, Tasks and Protected Types. 45 4.3 Analysis of Packages . 46 4.4 Analysis of Private Types . 47 4.4.1 Private Entities Visibility . 48 4.4.2 Private Type Declarations . 49 4.4.3 Deferred Constants and Incomplete Types . 51 4.4.4 Limited Types . 51 4.4.5 Analysis of Child Units . 51 4.4.6 Analysis of Subunits . 52 4.5 Name Resolution . 52 4.6 Summary . 53 5 Overload Resolution 55 5.1 Resolution Algorithm . 56 5.1.1 Additional Details for the Bottom-Up Pass . 57 CONTENTS v 5.1.2 Data Structures . 59 5.1.3 Additional Details for the Top-Down Pass . 60 5.2 Summary . 61 6 Analysis of Discriminants 63 6.1 Analysis of Discriminants . 64 6.2 Analysis of Discriminants in Derived Types . 67 6.3 Discriminals . 68 6.4 Summary . 69 7 Generic Units 71 7.1 Generic Units . 72 7.1.1 Analysis of Generic Units . 72 7.1.2 Instantiation of Generic Units . 75 7.1.3 Parameter Matching . 75 7.1.4 Private Types . 80 7.2 Nested Generic Units . 80 7.2.1 Analysis of Nested Generic Units . 80 7.2.2 Instantiation of Nested Generic Units . 81 7.3 Generic Child Units . 84 7.3.1 Analysis of Generic Child Units . 84 7.3.2 Instantiation of Child Generic Units . 85 7.4 Delayed Instantiation of Bodies . 89 7.5 Detection of Instantiation Circularities . 90 7.6 Summary . 90 8 Freezing Analysis 93 vi CONTENTS 8.1 Freezing Types and Subtypes . 94 8.2 Freezing Expressions . 95 8.3 Freezing Objects . 96 8.4 Freezing Subprograms . 96 8.5 Freezing Packages . 97 8.6 Freezing Generic Units . 97 8.7 Summary . 98 III Third Part: Expansion 99 9 Expansion of Tasks 101 9.1 Task Creation . 102 9.2 Task Termination . 103 9.3 Task Abortion . 103 9.4 Expansion of Task Type Declarations . 104 9.5 Task Body Expansion . 105 9.6 Example of Task Expansion . 106 9.7 Summary . 108 10 Expansion of Rendezvous and related Constructs 109 10.1 Entry Identification . 110 10.2 Entry-Call Expansion . 110 10.2.1 Expansion of Simple Entry-Calls . 112 10.2.2 Expansion of Conditional and Timed Entry-Calls . 112 10.3 Asynchronous Transfer of Control . 113 10.3.1 ATC Implementation Models . 114 CONTENTS vii 10.3.2 Expansion of ATC . 116 10.4 Expansion of Accept Statements . 117 10.4.1 Simple Accept Expansion . 117 10.4.2 Timed and Selective Accept . 118 10.4.3 Count Attribute Expansion . 120 10.5 Summary . 120 11 Expansion of Protected Objects 121 11.1 The Proxy Model . 123 11.1.1 Implementation . 124 11.2 Expansion of Protected Types . 125 11.2.1 Expansion of Protected-Type Specification . 125 11.2.2 Expansion of Protected Subprograms . 127 11.2.3 Expansion of Entry Barriers . 129 11.2.4 Expansion of Entry bodies . 129 11.2.5 Table to Barriers and Entry-Bodies . 130 11.2.6 Expansion of Entry Families . 130 11.3 Optimizations . 130 11.4 Summary . 131 12 Expansion of Controlled-Types 133 12.1 Implementation Overview . 134 12.1.1 Exceptional Block Exit . 135 12.1.2 Finalization of Anonymous Objects . 136 12.1.3 Finalization of Dynamically Allocated Objects . 136 12.1.4 Problems Related to Mutable Objects . 137 12.1.5 Controlled Class-Wide Objects . 137 viii CONTENTS 12.2 Expansion Activities for Controlled-Types . 138 12.2.1 Expansion of Assignment . 139 12.2.2 Expansion of Anonymous Controlled Objects . 140 12.2.3 Objects with Controlled Components . 141 12.3 Summary . 143 13 Expansion of Tagged-Types 145 13.1 Tagged and Polymorphic Objects . 146 13.2 The Dispatch Table . 147 13.3 Primitive Operations . 149 13.4 Summary . 152 IV Fourth Part: Run-Time 155 14 Tasking 157 14.1 The Ada Task Control Block . 157 14.2 Task States . 158 14.3 Task Creation and Termination . 159 14.4 Run-Time Subprograms for Task Creation and Termination . 163 14.4.1 GNARL.Enter Master . 165 14.4.2 GNARL.Create Task . 165 14.4.3 GNARL.Activate Tasks . 166 14.4.4 GNARL.Tasks Wrapper . 168 14.4.5 GNARL.Complete Activation . 168 14.4.6 GNARL.Complete Task . 169 14.4.7 GNARL.Complete Master . 169 CONTENTS ix 14.5 Summary . 170 15 The Rendezvous 171 15.1 The Entry-Call Record . 172 15.2 Entries and Queues . 173 15.3 Accepted-Calls Stack . 174 15.4 Selective Accept . 174 15.5 Run-Time Rendezvous Subprograms . 176 15.5.1 GNARL.Call Simple . 176 15.5.2 GNARL.Call Synchronous . 176 15.5.3 GNARL.Task Do Or Queue . 177 15.5.4 GNARL.Task Entry Call . 177 15.5.5 GNARL.Accept Trivial . 177 15.5.6 GNARL.Accept Call . 178 15.5.7 GNARL.Complete Rendezvous . 178 15.5.8 GNARL.Exceptional Complete Rendezvous . 178 15.5.9 GNARL.Selective Wait . 179 15.5.10 GNARL.Task Count . 180 15.6 Summary . 180 16 Protected Objects 181 16.1 The Lock . ..

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    268 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us