Commit fe1ca6f5 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 36adb807
......@@ -274,13 +274,14 @@ func (te *traceEvent) Argv() string {
return strings.Join(argv, ", ")
}
// ArgvTyped returns argument list with types qualified relative to original package
// ArgvTyped returns argument list with types
// types are qualified relative to original package
func (te *traceEvent) ArgvTyped() string {
return te.ArgvTypedRelativeTo(te.Pkg)
}
// ArgvTypedRelativeTo returns argument list with types qualified relative to specified package
func (te *traceEvent) ArgvTypedRelativeTo(pkg *types.Package) string {
//format.Node(&buf, fset, te.FuncDecl.Type.Params)
argv := []string{}
// default qualifier - relative to original package
......@@ -459,6 +460,52 @@ func (s StrSet) Itemv() []string {
// buildCtx is build context for discovering packages
// cwd is "current" directory for resolving local imports (e.g. packages like "./some/package")
func tracegen(pkgpath string, buildCtx *build.Context, cwd string) error {
// XXX ignore build tags?
bpkg, err := buildCtx.Import(pkgpath, cwd, 0)
if err != nil {
return err
}
// canonical package path e.g. "." -> "path/to/package"
pkgpath = bpkg.ImportPath
// XXX reject on .InvalidGoFiles ?
fset := token.NewFileSet() // XXX -> Package?
filev := []*ast.File{}
// parse go and cgo sources
for _, fgo := range append(bpkg.GoFiles, bpkg.CgoFiles...) {
fpath := bpkg.Dir + "/" + fgo
// don't load what should be generated by us. reasons:
// - code generated could be wrong with older version of the
// tool - it should not prevent from regenerating.
// - generated code imports packages which might be not there
// yet in gopath (lab.nexedi.com/kirr/go123/tracing)
if strings.HasPrefix(fgo, "ztrace") {
// if it is there but not created by us - complain
err = checkCanWrite(fpath)
if err != nil {
return err
}
continue
}
f, err := parser.ParseFile(fset, fpath, nil, parser.ParseComments)
if err != nil {
return err
}
filev = append(filev, f)
}
return nil
// XXX test-only with .TestGoFiles .XTestGoFiles
// XXX typechecking is much slower than parsing + we don't need to
// load anything except the package in question
// TODO -> use just AST parsing for loading?
......@@ -485,7 +532,7 @@ func tracegen(pkgpath string, buildCtx *build.Context, cwd string) error {
}
pkgdir := filepath.Dir(lprog.Fset.File(pkgi.Files[0].Pos()).Name())
pkgpath = pkgi.Pkg.Path() // e.g. "." -> "path/to/package"
pkgpath = pkgi.Pkg.Path()
//println("pkgpath", pkgpath)
//println("pkgdir", pkgdir)
//return nil
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment