func (v Value) AsFunction() Callable {
	switch c := v.iface.(type) {
	case *Closure:
		return c
	case *GoFunction:
		return c
	default:
		panic("value is not a Callable")
	}
}
AsFunction returns v as a Callable if possible by looking at the
possible concrete types (ok is false otherwise).  It is an optimisation as
type assertion in Go seems to have a significant cost.
package runtime
import (
	"unsafe"
)
type Value struct {
	scalar uint64
	iface  interface{}
}
var (
	dummyInt64   interface{} = int64(0)
	dummyFloat64 interface{} = float64(0)
	dummyBool    interface{} = false
)
func AsValue(i interface{}) Value {
	if i == nil {
		return NilValue
	}
	switch x := i.(type) {
	case int64:
		return IntValue(x)
	case int:
		return IntValue(int64(x))
	case float64:
		return FloatValue(x)
	case float32:
		return FloatValue(float64(x))
	case bool:
		return BoolValue(x)
	case string:
		return StringValue(x)
	case Value:
		return x
	default:
		return Value{iface: i}
	}
}
func (v Value) Interface() interface{} {
	if v.iface == nil {
		return nil
	}
	switch v.iface.(type) {
	case int64:
		return v.AsInt()
	case float64:
		return v.AsFloat()
	case bool:
		return v.AsBool()
	default:
		return v.iface
	}
}
func ifaceType(iface interface{}) uintptr {
	return *(*uintptr)(unsafe.Pointer(&iface))
}
func (v Value) Equals(v2 Value) bool {
	if v.scalar != v2.scalar || ifaceType(v.iface) != ifaceType(v2.iface) {
		return false
	}
	switch v.iface.(type) {
	case int64, float64:
		return true
	case string:
		if v.scalar != 0 {
			return true
		}
	}
	return v.iface == v2.iface
}
func goRuntimeInt64Hash(i uint64, seed uintptr) uintptr
func goRuntimeEfaceHash(i interface{}, seed uintptr) uintptr
func (v Value) Hash() uintptr {
	if v.scalar != 0 {
		return goRuntimeInt64Hash(v.scalar, 0)
	}
	return goRuntimeEfaceHash(v.iface, 0)
}
func IntValue(n int64) Value {
	return Value{uint64(n), dummyInt64}
}
func FloatValue(f float64) Value {
	return Value{*(*uint64)(unsafe.Pointer(&f)), dummyFloat64}
}
func BoolValue(b bool) Value {
	var s uint64
	if b {
		s = 1
	}
	return Value{s, dummyBool}
}
func StringValue(s string) (v Value) {
	v.iface = s
	ls := len(s)
	if ls <= 7 {
		bs := make([]byte, 8)
		copy(bs, s)
		bs[7] = byte(ls)
		v.scalar = *(*uint64)(unsafe.Pointer(&bs[0]))
	}
	return
}
func TableValue(t *Table) Value {
	return Value{iface: t}
}
func FunctionValue(c Callable) Value {
	return Value{iface: c}
}
func ContValue(c Cont) Value {
	return Value{iface: c}
}
func ArrayValue(a []Value) Value {
	return Value{iface: a}
}
func CodeValue(c *Code) Value {
	return Value{iface: c}
}
func ThreadValue(t *Thread) Value {
	return Value{iface: t}
}
func LightUserDataValue(d LightUserData) Value {
	return Value{iface: d}
}
func UserDataValue(u *UserData) Value {
	return Value{iface: u}
}
var NilValue = Value{}
func (v Value) Type() ValueType {
	if v.iface == nil {
		return NilType
	}
	switch v.iface.(type) {
	case int64:
		return IntType
	case float64:
		return FloatType
	case bool:
		return BoolType
	case string:
		return StringType
	case *Table:
		return TableType
	case *Code:
		return CodeType
	case *GoFunction, *Closure:
		return FunctionType
	case *Thread:
		return ThreadType
	case *UserData:
		return UserDataType
	default:
		return UnknownType
	}
}
func (v Value) NumberType() ValueType {
	switch v.iface.(type) {
	case int64:
		return IntType
	case float64:
		return FloatType
	}
	return UnknownType
}
func (v Value) AsInt() int64 {
	return int64(v.scalar)
}
func (v Value) AsFloat() float64 {
	return *(*float64)(unsafe.Pointer(&v.scalar))
}
func (v Value) AsBool() bool {
	return v.scalar != 0
}
func (v Value) AsString() string {
	return v.iface.(string)
}
func (v Value) AsTable() *Table {
	return v.iface.(*Table)
}
func (v Value) AsCont() Cont {
	switch cont := v.iface.(type) {
	case *GoCont:
		return cont
	case *LuaCont:
		return cont
	case *Termination:
		return cont
	default:
		panic("value is not a continuation")
	}
}
func (v Value) AsArray() []Value {
	return v.iface.([]Value)
}
func (v Value) AsClosure() *Closure {
	return v.iface.(*Closure)
}
func (v Value) AsCode() *Code {
	return v.iface.(*Code)
}
func (v Value) AsUserData() *UserData {
	return v.iface.(*UserData)
}