LLVMValueRef gen_error(compile_t* c, ast_t* ast) { size_t clause; ast_t* try_expr = ast_try_clause(ast, &clause); // Do the then block only if we error out in the else clause. if((try_expr != NULL) && (clause == 1)) gen_expr(c, ast_childidx(try_expr, 2)); codegen_scope_lifetime_end(c); codegen_debugloc(c, ast); gencall_throw(c); codegen_debugloc(c, NULL); return GEN_NOVALUE; }
static void maybe_apply(compile_t* c, reach_type_t* t, reach_type_t* t_elem) { // Returns the receiver if it isn't null. FIND_METHOD("apply"); start_function(c, m, t_elem->use_type, &t->use_type, 1); LLVMValueRef result = LLVMGetParam(m->func, 0); LLVMValueRef test = LLVMBuildIsNull(c->builder, result, ""); LLVMBasicBlockRef is_false = codegen_block(c, ""); LLVMBasicBlockRef is_true = codegen_block(c, ""); LLVMBuildCondBr(c->builder, test, is_true, is_false); LLVMPositionBuilderAtEnd(c->builder, is_false); result = LLVMBuildBitCast(c->builder, result, t_elem->use_type, ""); LLVMBuildRet(c->builder, result); LLVMPositionBuilderAtEnd(c->builder, is_true); gencall_throw(c); codegen_finishfun(c); BOX_FUNCTION(); }