Commit 15954beb by Hristian Kirtchev Committed by Arnaud Charlet

sem_ch4.adb (Operator_Check): Update the call to Is_Dimensioned_Type.

2011-12-20  Hristian Kirtchev  <kirtchev@adacore.com>

	* sem_ch4.adb (Operator_Check): Update the call to
	Is_Dimensioned_Type.
	* sem_dim.adb: Remove with and use clause for Namet.Sp. Reorganize
	all type declarations and datastructures involved. Propagate
	all changes involving data structures and types throughout
	the pakage. Alphabetize all subprograms. Add ??? comments.
	(AD_Hash): Removed.
	(Analyze_Aspect_Dimension): Rewritten. This
	routine now does all its checks in one pass rather than
	two. Refactor code. The error message are now in a more GNAT-ish style.
	(Create_Rational_From_Expr): This is now a function.
	(Get_Dimensions): Removed.
	(Get_Dimensions_String_Id): Removed.
	(Dimensions_Of): New rouitne.
	(Exists): New routines.
	(Is_Invalid): New routine.
	(Permits_Dimensions): Removed.
	(Present): Removed.
	(Set_Symbol): New routine.
	(System_Of): New routine.
	* sem_dim.ads: Rewrite the top level description of the
	package. Alphabetize subprograms. Add various comments on
	subprogram usage. Add ??? comments.
	(Is_Dimensioned_Type):
	Renamed to Has_Dimension_System.
	* sem_res.adb (Resolve_Op_Expon): Update the call to Is_Dimensioned_Type

