def visit_FunctionDef(self, node): self.curr_locals_declaration = self.gather(LocalNodeDeclarations, node) self.current = node self.typedefs = list() self.name_to_nodes = defaultdict(ordered_set) for arg in node.args.args: self.name_to_nodes[arg.id].append(arg) self.yield_points = self.gather(YieldPoints, node) # two stages, one for inter procedural propagation self.stage = 0 self.generic_visit(node) # and one for backward propagation # but this step is generally costly if cfg.getboolean('typing', 'enable_two_steps_typing'): self.stage = 1 self.generic_visit(node) # propagate type information through all aliases for name, nodes in self.name_to_nodes.items(): unique_types = ordered_set(self.result[n] for n in nodes) final_node = reduce(self.builder.Type.__add__, unique_types) for n in nodes: self.result[n] = final_node self.current_global_declarations[node.name] = node # return type may be unset if the function always raises return_type = self.result.get( node, self.builder.NamedType("pythonic::types::none_type")) self.result[node] = self.builder.Returnable(return_type), self.typedefs for k in self.gather(LocalNodeDeclarations, node): self.result[k] = self.get_qualifier(k)(self.result[k])
def visit_FunctionDef(self, node): self.curr_locals_declaration = self.gather( LocalNodeDeclarations, node) self.current = node self.typedefs = list() self.name_to_nodes = defaultdict(ordered_set) for arg in node.args.args: self.name_to_nodes[arg.id].append(arg) self.yield_points = self.gather(YieldPoints, node) # two stages, one for inter procedural propagation self.stage = 0 self.generic_visit(node) # and one for backward propagation # but this step is generally costly if cfg.getboolean('typing', 'enable_two_steps_typing'): self.stage = 1 self.generic_visit(node) # propagate type information through all aliases for name, nodes in self.name_to_nodes.items(): unique_types = ordered_set(self.result[n] for n in nodes) final_node = reduce(self.builder.Type.__add__, unique_types) for n in nodes: self.result[n] = final_node self.current_global_declarations[node.name] = node # return type may be unset if the function always raises return_type = self.result.get( node, self.builder.NamedType("pythonic::types::none_type")) self.result[node] = self.builder.Returnable(return_type), self.typedefs for k in self.gather(LocalNodeDeclarations, node): self.result[k] = self.get_qualifier(k)(self.result[k])