return false
}
- if strings.HasPrefix(lsym.Name, "type:") {
+ if ti := lsym.TypeInfo(); ti != nil {
// Type symbols do not contain information about their fields, unlike the cases above.
// Hand-implement field accesses.
// TODO: can this be replaced with reflectdata.writeType and just use the code above?
- t := (*lsym.Extra).(*obj.TypeInfo).Type.(*types.Type)
+ t := ti.Type.(*types.Type)
for _, f := range rttype.Type.Fields() {
if f.Offset == off && copyCompatibleType(v.Type, f.Type) {
base.Fatalf("fixedLoad data not known for %s:%d", sym, off)
}
- if strings.HasPrefix(lsym.Name, "type:") {
+ if ti := lsym.TypeInfo(); ti != nil {
// Type symbols do not contain information about their fields, unlike the cases above.
// Hand-implement field accesses.
// TODO: can this be replaced with reflectdata.writeType and just use the code above?
- t := (*lsym.Extra).(*obj.TypeInfo).Type.(*types.Type)
+ t := ti.Type.(*types.Type)
ptrSizedOpConst := OpConst64
if f.Config.PtrSize == 4 {
return isDirectType2(v.Args[0])
case OpAddr:
lsym := v.Aux.(*obj.LSym)
- if lsym.Extra == nil {
- return false
- }
- if ti, ok := (*lsym.Extra).(*obj.TypeInfo); ok {
+ if ti := lsym.TypeInfo(); ti != nil {
return types.IsDirectIface(ti.Type.(*types.Type))
}
}
return isDirectIface2(v.Args[0], depth-1)
case OpAddr:
lsym := v.Aux.(*obj.LSym)
- if lsym.Extra == nil {
- return false
- }
- if ii, ok := (*lsym.Extra).(*obj.ItabInfo); ok {
+ if ii := lsym.ItabInfo(); ii != nil {
return types.IsDirectIface(ii.Type.(*types.Type))
}
case OpConstNil:
P []byte
R []Reloc
- Extra *interface{} // *FuncInfo, *VarInfo, *FileInfo, or *TypeInfo, if present
+ Extra *interface{} // *FuncInfo, *VarInfo, *FileInfo, *TypeInfo, or *ItabInfo, if present
Pkg string
PkgIdx int32
return t
}
+// TypeInfo returns the *TypeInfo associated with s, or else nil.
+func (s *LSym) TypeInfo() *TypeInfo {
+ if s.Extra == nil {
+ return nil
+ }
+ t, _ := (*s.Extra).(*TypeInfo)
+ return t
+}
+
// An ItabInfo contains information for a symbol
// that contains a runtime.itab.
type ItabInfo struct {
return t
}
+// ItabInfo returns the *ItabInfo associated with s, or else nil.
+func (s *LSym) ItabInfo() *ItabInfo {
+ if s.Extra == nil {
+ return nil
+ }
+ i, _ := (*s.Extra).(*ItabInfo)
+ return i
+}
+
// WasmImport represents a WebAssembly (WASM) imported function with
// parameters and results translated into WASM types based on the Go function
// declaration.