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)) } }