def visitCallFunc(self, n): args_fs = [self.dispatch(arg) for arg in n.args] args = [arg for (arg,ss) in args_fs] fs1 = reduce(lambda x,y: x + y, [fs for (arg,fs) in args_fs], []) (node, fs2) = self.dispatch(n.node) if isinstance(node, FunName) and node.name in builtin_functions: return (CallFunc(node, args), fs1 + fs2) else: return (letify(node, lambda fun_expr: IndirectCallFunc(CallFunc(FunName('get_fun_ptr'), [fun_expr]), [CallFunc(FunName('get_free_vars'), [fun_expr])] + args)), fs1 + fs2)
def visitWhile(self, n): #test, body (Stmt), else_ #don't have to worry about else_ case! return While(letify(self.dispatch(n.test),lambda t: gen_is_true(t)), self.dispatch(n.body) , n.else_,n.phis)
def visitWhile(self, n): test = self.dispatch(n.test) body = self.dispatch(n.body) return While(letify(test, lambda t: gen_is_true(t)), body, n.else_)
def visitIf(self, n): test = self.dispatch(n.tests[0][0]) then = self.dispatch(n.tests[0][1]) else_ = self.dispatch(n.else_) return If([(letify(test, lambda t: gen_is_true(t)), then)], else_)