2024-02-24 21:00:04 +00:00
|
|
|
package otto
|
|
|
|
|
|
|
|
// Boolean
|
|
|
|
|
|
|
|
func builtinBoolean(call FunctionCall) Value {
|
2024-04-04 14:46:14 +00:00
|
|
|
return boolValue(call.Argument(0).bool())
|
2024-02-24 21:00:04 +00:00
|
|
|
}
|
|
|
|
|
2024-04-04 14:46:14 +00:00
|
|
|
func builtinNewBoolean(obj *object, argumentList []Value) Value {
|
|
|
|
return objectValue(obj.runtime.newBoolean(valueOfArrayIndex(argumentList, 0)))
|
2024-02-24 21:00:04 +00:00
|
|
|
}
|
|
|
|
|
2024-04-04 14:46:14 +00:00
|
|
|
func builtinBooleanToString(call FunctionCall) Value {
|
2024-02-24 21:00:04 +00:00
|
|
|
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-02-24 21:00:04 +00:00
|
|
|
}
|
2024-04-04 14:46:14 +00:00
|
|
|
return stringValue(value.string())
|
2024-02-24 21:00:04 +00:00
|
|
|
}
|
|
|
|
|
2024-04-04 14:46:14 +00:00
|
|
|
func builtinBooleanValueOf(call FunctionCall) Value {
|
2024-02-24 21:00:04 +00:00
|
|
|
value := call.This
|
|
|
|
if !value.IsBoolean() {
|
2024-04-04 14:46:14 +00:00
|
|
|
value = call.thisClassObject(classBooleanName).primitiveValue()
|
2024-02-24 21:00:04 +00:00
|
|
|
}
|
|
|
|
return value
|
|
|
|
}
|