diff options
author | Tristan Gingold <tgingold@free.fr> | 2017-10-02 20:47:13 +0200 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2017-10-02 20:49:37 +0200 |
commit | 1c1cdc4f5f7420f88a1ac4bc2df35a31cf45a892 (patch) | |
tree | 1935243db094054478243966d47d4a544cbe59d4 | |
parent | 255fb07204db93a302305795c2220901cf7a883e (diff) | |
download | ghdl-1c1cdc4f5f7420f88a1ac4bc2df35a31cf45a892.tar.gz ghdl-1c1cdc4f5f7420f88a1ac4bc2df35a31cf45a892.tar.bz2 ghdl-1c1cdc4f5f7420f88a1ac4bc2df35a31cf45a892.zip |
nodes_meta: Generate Attr_, add subprograms for interfaces.
-rw-r--r-- | src/vhdl/nodes_meta.adb | 29 | ||||
-rw-r--r-- | src/vhdl/nodes_meta.adb.in | 29 | ||||
-rw-r--r-- | src/vhdl/nodes_meta.ads | 23 | ||||
-rw-r--r-- | src/vhdl/nodes_meta.ads.in | 17 | ||||
-rwxr-xr-x | src/xtools/pnodes.py | 9 |
5 files changed, 77 insertions, 30 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; diff --git a/src/xtools/pnodes.py b/src/xtools/pnodes.py index 4fc12bbaa..cd03be04a 100755 --- a/src/xtools/pnodes.py +++ b/src/xtools/pnodes.py @@ -613,8 +613,11 @@ def get_types(): def get_attributes(): s = set([]) for f in funcs: - s |= set([f.acc]) - return [t for t in sorted(s)] + if f.acc: + s |= set([f.acc]) + res = [t for t in sorted(s)] + res.insert(0, 'None') + return res def gen_enum(prefix, vals): last = None @@ -635,7 +638,7 @@ def do_meta_specs(): elif l == ' -- FIELDS': gen_enum(' Field_', [f.name for f in funcs]) elif l == ' -- ATTRS': - gen_enum(' Field_', get_attributes()) + gen_enum(' Attr_', get_attributes()) elif l == ' -- FUNCS': for t in types: print ' function Get_' + t |