Fix r180999.
[gcc.git] / libgo / runtime / reflect.goc
1 // Copyright 2010 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 package reflect
6 #include "go-type.h"
7 #include "interface.h"
8 #include "runtime.h"
9 #include "go-panic.h"
10
11 typedef struct __go_type_descriptor Type;
12 typedef struct __go_interface Iface;
13 typedef struct __go_empty_interface Eface;
14
15 func ifaceE2I(inter *Type, e Eface, ret *Iface) {
16 const Type *t;
17 Eface err;
18
19 if(((uintptr)e.__type_descriptor&reflectFlags) != 0)
20 runtime_throw("invalid interface value");
21 t = e.__type_descriptor;
22 if(t == nil) {
23 // explicit conversions require non-nil interface value.
24 newTypeAssertionError(nil, nil, inter,
25 nil, nil, inter->__reflection,
26 nil, &err);
27 __go_panic(err);
28 }
29 ret->__object = e.__object;
30 ret->__methods = __go_convert_interface(inter, t);
31 }