/**
* @constructor
* Sk.builtin.bool
*
* @description
* Constructor for Python bool. Also used for builtin bool() function.
*
* Where possible, do not create a new instance but use the constants
* Sk.builtin.bool.true$ or Sk.builtin.bool.false$. These are defined in src/constant.js
*
* @extends {Sk.builtin.object}
*
* @param {(Object|number|boolean)} x Value to evaluate as true or false
* @return {Sk.builtin.bool} Sk.builtin.bool.true$ if x is true, Sk.builtin.bool.false$ otherwise
*/
Sk.builtin.bool = function (x) {
Sk.builtin.pyCheckArgsLen("bool", arguments.length, 1);
if (Sk.misceval.isTrue(x)) {
return Sk.builtin.bool.true$;
} else {
return Sk.builtin.bool.false$;
}
};
Sk.abstr.setUpInheritance("bool", Sk.builtin.bool, Sk.builtin.int_);
Sk.builtin.bool.prototype["$r"] = function () {
if (this.v) {
return new Sk.builtin.str("True");
}
return new Sk.builtin.str("False");
};
Sk.builtin.bool.prototype.tp$hash = function () {
return new Sk.builtin.int_(this.v);
};
Sk.builtin.bool.prototype.__int__ = new Sk.builtin.func(function(self) {
var v = Sk.builtin.asnum$(self);
return new Sk.builtin.int_(v);
});
Sk.builtin.bool.prototype.__float__ = new Sk.builtin.func(function(self) {
return new Sk.builtin.float_(Sk.ffi.remapToJs(self));
});
Sk.exportSymbol("Sk.builtin.bool", Sk.builtin.bool);