From patchwork Wed Jun 23 06:51:30 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 56596 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 26F1FB6F01 for ; Wed, 23 Jun 2010 16:51:39 +1000 (EST) Received: (qmail 6311 invoked by alias); 23 Jun 2010 06:51:36 -0000 Received: (qmail 6300 invoked by uid 22791); 23 Jun 2010 06:51:34 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL, BAYES_00, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mel.act-europe.fr (HELO mel.act-europe.fr) (212.99.106.210) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 23 Jun 2010 06:51:27 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 9CE9FCB0281; Wed, 23 Jun 2010 08:51:30 +0200 (CEST) Received: from mel.act-europe.fr ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id YseNEu3lxezh; Wed, 23 Jun 2010 08:51:30 +0200 (CEST) Received: from saumur.act-europe.fr (saumur.act-europe.fr [10.10.0.183]) by mel.act-europe.fr (Postfix) with ESMTP id 8A4D1CB027F; Wed, 23 Jun 2010 08:51:30 +0200 (CEST) Received: by saumur.act-europe.fr (Postfix, from userid 525) id 72582D9AB0; Wed, 23 Jun 2010 08:51:30 +0200 (CEST) Date: Wed, 23 Jun 2010 08:51:30 +0200 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Javier Miranda Subject: [Ada] Avoid dependency of package Atree on package Scil_ll Message-ID: <20100623065130.GA23360@adacore.com> Mime-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.9i X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org This patch does not affect the functionality of the compiler. Done to avoid compilation dependency of package Atree on the new package Scil_ll. Tested on x86_64-pc-linux-gnu, committed on trunk 2010-06-23 Javier Miranda * atree.ads (Set_Reporting_Proc): New subprogram. * atree.adb: Remove dependency on packages Opt and SCIL_LL. (Allocate_Initialize_Node, Replace, Rewrite): Replace direct calls to routines of package Scil_ll by indirect call to the registered subprogram. (Set_Reporting_Proc): New subprogram. Used to register a subprogram that is invoked when a node is allocated, replaced or rewritten. * scil_ll.adb (Copy_SCIL_Node): New routine that takes care of copying the SCIL node. Used as argument for Set_Reporting_Proc. (Initialize): Register Copy_SCIL_Node as the reporting routine that is invoked by atree. Index: atree.adb =================================================================== --- atree.adb (revision 161244) +++ atree.adb (working copy) @@ -38,14 +38,15 @@ pragma Style_Checks (All_Checks); with Debug; use Debug; with Nlists; use Nlists; -with Opt; use Opt; with Output; use Output; with Sinput; use Sinput; -with SCIL_LL; use SCIL_LL; with Tree_IO; use Tree_IO; package body Atree is + Reporting_Proc : Report_Proc := null; + -- Record argument to last call to Set_Reporting_Proc + --------------- -- Debugging -- --------------- @@ -534,10 +535,10 @@ package body Atree is Orig_Nodes.Set_Last (Nodes.Last); Allocate_List_Tables (Nodes.Last); - -- Update the SCIL_Node field (if available) + -- Invoke the reporting procedure (if available) - if Generate_SCIL then - Set_SCIL_Node (New_Id, Get_SCIL_Node (Src)); + if Reporting_Proc /= null then + Reporting_Proc.all (Target => New_Id, Source => Src); end if; return New_Id; @@ -925,6 +926,16 @@ package body Atree is return Ekind_In (Ekind (E), V1, V2, V3, V4, V5, V6); end Ekind_In; + ------------------------ + -- Set_Reporting_Proc -- + ------------------------ + + procedure Set_Reporting_Proc (P : Report_Proc) is + begin + pragma Assert (Reporting_Proc = null); + Reporting_Proc := P; + end Set_Reporting_Proc; + ------------------ -- Error_Posted -- ------------------ @@ -1580,10 +1591,10 @@ package body Atree is Orig_Nodes.Table (Old_Node) := Old_Node; - -- Update the SCIL_Node field (if available) + -- Invoke the reporting procedure (if available) - if Generate_SCIL then - Set_SCIL_Node (Old_Node, Get_SCIL_Node (New_Node)); + if Reporting_Proc /= null then + Reporting_Proc.all (Target => Old_Node, Source => New_Node); end if; end Replace; @@ -1644,10 +1655,10 @@ package body Atree is Fix_Parents (Ref_Node => New_Node, Fix_Node => Old_Node); - -- Update the SCIL_Node field (if available) + -- Invoke the reporting procedure (if available) - if Generate_SCIL then - Set_SCIL_Node (Old_Node, Get_SCIL_Node (New_Node)); + if Reporting_Proc /= null then + Reporting_Proc.all (Target => Old_Node, Source => New_Node); end if; end Rewrite; Index: atree.ads =================================================================== --- atree.ads (revision 161073) +++ atree.ads (working copy) @@ -6,7 +6,7 @@ -- -- -- S p e c -- -- -- --- Copyright (C) 1992-2009, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2010, 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- -- @@ -461,6 +461,12 @@ package Atree is -- function is used only by Sinfo.CN to change nodes into their -- corresponding entities. + type Report_Proc is access procedure (Target : Node_Id; Source : Node_Id); + + procedure Set_Reporting_Proc (P : Report_Proc); + -- Register a procedure that is invoked when a node is allocated, replaced + -- or rewritten. + type Traverse_Result is (Abandon, OK, OK_Orig, Skip); -- This is the type of the result returned by the Process function passed -- to Traverse_Func and Traverse_Proc. See below for details. Index: scil_ll.adb =================================================================== --- scil_ll.adb (revision 161244) +++ scil_ll.adb (working copy) @@ -37,6 +37,10 @@ with Table; package body SCIL_LL is + procedure Copy_SCIL_Node (Target : Node_Id; Source : Node_Id); + -- Copy the SCIL field from Source to Target (it is used as the argument + -- for a call to Set_Reporting_Proc in package atree). + function SCIL_Nodes_Table_Size return Pos; -- Used to initialize the table of SCIL nodes because we do not want -- to consume memory for this table if it is not required. @@ -64,6 +68,15 @@ package body SCIL_LL is -- This table records the value of attribute SCIL_Node of all the -- tree nodes. + -------------------- + -- Copy_SCIL_Node -- + -------------------- + + procedure Copy_SCIL_Node (Target : Node_Id; Source : Node_Id) is + begin + Set_SCIL_Node (Target, Get_SCIL_Node (Source)); + end Copy_SCIL_Node; + ---------------- -- Initialize -- ---------------- @@ -71,6 +84,7 @@ package body SCIL_LL is procedure Initialize is begin SCIL_Nodes.Init; + Set_Reporting_Proc (Copy_SCIL_Node'Access); end Initialize; -------------------