本文整理汇总了Golang中code/google/com/p/go/tools/go/types.Basic.Info方法的典型用法代码示例。如果您正苦于以下问题:Golang Basic.Info方法的具体用法?Golang Basic.Info怎么用?Golang Basic.Info使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类code/google/com/p/go/tools/go/types.Basic
的用法示例。
在下文中一共展示了Basic.Info方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: descriptorBasic
func (m *TypeMap) descriptorBasic(t *types.Basic, name string) TypeDebugDescriptor {
switch t.Kind() {
case types.String:
return m.descriptorStruct(types.NewStruct([]*types.Var{
types.NewVar(0, nil, "ptr", types.NewPointer(types.Typ[types.Uint8])),
types.NewVar(0, nil, "len", types.Typ[types.Int]),
}, nil), name)
case types.UnsafePointer:
return &BasicTypeDescriptor{
TypeDescriptorCommon: TypeDescriptorCommon{
Name: name,
Size: uint64(m.Sizes.Sizeof(t) * 8),
Alignment: uint64(m.Sizes.Alignof(t) * 8),
},
TypeEncoding: DW_ATE_unsigned,
}
default:
bt := &BasicTypeDescriptor{
TypeDescriptorCommon: TypeDescriptorCommon{
Name: t.String(),
Size: uint64(m.Sizes.Sizeof(t) * 8),
Alignment: uint64(m.Sizes.Alignof(t) * 8),
},
}
switch bi := t.Info(); {
case bi&types.IsBoolean != 0:
bt.TypeEncoding = DW_ATE_boolean
case bi&types.IsUnsigned != 0:
bt.TypeEncoding = DW_ATE_unsigned
case bi&types.IsInteger != 0:
bt.TypeEncoding = DW_ATE_signed
case bi&types.IsFloat != 0:
bt.TypeEncoding = DW_ATE_float
case bi&types.IsComplex != 0:
bt.TypeEncoding = DW_ATE_imaginary_float
case bi&types.IsUnsigned != 0:
bt.TypeEncoding = DW_ATE_unsigned
default:
panic(fmt.Sprintf("unhandled: %#v", t))
}
return bt
}
}