runtime: runtime.Caller should succeed even without debug info.
[gcc.git] / libgo / runtime / go-check-interface.c
1 /* go-check-interface.c -- check an interface type for a conversion
2
3 Copyright 2010 The Go Authors. All rights reserved.
4 Use of this source code is governed by a BSD-style
5 license that can be found in the LICENSE file. */
6
7 #include "go-panic.h"
8 #include "interface.h"
9 #include "runtime.h"
10
11 /* Check that an interface type matches for a conversion to a
12 non-interface type. This panics if the types are bad. The actual
13 extraction of the object is inlined. */
14
15 void
16 __go_check_interface_type (
17 const struct __go_type_descriptor *lhs_descriptor,
18 const struct __go_type_descriptor *rhs_descriptor,
19 const struct __go_type_descriptor *rhs_inter_descriptor)
20 {
21 if (rhs_descriptor == NULL)
22 {
23 struct __go_empty_interface panic_arg;
24
25 runtime_newTypeAssertionError(NULL, NULL, lhs_descriptor->__reflection,
26 NULL, &panic_arg);
27 __go_panic(panic_arg);
28 }
29
30 if (lhs_descriptor != rhs_descriptor
31 && !__go_type_descriptors_equal (lhs_descriptor, rhs_descriptor)
32 && (lhs_descriptor->__code != GO_UNSAFE_POINTER
33 || !__go_is_pointer_type (rhs_descriptor))
34 && (rhs_descriptor->__code != GO_UNSAFE_POINTER
35 || !__go_is_pointer_type (lhs_descriptor)))
36 {
37 struct __go_empty_interface panic_arg;
38
39 runtime_newTypeAssertionError(rhs_inter_descriptor->__reflection,
40 rhs_descriptor->__reflection,
41 lhs_descriptor->__reflection,
42 NULL, &panic_arg);
43 __go_panic(panic_arg);
44 }
45 }