| 1 |
------------------------------------------------------------------------------ |
| 2 |
-- -- |
| 3 |
-- GNAT COMPILER COMPONENTS -- |
| 4 |
-- -- |
| 5 |
-- E X P _ C H 4 -- |
| 6 |
-- -- |
| 7 |
-- S p e c -- |
| 8 |
-- -- |
| 9 |
-- Copyright (C) 1992-2025, Free Software Foundation, Inc. -- |
| 10 |
-- -- |
| 11 |
-- GNAT is free software; you can redistribute it and/or modify it under -- |
| 12 |
-- terms of the GNU General Public License as published by the Free Soft- -- |
| 13 |
-- ware Foundation; either version 3, or (at your option) any later ver- -- |
| 14 |
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- |
| 15 |
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- |
| 16 |
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- |
| 17 |
-- for more details. You should have received a copy of the GNU General -- |
| 18 |
-- Public License distributed with GNAT; see file COPYING3. If not, go to -- |
| 19 |
-- http://www.gnu.org/licenses for a complete copy of the license. -- |
| 20 |
-- -- |
| 21 |
-- GNAT was originally developed by the GNAT team at New York University. -- |
| 22 |
-- Extensive contributions were provided by Ada Core Technologies Inc. -- |
| 23 |
-- -- |
| 24 |
------------------------------------------------------------------------------ |
| 25 |
|
| 26 |
-- Expand routines for chapter 4 constructs |
| 27 |
|
| 28 |
with Types; use Types; |
| 29 |
|
| 30 |
package Exp_Ch4 is |
| 31 |
|
| 32 |
procedure Expand_N_Allocator (N : Node_Id); |
| 33 |
procedure Expand_N_And_Then (N : Node_Id); |
| 34 |
procedure Expand_N_Case_Expression (N : Node_Id); |
| 35 |
procedure Expand_N_Explicit_Dereference (N : Node_Id); |
| 36 |
procedure Expand_N_Expression_With_Actions (N : Node_Id); |
| 37 |
procedure Expand_N_If_Expression (N : Node_Id); |
| 38 |
procedure Expand_N_In (N : Node_Id); |
| 39 |
procedure Expand_N_Indexed_Component (N : Node_Id); |
| 40 |
procedure Expand_N_Not_In (N : Node_Id); |
| 41 |
procedure Expand_N_Null (N : Node_Id); |
| 42 |
procedure Expand_N_Op_Abs (N : Node_Id); |
| 43 |
procedure Expand_N_Op_Add (N : Node_Id); |
| 44 |
procedure Expand_N_Op_And (N : Node_Id); |
| 45 |
procedure Expand_N_Op_Concat (N : Node_Id); |
| 46 |
procedure Expand_N_Op_Divide (N : Node_Id); |
| 47 |
procedure Expand_N_Op_Expon (N : Node_Id); |
| 48 |
procedure Expand_N_Op_Eq (N : Node_Id); |
| 49 |
procedure Expand_N_Op_Ge (N : Node_Id); |
| 50 |
procedure Expand_N_Op_Gt (N : Node_Id); |
| 51 |
procedure Expand_N_Op_Le (N : Node_Id); |
| 52 |
procedure Expand_N_Op_Lt (N : Node_Id); |
| 53 |
procedure Expand_N_Op_Minus (N : Node_Id); |
| 54 |
procedure Expand_N_Op_Mod (N : Node_Id); |
| 55 |
procedure Expand_N_Op_Multiply (N : Node_Id); |
| 56 |
procedure Expand_N_Op_Ne (N : Node_Id); |
| 57 |
procedure Expand_N_Op_Not (N : Node_Id); |
| 58 |
procedure Expand_N_Op_Or (N : Node_Id); |
| 59 |
procedure Expand_N_Op_Plus (N : Node_Id); |
| 60 |
procedure Expand_N_Op_Rem (N : Node_Id); |
| 61 |
procedure Expand_N_Op_Rotate_Left (N : Node_Id); |
| 62 |
procedure Expand_N_Op_Rotate_Right (N : Node_Id); |
| 63 |
procedure Expand_N_Op_Shift_Left (N : Node_Id); |
| 64 |
procedure Expand_N_Op_Shift_Right (N : Node_Id); |
| 65 |
procedure Expand_N_Op_Shift_Right_Arithmetic (N : Node_Id); |
| 66 |
procedure Expand_N_Op_Subtract (N : Node_Id); |
| 67 |
procedure Expand_N_Op_Xor (N : Node_Id); |
| 68 |
procedure Expand_N_Or_Else (N : Node_Id); |
| 69 |
procedure Expand_N_Qualified_Expression (N : Node_Id); |
| 70 |
procedure Expand_N_Quantified_Expression (N : Node_Id); |
| 71 |
procedure Expand_N_Selected_Component (N : Node_Id); |
| 72 |
procedure Expand_N_Slice (N : Node_Id); |
| 73 |
procedure Expand_N_Type_Conversion (N : Node_Id); |
| 74 |
procedure Expand_N_Unchecked_Type_Conversion (N : Node_Id); |
| 75 |
|
| 76 |
function Build_Cleanup_For_Allocator |
| 77 |
(Loc : Source_Ptr; |
| 78 |
Obj_Id : Entity_Id; |
| 79 |
Pool : Entity_Id; |
| 80 |
Actions : List_Id) return Node_Id; |
| 81 |
-- Build a cleanup for the list of Actions that will deallocate the memory |
| 82 |
-- allocated in Pool and designated by Obj_Id if the execution of Actions |
| 83 |
-- raises an exception. |
| 84 |
|
| 85 |
function Build_Eq_Call |
| 86 |
(Typ : Entity_Id; |
| 87 |
Loc : Source_Ptr; |
| 88 |
Lhs : Node_Id; |
| 89 |
Rhs : Node_Id) return Node_Id; |
| 90 |
-- AI05-0123: Locate primitive equality for type if it exists, and build |
| 91 |
-- the corresponding call. If operation is abstract, replace call with |
| 92 |
-- an explicit raise. Return Empty if there is no primitive. |
| 93 |
-- Used in the construction of record-equality routines for records here |
| 94 |
-- and for variant records in exp_ch3.adb. These two paths are distinct |
| 95 |
-- for historical but also technical reasons: for variant records the |
| 96 |
-- constructed function includes a case statement with nested returns, |
| 97 |
-- while for records without variants only a simple expression is needed. |
| 98 |
|
| 99 |
function Expand_Record_Equality |
| 100 |
(Nod : Node_Id; |
| 101 |
Typ : Entity_Id; |
| 102 |
Lhs : Node_Id; |
| 103 |
Rhs : Node_Id) return Node_Id; |
| 104 |
-- Expand a record equality into an expression that compares the fields |
| 105 |
-- individually to yield the required Boolean result. Loc is the |
| 106 |
-- location for the generated nodes. Typ is the type of the record, and |
| 107 |
-- Lhs, Rhs are the record expressions to be compared, these |
| 108 |
-- expressions need not be analyzed but have to be side-effect-free. |
| 109 |
-- Nod provides the Sloc value for generated code. |
| 110 |
|
| 111 |
procedure Expand_Set_Membership (N : Node_Id); |
| 112 |
-- For each choice of a set membership, we create a simple equality or |
| 113 |
-- membership test. The whole membership is rewritten connecting these |
| 114 |
-- with OR ELSE. |
| 115 |
|
| 116 |
procedure Expand_Unchecked_Union_Equality (N : Node_Id); |
| 117 |
-- Expand a call to the predefined equality operator of an unchecked union |
| 118 |
-- type, possibly rewriting it as a raise statement. |
| 119 |
|
| 120 |
function Integer_Promotion_Possible (N : Node_Id) return Boolean; |
| 121 |
-- Returns true if the node is a type conversion whose operand is an |
| 122 |
-- arithmetic operation on signed integers, and the base type of the |
| 123 |
-- signed integer type is smaller than Standard.Integer. In such case we |
| 124 |
-- have special circuitry in Expand_N_Type_Conversion to promote both of |
| 125 |
-- the operands to type Integer. |
| 126 |
|
| 127 |
end Exp_Ch4; |