func (sc *Scope) available(name string) (*ast.Ident, bool) {
	sc.assertDone()
	for c := sc; c != nil; c = c.outer {
		if id, ok := c.declared(name); ok {
			return id, true
		}
	}
	return nil, false
}
available returns the named identifier if such a one is
declared in this scope or any of the outer scopes.
package main
import (
	"go/ast"
	"go/token"
)
type Scope struct {
	node           ast.Node               
	lbrace, rbrace token.Pos              
	outer          *Scope                 
	inner          []*Scope               
	idents         map[string]*ast.Ident  
	done           bool                   
}
func newScope(node ast.Node) *Scope {
	sc := new(Scope)
	sc.node = node
	return sc
}
func (sc *Scope) assertDone() {
	if !sc.done {
		panic("scope not done")
	}
}
func (sc *Scope) markDone() {
	if sc.done {
		panic("scope already done")
	}
	sc.done = true
}
func (sc *Scope) addIdent(ident *ast.Ident) {
	if sc.idents == nil {
		sc.idents = make(map[string]*ast.Ident)
	}
	sc.idents[ident.Name] = ident
}
func (sc *Scope) declared(name string) (*ast.Ident, bool) {
	sc.assertDone()
	id, ok := sc.idents[name]
	return id, ok
}