本文整理汇总了Golang中go/types.Object.GetType方法的典型用法代码示例。如果您正苦于以下问题:Golang Object.GetType方法的具体用法?Golang Object.GetType怎么用?Golang Object.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类go/types.Object
的用法示例。
在下文中一共展示了Object.GetType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: addSpilledParam
// addSpilledParam declares a parameter that is pre-spilled to the
// stack; the function body will load/store the spilled location.
// Subsequent registerization will eliminate spills where possible.
//
func (f *Function) addSpilledParam(obj types.Object) {
name := obj.GetName()
param := f.addParam(name, obj.GetType())
spill := &Alloc{
Name_: name + "~", // "~" means "spilled"
Type_: pointer(obj.GetType()),
}
f.objects[obj] = spill
f.Locals = append(f.Locals, spill)
f.emit(spill)
f.emit(&Store{Addr: spill, Val: param})
}
示例2: addNamedLocal
// addNamedLocal creates a local variable, adds it to function f and
// returns it. Its name and type are taken from obj. Subsequent
// calls to f.lookup(obj) will return the same local.
//
// Precondition: f.syntax != nil (i.e. a Go source function).
//
func (f *Function) addNamedLocal(obj types.Object) *Alloc {
l := f.addLocal(obj.GetType())
l.Name_ = obj.GetName()
f.objects[obj] = l
return l
}