本文整理汇总了Python中incoq.compiler.incast.L.tree_size方法的典型用法代码示例。如果您正苦于以下问题:Python L.tree_size方法的具体用法?Python L.tree_size怎么用?Python L.tree_size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类incoq.compiler.incast.L
的用法示例。
在下文中一共展示了L.tree_size方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: transform_source
# 需要导入模块: from incoq.compiler.incast import L [as 别名]
# 或者: from incoq.compiler.incast.L import tree_size [as 别名]
def transform_source(input_source, *, options=None, query_options=None):
"""Take in the Python source code to a module and return the
transformed source code and the symbol table.
"""
tree = P.Parser.p(input_source)
t1 = process_time()
tree, symtab = transform_ast(tree, options=options,
query_options=query_options)
t2 = process_time()
source = P.Parser.ts(tree)
# All good human beings have trailing newlines in their
# text files.
source = source + '\n'
symtab.stats['lines'] = get_loc_source(source)
# L.tree_size() is for IncASTs, but it should also work for
# Python ASTs. We have to re-parse the source to get rid of
# our Comment pseudo-nodes.
tree = P.Parser.p(source)
symtab.stats['ast_nodes'] = L.tree_size(tree)
symtab.stats['time'] = t2 - t1
return source, symtab
示例2: process
# 需要导入模块: from incoq.compiler.incast import L [as 别名]
# 或者: from incoq.compiler.incast.L import tree_size [as 别名]
def process(self, tree):
# Keep maps from each seen query name to its original expression
# and its rewritten expression.
self.queries_before = {}
self.queries_after = {}
# A query's symbol definition has to be updated before we
# discover any of its occurrences, or it will be incorrectly
# interpreted as a consistency error. For this reason, process
# all query definitions before the tree, and process these
# definitions in order of increasing size so that inner queries
# come first.
queries = list(self.symtab.get_queries().values())
queries.sort(key=lambda q: L.tree_size(q.node))
for query in queries:
query.node = super().process(query.node)
# Process tree.
tree = super().process(tree)
return tree