2019-03-14 04:50:29 +02:00
|
|
|
package eval
|
|
|
|
|
|
|
|
import (
|
2019-07-03 20:05:02 +02:00
|
|
|
"strconv"
|
|
|
|
|
2019-03-14 04:50:29 +02:00
|
|
|
"github.com/MontFerret/ferret/pkg/runtime/core"
|
|
|
|
"github.com/MontFerret/ferret/pkg/runtime/values"
|
|
|
|
)
|
|
|
|
|
|
|
|
func Param(input core.Value) string {
|
|
|
|
switch value := input.(type) {
|
|
|
|
case values.String:
|
|
|
|
return ParamString(string(value))
|
|
|
|
case values.Float:
|
|
|
|
return ParamFloat(float64(value))
|
|
|
|
case values.Int:
|
|
|
|
return ParamInt(int64(value))
|
|
|
|
default:
|
|
|
|
if input == values.None {
|
|
|
|
return "null"
|
|
|
|
}
|
|
|
|
|
|
|
|
return value.String()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func ParamString(param string) string {
|
2019-03-15 06:09:34 +02:00
|
|
|
return "`" + param + "`"
|
2019-03-14 04:50:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func ParamFloat(param float64) string {
|
|
|
|
return strconv.FormatFloat(param, 'f', 6, 64)
|
|
|
|
}
|
|
|
|
|
|
|
|
func ParamInt(param int64) string {
|
|
|
|
return strconv.FormatInt(param, 64)
|
|
|
|
}
|