MCPcopy
hub / github.com/gopherjs/gopherjs / toRType

Function toRType

compiler/natives/src/reflect/reflect.go:64–84  ·  view source on GitHub ↗

gopherjs:replace

(t *abi.Type)

Source from the content-addressed store, hash-verified

62
63//gopherjs:replace
64func toRType(t *abi.Type) *rtype {
65 const (
66 idRType = `rType`
67 idKindType = `kindType`
68 )
69
70 // rtypes are stored so that two types can be compared with `==`.
71 if jrt := js.InternalObject(t).Get(idRType); jrt != js.Undefined {
72 return (*rtype)(unsafe.Pointer(jrt.Unsafe()))
73 }
74
75 rtyp := &rtype{}
76 // Assign t to the abiType. The abiType is a `*Type` and the t field on `rtype` is `Type`.
77 // However, this is valid because of how pointers and references work in JS.
78 // We set this so that the t isn't a copy but the actual abiType object.
79 js.InternalObject(rtyp).Set("t", js.InternalObject(t))
80 js.InternalObject(t).Set(idRType, js.InternalObject(rtyp))
81 // Also copy over kindType to rtype so casts can be made directly from rtype to kindType.
82 js.InternalObject(rtyp).Set(idKindType, js.InternalObject(t).Get(idKindType))
83 return rtyp
84}
85
86//gopherjs:replace
87func (t *rtype) String() string {

Callers 15

TypeOfFunction · 0.85
ArrayOfFunction · 0.85
ChanOfFunction · 0.85
FuncOfFunction · 0.85
MapOfFunction · 0.85
SliceOfFunction · 0.85
StructOfFunction · 0.85
MakeFuncFunction · 0.85
CopyFunction · 0.85
MethodMethod · 0.85
callMethod · 0.85
TypeMethod · 0.85

Calls 5

InternalObjectFunction · 0.92
PointerMethod · 0.80
UnsafeMethod · 0.80
GetMethod · 0.65
SetMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…