aboutsummaryrefslogtreecommitdiffstats
path: root/src/vhdl
diff options
context:
space:
mode:
Diffstat (limited to 'src/vhdl')
-rw-r--r--src/vhdl/nodes_meta.adb29
-rw-r--r--src/vhdl/nodes_meta.adb.in29
-rw-r--r--src/vhdl/nodes_meta.ads23
-rw-r--r--src/vhdl/nodes_meta.ads.in17
4 files changed, 71 insertions, 27 deletions
diff --git a/src/vhdl/nodes_meta.adb b/src/vhdl/nodes_meta.adb
index 38fcca01c..69fe06520 100644
--- a/src/vhdl/nodes_meta.adb
+++ b/src/vhdl/nodes_meta.adb
@@ -4370,7 +4370,7 @@ package body Nodes_Meta is
Field_Base_Name
);
- Fields_Of_Iir_Last : constant array (Iir_Kind) of Integer :=
+ Fields_Of_Iir_Last : constant array (Iir_Kind) of Fields_Index_Extended :=
(
Iir_Kind_Unused => -1,
Iir_Kind_Error => 7,
@@ -4642,17 +4642,30 @@ package body Nodes_Meta is
Iir_Kind_Attribute_Name => 1902
);
- function Get_Fields (K : Iir_Kind) return Fields_Array
- is
- First : Natural;
- Last : Integer;
+ function Get_Fields_First (K : Iir_Kind) return Fields_Index is
begin
if K = Iir_Kind'First then
- First := Fields_Of_Iir'First;
+ return Fields_Of_Iir'First;
else
- First := Fields_Of_Iir_Last (Iir_Kind'Pred (K)) + 1;
+ return Fields_Of_Iir_Last (Iir_Kind'Pred (K)) + 1;
end if;
- Last := Fields_Of_Iir_Last (K);
+ end Get_Fields_First;
+
+ function Get_Fields_Last (K : Iir_Kind) return Fields_Index is
+ begin
+ return Fields_Of_Iir_Last (K);
+ end Get_Fields_Last;
+
+ function Get_Field_By_Index (Idx : Fields_Index) return Fields_Enum is
+ begin
+ return Fields_Of_Iir (Idx);
+ end Get_Field_By_Index;
+
+ function Get_Fields (K : Iir_Kind) return Fields_Array
+ is
+ First : constant Fields_Index := Get_Fields_First (K);
+ Last : constant Fields_Index := Fields_Of_Iir_Last (K);
+ begin
return Fields_Of_Iir (First .. Last);
end Get_Fields;
diff --git a/src/vhdl/nodes_meta.adb.in b/src/vhdl/nodes_meta.adb.in
index d94c2d626..8f9e96490 100644
--- a/src/vhdl/nodes_meta.adb.in
+++ b/src/vhdl/nodes_meta.adb.in
@@ -53,22 +53,35 @@ package body Nodes_Meta is
-- FIELDS_ARRAY
);
- Fields_Of_Iir_Last : constant array (Iir_Kind) of Integer :=
+ Fields_Of_Iir_Last : constant array (Iir_Kind) of Fields_Index_Extended :=
(
-- FIELDS_ARRAY_POS
);
- function Get_Fields (K : Iir_Kind) return Fields_Array
- is
- First : Natural;
- Last : Integer;
+ function Get_Fields_First (K : Iir_Kind) return Fields_Index is
begin
if K = Iir_Kind'First then
- First := Fields_Of_Iir'First;
+ return Fields_Of_Iir'First;
else
- First := Fields_Of_Iir_Last (Iir_Kind'Pred (K)) + 1;
+ return Fields_Of_Iir_Last (Iir_Kind'Pred (K)) + 1;
end if;
- Last := Fields_Of_Iir_Last (K);
+ end Get_Fields_First;
+
+ function Get_Fields_Last (K : Iir_Kind) return Fields_Index is
+ begin
+ return Fields_Of_Iir_Last (K);
+ end Get_Fields_Last;
+
+ function Get_Field_By_Index (Idx : Fields_Index) return Fields_Enum is
+ begin
+ return Fields_Of_Iir (Idx);
+ end Get_Field_By_Index;
+
+ function Get_Fields (K : Iir_Kind) return Fields_Array
+ is
+ First : constant Fields_Index := Get_Fields_First (K);
+ Last : constant Fields_Index := Fields_Of_Iir_Last (K);
+ begin
return Fields_Of_Iir (First .. Last);
end Get_Fields;
diff --git a/src/vhdl/nodes_meta.ads b/src/vhdl/nodes_meta.ads
index b25cb3a8b..62411dbac 100644
--- a/src/vhdl/nodes_meta.ads
+++ b/src/vhdl/nodes_meta.ads
@@ -398,22 +398,35 @@ package Nodes_Meta is
type Field_Attribute is
(
Attr_None,
- Attr_Ref, Attr_Maybe_Ref,
- Attr_Forward_Ref, Attr_Maybe_Forward_Ref,
- Attr_Of_Ref, Attr_Of_Maybe_Ref,
- Attr_Chain, Attr_Chain_Next
+ Attr_Chain,
+ Attr_Chain_Next,
+ Attr_Forward_Ref,
+ Attr_Maybe_Forward_Ref,
+ Attr_Maybe_Ref,
+ Attr_Of_Maybe_Ref,
+ Attr_Of_Ref,
+ Attr_Ref
);
-- Get the attribute of a field.
function Get_Field_Attribute (F : Fields_Enum) return Field_Attribute;
- type Fields_Array is array (Natural range <>) of Fields_Enum;
+ type Fields_Index_Extended is new Int32;
+ subtype Fields_Index is Fields_Index_Extended
+ range 0 .. Fields_Index_Extended'Last;
+
+ type Fields_Array is array (Fields_Index range <>) of Fields_Enum;
-- Return the list of fields for node K. The fields are sorted: first
-- the non nodes/list of nodes, then the nodes/lists that aren't reference,
-- and then the reference.
function Get_Fields (K : Iir_Kind) return Fields_Array;
+ -- Likewise, but without using arrays (for interfacing with C).
+ function Get_Fields_First (K : Iir_Kind) return Fields_Index;
+ function Get_Fields_Last (K : Iir_Kind) return Fields_Index;
+ function Get_Field_By_Index (Idx : Fields_Index) return Fields_Enum;
+
-- Get/Set a field.
function Get_Boolean
(N : Iir; F : Fields_Enum) return Boolean;
diff --git a/src/vhdl/nodes_meta.ads.in b/src/vhdl/nodes_meta.ads.in
index 893064816..18e7dca29 100644
--- a/src/vhdl/nodes_meta.ads.in
+++ b/src/vhdl/nodes_meta.ads.in
@@ -46,23 +46,28 @@ package Nodes_Meta is
-- Possible attributes of a field.
type Field_Attribute is
(
- Attr_None,
- Attr_Ref, Attr_Maybe_Ref,
- Attr_Forward_Ref, Attr_Maybe_Forward_Ref,
- Attr_Of_Ref, Attr_Of_Maybe_Ref,
- Attr_Chain, Attr_Chain_Next
+ -- ATTRS
);
-- Get the attribute of a field.
function Get_Field_Attribute (F : Fields_Enum) return Field_Attribute;
- type Fields_Array is array (Natural range <>) of Fields_Enum;
+ type Fields_Index_Extended is new Int32;
+ subtype Fields_Index is Fields_Index_Extended
+ range 0 .. Fields_Index_Extended'Last;
+
+ type Fields_Array is array (Fields_Index range <>) of Fields_Enum;
-- Return the list of fields for node K. The fields are sorted: first
-- the non nodes/list of nodes, then the nodes/lists that aren't reference,
-- and then the reference.
function Get_Fields (K : Iir_Kind) return Fields_Array;
+ -- Likewise, but without using arrays (for interfacing with C).
+ function Get_Fields_First (K : Iir_Kind) return Fields_Index;
+ function Get_Fields_Last (K : Iir_Kind) return Fields_Index;
+ function Get_Field_By_Index (Idx : Fields_Index) return Fields_Enum;
+
-- Get/Set a field.
-- FUNCS
end Nodes_Meta;