本文整理匯總了Golang中github.com/quarnster/completion/content.Type.Methods方法的典型用法代碼示例。如果您正苦於以下問題:Golang Type.Methods方法的具體用法?Golang Type.Methods怎麽用?Golang Type.Methods使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/quarnster/completion/content.Type
的用法示例。
在下文中一共展示了Type.Methods方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: GetType
func (d *DWARFHelper) GetType(off dwarf.Offset) (content.Type, error) {
var t content.Type
r := d.df.Reader()
r.Seek(off)
recurse := false
if e, err := r.Next(); err != nil {
return t, err
} else {
switch e.Tag {
case dwarf.TagVolatileType, dwarf.TagReferenceType, dwarf.TagRestrictType, dwarf.TagConstType, dwarf.TagSubroutineType:
recurse = true
case dwarf.TagPointerType:
t.Flags |= content.FLAG_TYPE_POINTER
recurse = true
case dwarf.TagArrayType:
recurse = true
t.Flags |= content.FLAG_TYPE_ARRAY
case dwarf.TagClassType, dwarf.TagTypedef, dwarf.TagBaseType, dwarf.TagEnumerationType, dwarf.TagStructType:
if v, ok := e.Val(dwarf.AttrName).(string); ok {
t.Name.Relative = v
}
case dwarf.TagUnionType:
t.Name.Relative = "union"
default:
return t, errors.New(fmt.Sprintf("Don't know how to handle %+v", e))
}
if recurse {
if v, ok := e.Val(dwarf.AttrType).(dwarf.Offset); ok {
if t2, err := d.GetType(v); err != nil {
return t, err
} else {
t.Specialization = append(t.Specialization, t2)
}
}
}
switch e.Tag {
case dwarf.TagVolatileType, dwarf.TagReferenceType, dwarf.TagRestrictType, dwarf.TagConstType:
if len(t.Specialization) == 0 {
t.Name.Relative = "void"
} else {
t = t.Specialization[0]
}
}
switch e.Tag {
case dwarf.TagPointerType:
if len(t.Specialization) == 0 {
t.Specialization = append(t.Specialization, content.Type{Name: content.FullyQualifiedName{Relative: "void"}})
}
case dwarf.TagVolatileType:
t.Flags |= content.FLAG_VOLATILE
case dwarf.TagReferenceType:
t.Flags |= content.FLAG_REFERENCE
case dwarf.TagRestrictType:
t.Flags |= content.FLAG_RESTRICT
case dwarf.TagConstType:
t.Flags |= content.FLAG_CONST
case dwarf.TagSubroutineType:
var m content.Method
if len(t.Specialization) > 0 {
m.Returns = append(m.Returns, content.Variable{Type: t.Specialization[0]})
} else {
m.Returns = append(m.Returns, content.Variable{Type: content.Type{Name: content.FullyQualifiedName{Relative: "void"}}})
}
t.Specialization = t.Specialization[0:0]
t.Flags = content.FLAG_TYPE_METHOD
for {
if e, err := r.Next(); err != nil {
return t, err
} else if e == nil || e.Tag == 0 {
break
} else if e.Tag == dwarf.TagFormalParameter {
var p content.Variable
if v, ok := e.Val(dwarf.AttrType).(dwarf.Offset); ok {
if t2, err := d.GetType(v); err != nil {
return t, err
} else {
p.Type = t2
}
}
if v, ok := e.Val(dwarf.AttrName).(string); ok {
p.Name.Relative = v
}
m.Parameters = append(m.Parameters, p)
}
}
t.Methods = append(t.Methods, m)
}
return t, nil
}
}