def check_err_int(self, llvm_result, badval): llvm_badval = llvm.core.Constant.int(llvm_result.type, badval) if_badval( self.translator, llvm_result, llvm_badval, callback=lambda b, *args: b.branch(self.translator.error_label))
def check_err(self, llvm_result, callback=None, cmp=llvm.core.ICMP_EQ, pos_node=None): """ Check for errors. If the result is NULL, and error should have been set Jumps to translator.error_label if an exception occurred. """ assert llvm_result.type.kind == llvm.core.TYPE_POINTER, llvm_result.type int_result = self.translator.builder.ptrtoint(llvm_result, llvm_types._intp) NULL = llvm.core.Constant.int(int_result.type, 0) if callback: if_badval(self.translator, int_result, NULL, callback=callback or default_callback, cmp=cmp) else: test = self.builder.icmp(cmp, int_result, NULL) name = 'no_error' if hasattr(pos_node, 'lineno'): name = 'no_error_%s' % error.format_pos(pos_node).rstrip(": ") bb = self.translator.append_basic_block(name) self.builder.cbranch(test, self.translator.error_label, bb) self.builder.position_at_end(bb) return llvm_result
def check_err_int(self, llvm_result, badval): llvm_badval = llvm.core.Constant.int(llvm_result.type, badval) if_badval(self.translator, llvm_result, llvm_badval, callback=lambda b, *args: b.branch(self.translator.error_label))