resolve: move resolver types to resolver package (#211)

The job of the resolver is to compute a binding for
each identifer, the local and free variables for each function,
and the locals and globals for each module. As a space optimization and
for convenience, this information is saved in the syntax tree rather
than in a side table.

We have a choice between declaring these resolver data structures
in the syntax package or the resolve package. Putting them in the syntax
package, as we did prior to this change, allowed each Identifier, File,
DefStmt, and LambdaExpr to depend directly on the resolver types,
even though those types didn't really belong there.
This change moves these types to the resolver package where they belong.

The dependencies on the types are broken by using an interface{} in each case.
(The values are are all pointers, so this does not induce new allocation.)

Also, this change eliminates syntax.Function, which was a false abstraction
of DefStmt and LambdaExpr. The two syntax nodes are now fully concrete;
it is in the resolver that their shared concept of Function belongs.

This is a breaking API change, but it should affect very few clients
and be trivial to fix.
diff --git a/syntax/syntax.go b/syntax/syntax.go
index 759f946..b4817c1 100644
--- a/syntax/syntax.go
+++ b/syntax/syntax.go
@@ -70,9 +70,7 @@
 	Path  string
 	Stmts []Stmt
 
-	// set by resolver:
-	Locals  []*Binding // this file's (comprehension-)local variables
-	Globals []*Binding // this file's global variables
+	Module interface{} // a *resolve.Module, set by resolver
 }
 
 func (x *File) Span() (start, end Position) {
@@ -118,36 +116,19 @@
 	return
 }
 
-// A Function represents the common parts of LambdaExpr and DefStmt.
-type Function struct {
-	commentsRef
-	StartPos Position // position of DEF or LAMBDA token
-	Params   []Expr   // param = ident | ident=expr | * | *ident | **ident
-	Body     []Stmt
-
-	// set by resolver:
-	HasVarargs      bool       // whether params includes *args (convenience)
-	HasKwargs       bool       // whether params includes **kwargs (convenience)
-	NumKwonlyParams int        // number of keyword-only optional parameters
-	Locals          []*Binding // this function's local/cell variables, parameters first
-	FreeVars        []*Binding // enclosing cells to capture in closure
-}
-
-func (x *Function) Span() (start, end Position) {
-	_, end = x.Body[len(x.Body)-1].Span()
-	return x.StartPos, end
-}
-
 // A DefStmt represents a function definition.
 type DefStmt struct {
 	commentsRef
-	Def  Position
-	Name *Ident
-	Function
+	Def    Position
+	Name   *Ident
+	Params []Expr // param = ident | ident=expr | * | *ident | **ident
+	Body   []Stmt
+
+	Function interface{} // a *resolve.Function, set by resolver
 }
 
 func (x *DefStmt) Span() (start, end Position) {
-	_, end = x.Function.Body[len(x.Body)-1].Span()
+	_, end = x.Body[len(x.Body)-1].Span()
 	return x.Def, end
 }
 
@@ -260,8 +241,7 @@
 	NamePos Position
 	Name    string
 
-	// set by resolver
-	Binding *Binding
+	Binding interface{} // a *resolver.Binding, set by resolver
 }
 
 func (x *Ident) Span() (start, end Position) {
@@ -425,11 +405,14 @@
 type LambdaExpr struct {
 	commentsRef
 	Lambda Position
-	Function
+	Params []Expr // param = ident | ident=expr | * | *ident | **ident
+	Body   Expr
+
+	Function interface{} // a *resolve.Function, set by resolver
 }
 
 func (x *LambdaExpr) Span() (start, end Position) {
-	_, end = x.Function.Body[len(x.Body)-1].Span()
+	_, end = x.Body.Span()
 	return x.Lambda, end
 }