2013-12-21 18:17:45 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include "nlr.h"
|
|
|
|
#include "misc.h"
|
|
|
|
#include "mpconfig.h"
|
2014-01-21 21:40:13 +00:00
|
|
|
#include "qstr.h"
|
2013-12-21 18:17:45 +00:00
|
|
|
#include "obj.h"
|
2014-01-27 23:15:32 +00:00
|
|
|
#include "runtime0.h"
|
2013-12-21 18:17:45 +00:00
|
|
|
|
|
|
|
typedef struct _mp_obj_none_t {
|
|
|
|
mp_obj_base_t base;
|
|
|
|
} mp_obj_none_t;
|
|
|
|
|
2014-02-12 16:15:40 +00:00
|
|
|
STATIC void none_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in, mp_print_kind_t kind) {
|
2013-12-21 18:17:45 +00:00
|
|
|
print(env, "None");
|
|
|
|
}
|
|
|
|
|
2014-02-12 16:15:40 +00:00
|
|
|
STATIC mp_obj_t none_unary_op(int op, mp_obj_t o_in) {
|
2014-01-27 23:15:32 +00:00
|
|
|
switch (op) {
|
2014-01-30 02:37:19 +00:00
|
|
|
case RT_UNARY_OP_BOOL: return mp_const_false;
|
2014-01-27 23:15:32 +00:00
|
|
|
default: return MP_OBJ_NULL; // op not supported for None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-21 18:17:45 +00:00
|
|
|
const mp_obj_type_t none_type = {
|
2014-02-15 16:10:44 +00:00
|
|
|
{ &mp_type_type },
|
2014-02-15 11:34:50 +00:00
|
|
|
.name = MP_QSTR_NoneType,
|
2014-01-05 20:34:09 +00:00
|
|
|
.print = none_print,
|
2014-01-27 23:15:32 +00:00
|
|
|
.unary_op = none_unary_op,
|
2013-12-21 18:17:45 +00:00
|
|
|
};
|
|
|
|
|
2014-02-12 16:15:40 +00:00
|
|
|
STATIC const mp_obj_none_t none_obj = {{&none_type}};
|
2013-12-21 18:17:45 +00:00
|
|
|
const mp_obj_t mp_const_none = (mp_obj_t)&none_obj;
|