本文整理汇总了Golang中tritium/proto.Function.Clone方法的典型用法代码示例。如果您正苦于以下问题:Golang Function.Clone方法的具体用法?Golang Function.Clone怎么用?Golang Function.Clone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tritium/proto.Function
的用法示例。
在下文中一共展示了Function.Clone方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: resolveFunctionDescendants
func (pkg *Package) resolveFunctionDescendants(fun *tp.Function) {
// Check if this function contains any types that have descendants
// name := fun.Stub(pkg.Package)
// pkg.Log.Infof("Checking for inheritance on function: %v", name)
newFun := &tp.Function{}
inherit := false
// Iterate over ScopeType, Arg types, return Type, opens Type
// ScopeType
thisTypeId := null.GetInt32(fun.ScopeTypeId)
newType := pkg.Package.FindDescendantType(thisTypeId)
if newType != -1 {
if !inherit {
// pkg.Log.Infof("\t -- ScopeType : Found ancestral type. Cloning function %v\n", null.GetString(fun.Name))
newFun = fun.Clone().(*tp.Function)
// pkg.Log.Infof("\t -- New fun: %v", newFun)
inherit = true
}
// pkg.Log.Infof("\t -- Resetting scopeId")
newFun.ScopeTypeId = proto.Int32(int32(newType))
}
// ReturnType
thisTypeId = null.GetInt32(fun.ReturnTypeId)
newType = pkg.Package.FindDescendantType(thisTypeId)
if newType != -1 {
if !inherit {
// pkg.Log.Infof("\t -- ReturnType : Found ancestral type. Cloning function %v\n", null.GetString(fun.Name))
newFun = fun.Clone().(*tp.Function)
// pkg.Log.Infof("\t -- New fun: %v", newFun)
inherit = true
}
// pkg.Log.Infof("\t -- Resetting returnId")
newFun.ReturnTypeId = proto.Int32(int32(newType))
}
// OpensType
thisTypeId = null.GetInt32(fun.OpensTypeId)
newType = pkg.Package.FindDescendantType(thisTypeId)
if newType != -1 {
if !inherit {
// pkg.Log.Infof("\t -- OpensType : Found ancestral type. Cloning function %v\n", null.GetString(fun.Name))
newFun = fun.Clone().(*tp.Function)
// pkg.Log.Infof("\t -- New fun: %v", newFun)
inherit = true
}
// pkg.Log.Infof("\t -- Resetting openTypeId")
newFun.OpensTypeId = proto.Int32(int32(newType))
}
// Arguments
for index, arg := range fun.Args {
thisTypeId = null.GetInt32(arg.TypeId)
newType = pkg.Package.FindDescendantType(thisTypeId)
if newType != -1 {
if !inherit {
// pkg.Log.Infof("\t -- ArgType : Found ancestral type. Cloning function %v\n", null.GetString(fun.Name))
newFun = fun.Clone().(*tp.Function)
// pkg.Log.Infof("\t -- New fun: %v", newFun)
inherit = true
}
// pkg.Log.Infof("\t -- Resetting argument")
newFun.Args[index].TypeId = proto.Int32(int32(newType))
}
}
// pkg.Log.Infof("\t -- Old function: %v\n\t -- New function: %v\n", fun, newFun)
if inherit {
resolveDefinition(pkg.Package, newFun, "")
pkg.Package.Functions = append(pkg.Package.Functions, newFun)
// println("replicated", pkg.Package.GetTypeName(newFun.GetScopeTypeId()), newFun.Stub(pkg.Package))
}
}