Skip to content

Commit 6a93efd

Browse files
committed
cmd/godefs: import from cmd/cgo
Signed-off-by: Koichi Shiraishi <[email protected]>
1 parent 1e299b1 commit 6a93efd

File tree

12 files changed

+8092
-0
lines changed

12 files changed

+8092
-0
lines changed

cmd/godefs/ast.go

Lines changed: 577 additions & 0 deletions
Large diffs are not rendered by default.

cmd/godefs/ast_go1.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Copyright 2021 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
//go:build !go1.18
6+
7+
package main
8+
9+
import (
10+
"go/ast"
11+
"go/token"
12+
)
13+
14+
func (f *File) walkUnexpected(x interface{}, context astContext, visit func(*File, interface{}, astContext)) {
15+
error_(token.NoPos, "unexpected type %T in walk", x)
16+
panic("unexpected type")
17+
}
18+
19+
func funcTypeTypeParams(n *ast.FuncType) *ast.FieldList {
20+
return nil
21+
}
22+
23+
func typeSpecTypeParams(n *ast.TypeSpec) *ast.FieldList {
24+
return nil
25+
}

cmd/godefs/ast_go118.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Copyright 2021 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
//go:build go1.18
6+
7+
package main
8+
9+
import (
10+
"go/ast"
11+
"go/token"
12+
)
13+
14+
func (f *File) walkUnexpected(x interface{}, context astContext, visit func(*File, interface{}, astContext)) {
15+
switch n := x.(type) {
16+
default:
17+
error_(token.NoPos, "unexpected type %T in walk", x)
18+
panic("unexpected type")
19+
20+
case *ast.IndexListExpr:
21+
f.walk(&n.X, ctxExpr, visit)
22+
f.walk(n.Indices, ctxExpr, visit)
23+
}
24+
}
25+
26+
func funcTypeTypeParams(n *ast.FuncType) *ast.FieldList {
27+
return n.TypeParams
28+
}
29+
30+
func typeSpecTypeParams(n *ast.TypeSpec) *ast.FieldList {
31+
return n.TypeParams
32+
}

0 commit comments

Comments
 (0)