# Path: pykit/analysis/callgraph.py
# def callgraph(func, graph=None, seen=None):
#     """
#     Eliminate dead code.
# 
#     TODO: Prune branches, dead loops
#     """
#     if seen is None:
#         seen = set()
#         graph = nx.DiGraph()
# 
#     if func in seen:
#         return
# 
#     graph.add_node(func)
#     seen.add(func)
# 
#     for op in func.ops:
#         if op.opcode == 'call':
#             callee, args = op.args
#             if isinstance(callee, ir.Function):
#                 graph.add_edge(func, callee)
#                 callgraph(func, graph, seen)
# 
#     return graph


from pykit.analysis import callgraph
# -*- coding: utf-8 -*-

"""
Invoke the code generator for each function in the call graph. This makes
sure each function is "initialized" (e.g. has a C declaration or a dummy
LLVM function, etc).
"""


def run(func, env, codegen=None):
    """
    Invoke the code generator after initializing all functions in the call graph
    """
    codegen = codegen or env["codegen.impl"]
    cache = env["codegen.cache"]


# Path: pykit/analysis/callgraph.py
# def callgraph(func, graph=None, seen=None):
#     """
#     Eliminate dead code.
# 
#     TODO: Prune branches, dead loops
#     """
#     if seen is None:
#         seen = set()
#         graph = nx.DiGraph()
# 
#     if func in seen:
#         return
# 
#     graph.add_node(func)
#     seen.add(func)
# 
#     for op in func.ops:
#         if op.opcode == 'call':
#             callee, args = op.args
#             if isinstance(callee, ir.Function):
#                 graph.add_edge(func, callee)
#                 callgraph(func, graph, seen)
# 
#     return graph


# Path: pykit/codegen/codegen.py
from pykit.analysis import callgraph

# -*- coding: utf-8 -*-

"""
Invoke the code generator for each function in the call graph. This makes
sure each function is "initialized" (e.g. has a C declaration or a dummy
LLVM function, etc).
"""


def run(func, env, codegen=None):
    """
    Invoke the code generator after initializing all functions in the call graph
    """
    codegen = codegen or env["codegen.impl"]
    cache = env["codegen.cache"]


    graph = callgraph.callgraph(func)