summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/d5/tengo/script/conversion.go
blob: c35c14118a7203c535ea2310c72d971c238036c0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package script

import (
	"github.com/d5/tengo/objects"
)

func objectToInterface(o objects.Object) interface{} {
	switch val := o.(type) {
	case *objects.Array:
		return val.Value
	case *objects.Map:
		return val.Value
	case *objects.Int:
		return val.Value
	case *objects.Float:
		return val.Value
	case *objects.Bool:
		if val == objects.TrueValue {
			return true
		}
		return false
	case *objects.Char:
		return val.Value
	case *objects.String:
		return val.Value
	case *objects.Bytes:
		return val.Value
	case *objects.Undefined:
		return nil
	}

	return o
}