Commit a87dac1b authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 219f3139
...@@ -193,24 +193,32 @@ func packageTrace(prog *loader.Program, pkgi *loader.PackageInfo) (*Package, err ...@@ -193,24 +193,32 @@ func packageTrace(prog *loader.Program, pkgi *loader.PackageInfo) (*Package, err
tconf := &types.Config{ tconf := &types.Config{
Importer: &progImporter{prog}, Importer: &progImporter{prog},
// XXX to ignore traceXXX() calls from original package code
IgnoreFuncBodies: true,
// we took imports from original source file verbatim, // we took imports from original source file verbatim,
// but most of them probably won't be used. // but most of them probably won't be used.
DisableUnusedImportCheck: true, DisableUnusedImportCheck: true,
} }
tfset := token.NewFileSet() // XXX ok to separate or use original package fset? // tfset := token.NewFileSet() // XXX ok to separate or use original package fset?
tpkg := types.NewPackage(pkgi.Pkg.Path(), pkgi.Pkg.Name()) tpkg := types.NewPackage(pkgi.Pkg.Path(), pkgi.Pkg.Name())
tinfo := &types.Info{Types: make(map[ast.Expr]types.TypeAndValue)} tinfo := &types.Info{Types: make(map[ast.Expr]types.TypeAndValue)}
p := &Package{ p := &Package{
Pkgi: pkgi, Pkgi: pkgi,
traceFset: tfset, // traceFset: tfset,
traceChecker: types.NewChecker(tconf, tfset, tpkg, tinfo), // traceChecker: types.NewChecker(tconf, tfset, tpkg, tinfo),
// XXX vvv do we need separate field for traceFset if it is = prog.Fset?
traceFset: prog.Fset,
traceChecker: types.NewChecker(tconf, prog.Fset, tpkg, tinfo),
tracePkg: tpkg, tracePkg: tpkg,
traceTypeInfo: tinfo, traceTypeInfo: tinfo,
} }
// preload original package files into tracing package // preload original package files into tracing package
fmt.Println("FFF", p.Pkgi.Files)
err := p.traceChecker.Files(p.Pkgi.Files) err := p.traceChecker.Files(p.Pkgi.Files)
if err != nil { if err != nil {
// must not happen // must not happen
......
...@@ -133,7 +133,7 @@ func TestGoTraceGen(t *testing.T) { ...@@ -133,7 +133,7 @@ func TestGoTraceGen(t *testing.T) {
} }
// XXX autodetect (go list ?) // XXX autodetect (go list ?)
testv := []string{"a/pkg1"} // XXX , "b/pkg2", "c/pkg3"} testv := []string{"a/pkg1", "b/pkg2", "c/pkg3"}
for _, tpkg := range testv { for _, tpkg := range testv {
err = tracegen(tpkg, tBuildCtx, "" /* = local imorts disabled */) err = tracegen(tpkg, tBuildCtx, "" /* = local imorts disabled */)
......
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