reflect.goc 634 B

1234567891011121314151617181920212223242526
  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. package reflect
  5. #include "runtime.h"
  6. #include "go-type.h"
  7. #include "interface.h"
  8. #include "go-panic.h"
  9. func ifaceE2I(inter *Type, e Eface, ret *Iface) {
  10. const Type *t;
  11. Eface err;
  12. t = e.__type_descriptor;
  13. if(t == nil) {
  14. // explicit conversions require non-nil interface value.
  15. runtime_newTypeAssertionError(
  16. nil, nil, inter->__reflection,
  17. nil, &err);
  18. runtime_panic(err);
  19. }
  20. ret->__object = e.__object;
  21. ret->__methods = __go_convert_interface(inter, t);
  22. }