Skip to content

Commit ee3f665

Browse files
committed
Update to latest MicroPython core, v1.5.2-76.
There are lots of changes, but most of them are to support configuration of more sophisticated object models, such as 64-bit NaN boxing (not used on the microbit). As usual there are bug fixes, and a few new features. One such feature is that dir() now lists instance members of an object.
1 parent 2befceb commit ee3f665

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

109 files changed

+2629
-1968
lines changed

inc/genhdr/mpversion.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// This file was generated by py/makeversionhdr.py
2-
#define MICROPY_GIT_TAG "v1.5-150-g46dcc80"
3-
#define MICROPY_GIT_HASH "46dcc80"
4-
#define MICROPY_BUILD_DATE "2015-11-17"
2+
#define MICROPY_GIT_TAG "v1.5.2-76-g6a2af82"
3+
#define MICROPY_GIT_HASH "6a2af82"
4+
#define MICROPY_BUILD_DATE "2016-01-21"
55
#define MICROPY_VERSION_MAJOR (1)
66
#define MICROPY_VERSION_MINOR (5)
7-
#define MICROPY_VERSION_MICRO (0)
8-
#define MICROPY_VERSION_STRING "1.5.0"
7+
#define MICROPY_VERSION_MICRO (2)
8+
#define MICROPY_VERSION_STRING "1.5.2"

inc/genhdr/qstrdefs.generated.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ QDEF(MP_QSTR___locals__, (const byte*)"\x7b\x0a" "__locals__")
1414
QDEF(MP_QSTR___main__, (const byte*)"\x8e\x08" "__main__")
1515
QDEF(MP_QSTR___module__, (const byte*)"\xff\x0a" "__module__")
1616
QDEF(MP_QSTR___name__, (const byte*)"\xe2\x08" "__name__")
17+
QDEF(MP_QSTR___dict__, (const byte*)"\x7f\x08" "__dict__")
1718
QDEF(MP_QSTR___hash__, (const byte*)"\xf7\x08" "__hash__")
1819
QDEF(MP_QSTR___next__, (const byte*)"\x02\x08" "__next__")
1920
QDEF(MP_QSTR___qualname__, (const byte*)"\x6b\x0c" "__qualname__")
@@ -128,6 +129,7 @@ QDEF(MP_QSTR_locals, (const byte*)"\x3b\x06" "locals")
128129
QDEF(MP_QSTR_map, (const byte*)"\xb9\x03" "map")
129130
QDEF(MP_QSTR_max, (const byte*)"\xb1\x03" "max")
130131
QDEF(MP_QSTR_min, (const byte*)"\xaf\x03" "min")
132+
QDEF(MP_QSTR_default, (const byte*)"\xce\x07" "default")
131133
QDEF(MP_QSTR_namedtuple, (const byte*)"\x1e\x0a" "namedtuple")
132134
QDEF(MP_QSTR_next, (const byte*)"\x42\x04" "next")
133135
QDEF(MP_QSTR_oct, (const byte*)"\xfd\x03" "oct")
@@ -265,9 +267,12 @@ QDEF(MP_QSTR_version, (const byte*)"\xbf\x07" "version")
265267
QDEF(MP_QSTR_version_info, (const byte*)"\x6e\x0c" "version_info")
266268
QDEF(MP_QSTR_implementation, (const byte*)"\x17\x0e" "implementation")
267269
QDEF(MP_QSTR_print_exception, (const byte*)"\x1c\x0f" "print_exception")
270+
QDEF(MP_QSTR_struct, (const byte*)"\x12\x06" "struct")
268271
QDEF(MP_QSTR_ustruct, (const byte*)"\x47\x07" "ustruct")
269272
QDEF(MP_QSTR_pack, (const byte*)"\xbc\x04" "pack")
273+
QDEF(MP_QSTR_pack_into, (const byte*)"\x1f\x09" "pack_into")
270274
QDEF(MP_QSTR_unpack, (const byte*)"\x07\x06" "unpack")
275+
QDEF(MP_QSTR_unpack_from, (const byte*)"\x0e\x0b" "unpack_from")
271276
QDEF(MP_QSTR_calcsize, (const byte*)"\x4d\x08" "calcsize")
272277
QDEF(MP_QSTR_gc, (const byte*)"\x61\x02" "gc")
273278
QDEF(MP_QSTR_collect, (const byte*)"\x9b\x07" "collect")
@@ -278,7 +283,6 @@ QDEF(MP_QSTR_mem_free, (const byte*)"\xcb\x08" "mem_free")
278283
QDEF(MP_QSTR_mem_alloc, (const byte*)"\x52\x09" "mem_alloc")
279284
QDEF(MP_QSTR_help, (const byte*)"\x94\x04" "help")
280285
QDEF(MP_QSTR_collections, (const byte*)"\xe0\x0b" "collections")
281-
QDEF(MP_QSTR_struct, (const byte*)"\x12\x06" "struct")
282286
QDEF(MP_QSTR_microbit, (const byte*)"\xc0\x08" "microbit")
283287
QDEF(MP_QSTR_reset, (const byte*)"\x10\x05" "reset")
284288
QDEF(MP_QSTR_sleep, (const byte*)"\xea\x05" "sleep")

