mirror of
https://github.com/golang/go
synced 2024-11-18 17:04:41 -07:00
go/ssa: cleanup: make NewFunction a member of *Program.
(since it always needs this field) LGTM=gri R=gri CC=golang-codereviews https://golang.org/cl/106960045
This commit is contained in:
parent
94d1589bd2
commit
1edc750a9c
@ -1102,9 +1102,7 @@ func (a *analysis) makeCGNode(fn *ssa.Function, obj nodeid, callersite *callsite
|
||||
// or a library.
|
||||
//
|
||||
func (a *analysis) genRootCalls() *cgnode {
|
||||
r := ssa.NewFunction("<root>", new(types.Signature), "root of callgraph")
|
||||
r.Prog = a.prog // hack.
|
||||
r.String() // (asserts that it doesn't crash)
|
||||
r := a.prog.NewFunction("<root>", new(types.Signature), "root of callgraph")
|
||||
root := a.makeCGNode(r, 0, nil)
|
||||
|
||||
// TODO(adonovan): make an ssa utility to construct an actual
|
||||
|
@ -640,11 +640,11 @@ func (f *Function) newBasicBlock(comment string) *BasicBlock {
|
||||
return b
|
||||
}
|
||||
|
||||
// NewFunction returns a new synthetic Function instance with its name
|
||||
// and signature fields set as specified.
|
||||
// NewFunction returns a new synthetic Function instance belonging to
|
||||
// prog, with its name and signature fields set as specified.
|
||||
//
|
||||
// The caller is responsible for initializing the remaining fields of
|
||||
// the function object, e.g. Pkg, Prog, Params, Blocks.
|
||||
// the function object, e.g. Pkg, Params, Blocks.
|
||||
//
|
||||
// It is practically impossible for clients to construct well-formed
|
||||
// SSA functions/packages/programs directly, so we assume this is the
|
||||
@ -655,8 +655,8 @@ func (f *Function) newBasicBlock(comment string) *BasicBlock {
|
||||
//
|
||||
// TODO(adonovan): think harder about the API here.
|
||||
//
|
||||
func NewFunction(name string, sig *types.Signature, provenance string) *Function {
|
||||
return &Function{name: name, Signature: sig, Synthetic: provenance}
|
||||
func (prog *Program) NewFunction(name string, sig *types.Signature, provenance string) *Function {
|
||||
return &Function{Prog: prog, name: name, Signature: sig, Synthetic: provenance}
|
||||
}
|
||||
|
||||
type extentNode [2]token.Pos
|
||||
|
@ -491,9 +491,8 @@ func newMethod(pkg *ssa.Package, recvType types.Type, name string) *ssa.Function
|
||||
// now, we'll set it to always be false since we're only
|
||||
// concerned with rtype. Encapsulate this better.
|
||||
sig := types.NewSignature(nil, types.NewVar(token.NoPos, nil, "recv", recvType), nil, nil, false)
|
||||
fn := ssa.NewFunction(name, sig, "fake reflect method")
|
||||
fn := pkg.Prog.NewFunction(name, sig, "fake reflect method")
|
||||
fn.Pkg = pkg
|
||||
fn.Prog = pkg.Prog
|
||||
return fn
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user