2019-01-09 23:39:40 +03:00
|
|
|
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:
|
2019-01-29 00:09:40 +03:00
|
|
|
if val == objects.TrueValue {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
return false
|
2019-01-09 23:39:40 +03:00
|
|
|
case *objects.Char:
|
|
|
|
return val.Value
|
|
|
|
case *objects.String:
|
|
|
|
return val.Value
|
2019-01-18 12:43:46 +03:00
|
|
|
case *objects.Bytes:
|
|
|
|
return val.Value
|
2019-01-11 14:15:31 +03:00
|
|
|
case *objects.Undefined:
|
|
|
|
return nil
|
2019-01-09 23:39:40 +03:00
|
|
|
}
|
|
|
|
|
2019-01-11 14:15:31 +03:00
|
|
|
return o
|
2019-01-09 23:39:40 +03:00
|
|
|
}
|