aboutsummaryrefslogtreecommitdiffstats
path: root/src/ortho/mcode/ortho_mcode.ads
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2020-07-24 18:31:11 +0200
committerTristan Gingold <tgingold@free.fr>2020-07-25 11:28:49 +0200
commit04cd83fb46bee1e7a7b37be95bee73449af9c8b8 (patch)
tree3fe35d0bc6d4b1be8d81ad44df685057c221d2dc /src/ortho/mcode/ortho_mcode.ads
parent4033dd795927a4953879bdc92d395788893a5468 (diff)
downloadghdl-04cd83fb46bee1e7a7b37be95bee73449af9c8b8.tar.gz
ghdl-04cd83fb46bee1e7a7b37be95bee73449af9c8b8.tar.bz2
ghdl-04cd83fb46bee1e7a7b37be95bee73449af9c8b8.zip
ortho: add unbounded records, rework array subtypes.
Diffstat (limited to 'src/ortho/mcode/ortho_mcode.ads')
-rw-r--r--src/ortho/mcode/ortho_mcode.ads40
1 files changed, 28 insertions, 12 deletions
diff --git a/src/ortho/mcode/ortho_mcode.ads b/src/ortho/mcode/ortho_mcode.ads
index ef24372e3..1e3aa6a44 100644
--- a/src/ortho/mcode/ortho_mcode.ads
+++ b/src/ortho/mcode/ortho_mcode.ads
@@ -64,8 +64,8 @@ package Ortho_Mcode is
-- Build a record type.
procedure Start_Record_Type (Elements : out O_Element_List);
- -- Add a field in the record; not constrained array are prohibited, since
- -- its size is unlimited.
+ -- Add a field in the record. Unconstrained fields must be at the end,
+ -- and cannot be followed by a constrained one.
procedure New_Record_Field
(Elements : in out O_Element_List;
El : out O_Fnode;
@@ -74,6 +74,17 @@ package Ortho_Mcode is
procedure Finish_Record_Type
(Elements : in out O_Element_List; Res : out O_Tnode);
+ type O_Element_Sublist is limited private;
+
+ -- Build a record subtype.
+ -- Re-declare only unconstrained fields with a subtype of them.
+ procedure Start_Record_Subtype
+ (Rtype : O_Tnode; Elements : out O_Element_Sublist);
+ procedure New_Subrecord_Field
+ (Elements : in out O_Element_Sublist; El : out O_Fnode; Etype : O_Tnode);
+ procedure Finish_Record_Subtype
+ (Elements : in out O_Element_Sublist; Res : out O_Tnode);
+
-- Build an uncomplete record type:
-- First call NEW_UNCOMPLETE_RECORD_TYPE, which returns a record type.
-- This type can be declared or used to define access types on it.
@@ -105,8 +116,8 @@ package Ortho_Mcode is
return O_Tnode;
-- Build a constrained array type.
- function New_Constrained_Array_Type (Atype : O_Tnode; Length : O_Cnode)
- return O_Tnode;
+ function New_Array_Subtype
+ (Atype : O_Tnode; El_Type : O_Tnode; Length : O_Cnode) return O_Tnode;
-- Build a scalar type; size may be 8, 16, 32 or 64.
function New_Unsigned_Type (Size : Natural) return O_Tnode;
@@ -179,9 +190,13 @@ package Ortho_Mcode is
-- Returns the size in bytes of ATYPE. The result is a literal of
-- unsigned type RTYPE
- -- ATYPE cannot be an unconstrained array type.
+ -- ATYPE cannot be an unconstrained type.
function New_Sizeof (Atype : O_Tnode; Rtype : O_Tnode) return O_Cnode;
+ -- Get the size of the bounded part of a record.
+ function New_Record_Sizeof
+ (Atype : O_Tnode; Rtype : O_Tnode) return O_Cnode;
+
-- Returns the alignment in bytes for ATYPE. The result is a literal of
-- unsgined type RTYPE.
function New_Alignof (Atype : O_Tnode; Rtype : O_Tnode) return O_Cnode;
@@ -498,14 +513,15 @@ private
O_Snode_Null : constant O_Snode := O_Snode (Ortho_Code.Exprs.O_Snode_Null);
O_Tnode_Null : constant O_Tnode := O_Tnode (Ortho_Code.O_Tnode_Null);
- type O_Element_List is new Ortho_Code.Types.O_Element_List;
- type O_Enum_List is new Ortho_Code.Types.O_Enum_List;
- type O_Inter_List is new Ortho_Code.Decls.O_Inter_List;
+ type O_Element_List is new Ortho_Code.Types.O_Element_List;
+ type O_Element_Sublist is new Ortho_Code.Types.O_Element_List;
+ type O_Enum_List is new Ortho_Code.Types.O_Enum_List;
+ type O_Inter_List is new Ortho_Code.Decls.O_Inter_List;
type O_Record_Aggr_List is new Ortho_Code.Consts.O_Record_Aggr_List;
- type O_Array_Aggr_List is new Ortho_Code.Consts.O_Array_Aggr_List;
- type O_Assoc_List is new Ortho_Code.Exprs.O_Assoc_List;
- type O_If_Block is new Ortho_Code.Exprs.O_If_Block;
- type O_Case_Block is new Ortho_Code.Exprs.O_Case_Block;
+ type O_Array_Aggr_List is new Ortho_Code.Consts.O_Array_Aggr_List;
+ type O_Assoc_List is new Ortho_Code.Exprs.O_Assoc_List;
+ type O_If_Block is new Ortho_Code.Exprs.O_If_Block;
+ type O_Case_Block is new Ortho_Code.Exprs.O_Case_Block;
pragma Inline (New_Lit);
pragma Inline (New_Dyadic_Op);