@@ -1498,6 +1498,7 @@ def __init__(self):
14981498 self ._inlineRequests = []
14991499
15001500 self ._printAllNativeCalls = os .getenv ("TP_COMPILER_LOG_NATIVE_CALLS" )
1501+ self ._native_ast_str = ""
15011502 self .verbose = False
15021503
15031504 def markExternal (self , functionNameToType ):
@@ -1575,30 +1576,28 @@ def add_functions(self, names_to_definitions):
15751576 )
15761577 func_type = llvmlite .ir .FunctionType (
15771578 type_to_llvm_type (function .output_type ),
1578- [type_to_llvm_type (x [1 ]) for x in function .args ]
1579+ [type_to_llvm_type (x [1 ]) for x in function .args ],
1580+ )
1581+ self ._functions_by_name [name ] = llvmlite .ir .Function (
1582+ module , func_type , name
15791583 )
1580- self ._functions_by_name [name ] = llvmlite .ir .Function (module , func_type , name )
15811584
1582- self ._functions_by_name [name ].linkage = ' external'
1585+ self ._functions_by_name [name ].linkage = " external"
15831586 self ._function_definitions [name ] = function
15841587
1585- if self .verbose :
1586- for name in names_to_definitions :
1587- definition = names_to_definitions [name ]
1588- func = self ._functions_by_name [name ]
1588+ self ._native_ast_str += "\n "
1589+ self ._native_ast_str += "*************\n "
1590+ self ._native_ast_str += "def %s(%s): #->%s\n " % (
1591+ name ,
1592+ "," .join (["%s=%s" % (k , str (t )) for k , t in function .args ]),
1593+ str (function .output_type ),
1594+ )
1595+ self ._native_ast_str += native_ast .indent (str (function .body .body )) + "\n "
1596+ self ._native_ast_str += "*************\n "
1597+ self ._native_ast_str += "\n "
15891598
1590- print ()
1591- print ("*************" )
1592- print (
1593- "def %s(%s): #->%s" % (
1594- name ,
1595- "," .join (["%s=%s" % (k , str (t )) for k , t in definition .args ]),
1596- str (definition .output_type )
1597- )
1598- )
1599- print (native_ast .indent (str (definition .body .body )))
1600- print ("*************" )
1601- print ()
1599+ if self .verbose :
1600+ print (self ._native_ast_str )
16021601
16031602 globalDefinitions = {}
16041603 globalDefinitionsLlvmValues = {}
0 commit comments