本文整理汇总了Python中incoq.compiler.incast.L.get_defined_functions方法的典型用法代码示例。如果您正苦于以下问题:Python L.get_defined_functions方法的具体用法?Python L.get_defined_functions怎么用?Python L.get_defined_functions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类incoq.compiler.incast.L
的用法示例。
在下文中一共展示了L.get_defined_functions方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: visit_Module
# 需要导入模块: from incoq.compiler.incast import L [as 别名]
# 或者: from incoq.compiler.incast.L import get_defined_functions [as 别名]
def visit_Module(self, node):
node = self.generic_visit(node)
fv = self.fresh_vars
ops = [L.SetAdd(), L.SetRemove()]
funcs = []
for op in ops:
func = make_aggr_oper_maint_func(fv, self.aggrinv, op)
funcs.append(func)
if self.aggrinv.uses_demand:
for op in ops:
func = make_aggr_restr_maint_func(fv, self.aggrinv, op)
funcs.append(func)
func_names = L.get_defined_functions(tuple(funcs))
self.maint_funcs.update(func_names)
node = node._replace(body=tuple(funcs) + node.body)
return node
示例2: analyze_costs
# 需要导入模块: from incoq.compiler.incast import L [as 别名]
# 或者: from incoq.compiler.incast.L import get_defined_functions [as 别名]
def analyze_costs(tree):
"""Analyze the costs of the functions in the program and return
a map from function name to cost. If recursion is present, only
non-recursive functions are analyzed.
"""
all_funcs = L.get_defined_functions(tree)
graph = L.analyze_functions(tree, all_funcs,
allow_recursion=True)
# Analyze the functions in topological order, constructing
# func_costs as we go.
func_costs = {}
func_params = graph.param_map
for f in graph.order:
body = graph.body_map[f]
cost = CallCostAnalyzer.run(body, func_params, func_costs)
# Eliminate image key terms that aren't formal parameters.
key_filter = lambda p: p if p in func_params[f] else None
cost = ImgkeySubstitutor.run(cost, key_filter)
func_costs[f] = cost
return func_costs