def visit_PyErr_OccurredNode(self, node): check_err = nodes.CheckErrorNode(nodes.ptrtoint( function_util.external_call(self.context, self.llvm_module, 'PyErr_Occurred')), goodval=nodes.ptrtoint(nodes.NULL)) result = nodes.CloneableNode(node.node) result = nodes.ExpressionNode(stmts=[result, check_err], expr=result.clone) return self.visit(result)
def visit_NativeCallNode(self, node): badval, goodval = node.badval, node.goodval if node not in self.visited_callnodes and (badval is not None or goodval is not None): self.visited_callnodes.add(node) result = node.cloneable body = nodes.CheckErrorNode(result, badval, goodval, node.exc_type, node.exc_msg, node.exc_args) node = nodes.ExpressionNode(stmts=[body], expr=result.clone) return self.visit(node) else: self.generic_visit(node) return node
def visit_Name(self, node): if (is_obj(node.type) and isinstance(node.ctx, ast.Load) and getattr(node, 'cf_maybe_null', False)): # Check for unbound objects and raise UnboundLocalError if so value = nodes.LLVMValueRefNode(Py_uintptr_t, None) node.loaded_name = value exc_msg = node.variable.name if hasattr(node, 'lineno'): exc_msg = '%s%s' % (error.format_pos(node), exc_msg) check_unbound = nodes.CheckErrorNode(value, badval=nodes.const( 0, Py_uintptr_t), exc_type=UnboundLocalError, exc_msg=exc_msg) node.check_unbound = self.visit(check_unbound) return node
def __init__(self, array_type, operands, **kwargs): super(BroadcastNode, self).__init__(**kwargs) self.operands = operands self.shape_type = numba.carray(npy_intp, array_type.ndim) self.array_type = array_type self.type = npy_intp.pointer() self.broadcast_retvals = {} self.check_errors = [] for op in operands: if op.type.is_array: # TODO: Put the raise code in a separate basic block and jump return_value = nodes.LLVMValueRefNode(int_, None) check_error = nodes.CheckErrorNode( return_value, 0, exc_type=ValueError, exc_msg="Shape mismatch while broadcasting") self.broadcast_retvals[op] = return_value self.check_errors.append(check_error)