builtin_boolean.go 725 B

12345678910111213141516171819202122232425262728
  1. package otto
  2. // Boolean
  3. func builtinBoolean(call FunctionCall) Value {
  4. return toValue_bool(call.Argument(0).bool())
  5. }
  6. func builtinNewBoolean(self *_object, argumentList []Value) Value {
  7. return toValue_object(self.runtime.newBoolean(valueOfArrayIndex(argumentList, 0)))
  8. }
  9. func builtinBoolean_toString(call FunctionCall) Value {
  10. value := call.This
  11. if !value.IsBoolean() {
  12. // Will throw a TypeError if ThisObject is not a Boolean
  13. value = call.thisClassObject(classBoolean).primitiveValue()
  14. }
  15. return toValue_string(value.string())
  16. }
  17. func builtinBoolean_valueOf(call FunctionCall) Value {
  18. value := call.This
  19. if !value.IsBoolean() {
  20. value = call.thisClassObject(classBoolean).primitiveValue()
  21. }
  22. return value
  23. }