On 11 December 2016 at 12:21, <akshanshcha...@gmail.com> wrote:

> I am not sure how to get any starting node of type BasicBlock (
> ssa#BasicBlock <https://godoc.org/golang.org/x/tools/go/ssa#BasicBlock>), so
> that I can traverse the Graph using Preds/Succs relation.
>

An ssa.Program is a essentially collection of packages.  Use one of its
methods (Package or ImportedPackage) to get the ssa.Package you want.
Then, use the (*Package).Func method to get the function you want.  If you
want a method, you can use (*Program).LookupMethod, giving it the receiver
type and the method name.

Once you have an *ssa.Function f, its control flow graph is rooted at
r.Blocks[0], which is the entry block.  To enumerate blocks in arbitrary
order, range over the Blocks slice.  For graph order, traverse depth-first
over the Succs slice; Preds is its inverse.  To visit nodes in dominator
tree preorder, use the Dominees method.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to