From b861073629c6c86c9095df98e35d78281ef9fa84 Mon Sep 17 00:00:00 2001 From: Tristan Gingold Date: Mon, 20 May 2019 18:16:03 +0200 Subject: libghdl: fix various issues. --- src/vhdl/python/libghdl/__init__.py | 9 +- src/vhdl/python/libghdl/thin/errorout.py | 3 +- src/vhdl/python/libghdl/thin/errorout_memory.py | 6 +- src/vhdl/python/libghdl/thin/vhdl/lists.py | 2 +- src/vhdl/python/libghdl/thin/vhdl/pyutils.py | 331 ++++++++++++------------ src/vhdl/python/pnodespy.py | 4 +- 6 files changed, 180 insertions(+), 175 deletions(-) diff --git a/src/vhdl/python/libghdl/__init__.py b/src/vhdl/python/libghdl/__init__.py index 6589aec3f..9bae63a8e 100644 --- a/src/vhdl/python/libghdl/__init__.py +++ b/src/vhdl/python/libghdl/__init__.py @@ -10,10 +10,11 @@ libghdl = ctypes.CDLL(os.path.join(_basedir, libghdl_filename)) libghdl.libghdl_init() # Set the default prefix. -_prefix = os.path.join(_basedir, "ghdl") -_prefix_opt = ("--PREFIX=" + _prefix).encode('utf-8') -libghdl.libghdl__set_option( - ctypes.c_char_p(_prefix_opt), len(_prefix_opt)) +if False: + _prefix = os.path.join(_basedir, "ghdl") + _prefix_opt = ("--PREFIX=" + _prefix).encode('utf-8') + libghdl.libghdl__set_option( + ctypes.c_char_p(_prefix_opt), len(_prefix_opt)) # libghdl diff --git a/src/vhdl/python/libghdl/thin/errorout.py b/src/vhdl/python/libghdl/thin/errorout.py index 0af8a0a1f..f059d99cc 100644 --- a/src/vhdl/python/libghdl/thin/errorout.py +++ b/src/vhdl/python/libghdl/thin/errorout.py @@ -1,4 +1,5 @@ -from ctypes import c_int8, c_int32 +from ctypes import c_int8, c_int32, Structure + class Error_Record(Structure): _fields_ = [("origin", c_int8), ("id", c_int8), diff --git a/src/vhdl/python/libghdl/thin/errorout_memory.py b/src/vhdl/python/libghdl/thin/errorout_memory.py index 2967863f5..d0a1e255c 100644 --- a/src/vhdl/python/libghdl/thin/errorout_memory.py +++ b/src/vhdl/python/libghdl/thin/errorout_memory.py @@ -1,10 +1,14 @@ +from libghdl import libghdl +from ctypes import c_int32, c_char_p +import libghdl.thin.errorout as errorout + Install_Handler = libghdl.errorout__memory__install_handler Get_Nbr_Messages = libghdl.errorout__memory__get_nbr_messages Get_Error_Record = libghdl.errorout__memory__get_error_record Get_Error_Record.argstypes = [c_int32] -Get_Error_Record.restype = Errorout.Error_Record +Get_Error_Record.restype = errorout.Error_Record Get_Error_Message = libghdl.errorout__memory__get_error_message_addr Get_Error_Message.argstype = [c_int32] diff --git a/src/vhdl/python/libghdl/thin/vhdl/lists.py b/src/vhdl/python/libghdl/thin/vhdl/lists.py index c1c40e6e7..8fc180073 100644 --- a/src/vhdl/python/libghdl/thin/vhdl/lists.py +++ b/src/vhdl/python/libghdl/thin/vhdl/lists.py @@ -1,5 +1,5 @@ from libghdl import libghdl -from ctypes import c_int32, POINTER +from ctypes import c_int32, c_bool, POINTER, Structure List_Type = c_int32 diff --git a/src/vhdl/python/libghdl/thin/vhdl/pyutils.py b/src/vhdl/python/libghdl/thin/vhdl/pyutils.py index 8fc01d434..28b4464f3 100644 --- a/src/vhdl/python/libghdl/thin/vhdl/pyutils.py +++ b/src/vhdl/python/libghdl/thin/vhdl/pyutils.py @@ -1,16 +1,13 @@ -from libghdl import libghdl from ctypes import (c_char_p, c_int32, c_int, c_bool, sizeof, c_void_p, byref) -import libghdl.iirs as iirs -import libghdl.thin as thin -import libghdl.nodes_meta as nodes_meta -from libghdl.nodes_meta import (Attr, types) -# from libghdl_defs import (fields, Iir_Kind, types, Attr) - -Null_Iir = 0 -Null_Iir_List = 0 +import libghdl.thin.name_table as name_table +import libghdl.thin.vhdl.nodes as nodes +import libghdl.thin.vhdl.nodes_meta as nodes_meta +import libghdl.thin.vhdl.lists as lists +import libghdl.thin.vhdl.flists as flists +from libghdl.thin.vhdl.nodes_meta import (Attr, types) def name_image(nameid): - return thin.Get_Name_Ptr(nameid).decode('utf-8') + return name_table.Get_Name_Ptr(nameid).decode('utf-8') def _build_enum_image(cls): d = [e for e in dir(cls) if e[0] != '_'] @@ -28,7 +25,7 @@ def fields_image(idx): return _fields_image[idx] -_kind_image = _build_enum_image(iirs.Iir_Kind) +_kind_image = _build_enum_image(nodes.Iir_Kind) def kind_image(k): @@ -56,18 +53,18 @@ def leftest_location(n): while True: if n == Null_Iir: return No_Location - k = iirs.Get_Kind(n) - if k == iirs.Iir_Kind.Array_Subtype_Definition: - n = iirs.Get_Subtype_Type_Mark(n) + k = nodes.Get_Kind(n) + if k == nodes.Iir_Kind.Array_Subtype_Definition: + n = nodes.Get_Subtype_Type_Mark(n) else: - return iirs.Get_Location(n) + return nodes.Get_Location(n) def fields_iter(n): """Iterate on fields of node n""" - if n == Null_Iir: + if n == nodes.Null_Iir: return - k = iirs.Get_Kind(n) + k = nodes.Get_Kind(n) first = nodes_meta.get_fields_first(k) last = nodes_meta.get_fields_last(k) for i in range(first, last + 1): @@ -76,9 +73,9 @@ def fields_iter(n): def chain_iter(n): """Iterate of a chain headed by node n""" - while n != Null_Iir: + while n != nodes.Null_Iir: yield n - n = iirs.Get_Chain(n) + n = nodes.Get_Chain(n) def chain_to_list(n): @@ -89,7 +86,7 @@ def chain_to_list(n): def nodes_iter(n): """Iterate of all nodes of n, including n. Nodes are returned only once.""" - if n == Null_Iir: + if n == nodes.Null_Iir: return # print 'nodes_iter for {0}'.format(n) yield n @@ -104,12 +101,12 @@ def nodes_iter(n): yield n1 elif attr == Attr.Chain: n2 = nodes_meta.Get_Iir(n, f) - while n2 != Null_Iir: + while n2 != nodes.Null_Iir: for n1 in nodes_iter(n2): yield n1 - n2 = iirs.Get_Chain(n2) + n2 = nodes.Get_Chain(n2) elif attr == Attr.Maybe_Ref: - if not iirs.Get_Is_Ref(n, f): + if not nodes.Get_Is_Ref(n, f): for n1 in nodes_iter(nodes_meta.Get_Iir(n, f)): yield n1 elif typ == types.Iir_List: @@ -128,50 +125,50 @@ def nodes_iter(n): def list_iter(lst): """Iterate of all element of Iir_List lst.""" - if lst <= thin.Iir_List_All: + if lst <= nodes.Iir_List_All: return - iter = thin.Lists.Iterate(lst) - while thin.Lists.Is_Valid(byref(iter)): - yield thin.Lists.Get_Element(byref(iter)) - thin.Lists.Next(byref(iter)) + iter = lists.Iterate(lst) + while lists.Is_Valid(byref(iter)): + yield lists.Get_Element(byref(iter)) + lists.Next(byref(iter)) def flist_iter(lst): """Iterate of all element of Iir_List lst.""" - if lst <= thin.Iir_Flist_All: + if lst <= nodes.Iir_Flist_All: return - for i in range(thin.Flists.Flast(lst) + 1): - yield thin.Flists.Get_Nth_Element(lst, i) + for i in range(flists.Flast(lst) + 1): + yield flists.Get_Nth_Element(lst, i) def declarations_iter(n): """Iterator on all declarations in n.""" - k = iirs.Get_Kind(n) + k = nodes.Get_Kind(n) if nodes_meta.Has_Generic_Chain(k): - for n1 in chain_iter(iirs.Get_Generic_Chain(n)): + for n1 in chain_iter(nodes.Get_Generic_Chain(n)): yield n1 if nodes_meta.Has_Port_Chain(k): - for n1 in chain_iter(iirs.Get_Port_Chain(n)): + for n1 in chain_iter(nodes.Get_Port_Chain(n)): yield n1 if nodes_meta.Has_Interface_Declaration_Chain(k): - for n1 in chain_iter(iirs.Get_Interface_Declaration_Chain(n)): + for n1 in chain_iter(nodes.Get_Interface_Declaration_Chain(n)): yield n1 if nodes_meta.Has_Declaration_Chain(k): - for n1 in chain_iter(iirs.Get_Declaration_Chain(n)): - k1 = iirs.Get_Kind(n1) - if k1 in iirs.Iir_Kinds.Specification \ - or k1 == iirs.Iir_Kind.Use_Clause: + for n1 in chain_iter(nodes.Get_Declaration_Chain(n)): + k1 = nodes.Get_Kind(n1) + if k1 in nodes.Iir_Kinds.Specification \ + or k1 == nodes.Iir_Kind.Use_Clause: # Not a declaration pass - elif k1 == iirs.Iir_Kind.Signal_Attribute_Declaration: + elif k1 == nodes.Iir_Kind.Signal_Attribute_Declaration: # Not a declaration pass - elif k1 in [iirs.Iir_Kind.Type_Declaration, - iirs.Iir_Kind.Anonymous_Type_Declaration]: + elif k1 in [nodes.Iir_Kind.Type_Declaration, + nodes.Iir_Kind.Anonymous_Type_Declaration]: yield n1 # Handle nested declarations: record elements, physical units, # enumeration literals... - typ = iirs.Get_Type_Definition(n1) + typ = nodes.Get_Type_Definition(n1) for n2 in declarations_iter(n1): yield n2 else: @@ -180,80 +177,80 @@ def declarations_iter(n): for n2 in declarations_iter(n1): yield n2 if nodes_meta.Has_Concurrent_Statement_Chain(k): - for n1 in chain_iter(iirs.Get_Concurrent_Statement_Chain(n)): + for n1 in chain_iter(nodes.Get_Concurrent_Statement_Chain(n)): for n2 in declarations_iter(n1): yield n2 if nodes_meta.Has_Sequential_Statement_Chain(k): - for n1 in chain_iter(iirs.Get_Sequential_Statement_Chain(n)): + for n1 in chain_iter(nodes.Get_Sequential_Statement_Chain(n)): for n2 in declarations_iter(n1): yield n2 if nodes_meta.Has_Parameter_Specification(k): - yield iirs.Get_Parameter_Specification(n) + yield nodes.Get_Parameter_Specification(n) if nodes_meta.Has_Generate_Statement_Body(k): - for n1 in declarations_iter(iirs.Get_Generate_Statement_Body(n)): + for n1 in declarations_iter(nodes.Get_Generate_Statement_Body(n)): yield n1 if nodes_meta.Has_Else_Clause(k): - n1 = iirs.Get_Else_Clause(n) + n1 = nodes.Get_Else_Clause(n) if n1 != Null_Iir: for n2 in declarations_iter(n1): yield n2 if nodes_meta.Has_Generate_Else_Clause(k): - n1 = iirs.Get_Generate_Else_Clause(n) + n1 = nodes.Get_Generate_Else_Clause(n) if n1 != Null_Iir: for n2 in declarations_iter(n1): yield n2 if nodes_meta.Has_Block_Header(k): - n1 = iirs.Get_Block_Header(n) + n1 = nodes.Get_Block_Header(n) if n1 != Null_Iir: for n2 in declarations_iter(n1): yield n2 # All these nodes are handled: - if k in [iirs.Iir_Kind.Entity_Declaration, - iirs.Iir_Kind.Architecture_Body, - iirs.Iir_Kind.Package_Declaration, - iirs.Iir_Kind.Package_Body, - iirs.Iir_Kind.Process_Statement, - iirs.Iir_Kind.Sensitized_Process_Statement, - iirs.Iir_Kind.Concurrent_Assertion_Statement, - iirs.Iir_Kind.Concurrent_Simple_Signal_Assignment, - iirs.Iir_Kind.Concurrent_Selected_Signal_Assignment, - iirs.Iir_Kind.Concurrent_Conditional_Signal_Assignment, - iirs.Iir_Kind.Concurrent_Procedure_Call_Statement, - iirs.Iir_Kind.Block_Statement, - iirs.Iir_Kind.Block_Header, - iirs.Iir_Kind.For_Generate_Statement, - iirs.Iir_Kind.If_Generate_Statement, - iirs.Iir_Kind.Generate_Statement_Body, - iirs.Iir_Kind.Assertion_Statement, - iirs.Iir_Kind.Wait_Statement, - iirs.Iir_Kind.Simple_Signal_Assignment_Statement, - iirs.Iir_Kind.Variable_Assignment_Statement, - iirs.Iir_Kind.For_Loop_Statement, - iirs.Iir_Kind.While_Loop_Statement, - iirs.Iir_Kind.Case_Statement, - iirs.Iir_Kind.Null_Statement, - iirs.Iir_Kind.Exit_Statement, - iirs.Iir_Kind.Next_Statement, - iirs.Iir_Kind.Procedure_Call_Statement, - iirs.Iir_Kind.Signal_Declaration, - iirs.Iir_Kind.Constant_Declaration, - iirs.Iir_Kind.Variable_Declaration, - iirs.Iir_Kind.File_Declaration, - iirs.Iir_Kind.Object_Alias_Declaration, - iirs.Iir_Kind.Attribute_Declaration, - iirs.Iir_Kind.Component_Declaration, - iirs.Iir_Kind.Use_Clause, - iirs.Iir_Kind.If_Statement, - iirs.Iir_Kind.Elsif, - iirs.Iir_Kind.Return_Statement, - iirs.Iir_Kind.Type_Declaration, - iirs.Iir_Kind.Anonymous_Type_Declaration, - iirs.Iir_Kind.Subtype_Declaration, - iirs.Iir_Kind.Function_Declaration, - iirs.Iir_Kind.Function_Body, - iirs.Iir_Kind.Procedure_Declaration, - iirs.Iir_Kind.Procedure_Body, - iirs.Iir_Kind.Component_Instantiation_Statement, + if k in [nodes.Iir_Kind.Entity_Declaration, + nodes.Iir_Kind.Architecture_Body, + nodes.Iir_Kind.Package_Declaration, + nodes.Iir_Kind.Package_Body, + nodes.Iir_Kind.Process_Statement, + nodes.Iir_Kind.Sensitized_Process_Statement, + nodes.Iir_Kind.Concurrent_Assertion_Statement, + nodes.Iir_Kind.Concurrent_Simple_Signal_Assignment, + nodes.Iir_Kind.Concurrent_Selected_Signal_Assignment, + nodes.Iir_Kind.Concurrent_Conditional_Signal_Assignment, + nodes.Iir_Kind.Concurrent_Procedure_Call_Statement, + nodes.Iir_Kind.Block_Statement, + nodes.Iir_Kind.Block_Header, + nodes.Iir_Kind.For_Generate_Statement, + nodes.Iir_Kind.If_Generate_Statement, + nodes.Iir_Kind.Generate_Statement_Body, + nodes.Iir_Kind.Assertion_Statement, + nodes.Iir_Kind.Wait_Statement, + nodes.Iir_Kind.Simple_Signal_Assignment_Statement, + nodes.Iir_Kind.Variable_Assignment_Statement, + nodes.Iir_Kind.For_Loop_Statement, + nodes.Iir_Kind.While_Loop_Statement, + nodes.Iir_Kind.Case_Statement, + nodes.Iir_Kind.Null_Statement, + nodes.Iir_Kind.Exit_Statement, + nodes.Iir_Kind.Next_Statement, + nodes.Iir_Kind.Procedure_Call_Statement, + nodes.Iir_Kind.Signal_Declaration, + nodes.Iir_Kind.Constant_Declaration, + nodes.Iir_Kind.Variable_Declaration, + nodes.Iir_Kind.File_Declaration, + nodes.Iir_Kind.Object_Alias_Declaration, + nodes.Iir_Kind.Attribute_Declaration, + nodes.Iir_Kind.Component_Declaration, + nodes.Iir_Kind.Use_Clause, + nodes.Iir_Kind.If_Statement, + nodes.Iir_Kind.Elsif, + nodes.Iir_Kind.Return_Statement, + nodes.Iir_Kind.Type_Declaration, + nodes.Iir_Kind.Anonymous_Type_Declaration, + nodes.Iir_Kind.Subtype_Declaration, + nodes.Iir_Kind.Function_Declaration, + nodes.Iir_Kind.Function_Body, + nodes.Iir_Kind.Procedure_Declaration, + nodes.Iir_Kind.Procedure_Body, + nodes.Iir_Kind.Component_Instantiation_Statement, ]: return assert False, "unknown node of kind {}".format(kind_image(k)) @@ -261,37 +258,37 @@ def declarations_iter(n): def concurrent_stmts_iter(n): """Iterator on concurrent statements in n.""" - k = iirs.Get_Kind(n) - if k == iirs.Iir_Kind.Design_File: - for n1 in chain_iter(iirs.Get_First_Design_Unit(n)): + k = nodes.Get_Kind(n) + if k == nodes.Iir_Kind.Design_File: + for n1 in chain_iter(nodes.Get_First_Design_Unit(n)): for n2 in concurrent_stmts_iter(n1): yield n2 - elif k == iirs.Iir_Kind.Design_Unit: - for n1 in concurrent_stmts_iter(iirs.Get_Library_Unit(n)): + elif k == nodes.Iir_Kind.Design_Unit: + for n1 in concurrent_stmts_iter(nodes.Get_Library_Unit(n)): yield n1 - elif k == iirs.Iir_Kind.Entity_Declaration \ - or k == iirs.Iir_Kind.Architecture_Body \ - or k == iirs.Iir_Kind.Block_Statement: - for n1 in chain_iter(iirs.Get_Concurrent_Statement_Chain(n)): + elif k == nodes.Iir_Kind.Entity_Declaration \ + or k == nodes.Iir_Kind.Architecture_Body \ + or k == nodes.Iir_Kind.Block_Statement: + for n1 in chain_iter(nodes.Get_Concurrent_Statement_Chain(n)): yield n1 for n2 in concurrent_stmts_iter(n1): yield n2 - elif k == iirs.Iir_Kind.For_Generate_Statement: - for n1 in concurrent_stmts_iter(iirs.Get_Generate_Statement_Body(n)): + elif k == nodes.Iir_Kind.For_Generate_Statement: + for n1 in concurrent_stmts_iter(nodes.Get_Generate_Statement_Body(n)): yield n1 - elif k == iirs.Iir_Kind.If_Generate_Statement: + elif k == nodes.Iir_Kind.If_Generate_Statement: while n != Null_Iir: for n1 in concurrent_stmts_iter( - iirs.Get_Generate_Statement_Body(n)): + nodes.Get_Generate_Statement_Body(n)): yield n1 - n = iirs.Get_Generate_Else_Clause(n) - elif k == iirs.Iir_Kind.Case_Generate_Statement: - alt = iirs.Get_Case_Statement_Alternative_Chain(n) + n = nodes.Get_Generate_Else_Clause(n) + elif k == nodes.Iir_Kind.Case_Generate_Statement: + alt = nodes.Get_Case_Statement_Alternative_Chain(n) for n1 in chain_iter(alt): - blk = iirs.Get_Associated_Block(n1) + blk = nodes.Get_Associated_Block(n1) if blk != Null_Iir: for n2 in concurrent_stmts_iter( - iirs.Get_Generate_Statement_Body(n)): + nodes.Get_Generate_Statement_Body(n)): yield n2 @@ -300,59 +297,59 @@ def constructs_iter(n): that appear directly within a declarative part.""" if n == thin.Null_Iir: return - k = iirs.Get_Kind(n) - if k == iirs.Iir_Kind.Design_File: - for n1 in chain_iter(iirs.Get_First_Design_Unit(n)): + k = nodes.Get_Kind(n) + if k == nodes.Iir_Kind.Design_File: + for n1 in chain_iter(nodes.Get_First_Design_Unit(n)): for n2 in constructs_iter(n1): yield n2 - elif k == iirs.Iir_Kind.Design_Unit: - n1 = iirs.Get_Library_Unit(n) + elif k == nodes.Iir_Kind.Design_Unit: + n1 = nodes.Get_Library_Unit(n) yield n1 for n2 in constructs_iter(n1): yield n2 - elif k in [iirs.Iir_Kind.Entity_Declaration, - iirs.Iir_Kind.Architecture_Body, - iirs.Iir_Kind.Block_Statement, - iirs.Iir_Kind.Generate_Statement_Body]: - for n1 in chain_iter(iirs.Get_Declaration_Chain(n)): + elif k in [nodes.Iir_Kind.Entity_Declaration, + nodes.Iir_Kind.Architecture_Body, + nodes.Iir_Kind.Block_Statement, + nodes.Iir_Kind.Generate_Statement_Body]: + for n1 in chain_iter(nodes.Get_Declaration_Chain(n)): yield n1 for n2 in constructs_iter(n1): yield n2 - for n1 in chain_iter(iirs.Get_Concurrent_Statement_Chain(n)): + for n1 in chain_iter(nodes.Get_Concurrent_Statement_Chain(n)): yield n1 for n2 in constructs_iter(n1): yield n2 - elif k in [iirs.Iir_Kind.Configuration_Declaration, - iirs.Iir_Kind.Package_Declaration, - iirs.Iir_Kind.Package_Body, - iirs.Iir_Kind.Function_Body, - iirs.Iir_Kind.Procedure_Body, - iirs.Iir_Kind.Protected_Type_Declaration, - iirs.Iir_Kind.Protected_Type_Body, - iirs.Iir_Kind.Process_Statement, - iirs.Iir_Kind.Sensitized_Process_Statement]: - for n1 in chain_iter(iirs.Get_Declaration_Chain(n)): + elif k in [nodes.Iir_Kind.Configuration_Declaration, + nodes.Iir_Kind.Package_Declaration, + nodes.Iir_Kind.Package_Body, + nodes.Iir_Kind.Function_Body, + nodes.Iir_Kind.Procedure_Body, + nodes.Iir_Kind.Protected_Type_Declaration, + nodes.Iir_Kind.Protected_Type_Body, + nodes.Iir_Kind.Process_Statement, + nodes.Iir_Kind.Sensitized_Process_Statement]: + for n1 in chain_iter(nodes.Get_Declaration_Chain(n)): yield n1 for n2 in constructs_iter(n1): yield n2 - elif k == iirs.Iir_Kind.For_Generate_Statement: - n1 = iirs.Get_Generate_Statement_Body(n) + elif k == nodes.Iir_Kind.For_Generate_Statement: + n1 = nodes.Get_Generate_Statement_Body(n) yield n1 for n2 in constructs_iter(n1): yield n2 - elif k == iirs.Iir_Kind.If_Generate_Statement: + elif k == nodes.Iir_Kind.If_Generate_Statement: while n != Null_Iir: - n1 = iirs.Get_Generate_Statement_Body(n) + n1 = nodes.Get_Generate_Statement_Body(n) yield n1 for n2 in constructs_iter(n1): yield n2 - n = iirs.Get_Generate_Else_Clause(n) - elif k == iirs.Iir_Kind.Case_Generate_Statement: - alt = iirs.Get_Case_Statement_Alternative_Chain(n) + n = nodes.Get_Generate_Else_Clause(n) + elif k == nodes.Iir_Kind.Case_Generate_Statement: + alt = nodes.Get_Case_Statement_Alternative_Chain(n) for n1 in chain_iter(alt): - blk = iirs.Get_Associated_Block(n1) + blk = nodes.Get_Associated_Block(n1) if blk != Null_Iir: - n2 = iirs.Get_Generate_Statement_Body(blk) + n2 = nodes.Get_Generate_Statement_Body(blk) yield n2 for n3 in constructs_iter(n2): yield n3 @@ -362,46 +359,46 @@ def sequential_iter(n): a process or a subprogram body.""" if n == thin.Null_Iir: return - k = iirs.Get_Kind(n) - if k in [iirs.Iir_Kind.Process_Statement, - iirs.Iir_Kind.Sensitized_Process_Statement, - iirs.Iir_Kind.Function_Body, - iirs.Iir_Kind.Procedure_Body]: - for n1 in chain_iter(iirs.Get_Sequential_Statement_Chain(n)): + k = nodes.Get_Kind(n) + if k in [nodes.Iir_Kind.Process_Statement, + nodes.Iir_Kind.Sensitized_Process_Statement, + nodes.Iir_Kind.Function_Body, + nodes.Iir_Kind.Procedure_Body]: + for n1 in chain_iter(nodes.Get_Sequential_Statement_Chain(n)): yield n1 for n2 in sequential_iter(n1): yield n2 - elif k == iirs.Iir_Kind.If_Statement: + elif k == nodes.Iir_Kind.If_Statement: while True: - n = iirs.Get_Chain(n) + n = nodes.Get_Chain(n) if n == thin.Null_Iir: break yield n for n1 in sequential_iter(n): yield n1 - elif k == iirs.Iir_Kind.Case_Statement: - for ch in chain_iter(iirs.Get_Case_Statement_Alternative_Chain(n)): - stmt = iirs.Get_Associated_Chain(ch) + elif k == nodes.Iir_Kind.Case_Statement: + for ch in chain_iter(nodes.Get_Case_Statement_Alternative_Chain(n)): + stmt = nodes.Get_Associated_Chain(ch) if stmt != thin.Null_Iir: for n1 in chain_iter(stmt): yield n1 for n2 in sequential_iter(n1): yield n2 - elif k in [iirs.Iir_Kind.For_Loop_Statement, - iirs.Iir_Kind.While_Loop_Statement]: - for n1 in chain_iter(iirs.Get_Sequential_Statement_Chain(n)): + elif k in [nodes.Iir_Kind.For_Loop_Statement, + nodes.Iir_Kind.While_Loop_Statement]: + for n1 in chain_iter(nodes.Get_Sequential_Statement_Chain(n)): yield n1 for n2 in sequential_iter(n1): yield n2 - elif k in [iirs.Iir_Kind.Assertion_Statement, - iirs.Iir_Kind.Wait_Statement, - iirs.Iir_Kind.Null_Statement, - iirs.Iir_Kind.Exit_Statement, - iirs.Iir_Kind.Next_Statement, - iirs.Iir_Kind.Return_Statement, - iirs.Iir_Kind.Variable_Assignment_Statement, - iirs.Iir_Kind.Simple_Signal_Assignment_Statement, - iirs.Iir_Kind.Procedure_Call_Statement]: + elif k in [nodes.Iir_Kind.Assertion_Statement, + nodes.Iir_Kind.Wait_Statement, + nodes.Iir_Kind.Null_Statement, + nodes.Iir_Kind.Exit_Statement, + nodes.Iir_Kind.Next_Statement, + nodes.Iir_Kind.Return_Statement, + nodes.Iir_Kind.Variable_Assignment_Statement, + nodes.Iir_Kind.Simple_Signal_Assignment_Statement, + nodes.Iir_Kind.Procedure_Call_Statement]: return else: assert False, "unknown node of kind {}".format(kind_image(k)) diff --git a/src/vhdl/python/pnodespy.py b/src/vhdl/python/pnodespy.py index d2ea23125..b4d81a26a 100755 --- a/src/vhdl/python/pnodespy.py +++ b/src/vhdl/python/pnodespy.py @@ -138,6 +138,7 @@ def do_libghdl_nodes(): print('from libghdl import libghdl') print(""" Null_Iir = 0 + Null_Iir_List = 0 Iir_List_All = 1 @@ -230,7 +231,8 @@ def do_libghdl_tokens(): def do_libghdl_errorout(): - print("""from ctypes import c_int8, c_int32 + print("""from ctypes import c_int8, c_int32, Structure + class Error_Record(Structure): _fields_ = [("origin", c_int8), ("id", c_int8), -- cgit v1.2.3