blob: 9b53ffae94f012f0e349c81b06e7ad7562ae2c07 [file] [log] [blame]
Damiend99b0522013-12-21 18:17:45 +00001#include <stdlib.h>
2#include <stdint.h>
3
4#include "nlr.h"
5#include "misc.h"
6#include "mpconfig.h"
7#include "obj.h"
8
9typedef struct _mp_obj_bool_t {
10 mp_obj_base_t base;
11 bool value;
12} mp_obj_bool_t;
13
14void bool_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in) {
15 mp_obj_bool_t *self = self_in;
16 if (self->value) {
17 print(env, "True");
18 } else {
19 print(env, "False");
20 }
21}
22
23const mp_obj_type_t bool_type = {
24 { &mp_const_type },
25 "bool",
26 bool_print, // print
27 NULL, // call_n
28 NULL, // unary_op
29 NULL, // binary_op
30 NULL, // getiter
31 NULL, // iternext
32 {{NULL, NULL},}, // method list
33};
34
35static const mp_obj_bool_t false_obj = {{&bool_type}, false};
36static const mp_obj_bool_t true_obj = {{&bool_type}, true};
37
38const mp_obj_t mp_const_false = (mp_obj_t)&false_obj;
39const mp_obj_t mp_const_true = (mp_obj_t)&true_obj;