rum-goggles/v1/vendor/github.com/robertkrimen/otto/builtin_boolean.go

29 lines
719 B
Go
Raw Normal View History

package otto
// Boolean
func builtinBoolean(call FunctionCall) Value {
2024-04-04 14:46:14 +00:00
return boolValue(call.Argument(0).bool())
}
2024-04-04 14:46:14 +00:00
func builtinNewBoolean(obj *object, argumentList []Value) Value {
return objectValue(obj.runtime.newBoolean(valueOfArrayIndex(argumentList, 0)))
}
2024-04-04 14:46:14 +00:00
func builtinBooleanToString(call FunctionCall) Value {
value := call.This
if !value.IsBoolean() {
// Will throw a TypeError if ThisObject is not a Boolean
2024-04-04 14:46:14 +00:00
value = call.thisClassObject(classBooleanName).primitiveValue()
}
2024-04-04 14:46:14 +00:00
return stringValue(value.string())
}
2024-04-04 14:46:14 +00:00
func builtinBooleanValueOf(call FunctionCall) Value {
value := call.This
if !value.IsBoolean() {
2024-04-04 14:46:14 +00:00
value = call.thisClassObject(classBooleanName).primitiveValue()
}
return value
}