mirror of
https://github.com/go-delve/delve.git
synced 2025-10-28 04:35:19 +08:00
proc,_scripts/rtype.go: add rtype annotations for g.atomicstatus (#3143)
Adds some rtype annotations for g.atomicstatus and update _scripts/rtype.go to handle types outside of the runtime package.
This commit is contained in:
committed by
GitHub
parent
1effee3576
commit
4372ce0d27
@ -512,20 +512,44 @@ func report() {
|
||||
}
|
||||
}
|
||||
|
||||
// check parses the runtime package and checks that all the rules retrieved
|
||||
// from the 'proc' package pass.
|
||||
func check() {
|
||||
pkgs2, err := packages.Load(&packages.Config{Mode: packages.LoadSyntax, Fset: fset}, "runtime")
|
||||
func lookupPackage(pkgmap map[string]*packages.Package, name string) *packages.Package {
|
||||
if pkgmap[name] != nil {
|
||||
return pkgmap[name]
|
||||
}
|
||||
|
||||
pkgs, err := packages.Load(&packages.Config{Mode: packages.LoadSyntax, Fset: fset}, name)
|
||||
if err != nil {
|
||||
log.Fatalf("could not load runtime package: %v", err)
|
||||
}
|
||||
packages.Visit(pkgs, func(pkg *packages.Package) bool {
|
||||
if pkgmap[pkg.ID] == nil {
|
||||
pkgmap[pkg.ID] = pkg
|
||||
}
|
||||
return true
|
||||
}, nil)
|
||||
|
||||
return pkgmap[name]
|
||||
}
|
||||
|
||||
func lookupTypeDef(pkgmap map[string]*packages.Package, typ string) types.Object {
|
||||
dot := strings.Index(typ, ".")
|
||||
if dot < 0 {
|
||||
return lookupPackage(pkgmap, "runtime").Types.Scope().Lookup(typ)
|
||||
}
|
||||
|
||||
return lookupPackage(pkgmap, typ[:dot]).Types.Scope().Lookup(typ[dot+1:])
|
||||
}
|
||||
|
||||
// check parses the runtime package and checks that all the rules retrieved
|
||||
// from the 'proc' package pass.
|
||||
func check() {
|
||||
pkgmap := map[string]*packages.Package{}
|
||||
allok := true
|
||||
|
||||
for _, rule := range checkVarTypeRules {
|
||||
//TODO: implement
|
||||
pos := fset.Position(rule.pos)
|
||||
def := pkgs2[0].Types.Scope().Lookup(rule.V)
|
||||
def := lookupPackage(pkgmap, "runtime").Types.Scope().Lookup(rule.V)
|
||||
if def == nil {
|
||||
fmt.Fprintf(os.Stderr, "%s:%d: could not find variable %s\n", pos.Filename, pos.Line, rule.V)
|
||||
allok = false
|
||||
@ -547,7 +571,7 @@ func check() {
|
||||
rules := checkFieldTypeRules[S]
|
||||
pos := fset.Position(rules[0].pos)
|
||||
|
||||
def := pkgs2[0].Types.Scope().Lookup(S)
|
||||
def := lookupTypeDef(pkgmap, S)
|
||||
if def == nil {
|
||||
fmt.Fprintf(os.Stderr, "%s:%d: could not find struct %s\n", pos.Filename, pos.Line, S)
|
||||
allok = false
|
||||
@ -594,7 +618,7 @@ func check() {
|
||||
for _, C := range Cs {
|
||||
rules := checkConstValRules[C]
|
||||
pos := fset.Position(rules[0].pos)
|
||||
def := pkgs2[0].Types.Scope().Lookup(C)
|
||||
def := lookupPackage(pkgmap, "runtime").Types.Scope().Lookup(C)
|
||||
if def == nil {
|
||||
fmt.Fprintf(os.Stderr, "%s:%d: could not find constant %s\n", pos.Filename, pos.Line, C)
|
||||
allok = false
|
||||
|
||||
Reference in New Issue
Block a user