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
This commit is contained in:
Hristian Kirtchev 2011-12-20 13:55:31 +00:00 committed by Arnaud Charlet
parent 76d49f494a
commit 15954beb2b
8 changed files with 869 additions and 1068 deletions

View File

@ -1,3 +1,32 @@
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>
* sem_ch13.adb (Check_Indexing_Functions): The return type of an

View File

@ -1,14 +1,14 @@
------------------------------------------------------------------------------
-- --
-- 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 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- --
-- 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- --
@ -24,8 +24,8 @@
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNARL was developed by the GNARL team at Florida State University. --
-- Extensive contributions were provided by Ada Core Technologies, Inc. --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------

View File

@ -1,14 +1,14 @@
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- S Y S T E M . D I M _ M K S --
-- --
-- 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- --
-- 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- --
@ -24,14 +24,14 @@
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNARL was developed by the GNARL team at Florida State University. --
-- Extensive contributions were provided by Ada Core Technologies, Inc. --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This package defines the MKS dimension system which is the SI system of
-- units.
-- Some other prefixes of this sytem are defined in a child package (see
-- Defines the MKS dimension system which is the SI system of units
-- 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
-- declarations in this package.

View File

@ -1,14 +1,14 @@
------------------------------------------------------------------------------
-- --
-- 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 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- --
-- 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- --
@ -24,8 +24,8 @@
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNARL was developed by the GNARL team at Florida State University. --
-- Extensive contributions were provided by Ada Core Technologies, Inc. --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------

View File

@ -6042,7 +6042,7 @@ package body Sem_Ch4 is
and then Base_Type (Etype (R)) /= Universal_Integer
then
if Ada_Version >= Ada_2012
and then Is_Dimensioned_Type (Etype (L))
and then Has_Dimension_System (Etype (L))
then
Error_Msg_NE
("exponent for dimensioned type must be a rational" &

File diff suppressed because it is too large Load Diff

View File

@ -23,17 +23,17 @@
-- --
------------------------------------------------------------------------------
-- This new package of the GNAT compiler has been created in order to enable
-- any user of the GNAT compiler to deal with physical issues.
-- This package provides support for numerical systems with dimensions. A
-- "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
-- assign a dimension, defined from the MKS system (package System.Dim_Mks)
-- or their own dimension systems, with any item and to run operations with
-- dimensionned entities.
-- Package System.Dim_Mks offers a ready-to-use system of SI base units. In
-- addition, the implementation of this feature offers the ability to define
-- an arbitrary system of units through the use of Ada 2012 aspects.
-- In that case, a dimensionality checking will be performed at compile time.
-- If no dimension has been assigned, the compiler assumes that the item is
-- dimensionless.
-- Dimensionality checking is part of type analysis performed by the compiler.
-- It ensures that manipulation of quantified numeric values is sensible with
-- respect to the system of units.
-----------------------------
-- Aspect_Dimension_System --
@ -93,63 +93,68 @@ with Types; use Types;
package Sem_Dim is
-----------------------------
-- Aspect_Dimension_System --
-----------------------------
procedure Analyze_Aspect_Dimension
(N : Node_Id;
Id : Node_Id;
Aggr : Node_Id);
-- Analyze the contents of aspect Dimension. Associate the provided values
-- and quantifiers with the related context N.
-- ??? comment on usage of formals needed
procedure Analyze_Aspect_Dimension_System
(N : Node_Id;
Id : Node_Id;
Expr : Node_Id);
-- Analyzes the aggregate of Aspect_Dimension_System
----------------------
-- Aspect_Dimension --
----------------------
procedure Analyze_Aspect_Dimension
(N : Node_Id;
Id : Node_Id;
Expr : Node_Id);
-- Analyzes the aggregate of Aspect_Dimension and attaches the
-- corresponding dimension to N.
-------------------------------------------
-- Dimensionality checking & propagation --
-------------------------------------------
-- Analyze the contents of aspect Dimension_System. Extract the numerical
-- type, unit name and corresponding symbol from each indivitual dimension.
-- ??? comment on usage of formals needed
procedure Analyze_Dimension (N : Node_Id);
-- Performs a dimension analysis and propagates dimension between nodes
-- when needed.
-- N may denote any of the following contexts:
-- * 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
(N : Node_Id;
B_Typ : Entity_Id);
-- Evaluate the Expon operator for dimensioned type with rational exponent
function Is_Dimensioned_Type (E : Entity_Id) return Boolean;
-- Return True if the type is a dimensioned type (i.e: a type which has an
-- aspect Dimension_System)
procedure Remove_Dimension_In_Call (N : Node_Id);
-- 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);
-- At the end of Analyze_Declarations routine (see Sem_Ch3), removes the
-- dimension of the expression for each declaration.
procedure Remove_Dimension_In_Statement (S : Node_Id);
-- At the end of the Analyze_Statements routine (see Sem_Ch5), removes the
-- dimension for every statements.
------------------
-- Dimension_IO --
------------------
-- ??? the above doesn't explain the purpose of this routine. why is this
-- procedure needed?
procedure Expand_Put_Call_With_Dimension_String (N : Node_Id);
-- Expansion of Put call (from package System.Dim_Float_IO and
-- System.Dim_Integer_IO) for a dimensioned object in order to add the
-- dimension symbols as a suffix of the numeric value.
-- Determine whether N denotes a subprogram call to one of the routines
-- 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
-- a dimension.
function Has_Dimension_System (Typ : Entity_Id) return Boolean;
-- Return True if type Typ has aspect Dimension_System applied to it
procedure Remove_Dimension_In_Call (Call : Node_Id);
-- Remove the dimensions from all formal parameters of Call
procedure Remove_Dimension_In_Declaration (Decl : Node_Id);
-- Remove the dimensions from the expression of Decl
procedure Remove_Dimension_In_Statement (Stmt : Node_Id);
-- Remove the dimensions associated with Stmt
end Sem_Dim;

View File

@ -8016,7 +8016,7 @@ package body Sem_Res is
-- Evaluate the exponentiation operator for dimensioned type with
-- 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);
-- Skip the Eval_Op_Expon if the node has already been evaluated