//Fixes Type and its' subtypes recursively func checkType(sym st.Symbol) { if sym == nil { fmt.Printf("ERROR: sym == nil. func fixType, typesVisitor.go\n") } // if pr,ok := sym.(*st.BasicTypeSymbol); ok{ // //fmt.Printf("%T %v\n",pr.BaseType,pr.BaseType.Name()); // //fmt.Printf("%p %p\n",sym,pr); // } // on := "" // if sym.Object() != nil{ // on = sym.Object().Name; // } // // pn:=""; // if sym.PackageFrom() != nil{ // pn= sym.PackageFrom().AstPackage.Name; // } // // // fmt.Printf("%s: %s %T\n",pn, on ,sym); if st.IsPredeclaredIdentifier(sym.Name()) { return } if sym.PackageFrom() != curPack { return } if checkIsVisited(sym) { return } switch t := sym.(type) { case *st.AliasTypeSymbol: checkAliasTypeSymbol(t) case *st.PointerTypeSymbol: checkPointerTypeSymbol(t) case *st.ArrayTypeSymbol: checkArrayTypeSymbol(t) case *st.StructTypeSymbol: checkStructTypeSymbol(t) case *st.InterfaceTypeSymbol: checkInterfaceTypeSymbol(t) case *st.MapTypeSymbol: checkMapTypeSymbol(t) case *st.ChanTypeSymbol: checkChanTypeSymbol(t) case *st.FunctionTypeSymbol: checkFunctionTypeSymbol(t) case *st.VariableSymbol: checkVariableSymbol(t) case *st.FunctionSymbol: checkFunctionSymbol(t) } }
func checkIsVisited(sym st.Symbol) bool { if _, ok := sym.(st.ITypeSymbol); !ok { return false } symName := sym.Name() if v, ok := visited[symName]; ok && v { //Symbol already checked return true } else if _, ok := sym.(st.ITypeSymbol); symName != "" && ok { //Mark as checked visited[symName] = true } return false }