aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/sem_dim.ads
diff options
context:
space:
mode:
authorHristian Kirtchev <kirtchev@adacore.com>2011-12-20 13:55:31 +0000
committerArnaud Charlet <charlet@gcc.gnu.org>2011-12-20 14:55:31 +0100
commit15954beb2b32750807397741eda32d81fcb66121 (patch)
tree0d8ec627102afb8f521f3ec74acc1b8fcebe8f89 /gcc/ada/sem_dim.ads
parent76d49f494a31b307249417d0f78ed93303bbd96c (diff)
downloadgcc-15954beb2b32750807397741eda32d81fcb66121.zip
gcc-15954beb2b32750807397741eda32d81fcb66121.tar.gz
gcc-15954beb2b32750807397741eda32d81fcb66121.tar.bz2
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
Diffstat (limited to 'gcc/ada/sem_dim.ads')
-rw-r--r--gcc/ada/sem_dim.ads103
1 files changed, 54 insertions, 49 deletions
diff --git a/gcc/ada/sem_dim.ads b/gcc/ada/sem_dim.ads
index cda1135..be6a8da 100644
--- a/gcc/ada/sem_dim.ads
+++ b/gcc/ada/sem_dim.ads
@@ -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_System
+ procedure Analyze_Aspect_Dimension
(N : Node_Id;
Id : Node_Id;
- Expr : Node_Id);
- -- Analyzes the aggregate of Aspect_Dimension_System
-
- ----------------------
- -- Aspect_Dimension --
- ----------------------
+ 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
+ procedure Analyze_Aspect_Dimension_System
(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
+ -- ??? the above doesn't explain the purpose of this routine. why is this
+ -- procedure needed?
- 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 Expand_Put_Call_With_Dimension_String (N : Node_Id);
+ -- 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.
- 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.
+ 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_Statement (S : Node_Id);
- -- At the end of the Analyze_Statements routine (see Sem_Ch5), removes the
- -- dimension for every statements.
+ procedure Remove_Dimension_In_Call (Call : Node_Id);
+ -- Remove the dimensions from all formal parameters of Call
- ------------------
- -- Dimension_IO --
- ------------------
+ procedure Remove_Dimension_In_Declaration (Decl : Node_Id);
+ -- Remove the dimensions from the expression of Decl
- 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.
+ procedure Remove_Dimension_In_Statement (Stmt : Node_Id);
+ -- Remove the dimensions associated with Stmt
end Sem_Dim;