1 package loader
2 3 import (
4 "golang.org/x/tools/go/ssa"
5 )
6 7 // LoadSSA constructs the SSA form of the loaded packages.
8 //
9 // The program must already be parsed and type-checked with the .Parse() method.
10 func (p *Program) LoadSSA() *ssa.Program {
11 // TODO: re-enable SanityCheckFunctions when x/tools is upgraded to
12 // a version with a fix for https://golang.org/issues/73594.
13 prog := ssa.NewProgram(p.fset /*ssa.SanityCheckFunctions|*/, ssa.BareInits|ssa.GlobalDebug|ssa.InstantiateGenerics)
14 15 for _, pkg := range p.sorted {
16 prog.CreatePackage(pkg.Pkg, pkg.Files, &pkg.info, true)
17 }
18 19 return prog
20 }
21 22 // LoadSSA constructs the SSA form of this package.
23 //
24 // The program must already be parsed and type-checked with the .Parse() method.
25 func (p *Package) LoadSSA() *ssa.Package {
26 prog := ssa.NewProgram(p.program.fset, ssa.SanityCheckFunctions|ssa.BareInits|ssa.GlobalDebug)
27 return prog.CreatePackage(p.Pkg, p.Files, &p.info, true)
28 }
29