static bool check_value(compile_t* c, ast_t* pattern, ast_t* param_type, LLVMValueRef value, LLVMBasicBlockRef next_block) { LLVMValueRef l_value = gen_expr(c, pattern); if(l_value == NULL) return false; gentype_t g; if(!gentype(c, param_type, &g)) return false; LLVMValueRef r_value = gen_assign_cast(c, g.use_type, value, param_type); if(r_value == NULL) return false; LLVMValueRef test = gen_pattern_eq(c, pattern, r_value); if(test == NULL) return false; LLVMBasicBlockRef continue_block = codegen_block(c, "pattern_continue"); LLVMBuildCondBr(c->builder, test, continue_block, next_block); LLVMPositionBuilderAtEnd(c->builder, continue_block); return true; }
static bool check_value(compile_t* c, ast_t* pattern, ast_t* param_type, LLVMValueRef value, LLVMBasicBlockRef next_block) { reach_type_t* t = reach_type(c->reach, param_type); LLVMValueRef r_value = gen_assign_cast(c, t->use_type, value, param_type); if(r_value == NULL) return false; LLVMValueRef result = gen_pattern_eq(c, pattern, r_value); if(result == NULL) return false; LLVMBasicBlockRef continue_block = codegen_block(c, "pattern_continue"); LLVMValueRef test = LLVMBuildTrunc(c->builder, result, c->i1, ""); LLVMBuildCondBr(c->builder, test, continue_block, next_block); LLVMPositionBuilderAtEnd(c->builder, continue_block); return true; }