1
0
mirror of https://github.com/golang/go synced 2024-11-19 00:04:40 -07:00
go/oracle
Alan Donovan 25a0cc4bfd go.tools/oracle: refactor Oracle API to allow repeated queries on same scope.
The existing standalone Query function builds an importer, ssa.Program, oracle,
and query position, executes the query and returns the result.
For clients (such as Frederik Zipp's web-based github.com/fzipp/pythia tool)
that wish to load the program once and make several queries, we now expose
these as separate operations too.  Here's a client, in pseudocode:

        o := oracle.New(...)
        for ... {
                qpos := o.ParseQueryPos(...)
                res := o.Query(mode, qpos)
                print result
        }

NB: this is a slight deoptimisation in the one-shot case since we have to
build the entire SSA program with debug info, not just the query package,
since we now don't know the query package at that time.

The 'exact' param to ParseQueryPos needs more thought since its
ideal value is a function of the query mode.  This will do for now.

Details:
- expose Oracle type, New() func and Query() method.
- expose QueryPos type and ParseQueryPos func.
- improved package doc comment.
- un-exposed the "needs" bits.
- added test.

R=crawshaw
CC=frederik.zipp, golang-dev
https://golang.org/cl/13810043
2013-09-23 15:02:18 -04:00
..
json go.tools/pointer: reflection, part 1: maps, and some core features. 2013-09-16 09:49:10 -04:00
testdata/src go.tools/oracle: refactor Oracle API to allow repeated queries on same scope. 2013-09-23 15:02:18 -04:00
callees.go go.tools/oracle: refactor Oracle API to allow repeated queries on same scope. 2013-09-23 15:02:18 -04:00
callers.go go.tools/oracle: refactor Oracle API to allow repeated queries on same scope. 2013-09-23 15:02:18 -04:00
callgraph.go go.tools/oracle: refactor Oracle API to allow repeated queries on same scope. 2013-09-23 15:02:18 -04:00
callstack.go go.tools/oracle: refactor Oracle API to allow repeated queries on same scope. 2013-09-23 15:02:18 -04:00
describe.go go.tools/oracle: refactor Oracle API to allow repeated queries on same scope. 2013-09-23 15:02:18 -04:00
freevars.go go.tools/oracle: refactor Oracle API to allow repeated queries on same scope. 2013-09-23 15:02:18 -04:00
implements.go go.tools/oracle: refactor Oracle API to allow repeated queries on same scope. 2013-09-23 15:02:18 -04:00
oracle_test.go go.tools/oracle: refactor Oracle API to allow repeated queries on same scope. 2013-09-23 15:02:18 -04:00
oracle.go go.tools/oracle: refactor Oracle API to allow repeated queries on same scope. 2013-09-23 15:02:18 -04:00
peers.go go.tools/oracle: refactor Oracle API to allow repeated queries on same scope. 2013-09-23 15:02:18 -04:00
referrers.go go.tools/oracle: refactor Oracle API to allow repeated queries on same scope. 2013-09-23 15:02:18 -04:00