def visitCall(self, node): func = tools.singleCall(node) if func is not None: result = ast.DirectCall(func, node.expr, node.args, node.kwds, node.vargs, node.kargs) result.annotation = node.annotation return self(result) return node
def visitMethodCall(self, node): func = tools.singleCall(node) if func is not None: funcobj = self.getMethodFunction(node.expr, node.name) # TODO deal with single call / multiple function object case? if not funcobj: return node newargs = [node.expr] newargs.extend(node.args) result = ast.DirectCall(func, funcobj, newargs, node.kwds, node.vargs, node.kargs) result.annotation = node.annotation return self(result) return node
def visitDirectCall(self, node): tempresult = self.default(node) invokes = tempresult.annotation.invokes assert invokes is not None, "All invocations must be resolved to clone." if invokes[0]: # We do this computation after transfer, as it can reduce the number of invocations. func = tools.singleCall(tempresult) if not func: names = tuple(set([code.name for code, context in invokes[0]])) raise Exception, "Cannot clone the direct call in %r, as it has multiple targets. %r" % (self.code, names) else: # This op is never actually executed, so we can't determine the target. # Set the target to "None", as the op should be subsequently eliminated. func = None result = ast.DirectCall(func, *tempresult.children()[1:]) self.transferAnalysisData(node, result) return result
def visitDirectCall(self, node): tempresult = self.default(node) invokes = tempresult.annotation.invokes assert invokes is not None, "All invocations must be resolved to clone." if invokes[0]: # We do this computation after transfer, as it can reduce the number of invocations. func = tools.singleCall(tempresult) if not func: names = tuple(set([code.name for code, context in invokes[0]])) raise Exception, "Cannot clone the direct call in %r, as it has multiple targets. %r" % ( self.code, names) else: # This op is never actually executed, so we can't determine the target. # Set the target to "None", as the op should be subsequently eliminated. func = None result = ast.DirectCall(func, *tempresult.children()[1:]) self.transferAnalysisData(node, result) return result