2005-11-14 Robert Dewar <dewar@adacore.com> * a-secain.adb, a-slcain.adb, a-shcain.adb, a-chtgke.ads, a-chtgke.adb, a-stwiha.adb, a-strhas.adb, a-chzla1.ads, a-chzla9.ads, a-stzbou.adb, a-stzbou.ads, a-stzfix.adb, a-stzhas.adb, a-stzmap.adb, a-stzmap.ads, a-stzsea.adb, a-stzsea.ads, a-stzsup.adb, a-stzsup.ads, a-stzunb.adb, a-stzunb.ads, a-szuzha.adb, a-szuzha.ads, a-szuzti.adb, a-szuzti.ads, a-ztcoau.adb, a-ztcoau.ads, a-ztcoio.adb, a-ztcstr.adb, a-ztcstr.ads, a-ztdeau.adb, a-ztdeau.ads, a-ztdeio.adb, a-ztdeio.ads, a-ztedit.adb, a-ztedit.ads, a-ztenau.ads, a-ztenio.adb, a-ztenio.ads, a-ztexio.adb, a-ztexio.ads, a-ztfiio.adb, a-ztfiio.ads, a-ztflau.adb, a-ztflau.ads, a-ztflio.adb, a-ztflio.ads, a-ztgeau.adb, a-ztgeau.ads, a-ztinau.adb, a-ztinau.ads, a-ztinio.adb, a-ztmoau.ads, a-ztmoio.adb, a-ztmoio.ads, a-zttest.adb, g-enblsp-vms-alpha.adb, g-enblsp-vms-alpha.adb, g-enblsp-vms-ia64.adb, g-enblsp-vms-ia64.adb, system-linux-hppa.ads, a-chacon.adb, a-chacon.ads, a-wichun.adb, a-wichun.ads, a-zchuni.adb, a-zchuni.ads, g-trasym-vms-alpha.adb, g-trasym-vms-ia64.adb, system-hpux-ia64.ads, g-soccon-unixware.ads, g-soliop-unixware.ads, g-soccon-interix.ads, g-soliop-solaris.ads, g-eacodu-vms.adb, g-expect-vms.adb, g-socthi-vms.adb, g-soliop-mingw.ads, a-intnam-unixware.ads, a-intnam-lynxos.ads, a-intnam-tru64.ads, a-intnam-aix.ads, a-intnam-linux.ads, a-intnam-linux.ads, a-intnam-dummy.ads, a-numaux-libc-x86.ads, a-intnam-interix.ads, a-intnam-solaris.ads, a-calend-vms.adb, a-calend-vms.ads, a-intnam-vms.ads, a-calend-mingw.adb, a-intnam-mingw.ads, a-intnam-vxworks.ads, a-numaux-vxworks.ads, system-unixware.ads, system-linux-ia64.ads, a-intnam-freebsd.ads, system-freebsd-x86.ads, system-lynxos-ppc.ads, system-linux-x86_64.ads, a-stunha.adb, a-cgaaso.ads, a-cgaaso.adb, a-chtgop.adb, a-cgcaso.adb, a-cgarso.adb, a-cohata.ads, a-crbtgk.adb, a-crbltr.ads, a-coprnu.adb, a-rbtgso.adb, a-intnam-darwin.ads, system-darwin-ppc.ads, gprmake.adb, makegpr.ads, system-tru64.ads, system-aix.ads, system-solaris-x86.ads, system-irix-o32.ads, s-interr-sigaction.adb, system-irix-n32.ads, s-parame-mingw.adb, system-hpux.ads, s-traceb-hpux.adb, system-linux-x86.ads, s-inmaop-dummy.adb, system-os2.ads, system-interix.ads, system-solaris-sparc.ads, system-solaris-sparcv9.ads, s-inmaop-vms.adb, s-mastop-vms.adb, expander.adb, expander.ads, s-gloloc-mingw.adb, system-mingw.ads, system-vms-zcx.ads, s-osinte-fsu.adb, s-traceb-mastop.adb, a-exextr.adb, a-exstat.adb, a-filico.ads, a-finali.ads, a-interr.ads, a-intsig.adb, a-intsig.ads, a-except.ads, a-numaux-x86.ads, a-astaco.adb, a-calend.adb, a-calend.ads, a-chahan.adb, a-chahan.ads, a-chlat9.ads, a-colien.adb, a-colien.ads, a-colire.adb, a-colire.ads, a-comlin.adb, a-comlin.ads, a-cwila1.ads, a-cwila9.ads, a-elchha.adb, a-decima.adb, a-decima.ads, a-diocst.ads, a-direio.adb, a-direio.ads, a-excach.adb, a-excach.adb, a-exctra.ads, ali-util.adb, a-ngcefu.adb, a-ngcoty.adb, a-ngcoty.ads, a-nudira.adb, a-nudira.ads, a-nuflra.adb, a-numaux.ads, a-reatim.ads, a-sequio.adb, a-sequio.ads, a-siocst.ads, a-ssicst.ads, a-stmaco.ads, a-storio.adb, a-strbou.adb, a-strbou.ads, a-stream.ads, a-strfix.adb, a-strmap.adb, a-strmap.ads, a-strsea.adb, a-strsea.ads, a-strsup.adb, a-strsup.ads, a-strunb.adb, a-strunb.ads, a-stwibo.adb, a-stwibo.ads, a-stwifi.adb, a-stwima.adb, a-stwima.ads, a-stwise.adb, a-stwise.ads, a-stwisu.adb, a-stwisu.ads, a-stwiun.adb, a-stwiun.ads, a-suteio.adb, a-suteio.ads, a-swmwco.ads, a-swuwti.adb, a-swuwti.ads, a-sytaco.adb, a-sytaco.ads, a-tasatt.adb, a-taside.adb, a-taside.ads, a-teioed.adb, a-textio.adb, a-textio.ads, a-ticoau.adb, a-ticoau.ads, a-ticoio.adb, a-tideau.adb, a-tideio.adb, a-tienau.adb, a-tienio.adb, a-tifiio.adb, a-tiflio.adb, a-tigeau.adb, a-tigeau.ads, a-tiinau.adb, a-tiinio.adb, a-timoau.adb, a-timoio.adb, a-timoio.ads, a-tiocst.ads, a-titest.adb, atree.adb, a-witeio.adb, a-witeio.ads, a-wtcoau.adb, a-wtcoau.ads, a-wtcoio.adb, a-wtcstr.ads, a-wtdeau.adb, a-wtdeio.adb, a-wtedit.adb, a-wtedit.ads, a-wtenau.adb, a-wtenio.adb, a-wtfiio.adb, a-wtflio.adb, a-wtgeau.adb, a-wtinau.adb, a-wtinio.adb, a-wtmoau.adb, a-wtmoio.adb, a-wttest.adb, back_end.adb, bindgen.adb, butil.adb, butil.ads, checks.ads, cio.c, comperr.adb, csets.ads, cstand.adb, debug.ads, elists.ads, errno.c, errout.adb, errout.ads, erroutc.adb, erroutc.ads, errutil.adb, errutil.ads, errutil.ads, err_vars.ads, eval_fat.adb, exp_ch11.adb, exp_ch11.ads, exp_ch2.adb, exp_ch7.ads, exp_imgv.ads, exp_pakd.adb, exp_prag.adb, exp_prag.ads, exp_tss.adb, exp_tss.ads, exp_vfpt.ads, fe.h, fmap.adb, freeze.ads, frontend.adb, frontend.ads, g-arrspl.adb, g-arrspl.ads, g-awk.adb, g-awk.ads, g-boumai.ads, g-calend.adb, g-calend.ads, g-catiio.adb, g-comlin.adb, g-comlin.ads, g-comlin.ads, g-comlin.ads, g-comver.adb, g-crc32.adb, g-crc32.ads, g-ctrl_c.ads, g-curexc.ads, g-debpoo.ads, g-debuti.adb, g-diopit.adb, g-diopit.ads, g-dirope.adb, g-dirope.ads, g-dyntab.adb, g-dyntab.ads, g-excact.adb, g-excact.ads, g-except.ads, g-exctra.adb, g-exctra.ads, g-expect.ads, g-flocon.ads, g-hesorg.ads, g-io.adb, g-locfil.ads, g-md5.adb, g-md5.ads, g-md5.ads, g-moreex.adb, g-signal.ads, g-signal.adb, gnatbind.ads, gnatchop.adb, gnatcmd.adb, gnatfind.adb, gnatlbr.adb, gnatmake.ads, gnatmem.adb, gnatprep.adb, gnatprep.ads, gnatsym.adb, gnatxref.adb, g-os_lib.adb, g-os_lib.ads, g-pehage.adb, g-pehage.ads, gprep.ads, g-regexp.adb, g-regexp.ads, g-regist.adb, g-regist.ads, g-regpat.ads, g-semaph.adb, g-socthi.adb, g-soliop.ads, g-spipat.adb, g-spipat.ads, g-sptabo.ads, g-sptain.ads, g-sptavs.ads, g-string.ads, g-tasloc.adb, g-tasloc.ads, g-trasym.adb, g-trasym.ads, i-fortra.adb, i-fortra.ads, inline.adb, layout.adb, live.adb, make.ads, makeutl.ads, makeutl.adb, mdll-fil.adb, mdll-fil.ads, mdll-utl.ads, memroot.ads, memtrack.adb, mlib.ads, mlib-fil.adb, mlib-fil.ads, mlib-prj.ads, mlib-utl.adb, mlib-utl.ads, nlists.adb, nlists.ads, osint.adb, osint.ads, osint-c.adb, osint-l.adb, osint-l.ads, osint-m.ads, output.adb, par.adb, par.adb, par.ads, par-ch11.adb, par-ch12.adb, par-ch2.adb, par-ch4.adb, par-ch5.adb, par-ch6.adb, par-ch9.adb, par-endh.adb, par-labl.adb, par-load.adb, par-tchk.adb, prep.adb, prepcomp.adb, prepcomp.ads, prj-attr.ads, prj-com.ads, prj-dect.adb, prj-dect.ads, prj-env.ads, prj-err.ads, prj-ext.ads, prj-makr.adb, prj-makr.ads, prj-nmsc.ads, prj-pars.adb, prj-pars.ads, prj-part.ads, prj-pp.ads, prj-proc.ads, prj-strt.adb, prj-strt.ads, prj-tree.adb, prj-util.adb, prj-util.ads, rtsfind.adb, sem.adb, sem.ads, sem_case.adb, sem_case.ads, sem_ch11.adb, sem_ch4.adb, sem_ch6.ads, sem_ch7.ads, sem_dist.ads, sem_elab.ads, sem_elim.ads, sem_eval.ads, sem_intr.ads, sem_maps.adb, sem_maps.ads, sem_maps.ads, sem_res.ads, sem_type.ads, sfn_scan.adb, sfn_scan.ads, s-imgwch.ads, s-imgwiu.adb, s-imgwiu.ads, s-inmaop.ads, sinput.adb, sinput.ads, s-pack03.adb, s-pack03.ads, s-pack05.adb, s-pack05.ads, s-pack06.adb, s-pack06.ads, s-pack07.adb, s-pack07.ads, s-pack09.adb, s-pack09.ads, s-pack10.adb, s-pack10.ads, s-pack11.adb, s-pack11.ads, s-pack12.adb, s-pack12.ads, s-pack13.adb, s-pack13.ads, s-pack14.adb, s-pack14.ads, s-pack15.adb, s-pack15.ads, s-pack17.adb, s-pack17.ads, s-pack18.adb, s-pack18.ads, s-pack19.adb, s-pack19.ads, s-pack20.adb, s-pack20.ads, s-pack21.adb, s-pack21.ads, s-pack22.adb, s-pack22.ads, s-pack23.adb, s-pack23.ads, s-pack24.adb, s-pack24.ads, s-pack25.adb, s-pack25.ads, s-pack26.adb, s-pack26.ads, s-pack27.adb, s-pack27.ads, s-pack28.adb, s-pack28.ads, s-pack29.adb, s-pack29.ads, s-pack30.adb, s-pack30.ads, s-pack31.adb, s-pack31.ads, s-pack33.adb, s-pack33.ads, s-pack34.adb, s-pack34.ads, s-pack35.adb, s-pack35.ads, s-pack36.adb, s-pack36.ads, s-pack37.adb, s-pack37.ads, s-pack38.adb, s-pack38.ads, s-pack39.adb, s-pack39.ads, s-pack40.adb, s-pack40.ads, s-pack41.adb, s-pack41.ads, s-pack42.adb, s-pack42.ads, s-pack43.adb, s-pack43.ads, s-pack44.adb, s-pack44.ads, s-pack45.adb, s-pack45.ads, s-pack46.adb, s-pack46.ads, s-pack47.adb, s-pack47.ads, s-pack48.adb, s-pack48.ads, s-pack49.adb, s-pack49.ads, s-pack50.adb, s-pack50.ads, s-pack51.adb, s-pack51.ads, s-pack52.adb, s-pack52.ads, s-pack53.adb, s-pack53.ads, s-pack54.adb, s-pack54.ads, s-pack55.adb, s-pack55.ads, s-pack56.adb, s-pack56.ads, s-pack57.adb, s-pack57.ads, s-pack58.adb, s-pack58.ads, s-pack59.adb, s-pack59.ads, s-pack60.adb, s-pack60.adb, s-pack60.ads, s-pack61.adb, s-pack61.ads, s-pack62.adb, s-pack62.ads, s-pack63.adb, s-pack63.ads, s-parint.adb, s-parint.adb, s-parint.ads, sprint.ads, s-purexc.ads, s-restri.ads, s-restri.adb, s-scaval.adb, s-scaval.ads, s-secsta.adb, s-secsta.ads, s-sequio.adb, s-sequio.ads, stand.ads, s-tasuti.adb, s-traceb.adb, s-traceb.ads, stringt.adb, stringt.ads, styleg.ads, s-valboo.adb, s-valboo.ads, s-valcha.adb, s-valcha.ads, s-valdec.adb, s-valdec.ads, s-valint.adb, s-valint.ads, s-valint.ads, s-vallld.adb, s-vallld.ads, s-vallli.adb, s-vallli.ads, s-valllu.adb, s-valllu.ads, s-valrea.adb, s-valrea.ads, s-valuns.adb, s-valuns.ads, s-valuti.adb, s-valuti.ads, s-valwch.ads, s-veboop.adb, s-veboop.ads, s-vercon.adb, s-vercon.ads, s-wchcnv.adb, s-wchcnv.ads, s-wchcon.ads, s-wchjis.adb, s-wchjis.ads, s-wchstw.adb, s-wchstw.adb, s-wchstw.ads, s-wchwts.adb, s-wchwts.ads, s-widboo.adb, s-widboo.ads, s-widcha.adb, s-widcha.ads, s-widenu.adb, s-widenu.ads, s-widlli.adb, s-widlli.ads, s-widllu.adb, s-widllu.ads, s-widwch.adb, s-widwch.ads, s-wwdcha.adb, s-wwdcha.ads, s-wwdenu.adb, s-wwdenu.ads, symbols.adb, symbols.ads, table.ads, targparm.adb, targparm.ads, tb-alvms.c, tb-alvxw.c, tbuild.adb, tree_io.ads, treepr.adb, treeprs.adt, ttypef.ads, ttypes.ads, types.adb, uintp.adb, uintp.ads, uname.ads, urealp.ads, usage.ads, validsw.ads, vxaddr2line.adb, widechar.adb, widechar.ads, xeinfo.adb, xnmake.adb, xref_lib.ads, xr_tabls.adb, xr_tabls.ads, xsinfo.adb, xtreeprs.adb, xsnames.adb, vms_conv.ads, vms_conv.adb, a-dirval.ads, a-dirval.adb, a-dirval-mingw.adb, a-direct.ads, a-direct.adb, indepsw.ads, prj-attr-pm.ads, system-linux-ppc.ads, a-numaux-darwin.ads, a-numaux-darwin.adb, a-swuwha.ads, a-stunha.ads: Minor reformatting From-SVN: r107016
634 lines
18 KiB
Ada
634 lines
18 KiB
Ada
------------------------------------------------------------------------------
|
|
-- --
|
|
-- GNAT COMPILER COMPONENTS --
|
|
-- --
|
|
-- T B U I L D --
|
|
-- --
|
|
-- B o d y --
|
|
-- --
|
|
-- Copyright (C) 1992-2005, Free Software Foundation, Inc. --
|
|
-- --
|
|
-- GNAT is free software; you can redistribute it and/or modify it under --
|
|
-- terms of the GNU General Public License as published by the Free Soft- --
|
|
-- ware Foundation; either version 2, or (at your option) any later ver- --
|
|
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
|
|
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
|
|
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
|
|
-- for more details. You should have received a copy of the GNU General --
|
|
-- Public License distributed with GNAT; see file COPYING. If not, write --
|
|
-- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
|
|
-- Boston, MA 02110-1301, USA. --
|
|
-- --
|
|
-- GNAT was originally developed by the GNAT team at New York University. --
|
|
-- Extensive contributions were provided by Ada Core Technologies Inc. --
|
|
-- --
|
|
------------------------------------------------------------------------------
|
|
|
|
with Atree; use Atree;
|
|
with Einfo; use Einfo;
|
|
with Elists; use Elists;
|
|
with Lib; use Lib;
|
|
with Namet; use Namet;
|
|
with Nlists; use Nlists;
|
|
with Nmake; use Nmake;
|
|
with Restrict; use Restrict;
|
|
with Rident; use Rident;
|
|
with Sinfo; use Sinfo;
|
|
with Snames; use Snames;
|
|
with Stand; use Stand;
|
|
with Stringt; use Stringt;
|
|
with Uintp; use Uintp;
|
|
|
|
package body Tbuild is
|
|
|
|
-----------------------
|
|
-- Local Subprograms --
|
|
-----------------------
|
|
|
|
procedure Add_Unique_Serial_Number;
|
|
-- Add a unique serialization to the string in the Name_Buffer. This
|
|
-- consists of a unit specific serial number, and b/s for body/spec.
|
|
|
|
------------------------------
|
|
-- Add_Unique_Serial_Number --
|
|
------------------------------
|
|
|
|
procedure Add_Unique_Serial_Number is
|
|
Unit_Node : constant Node_Id := Unit (Cunit (Current_Sem_Unit));
|
|
|
|
begin
|
|
Add_Nat_To_Name_Buffer (Increment_Serial_Number);
|
|
|
|
-- Add either b or s, depending on whether current unit is a spec
|
|
-- or a body. This is needed because we may generate the same name
|
|
-- in a spec and a body otherwise.
|
|
|
|
Name_Len := Name_Len + 1;
|
|
|
|
if Nkind (Unit_Node) = N_Package_Declaration
|
|
or else Nkind (Unit_Node) = N_Subprogram_Declaration
|
|
or else Nkind (Unit_Node) in N_Generic_Declaration
|
|
then
|
|
Name_Buffer (Name_Len) := 's';
|
|
else
|
|
Name_Buffer (Name_Len) := 'b';
|
|
end if;
|
|
end Add_Unique_Serial_Number;
|
|
|
|
----------------
|
|
-- Checks_Off --
|
|
----------------
|
|
|
|
function Checks_Off (N : Node_Id) return Node_Id is
|
|
begin
|
|
return
|
|
Make_Unchecked_Expression (Sloc (N),
|
|
Expression => N);
|
|
end Checks_Off;
|
|
|
|
----------------
|
|
-- Convert_To --
|
|
----------------
|
|
|
|
function Convert_To (Typ : Entity_Id; Expr : Node_Id) return Node_Id is
|
|
Result : Node_Id;
|
|
|
|
begin
|
|
if Present (Etype (Expr))
|
|
and then (Etype (Expr)) = Typ
|
|
then
|
|
return Relocate_Node (Expr);
|
|
else
|
|
Result :=
|
|
Make_Type_Conversion (Sloc (Expr),
|
|
Subtype_Mark => New_Occurrence_Of (Typ, Sloc (Expr)),
|
|
Expression => Relocate_Node (Expr));
|
|
|
|
Set_Etype (Result, Typ);
|
|
return Result;
|
|
end if;
|
|
end Convert_To;
|
|
|
|
------------------
|
|
-- Discard_List --
|
|
------------------
|
|
|
|
procedure Discard_List (L : List_Id) is
|
|
pragma Warnings (Off, L);
|
|
begin
|
|
null;
|
|
end Discard_List;
|
|
|
|
------------------
|
|
-- Discard_Node --
|
|
------------------
|
|
|
|
procedure Discard_Node (N : Node_Or_Entity_Id) is
|
|
pragma Warnings (Off, N);
|
|
begin
|
|
null;
|
|
end Discard_Node;
|
|
|
|
-------------------------------------------
|
|
-- Make_Byte_Aligned_Attribute_Reference --
|
|
-------------------------------------------
|
|
|
|
function Make_Byte_Aligned_Attribute_Reference
|
|
(Sloc : Source_Ptr;
|
|
Prefix : Node_Id;
|
|
Attribute_Name : Name_Id)
|
|
return Node_Id
|
|
is
|
|
N : constant Node_Id :=
|
|
Make_Attribute_Reference (Sloc,
|
|
Prefix => Prefix,
|
|
Attribute_Name => Attribute_Name);
|
|
|
|
begin
|
|
pragma Assert (Attribute_Name = Name_Address
|
|
or else
|
|
Attribute_Name = Name_Unrestricted_Access);
|
|
Set_Must_Be_Byte_Aligned (N, True);
|
|
return N;
|
|
end Make_Byte_Aligned_Attribute_Reference;
|
|
|
|
--------------------
|
|
-- Make_DT_Access --
|
|
--------------------
|
|
|
|
function Make_DT_Access
|
|
(Loc : Source_Ptr;
|
|
Rec : Node_Id;
|
|
Typ : Entity_Id) return Node_Id
|
|
is
|
|
Full_Type : Entity_Id := Typ;
|
|
|
|
begin
|
|
if Is_Private_Type (Typ) then
|
|
Full_Type := Underlying_Type (Typ);
|
|
end if;
|
|
|
|
return
|
|
Unchecked_Convert_To (
|
|
New_Occurrence_Of
|
|
(Etype (Node (First_Elmt (Access_Disp_Table (Full_Type)))), Loc),
|
|
Make_Selected_Component (Loc,
|
|
Prefix => New_Copy (Rec),
|
|
Selector_Name =>
|
|
New_Reference_To (First_Tag_Component (Full_Type), Loc)));
|
|
end Make_DT_Access;
|
|
|
|
--------------------------------
|
|
-- Make_Implicit_If_Statement --
|
|
--------------------------------
|
|
|
|
function Make_Implicit_If_Statement
|
|
(Node : Node_Id;
|
|
Condition : Node_Id;
|
|
Then_Statements : List_Id;
|
|
Elsif_Parts : List_Id := No_List;
|
|
Else_Statements : List_Id := No_List) return Node_Id
|
|
is
|
|
begin
|
|
Check_Restriction (No_Implicit_Conditionals, Node);
|
|
|
|
return Make_If_Statement (Sloc (Node),
|
|
Condition,
|
|
Then_Statements,
|
|
Elsif_Parts,
|
|
Else_Statements);
|
|
end Make_Implicit_If_Statement;
|
|
|
|
-------------------------------------
|
|
-- Make_Implicit_Label_Declaration --
|
|
-------------------------------------
|
|
|
|
function Make_Implicit_Label_Declaration
|
|
(Loc : Source_Ptr;
|
|
Defining_Identifier : Node_Id;
|
|
Label_Construct : Node_Id) return Node_Id
|
|
is
|
|
N : constant Node_Id :=
|
|
Make_Implicit_Label_Declaration (Loc, Defining_Identifier);
|
|
begin
|
|
Set_Label_Construct (N, Label_Construct);
|
|
return N;
|
|
end Make_Implicit_Label_Declaration;
|
|
|
|
----------------------------------
|
|
-- Make_Implicit_Loop_Statement --
|
|
----------------------------------
|
|
|
|
function Make_Implicit_Loop_Statement
|
|
(Node : Node_Id;
|
|
Statements : List_Id;
|
|
Identifier : Node_Id := Empty;
|
|
Iteration_Scheme : Node_Id := Empty;
|
|
Has_Created_Identifier : Boolean := False;
|
|
End_Label : Node_Id := Empty) return Node_Id
|
|
is
|
|
begin
|
|
Check_Restriction (No_Implicit_Loops, Node);
|
|
|
|
if Present (Iteration_Scheme)
|
|
and then Present (Condition (Iteration_Scheme))
|
|
then
|
|
Check_Restriction (No_Implicit_Conditionals, Node);
|
|
end if;
|
|
|
|
return Make_Loop_Statement (Sloc (Node),
|
|
Identifier => Identifier,
|
|
Iteration_Scheme => Iteration_Scheme,
|
|
Statements => Statements,
|
|
Has_Created_Identifier => Has_Created_Identifier,
|
|
End_Label => End_Label);
|
|
end Make_Implicit_Loop_Statement;
|
|
|
|
--------------------------
|
|
-- Make_Integer_Literal --
|
|
---------------------------
|
|
|
|
function Make_Integer_Literal
|
|
(Loc : Source_Ptr;
|
|
Intval : Int) return Node_Id
|
|
is
|
|
begin
|
|
return Make_Integer_Literal (Loc, UI_From_Int (Intval));
|
|
end Make_Integer_Literal;
|
|
|
|
--------------------------------
|
|
-- Make_Linker_Section_Pragma --
|
|
--------------------------------
|
|
|
|
function Make_Linker_Section_Pragma
|
|
(Ent : Entity_Id;
|
|
Loc : Source_Ptr;
|
|
Sec : String) return Node_Id
|
|
is
|
|
LS : Node_Id;
|
|
|
|
begin
|
|
LS :=
|
|
Make_Pragma
|
|
(Loc,
|
|
Name_Linker_Section,
|
|
New_List
|
|
(Make_Pragma_Argument_Association
|
|
(Sloc => Loc,
|
|
Expression => New_Occurrence_Of (Ent, Loc)),
|
|
Make_Pragma_Argument_Association
|
|
(Sloc => Loc,
|
|
Expression =>
|
|
Make_String_Literal
|
|
(Sloc => Loc,
|
|
Strval => Sec))));
|
|
|
|
Set_Has_Gigi_Rep_Item (Ent);
|
|
return LS;
|
|
end Make_Linker_Section_Pragma;
|
|
|
|
---------------------------------
|
|
-- Make_Raise_Constraint_Error --
|
|
---------------------------------
|
|
|
|
function Make_Raise_Constraint_Error
|
|
(Sloc : Source_Ptr;
|
|
Condition : Node_Id := Empty;
|
|
Reason : RT_Exception_Code) return Node_Id
|
|
is
|
|
begin
|
|
pragma Assert (Reason in RT_CE_Exceptions);
|
|
return
|
|
Make_Raise_Constraint_Error (Sloc,
|
|
Condition => Condition,
|
|
Reason =>
|
|
UI_From_Int (RT_Exception_Code'Pos (Reason)));
|
|
end Make_Raise_Constraint_Error;
|
|
|
|
------------------------------
|
|
-- Make_Raise_Program_Error --
|
|
------------------------------
|
|
|
|
function Make_Raise_Program_Error
|
|
(Sloc : Source_Ptr;
|
|
Condition : Node_Id := Empty;
|
|
Reason : RT_Exception_Code) return Node_Id
|
|
is
|
|
begin
|
|
pragma Assert (Reason in RT_PE_Exceptions);
|
|
return
|
|
Make_Raise_Program_Error (Sloc,
|
|
Condition => Condition,
|
|
Reason =>
|
|
UI_From_Int (RT_Exception_Code'Pos (Reason)));
|
|
end Make_Raise_Program_Error;
|
|
|
|
------------------------------
|
|
-- Make_Raise_Storage_Error --
|
|
------------------------------
|
|
|
|
function Make_Raise_Storage_Error
|
|
(Sloc : Source_Ptr;
|
|
Condition : Node_Id := Empty;
|
|
Reason : RT_Exception_Code) return Node_Id
|
|
is
|
|
begin
|
|
pragma Assert (Reason in RT_SE_Exceptions);
|
|
return
|
|
Make_Raise_Storage_Error (Sloc,
|
|
Condition => Condition,
|
|
Reason =>
|
|
UI_From_Int (RT_Exception_Code'Pos (Reason)));
|
|
end Make_Raise_Storage_Error;
|
|
|
|
-------------------------
|
|
-- Make_String_Literal --
|
|
-------------------------
|
|
|
|
function Make_String_Literal
|
|
(Sloc : Source_Ptr;
|
|
Strval : String) return Node_Id
|
|
is
|
|
begin
|
|
Start_String;
|
|
Store_String_Chars (Strval);
|
|
return
|
|
Make_String_Literal (Sloc,
|
|
Strval => End_String);
|
|
end Make_String_Literal;
|
|
|
|
---------------------------
|
|
-- Make_Unsuppress_Block --
|
|
---------------------------
|
|
|
|
-- Generates the following expansion:
|
|
|
|
-- declare
|
|
-- pragma Suppress (<check>);
|
|
-- begin
|
|
-- <stmts>
|
|
-- end;
|
|
|
|
function Make_Unsuppress_Block
|
|
(Loc : Source_Ptr;
|
|
Check : Name_Id;
|
|
Stmts : List_Id) return Node_Id
|
|
is
|
|
begin
|
|
return
|
|
Make_Block_Statement (Loc,
|
|
Declarations => New_List (
|
|
Make_Pragma (Loc,
|
|
Chars => Name_Suppress,
|
|
Pragma_Argument_Associations => New_List (
|
|
Make_Pragma_Argument_Association (Loc,
|
|
Expression => Make_Identifier (Loc, Check))))),
|
|
|
|
Handled_Statement_Sequence =>
|
|
Make_Handled_Sequence_Of_Statements (Loc,
|
|
Statements => Stmts));
|
|
end Make_Unsuppress_Block;
|
|
|
|
--------------------------
|
|
-- New_Constraint_Error --
|
|
--------------------------
|
|
|
|
function New_Constraint_Error (Loc : Source_Ptr) return Node_Id is
|
|
Ident_Node : Node_Id;
|
|
Raise_Node : Node_Id;
|
|
|
|
begin
|
|
Ident_Node := New_Node (N_Identifier, Loc);
|
|
Set_Chars (Ident_Node, Chars (Standard_Entity (S_Constraint_Error)));
|
|
Set_Entity (Ident_Node, Standard_Entity (S_Constraint_Error));
|
|
Raise_Node := New_Node (N_Raise_Statement, Loc);
|
|
Set_Name (Raise_Node, Ident_Node);
|
|
return Raise_Node;
|
|
end New_Constraint_Error;
|
|
|
|
-----------------------
|
|
-- New_External_Name --
|
|
-----------------------
|
|
|
|
function New_External_Name
|
|
(Related_Id : Name_Id;
|
|
Suffix : Character := ' ';
|
|
Suffix_Index : Int := 0;
|
|
Prefix : Character := ' ') return Name_Id
|
|
is
|
|
begin
|
|
Get_Name_String (Related_Id);
|
|
|
|
if Prefix /= ' ' then
|
|
pragma Assert (Is_OK_Internal_Letter (Prefix));
|
|
|
|
for J in reverse 1 .. Name_Len loop
|
|
Name_Buffer (J + 1) := Name_Buffer (J);
|
|
end loop;
|
|
|
|
Name_Len := Name_Len + 1;
|
|
Name_Buffer (1) := Prefix;
|
|
end if;
|
|
|
|
if Suffix /= ' ' then
|
|
pragma Assert (Is_OK_Internal_Letter (Suffix));
|
|
Name_Len := Name_Len + 1;
|
|
Name_Buffer (Name_Len) := Suffix;
|
|
end if;
|
|
|
|
if Suffix_Index /= 0 then
|
|
if Suffix_Index < 0 then
|
|
Add_Unique_Serial_Number;
|
|
else
|
|
Add_Nat_To_Name_Buffer (Suffix_Index);
|
|
end if;
|
|
end if;
|
|
|
|
return Name_Find;
|
|
end New_External_Name;
|
|
|
|
function New_External_Name
|
|
(Related_Id : Name_Id;
|
|
Suffix : String;
|
|
Suffix_Index : Int := 0;
|
|
Prefix : Character := ' ') return Name_Id
|
|
is
|
|
begin
|
|
Get_Name_String (Related_Id);
|
|
|
|
if Prefix /= ' ' then
|
|
pragma Assert (Is_OK_Internal_Letter (Prefix));
|
|
|
|
for J in reverse 1 .. Name_Len loop
|
|
Name_Buffer (J + 1) := Name_Buffer (J);
|
|
end loop;
|
|
|
|
Name_Len := Name_Len + 1;
|
|
Name_Buffer (1) := Prefix;
|
|
end if;
|
|
|
|
if Suffix /= "" then
|
|
Name_Buffer (Name_Len + 1 .. Name_Len + Suffix'Length) := Suffix;
|
|
Name_Len := Name_Len + Suffix'Length;
|
|
end if;
|
|
|
|
if Suffix_Index /= 0 then
|
|
if Suffix_Index < 0 then
|
|
Add_Unique_Serial_Number;
|
|
else
|
|
Add_Nat_To_Name_Buffer (Suffix_Index);
|
|
end if;
|
|
end if;
|
|
|
|
return Name_Find;
|
|
end New_External_Name;
|
|
|
|
function New_External_Name
|
|
(Suffix : Character;
|
|
Suffix_Index : Nat) return Name_Id
|
|
is
|
|
begin
|
|
Name_Buffer (1) := Suffix;
|
|
Name_Len := 1;
|
|
Add_Nat_To_Name_Buffer (Suffix_Index);
|
|
return Name_Find;
|
|
end New_External_Name;
|
|
|
|
-----------------------
|
|
-- New_Internal_Name --
|
|
-----------------------
|
|
|
|
function New_Internal_Name (Id_Char : Character) return Name_Id is
|
|
begin
|
|
pragma Assert (Is_OK_Internal_Letter (Id_Char));
|
|
Name_Buffer (1) := Id_Char;
|
|
Name_Len := 1;
|
|
Add_Unique_Serial_Number;
|
|
return Name_Enter;
|
|
end New_Internal_Name;
|
|
|
|
-----------------------
|
|
-- New_Occurrence_Of --
|
|
-----------------------
|
|
|
|
function New_Occurrence_Of
|
|
(Def_Id : Entity_Id;
|
|
Loc : Source_Ptr) return Node_Id
|
|
is
|
|
Occurrence : Node_Id;
|
|
|
|
begin
|
|
Occurrence := New_Node (N_Identifier, Loc);
|
|
Set_Chars (Occurrence, Chars (Def_Id));
|
|
Set_Entity (Occurrence, Def_Id);
|
|
|
|
if Is_Type (Def_Id) then
|
|
Set_Etype (Occurrence, Def_Id);
|
|
else
|
|
Set_Etype (Occurrence, Etype (Def_Id));
|
|
end if;
|
|
|
|
return Occurrence;
|
|
end New_Occurrence_Of;
|
|
|
|
----------------------
|
|
-- New_Reference_To --
|
|
----------------------
|
|
|
|
function New_Reference_To
|
|
(Def_Id : Entity_Id;
|
|
Loc : Source_Ptr) return Node_Id
|
|
is
|
|
Occurrence : Node_Id;
|
|
|
|
begin
|
|
Occurrence := New_Node (N_Identifier, Loc);
|
|
Set_Chars (Occurrence, Chars (Def_Id));
|
|
Set_Entity (Occurrence, Def_Id);
|
|
return Occurrence;
|
|
end New_Reference_To;
|
|
|
|
-----------------------
|
|
-- New_Suffixed_Name --
|
|
-----------------------
|
|
|
|
function New_Suffixed_Name
|
|
(Related_Id : Name_Id;
|
|
Suffix : String) return Name_Id
|
|
is
|
|
begin
|
|
Get_Name_String (Related_Id);
|
|
Name_Len := Name_Len + 1;
|
|
Name_Buffer (Name_Len) := '_';
|
|
Name_Buffer (Name_Len + 1 .. Name_Len + Suffix'Length) := Suffix;
|
|
Name_Len := Name_Len + Suffix'Length;
|
|
return Name_Find;
|
|
end New_Suffixed_Name;
|
|
|
|
-------------------
|
|
-- OK_Convert_To --
|
|
-------------------
|
|
|
|
function OK_Convert_To (Typ : Entity_Id; Expr : Node_Id) return Node_Id is
|
|
Result : Node_Id;
|
|
begin
|
|
Result :=
|
|
Make_Type_Conversion (Sloc (Expr),
|
|
Subtype_Mark => New_Occurrence_Of (Typ, Sloc (Expr)),
|
|
Expression => Relocate_Node (Expr));
|
|
Set_Conversion_OK (Result, True);
|
|
Set_Etype (Result, Typ);
|
|
return Result;
|
|
end OK_Convert_To;
|
|
|
|
--------------------------
|
|
-- Unchecked_Convert_To --
|
|
--------------------------
|
|
|
|
function Unchecked_Convert_To
|
|
(Typ : Entity_Id;
|
|
Expr : Node_Id) return Node_Id
|
|
is
|
|
Loc : constant Source_Ptr := Sloc (Expr);
|
|
Result : Node_Id;
|
|
|
|
begin
|
|
-- If the expression is already of the correct type, then nothing
|
|
-- to do, except for relocating the node in case this is required.
|
|
|
|
if Present (Etype (Expr))
|
|
and then (Base_Type (Etype (Expr)) = Typ
|
|
or else Etype (Expr) = Typ)
|
|
then
|
|
return Relocate_Node (Expr);
|
|
|
|
-- Cases where the inner expression is itself an unchecked conversion
|
|
-- to the same type, and we can thus eliminate the outer conversion.
|
|
|
|
elsif Nkind (Expr) = N_Unchecked_Type_Conversion
|
|
and then Entity (Subtype_Mark (Expr)) = Typ
|
|
then
|
|
Result := Relocate_Node (Expr);
|
|
|
|
elsif Nkind (Expr) = N_Null
|
|
and then Is_Access_Type (Typ)
|
|
then
|
|
-- No need for a conversion
|
|
|
|
Result := Relocate_Node (Expr);
|
|
|
|
-- All other cases
|
|
|
|
else
|
|
Result :=
|
|
Make_Unchecked_Type_Conversion (Loc,
|
|
Subtype_Mark => New_Occurrence_Of (Typ, Loc),
|
|
Expression => Relocate_Node (Expr));
|
|
end if;
|
|
|
|
Set_Etype (Result, Typ);
|
|
return Result;
|
|
end Unchecked_Convert_To;
|
|
|
|
end Tbuild;
|