mirror of
https://github.com/odin-lang/Odin.git
synced 2026-02-13 06:43:35 +00:00
Use context.assertion_failure_proc with type assertions when the context is available, otherwise use a trivial trap.
This commit is contained in:
@@ -3865,7 +3865,12 @@ gb_internal lbValue lb_build_unary_and(lbProcedure *p, Ast *expr) {
|
||||
args[4] = lb_typeid(p->module, src_type);
|
||||
args[5] = lb_typeid(p->module, dst_type);
|
||||
}
|
||||
lb_emit_runtime_call(p, "type_assertion_check", args);
|
||||
|
||||
char const *name = "type_assertion_check_contextless";
|
||||
if (p->context_stack.count > 0) {
|
||||
name = "type_assertion_check_with_context";
|
||||
}
|
||||
lb_emit_runtime_call(p, name, args);
|
||||
}
|
||||
|
||||
lbValue data_ptr = v;
|
||||
@@ -3881,16 +3886,28 @@ gb_internal lbValue lb_build_unary_and(lbProcedure *p, Ast *expr) {
|
||||
|
||||
lbValue any_id = lb_emit_struct_ev(p, v, 1);
|
||||
|
||||
isize arg_count = 6;
|
||||
if (build_context.no_rtti) {
|
||||
arg_count = 4;
|
||||
}
|
||||
|
||||
lbValue id = lb_typeid(p->module, type);
|
||||
lbValue ok = lb_emit_comp(p, Token_CmpEq, any_id, id);
|
||||
auto args = array_make<lbValue>(permanent_allocator(), 6);
|
||||
auto args = array_make<lbValue>(permanent_allocator(), arg_count);
|
||||
args[0] = ok;
|
||||
|
||||
lb_set_file_line_col(p, array_slice(args, 1, args.count), pos);
|
||||
|
||||
args[4] = any_id;
|
||||
args[5] = id;
|
||||
lb_emit_runtime_call(p, "type_assertion_check", args);
|
||||
if (!build_context.no_rtti) {
|
||||
args[4] = any_id;
|
||||
args[5] = id;
|
||||
}
|
||||
|
||||
char const *name = "type_assertion_check_contextless";
|
||||
if (p->context_stack.count > 0) {
|
||||
name = "type_assertion_check_with_context";
|
||||
}
|
||||
lb_emit_runtime_call(p, name, args);
|
||||
}
|
||||
|
||||
return lb_emit_conv(p, data_ptr, tv.type);
|
||||
|
||||
Reference in New Issue
Block a user