From-SVN: r182537
parent 76d49f49
2011-12-20 Hristian Kirtchev <kirtchev@adacore.com>
* sem_ch4.adb (Operator_Check): Update the call to
Is_Dimensioned_Type.
* sem_dim.adb: Remove with and use clause for Namet.Sp. Reorganize
all type declarations and datastructures involved. Propagate
all changes involving data structures and types throughout
the pakage. Alphabetize all subprograms. Add ??? comments.
(AD_Hash): Removed.
(Analyze_Aspect_Dimension): Rewritten. This
routine now does all its checks in one pass rather than
two. Refactor code. The error message are now in a more GNAT-ish style.
(Create_Rational_From_Expr): This is now a function.
(Get_Dimensions): Removed.
(Get_Dimensions_String_Id): Removed.
(Dimensions_Of): New rouitne.
(Exists): New routines.
(Is_Invalid): New routine.
(Permits_Dimensions): Removed.
(Present): Removed.
(Set_Symbol): New routine.
(System_Of): New routine.
* sem_dim.ads: Rewrite the top level description of the
package. Alphabetize subprograms. Add various comments on
subprogram usage. Add ??? comments.
(Is_Dimensioned_Type):
Renamed to Has_Dimension_System.
* sem_res.adb (Resolve_Op_Expon): Update the call to Is_Dimensioned_Type
2011-12-20 Ed Schonberg <schonberg@adacore.com> 2011-12-20 Ed Schonberg <schonberg@adacore.com>
* sem_ch13.adb (Check_Indexing_Functions): The return type of an * sem_ch13.adb (Check_Indexing_Functions): The return type of an
......
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
-- -- -- --
-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS -- -- GNAT RUN-TIME COMPONENTS --
-- -- -- --
-- S Y S T E M . D I M _ M K S _ I O -- -- S Y S T E M . D I M _ M K S _ I O --
-- -- -- --
-- S p e c -- -- S p e c --
-- -- -- --
-- Copyright (C) 1992-2011, Free Software Foundation, Inc. -- -- Copyright (C) 2011, Free Software Foundation, Inc. --
-- -- -- --
-- GNARL is free software; you can redistribute it and/or modify it under -- -- 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- -- -- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- -- -- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
...@@ -24,8 +24,8 @@ ...@@ -24,8 +24,8 @@
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. -- -- <http://www.gnu.org/licenses/>. --
-- -- -- --
-- GNARL was developed by the GNARL team at Florida State University. -- -- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies, Inc. -- -- Extensive contributions were provided by Ada Core Technologies Inc. --
-- -- -- --
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
......
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
-- -- -- --
-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS -- -- GNAT RUN-TIME COMPONENTS --
-- -- -- --
-- S Y S T E M . D I M _ M K S -- -- S Y S T E M . D I M _ M K S --
-- -- -- --
-- S p e c -- -- S p e c --
-- -- -- --
-- Copyright (C) 1992-2011, Free Software Foundation, Inc. -- -- Copyright (C) 2011, Free Software Foundation, Inc. --
-- -- -- --
-- GNARL is free software; you can redistribute it and/or modify it under -- -- 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- -- -- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- -- -- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
...@@ -24,14 +24,14 @@ ...@@ -24,14 +24,14 @@
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. -- -- <http://www.gnu.org/licenses/>. --
-- -- -- --
-- GNARL was developed by the GNARL team at Florida State University. -- -- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies, Inc. -- -- Extensive contributions were provided by Ada Core Technologies Inc. --
-- -- -- --
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
-- This package defines the MKS dimension system which is the SI system of -- Defines the MKS dimension system which is the SI system of units
-- units.
-- Some other prefixes of this sytem are defined in a child package (see -- Some other prefixes of this system are defined in a child package (see
-- System.Dim_Mks.Other_Prefixes) in order to avoid too many constant -- System.Dim_Mks.Other_Prefixes) in order to avoid too many constant
-- declarations in this package. -- declarations in this package.
......
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
-- -- -- --
-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS -- -- GNAT RUN-TIME COMPONENTS --
-- -- -- --
-- S Y S T E M . D I M _ M K S . O T H E R _ P R E F I X E S -- -- S Y S T E M . D I M _ M K S . O T H E R _ P R E F I X E S --
-- -- -- --
-- S p e c -- -- S p e c --
-- -- -- --
-- Copyright (C) 1992-2011, Free Software Foundation, Inc. -- -- Copyright (C) 2011, Free Software Foundation, Inc. --
-- -- -- --
-- GNARL is free software; you can redistribute it and/or modify it under -- -- 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- -- -- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- -- -- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
...@@ -24,8 +24,8 @@ ...@@ -24,8 +24,8 @@
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. -- -- <http://www.gnu.org/licenses/>. --
-- -- -- --
-- GNARL was developed by the GNARL team at Florida State University. -- -- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies, Inc. -- -- Extensive contributions were provided by Ada Core Technologies Inc. --
-- -- -- --
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
......
...@@ -6042,7 +6042,7 @@ package body Sem_Ch4 is ...@@ -6042,7 +6042,7 @@ package body Sem_Ch4 is
and then Base_Type (Etype (R)) /= Universal_Integer and then Base_Type (Etype (R)) /= Universal_Integer
then then
if Ada_Version >= Ada_2012 if Ada_Version >= Ada_2012
and then Is_Dimensioned_Type (Etype (L)) and then Has_Dimension_System (Etype (L))
then then
Error_Msg_NE Error_Msg_NE
("exponent for dimensioned type must be a rational" & ("exponent for dimensioned type must be a rational" &
......
...@@ -23,17 +23,17 @@ ...@@ -23,17 +23,17 @@
-- -- -- --
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
-- This new package of the GNAT compiler has been created in order to enable -- This package provides support for numerical systems with dimensions. A
-- any user of the GNAT compiler to deal with physical issues. -- "dimension" is a compile-time property of a numerical type which represents
-- a relation between various quantifiers such as length, velocity, etc.
-- Indeed, the user is now able to create their own dimension system and to -- Package System.Dim_Mks offers a ready-to-use system of SI base units. In
-- assign a dimension, defined from the MKS system (package System.Dim_Mks) -- addition, the implementation of this feature offers the ability to define
-- or their own dimension systems, with any item and to run operations with -- an arbitrary system of units through the use of Ada 2012 aspects.
-- dimensionned entities.
-- In that case, a dimensionality checking will be performed at compile time. -- Dimensionality checking is part of type analysis performed by the compiler.
-- If no dimension has been assigned, the compiler assumes that the item is -- It ensures that manipulation of quantified numeric values is sensible with
-- dimensionless. -- respect to the system of units.
----------------------------- -----------------------------
-- Aspect_Dimension_System -- -- Aspect_Dimension_System --
...@@ -93,63 +93,68 @@ with Types; use Types; ...@@ -93,63 +93,68 @@ with Types; use Types;
package Sem_Dim is package Sem_Dim is
----------------------------- procedure Analyze_Aspect_Dimension
-- Aspect_Dimension_System --
-----------------------------
procedure Analyze_Aspect_Dimension_System
(N : Node_Id; (N : Node_Id;
Id : Node_Id; Id : Node_Id;
Expr : Node_Id); Aggr : Node_Id);
-- Analyzes the aggregate of Aspect_Dimension_System -- Analyze the contents of aspect Dimension. Associate the provided values
-- and quantifiers with the related context N.
---------------------- -- ??? comment on usage of formals needed
-- Aspect_Dimension --
----------------------
procedure Analyze_Aspect_Dimension procedure Analyze_Aspect_Dimension_System
(N : Node_Id; (N : Node_Id;
Id : Node_Id; Id : Node_Id;
Expr : Node_Id); Expr : Node_Id);
-- Analyzes the aggregate of Aspect_Dimension and attaches the -- Analyze the contents of aspect Dimension_System. Extract the numerical
-- corresponding dimension to N. -- type, unit name and corresponding symbol from each indivitual dimension.
-- ??? comment on usage of formals needed
-------------------------------------------
-- Dimensionality checking & propagation --
-------------------------------------------
procedure Analyze_Dimension (N : Node_Id); procedure Analyze_Dimension (N : Node_Id);
-- Performs a dimension analysis and propagates dimension between nodes -- N may denote any of the following contexts:
-- when needed. -- * assignment statement
-- * attribute reference
-- * binary operator
-- * compontent declaration
-- * extended return statement
-- * function call
-- * identifier
-- * indexed component
-- * object declaration
-- * object renaming declaration
-- * qualified expression
-- * selected component
-- * simple return statement
-- * slice
-- * subtype declaration
-- * type conversion
-- * unary operator
-- * unchecked type conversion
-- Depending on the context, ensure that all expressions and entities
-- involved do not violate the rules of a system.
procedure Eval_Op_Expon_For_Dimensioned_Type procedure Eval_Op_Expon_For_Dimensioned_Type
(N : Node_Id; (N : Node_Id;
B_Typ : Entity_Id); B_Typ : Entity_Id);
-- Evaluate the Expon operator for dimensioned type with rational exponent -- Evaluate the Expon operator for dimensioned type with rational exponent
-- ??? the above doesn't explain the purpose of this routine. why is this
-- procedure needed?
function Is_Dimensioned_Type (E : Entity_Id) return Boolean; procedure Expand_Put_Call_With_Dimension_String (N : Node_Id);
-- Return True if the type is a dimensioned type (i.e: a type which has an -- Determine whether N denotes a subprogram call to one of the routines
-- aspect Dimension_System) -- defined in System.Dim_Float_IO or System.Dim_Integer_IO and add an
-- extra actual to the call to represent the symbolic representation of
procedure Remove_Dimension_In_Call (N : Node_Id); -- a dimension.
-- At the end of the Expand_Call routine, remove the dimensions of every
-- parameter in the call N.
procedure Remove_Dimension_In_Declaration (D : Node_Id); function Has_Dimension_System (Typ : Entity_Id) return Boolean;
-- At the end of Analyze_Declarations routine (see Sem_Ch3), removes the -- Return True if type Typ has aspect Dimension_System applied to it
-- dimension of the expression for each declaration.
procedure Remove_Dimension_In_Statement (S : Node_Id); procedure Remove_Dimension_In_Call (Call : Node_Id);
-- At the end of the Analyze_Statements routine (see Sem_Ch5), removes the -- Remove the dimensions from all formal parameters of Call
-- dimension for every statements.
------------------ procedure Remove_Dimension_In_Declaration (Decl : Node_Id);
-- Dimension_IO -- -- Remove the dimensions from the expression of Decl
------------------
procedure Expand_Put_Call_With_Dimension_String (N : Node_Id); procedure Remove_Dimension_In_Statement (Stmt : Node_Id);
-- Expansion of Put call (from package System.Dim_Float_IO and -- Remove the dimensions associated with Stmt
-- System.Dim_Integer_IO) for a dimensioned object in order to add the
-- dimension symbols as a suffix of the numeric value.
end Sem_Dim; end Sem_Dim;
...@@ -8016,7 +8016,7 @@ package body Sem_Res is ...@@ -8016,7 +8016,7 @@ package body Sem_Res is
-- Evaluate the exponentiation operator for dimensioned type with -- Evaluate the exponentiation operator for dimensioned type with
-- rational exponent. -- rational exponent.
if Ada_Version >= Ada_2012 and then Is_Dimensioned_Type (B_Typ) then if Ada_Version >= Ada_2012 and then Has_Dimension_System (B_Typ) then
Eval_Op_Expon_For_Dimensioned_Type (N, B_Typ); Eval_Op_Expon_For_Dimensioned_Type (N, B_Typ);
-- Skip the Eval_Op_Expon if the node has already been evaluated -- Skip the Eval_Op_Expon if the node has already been evaluated
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment