Skip to content

Commit 65491f5

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

File tree

12 files changed

+8088
-0
lines changed

12 files changed

+8088
-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: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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+
package main
6+
7+
import (
8+
"go/ast"
9+
"go/token"
10+
)
11+
12+
func (f *File) walkUnexpected(x interface{}, context astContext, visit func(*File, interface{}, astContext)) {
13+
error_(token.NoPos, "unexpected type %T in walk", x)
14+
panic("unexpected type")
15+
}
16+
17+
func funcTypeTypeParams(n *ast.FuncType) *ast.FieldList {
18+
return nil
19+
}
20+
21+
func typeSpecTypeParams(n *ast.TypeSpec) *ast.FieldList {
22+
return nil
23+
}

cmd/godefs/ast_go118.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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+
package main
6+
7+
import (
8+
"go/ast"
9+
"go/token"
10+
)
11+
12+
func (f *File) walkUnexpected(x interface{}, context astContext, visit func(*File, interface{}, astContext)) {
13+
switch n := x.(type) {
14+
default:
15+
error_(token.NoPos, "unexpected type %T in walk", x)
16+
panic("unexpected type")
17+
18+
case *ast.IndexListExpr:
19+
f.walk(&n.X, ctxExpr, visit)
20+
f.walk(n.Indices, ctxExpr, visit)
21+
}
22+
}
23+
24+
func funcTypeTypeParams(n *ast.FuncType) *ast.FieldList {
25+
return n.TypeParams
26+
}
27+
28+
func typeSpecTypeParams(n *ast.TypeSpec) *ast.FieldList {
29+
return n.TypeParams
30+
}

0 commit comments

Comments
 (0)