gopherjs:replace
(t *abi.Type)
| 62 | |
| 63 | //gopherjs:replace |
| 64 | func 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 |
| 87 | func (t *rtype) String() string { |
no test coverage detected
searching dependent graphs…