package value type Value struct { t Type d Data } func NewInt(x int64) Value { t := Type{Kind: IntType} return Value{t: t, d: IntData(x)} } func NewFloat(x float64) Value { t := Type{Kind: FloatType} return Value{t: t, d: FloatData(x)} } func NewString(str string) Value { t := Type{Kind: StringType} return Value{t: t, d: StringData(str)} } func NewBool(b bool) Value { t := Type{Kind: BoolType} return Value{t: t, d: BoolData(b)} } func NewArray(arr []Value) Value { t := Type{Kind: ArrayType} return Value{t: t, d: ArrayData{arr: &arr}} } func NewNull() Value { t := Type{Kind: NullType} return Value{t: t} } func NewFunction() Value { panic("not implemented") } func NewObject() Value { panic("not implemented") } func (v Value) Type() Type { return v.t } func (v Value) Data() Data { return v.d }