def __init__(self, context, func, ast, allow_rebind_args, env, **kwargs): super(ControlFlowAnalysis, self).__init__(context, func, ast, env=env, **kwargs) self.visitchildren = self.generic_visit self.current_directives = kwargs.get('directives', None) or {} self.current_directives['warn'] = kwargs.get('warn', True) self.set_default_directives() self.symtab = self.initialize_symtab(allow_rebind_args) self.graphviz = self.current_directives['control_flow.dot_output'] if self.graphviz: self.gv_ctx = graphviz.GVContext() self.source_descr = reporting.SourceDescr(func, ast) # Stack of control flow blocks self.stack = [] flow = ControlFlow(self.env, self.source_descr) self.env.translation.crnt.flow = flow self.flow = flow # TODO: Use the message collection from the environment # messages = reporting.MessageCollection() messages = env.crnt.error_env.collection self.warner = reaching.CFWarner(messages, self.current_directives) if env: if hasattr(env, 'translation'): env.translation.crnt.cfg_transform = self
def __init__(self, func, ast, warnstyle): self.func = func self.ast = ast # copy.deepcopy(ast) # Retrieve the source code now source_descr = reporting.SourceDescr(func, ast) self.source = source_descr.get_lines() collection_cls = self.warning_styles[warnstyle] self.collection = collection_cls(self.ast, self.source)