func (c *Const) Int64() int64 {
	switch x := exact.ToInt(c.Value); x.Kind() {
	case exact.Int:
		if i, ok := exact.Int64Val(x); ok {
			return i
		}
		return 0
	case exact.Float:
		f, _ := exact.Float64Val(x)
		return int64(f)
	}
	panic(fmt.Sprintf("unexpected constant value: %T", c.Value))
}
TODO(adonovan): move everything below into golang.org/x/tools/go/ssa/interp.
Int64 returns the numeric value of this constant truncated to fit
a signed 64-bit integer.
package ssa
import (
	"fmt"
	exact "go/constant"
	"go/token"
	"go/types"
	"strconv"
)
func NewConst(val exact.Value, typ types.Type) *Const {
	return &Const{typ, val}
}
func intConst(i int64) *Const {
	return NewConst(exact.MakeInt64(i), tInt)
}
func nilConst(typ types.Type) *Const {
	return NewConst(nil, typ)
}
func stringConst(s string) *Const {
	return NewConst(exact.MakeString(s), tString)
}
func zeroConst(t types.Type) *Const {
	switch t := t.(type) {
	case *types.Basic:
		switch {
		case t.Info()&types.IsBoolean != 0:
			return NewConst(exact.MakeBool(false), t)
		case t.Info()&types.IsNumeric != 0:
			return NewConst(exact.MakeInt64(0), t)
		case t.Info()&types.IsString != 0:
			return NewConst(exact.MakeString(""), t)
		case t.Kind() == types.UnsafePointer:
			fallthrough
		case t.Kind() == types.UntypedNil:
			return nilConst(t)
		default:
			panic(fmt.Sprint("zeroConst for unexpected type:", t))
		}
	case *types.Pointer, *types.Slice, *types.Interface, *types.Chan, *types.Map, *types.Signature:
		return nilConst(t)
	case *types.Named:
		return NewConst(zeroConst(t.Underlying()).Value, t)
	case *types.Array, *types.Struct, *types.Tuple:
		panic(fmt.Sprint("zeroConst applied to aggregate:", t))
	}
	panic(fmt.Sprint("zeroConst: unexpected ", t))
}
func (c *Const) RelString(from *types.Package) string {
	var s string
	if c.Value == nil {
		s = "nil"
	} else if c.Value.Kind() == exact.String {
		s = exact.StringVal(c.Value)
		const max = 20
		if len(s) > max {
			s = s[:max-3] + "..."  
		}
		s = strconv.Quote(s)
	} else {
		s = c.Value.String()
	}
	return s + ":" + relType(c.Type(), from)
}
func (c *Const) Name() string {
	return c.RelString(nil)
}
func (c *Const) String() string {
	return c.Name()
}
func (c *Const) Type() types.Type {
	return c.typ
}
func (c *Const) Referrers() *[]Instruction {
	return nil
}
func (c *Const) Parent() *Function { return nil }
func (c *Const) Pos() token.Pos {
	return token.NoPos
}
func (c *Const) IsNil() bool {
	return c.Value == nil
}