]> git.ipfire.org Git - thirdparty/gcc.git/blob - libgo/runtime/go-unreflect.c
Add Go frontend, libgo library, and Go testsuite.
[thirdparty/gcc.git] / libgo / runtime / go-unreflect.c
1 /* go-unreflect.c -- implement unsafe.Unreflect for Go.
2
3 Copyright 2009 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-alloc.h"
8 #include "go-type.h"
9 #include "interface.h"
10
11 /* Implement unsafe.Unreflect. */
12
13 struct __go_empty_interface Unreflect (struct __go_empty_interface type,
14 void *object)
15 asm ("libgo_unsafe.unsafe.Unreflect");
16
17 struct __go_empty_interface
18 Unreflect (struct __go_empty_interface type, void *object)
19 {
20 struct __go_empty_interface ret;
21
22 /* FIXME: We should check __type_descriptor to verify that this is
23 really a type descriptor. */
24 ret.__type_descriptor = type.__object;
25 if (__go_is_pointer_type (ret.__type_descriptor))
26 ret.__object = *(void **) object;
27 else
28 ret.__object = object;
29 return ret;
30 }