inc/lib/utils/pyexec.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ extern pyexec_mode_kind_t pyexec_mode_kind;
3939
int pyexec_raw_repl(void);
4040
int pyexec_friendly_repl(void);
4141
int pyexec_file(const char *filename);
42+
int pyexec_frozen_module(const char *name);
4243
void pyexec_event_repl_init(void);
4344
int pyexec_event_repl_process_char(int c);
4445

inc/py/bc.h

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ typedef struct _mp_exc_stack {
6666
// bit 1 is whether the opcode was SETUP_WITH or SETUP_FINALLY
6767
mp_obj_t *val_sp;
6868
// Saved exception, valid if currently_in_except_block bit is 1
69-
mp_obj_t prev_exc;
69+
mp_obj_base_t *prev_exc;
7070
} mp_exc_stack_t;
7171

7272
typedef struct _mp_code_state {
@@ -80,7 +80,7 @@ typedef struct _mp_code_state {
8080
#if MICROPY_STACKLESS
8181
struct _mp_code_state *prev;
8282
#endif
83-
mp_uint_t n_state;
83+
size_t n_state;
8484
// Variable-length
8585
mp_obj_t state[0];
8686
// Variable-length, never accessed by name, only as (void*)(state + n_state)
@@ -90,18 +90,19 @@ typedef struct _mp_code_state {
9090
mp_uint_t mp_decode_uint(const byte **ptr);
9191

9292
mp_vm_return_kind_t mp_execute_bytecode(mp_code_state *code_state, volatile mp_obj_t inject_exc);
93-
mp_code_state *mp_obj_fun_bc_prepare_codestate(mp_obj_t func, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args);
94-
void mp_setup_code_state(mp_code_state *code_state, mp_obj_t self_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args);
93+
mp_code_state *mp_obj_fun_bc_prepare_codestate(mp_obj_t func, size_t n_args, size_t n_kw, const mp_obj_t *args);
94+
struct _mp_obj_fun_bc_t;
95+
void mp_setup_code_state(mp_code_state *code_state, struct _mp_obj_fun_bc_t *self, size_t n_args, size_t n_kw, const mp_obj_t *args);
9596
void mp_bytecode_print(const void *descr, const byte *code, mp_uint_t len, const mp_uint_t *const_table);
9697
void mp_bytecode_print2(const byte *code, mp_uint_t len);
9798
const byte *mp_bytecode_print_str(const byte *ip);
9899
#define mp_bytecode_print_inst(code) mp_bytecode_print2(code, 1)
99100

100101
// Helper macros to access pointer with least significant bits holding flags
101-
#define MP_TAGPTR_PTR(x) ((void*)((mp_uint_t)(x) & ~((mp_uint_t)3)))
102-
#define MP_TAGPTR_TAG0(x) ((mp_uint_t)(x) & 1)
103-
#define MP_TAGPTR_TAG1(x) ((mp_uint_t)(x) & 2)
104-
#define MP_TAGPTR_MAKE(ptr, tag) ((void*)((mp_uint_t)(ptr) | (tag)))
102+
#define MP_TAGPTR_PTR(x) ((void*)((uintptr_t)(x) & ~((uintptr_t)3)))
103+
#define MP_TAGPTR_TAG0(x) ((uintptr_t)(x) & 1)
104+
#define MP_TAGPTR_TAG1(x) ((uintptr_t)(x) & 2)
105+
#define MP_TAGPTR_MAKE(ptr, tag) ((void*)((uintptr_t)(ptr) | (tag)))
105106

106107
#if MICROPY_PERSISTENT_CODE_LOAD || MICROPY_PERSISTENT_CODE_SAVE
107108

inc/py/bc0.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,6 @@
8080
#define MP_BC_POP_EXCEPT (0x45)
8181
#define MP_BC_UNWIND_JUMP (0x46) // rel byte code offset, 16-bit signed, in excess; then a byte
8282

83-
#define MP_BC_NOT (0x47)
84-
8583
#define MP_BC_BUILD_TUPLE (0x50) // uint
8684
#define MP_BC_BUILD_LIST (0x51) // uint
8785
#define MP_BC_LIST_APPEND (0x52) // uint
@@ -115,7 +113,7 @@
115113
#define MP_BC_LOAD_CONST_SMALL_INT_MULTI (0x70) // + N(64)
116114
#define MP_BC_LOAD_FAST_MULTI (0xb0) // + N(16)
117115
#define MP_BC_STORE_FAST_MULTI (0xc0) // + N(16)
118-
#define MP_BC_UNARY_OP_MULTI (0xd0) // + op(6)
119-
#define MP_BC_BINARY_OP_MULTI (0xd6) // + op(36)
116+
#define MP_BC_UNARY_OP_MULTI (0xd0) // + op(7)
117+
#define MP_BC_BINARY_OP_MULTI (0xd7) // + op(36)
120118

121119
#endif // __MICROPY_INCLUDED_PY_BC0_H__

inc/py/builtin.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@
2828

2929
#include "py/obj.h"
3030

31-
mp_obj_t mp_builtin___import__(mp_uint_t n_args, const mp_obj_t *args);
32-
mp_obj_t mp_builtin_open(mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kwargs);
33-
mp_obj_t mp_micropython_mem_info(mp_uint_t n_args, const mp_obj_t *args);
31+
mp_obj_t mp_builtin___import__(size_t n_args, const mp_obj_t *args);
32+
mp_obj_t mp_builtin_open(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs);
33+
mp_obj_t mp_micropython_mem_info(size_t n_args, const mp_obj_t *args);
3434

3535
MP_DECLARE_CONST_FUN_OBJ(mp_builtin___build_class___obj);
3636
MP_DECLARE_CONST_FUN_OBJ(mp_builtin___import___obj);
@@ -101,8 +101,12 @@ extern const mp_obj_module_t mp_module_ure;
101101
extern const mp_obj_module_t mp_module_uheapq;
102102
extern const mp_obj_module_t mp_module_uhashlib;
103103
extern const mp_obj_module_t mp_module_ubinascii;
104+
extern const mp_obj_module_t mp_module_urandom;
104105
extern const mp_obj_module_t mp_module_ussl;
105106
extern const mp_obj_module_t mp_module_machine;
106107
extern const mp_obj_module_t mp_module_lwip;
107108

109+
// extmod functions
110+
MP_DECLARE_CONST_FUN_OBJ(pyb_mount_obj);
111+
108112
#endif // __MICROPY_INCLUDED_PY_BUILTIN_H__

inc/py/compile.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ enum {
4343
// the compiler will clear the parse tree before it returns
4444
mp_obj_t mp_compile(mp_parse_tree_t *parse_tree, qstr source_file, uint emit_opt, bool is_repl);
4545

46+
#if MICROPY_PERSISTENT_CODE_SAVE
47+
// this has the same semantics as mp_compile
48+
mp_raw_code_t *mp_compile_to_raw_code(mp_parse_tree_t *parse_tree, qstr source_file, uint emit_opt, bool is_repl);
49+
#endif
50+
4651
// this is implemented in runtime.c
4752
mp_obj_t mp_parse_compile_execute(mp_lexer_t *lex, mp_parse_input_kind_t parse_input_kind, mp_obj_dict_t *globals, mp_obj_dict_t *locals);
4853

inc/py/emit.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ typedef struct _emit_method_table_t {
8585
void (*load_const_tok)(emit_t *emit, mp_token_kind_t tok);
8686
void (*load_const_small_int)(emit_t *emit, mp_int_t arg);
8787
void (*load_const_str)(emit_t *emit, qstr qst);
88-
void (*load_const_obj)(emit_t *emit, void *obj);
88+
void (*load_const_obj)(emit_t *emit, mp_obj_t obj);
8989
void (*load_null)(emit_t *emit);
9090
void (*load_attr)(emit_t *emit, qstr qst);
9191
void (*load_method)(emit_t *emit, qstr qst);
@@ -205,7 +205,7 @@ void mp_emit_bc_import_star(emit_t *emit);
205205
void mp_emit_bc_load_const_tok(emit_t *emit, mp_token_kind_t tok);
206206
void mp_emit_bc_load_const_small_int(emit_t *emit, mp_int_t arg);
207207
void mp_emit_bc_load_const_str(emit_t *emit, qstr qst);
208-
void mp_emit_bc_load_const_obj(emit_t *emit, void *obj);
208+
void mp_emit_bc_load_const_obj(emit_t *emit, mp_obj_t obj);
209209
void mp_emit_bc_load_null(emit_t *emit);
210210
void mp_emit_bc_load_attr(emit_t *emit, qstr qst);
211211
void mp_emit_bc_load_method(emit_t *emit, qstr qst);

inc/py/emitglue.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ typedef struct _mp_reader_t {
6262
} mp_reader_t;
6363

6464
mp_raw_code_t *mp_raw_code_load(mp_reader_t *reader);
65+
mp_raw_code_t *mp_raw_code_load_mem(const byte *buf, size_t len);
6566
mp_raw_code_t *mp_raw_code_load_file(const char *filename);
6667
#endif
6768

inc/py/gc.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,21 +42,21 @@ bool gc_is_locked(void);
4242
// A given port must implement gc_collect by using the other collect functions.
4343
void gc_collect(void);
4444
void gc_collect_start(void);
45-
void gc_collect_root(void **ptrs, mp_uint_t len);
45+
void gc_collect_root(void **ptrs, size_t len);
4646
void gc_collect_end(void);
4747

48-
void *gc_alloc(mp_uint_t n_bytes, bool has_finaliser);
48+
void *gc_alloc(size_t n_bytes, bool has_finaliser);
4949
void gc_free(void *ptr); // does not call finaliser
50-
mp_uint_t gc_nbytes(const void *ptr);
51-
void *gc_realloc(void *ptr, mp_uint_t n_bytes, bool allow_move);
50+
size_t gc_nbytes(const void *ptr);
51+
void *gc_realloc(void *ptr, size_t n_bytes, bool allow_move);
5252

5353
typedef struct _gc_info_t {
54-
mp_uint_t total;
55-
mp_uint_t used;
56-
mp_uint_t free;
57-
mp_uint_t num_1block;
58-
mp_uint_t num_2block;
59-
mp_uint_t max_block;
54+
size_t total;
55+
size_t used;
56+
size_t free;
57+
size_t num_1block;
58+
size_t num_2block;
59+
size_t max_block;
6060
} gc_info_t;
6161

6262
void gc_info(gc_info_t *info);

0 commit comments

Comments
 (0)