typer.c (788B)
1 #include "typer.h" 2 #include "utils.h" 3 #include <string.h> 4 5 static const char* 6 c_types_to_ox_str(const char* ctype) 7 { 8 if (strcmp(ctype, "__int32_t") == 0) { 9 return "i32"; 10 } else if (strcmp(ctype, "__int64_t") == 0) { 11 return "i64"; 12 } else { 13 return "UNKNOWN C TYPE"; 14 } 15 } 16 17 void 18 types_match_or_panic(Node* node, gcc_jit_type* expect, gcc_jit_type* actual) 19 { 20 if (!gcc_jit_compatible_types(expect, actual)) { 21 gcc_jit_object* obj_a = gcc_jit_type_as_object(expect); 22 gcc_jit_object* obj_b = gcc_jit_type_as_object(actual); 23 const char* type_a = c_types_to_ox_str(gcc_jit_object_get_debug_string(obj_a)); 24 const char* type_b = c_types_to_ox_str(gcc_jit_object_get_debug_string(obj_b)); 25 panic_at(node, "Incompatible types: expected type <%s>, but got <%s>", type_a, type_b); 26 } 27 }