Skip to content

Commit 1e1ea9d

Browse files
committed
Update to latest MicroPython core, v1.7-9.
Main changes are: - nested str formatting with {} - complete bignum support for negative args to and/or/xor - fix for failed map reallocation - improved float formatting, and fixes for buffer overflows - inline asm funcs can take 4 args, and specify a return type
1 parent 616b4da commit 1e1ea9d

Some content is hidden

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

57 files changed

+1214
-377
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.6-11-gfa67b52"
3-
#define MICROPY_GIT_HASH "fa67b52"
4-
#define MICROPY_BUILD_DATE "2016-02-01"
2+
#define MICROPY_GIT_TAG "v1.7-9-gbe020eb"
3+
#define MICROPY_GIT_HASH "be020eb"
4+
#define MICROPY_BUILD_DATE "2016-04-18"
55
#define MICROPY_VERSION_MAJOR (1)
6-
#define MICROPY_VERSION_MINOR (6)
6+
#define MICROPY_VERSION_MINOR (7)
77
#define MICROPY_VERSION_MICRO (0)
8-
#define MICROPY_VERSION_STRING "1.6.0"
8+
#define MICROPY_VERSION_STRING "1.7.0"

inc/genhdr/qstrdefs.generated.h

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,39 @@ QDEF(MP_QSTR_label, (const byte*)"\x43\x05" "label")
5050
QDEF(MP_QSTR_align, (const byte*)"\xa8\x05" "align")
5151
QDEF(MP_QSTR_data, (const byte*)"\x15\x04" "data")
5252
QDEF(MP_QSTR_uint, (const byte*)"\xe3\x04" "uint")
53+
QDEF(MP_QSTR_nop, (const byte*)"\xb4\x03" "nop")
54+
QDEF(MP_QSTR_mov, (const byte*)"\xf1\x03" "mov")
55+
QDEF(MP_QSTR_and_, (const byte*)"\x91\x04" "and_")
56+
QDEF(MP_QSTR_cmp, (const byte*)"\x3b\x03" "cmp")
57+
QDEF(MP_QSTR_add, (const byte*)"\x44\x03" "add")
58+
QDEF(MP_QSTR_sub, (const byte*)"\x21\x03" "sub")
59+
QDEF(MP_QSTR_lsl, (const byte*)"\xb6\x03" "lsl")
60+
QDEF(MP_QSTR_lsr, (const byte*)"\xa8\x03" "lsr")
61+
QDEF(MP_QSTR_asr, (const byte*)"\x65\x03" "asr")
62+
QDEF(MP_QSTR_ldr, (const byte*)"\x5f\x03" "ldr")
63+
QDEF(MP_QSTR_ldrb, (const byte*)"\x5d\x04" "ldrb")
64+
QDEF(MP_QSTR_ldrh, (const byte*)"\x57\x04" "ldrh")
65+
QDEF(MP_QSTR_str, (const byte*)"\x50\x03" "str")
66+
QDEF(MP_QSTR_strb, (const byte*)"\x32\x04" "strb")
67+
QDEF(MP_QSTR_strh, (const byte*)"\x38\x04" "strh")
68+
QDEF(MP_QSTR_b, (const byte*)"\xc7\x01" "b")
69+
QDEF(MP_QSTR_bl, (const byte*)"\xcb\x02" "bl")
70+
QDEF(MP_QSTR_bx, (const byte*)"\xdf\x02" "bx")
71+
QDEF(MP_QSTR_push, (const byte*)"\xbb\x04" "push")
72+
QDEF(MP_QSTR_pop, (const byte*)"\x2a\x03" "pop")
73+
QDEF(MP_QSTR_cpsid, (const byte*)"\xe8\x05" "cpsid")
74+
QDEF(MP_QSTR_cpsie, (const byte*)"\xe9\x05" "cpsie")
75+
QDEF(MP_QSTR_wfi, (const byte*)"\x9d\x03" "wfi")
76+
QDEF(MP_QSTR_clz, (const byte*)"\x50\x03" "clz")
77+
QDEF(MP_QSTR_rbit, (const byte*)"\xe8\x04" "rbit")
78+
QDEF(MP_QSTR_movw, (const byte*)"\x66\x04" "movw")
79+
QDEF(MP_QSTR_movt, (const byte*)"\x65\x04" "movt")
80+
QDEF(MP_QSTR_movwt, (const byte*)"\x52\x05" "movwt")
81+
QDEF(MP_QSTR_mrs, (const byte*)"\x89\x03" "mrs")
82+
QDEF(MP_QSTR_sdiv, (const byte*)"\xcd\x04" "sdiv")
83+
QDEF(MP_QSTR_udiv, (const byte*)"\x8b\x04" "udiv")
84+
QDEF(MP_QSTR_ldrex, (const byte*)"\xe2\x05" "ldrex")
85+
QDEF(MP_QSTR_strex, (const byte*)"\xad\x05" "strex")
5386
QDEF(MP_QSTR_builtins, (const byte*)"\xf7\x08" "builtins")
5487
QDEF(MP_QSTR_Ellipsis, (const byte*)"\xf0\x08" "Ellipsis")
5588
QDEF(MP_QSTR_StopIteration, (const byte*)"\xea\x0d" "StopIteration")
@@ -149,7 +182,6 @@ QDEF(MP_QSTR_sorted, (const byte*)"\x5e\x06" "sorted")
149182
QDEF(MP_QSTR_staticmethod, (const byte*)"\x62\x0c" "staticmethod")
150183
QDEF(MP_QSTR_sum, (const byte*)"\x2e\x03" "sum")
151184
QDEF(MP_QSTR_super, (const byte*)"\xc4\x05" "super")
152-
QDEF(MP_QSTR_str, (const byte*)"\x50\x03" "str")
153185
QDEF(MP_QSTR_sys, (const byte*)"\xbc\x03" "sys")
154186
QDEF(MP_QSTR_to_bytes, (const byte*)"\xd8\x08" "to_bytes")
155187
QDEF(MP_QSTR_tuple, (const byte*)"\xfd\x05" "tuple")
@@ -167,7 +199,6 @@ QDEF(MP_QSTR_fromkeys, (const byte*)"\x37\x08" "fromkeys")
167199
QDEF(MP_QSTR_get, (const byte*)"\x33\x03" "get")
168200
QDEF(MP_QSTR_items, (const byte*)"\xe3\x05" "items")
169201
QDEF(MP_QSTR_keys, (const byte*)"\x01\x04" "keys")
170-
QDEF(MP_QSTR_pop, (const byte*)"\x2a\x03" "pop")
171202
QDEF(MP_QSTR_popitem, (const byte*)"\xbf\x07" "popitem")
172203
QDEF(MP_QSTR_setdefault, (const byte*)"\x6c\x0a" "setdefault")
173204
QDEF(MP_QSTR_update, (const byte*)"\xb4\x06" "update")
@@ -189,7 +220,6 @@ QDEF(MP_QSTR_rstrip, (const byte*)"\x3b\x06" "rstrip")
189220
QDEF(MP_QSTR_format, (const byte*)"\x26\x06" "format")
190221
QDEF(MP_QSTR_key, (const byte*)"\x32\x03" "key")
191222
QDEF(MP_QSTR_reverse, (const byte*)"\x25\x07" "reverse")
192-
QDEF(MP_QSTR_add, (const byte*)"\x44\x03" "add")
193223
QDEF(MP_QSTR_find, (const byte*)"\x01\x04" "find")
194224
QDEF(MP_QSTR_rfind, (const byte*)"\xd2\x05" "rfind")
195225
QDEF(MP_QSTR_rindex, (const byte*)"\xe9\x06" "rindex")
@@ -516,7 +546,6 @@ QDEF(MP_QSTR_a_colon_1, (const byte*)"\x0f\x03" "a:1")
516546
QDEF(MP_QSTR_a_colon_2, (const byte*)"\x0c\x03" "a:2")
517547
QDEF(MP_QSTR_a_colon_4, (const byte*)"\x0a\x03" "a:4")
518548
QDEF(MP_QSTR_a_colon_5, (const byte*)"\x0b\x03" "a:5")
519-
QDEF(MP_QSTR_b, (const byte*)"\xc7\x01" "b")
520549
QDEF(MP_QSTR_b2_colon_1, (const byte*)"\xde\x04" "b2:1")
521550
QDEF(MP_QSTR_b3, (const byte*)"\x94\x02" "b3")
522551
QDEF(MP_QSTR_b4, (const byte*)"\x93\x02" "b4")

inc/lib/utils/pyexec.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ int pyexec_file(const char *filename);
4242
int pyexec_frozen_module(const char *name);
4343
void pyexec_event_repl_init(void);
4444
int pyexec_event_repl_process_char(int c);
45+
extern uint8_t pyexec_repl_active;
4546

4647
MP_DECLARE_CONST_FUN_OBJ(pyb_set_repl_info_obj);
4748

inc/py/builtin.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ extern const mp_obj_module_t mp_module_urandom;
105105
extern const mp_obj_module_t mp_module_ussl;
106106
extern const mp_obj_module_t mp_module_machine;
107107
extern const mp_obj_module_t mp_module_lwip;
108+
extern const mp_obj_module_t mp_module_websocket;
108109

109110
// extmod functions
110111
MP_DECLARE_CONST_FUN_OBJ(pyb_mount_obj);

inc/py/emit.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ typedef struct _emit_method_table_t {
106106
void (*break_loop)(emit_t *emit, mp_uint_t label, mp_uint_t except_depth);
107107
void (*continue_loop)(emit_t *emit, mp_uint_t label, mp_uint_t except_depth);
108108
void (*setup_with)(emit_t *emit, mp_uint_t label);
109-
void (*with_cleanup)(emit_t *emit);
109+
void (*with_cleanup)(emit_t *emit, mp_uint_t label);
110110
void (*setup_except)(emit_t *emit, mp_uint_t label);
111111
void (*setup_finally)(emit_t *emit, mp_uint_t label);
112112
void (*end_finally)(emit_t *emit);
@@ -227,7 +227,7 @@ void mp_emit_bc_unwind_jump(emit_t *emit, mp_uint_t label, mp_uint_t except_dept
227227
#define mp_emit_bc_break_loop mp_emit_bc_unwind_jump
228228
#define mp_emit_bc_continue_loop mp_emit_bc_unwind_jump
229229
void mp_emit_bc_setup_with(emit_t *emit, mp_uint_t label);
230-
void mp_emit_bc_with_cleanup(emit_t *emit);
230+
void mp_emit_bc_with_cleanup(emit_t *emit, mp_uint_t label);
231231
void mp_emit_bc_setup_except(emit_t *emit, mp_uint_t label);
232232
void mp_emit_bc_setup_finally(emit_t *emit, mp_uint_t label);
233233
void mp_emit_bc_end_finally(emit_t *emit);

inc/py/grammar.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ DEF_RULE(factor_2, c(factor_2), and(2), rule(factor_op), rule(factor))
241241
DEF_RULE(factor_op, nc, or(3), tok(OP_PLUS), tok(OP_MINUS), tok(OP_TILDE))
242242
DEF_RULE(power, c(power), and(3), rule(atom), opt_rule(power_trailers), opt_rule(power_dbl_star))
243243
DEF_RULE(power_trailers, c(power_trailers), one_or_more, rule(trailer))
244-
DEF_RULE(power_dbl_star, c(power_dbl_star), and(2), tok(OP_DBL_STAR), rule(factor))
244+
DEF_RULE(power_dbl_star, nc, ident | and(2), tok(OP_DBL_STAR), rule(factor))
245245

246246
// atom: '(' [yield_expr|testlist_comp] ')' | '[' [testlist_comp] ']' | '{' [dictorsetmaker] '}' | NAME | NUMBER | STRING+ | '...' | 'None' | 'True' | 'False'
247247
// testlist_comp: (test|star_expr) ( comp_for | (',' (test|star_expr))* [','] )

inc/py/misc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ bool unichar_isalpha(unichar c);
123123
bool unichar_isprint(unichar c);
124124
bool unichar_isdigit(unichar c);
125125
bool unichar_isxdigit(unichar c);
126+
bool unichar_isident(unichar c);
126127
bool unichar_isupper(unichar c);
127128
bool unichar_islower(unichar c);
128129
unichar unichar_tolower(unichar c);

inc/py/mpconfig.h

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,20 @@
283283
#define MICROPY_ENABLE_COMPILER (1)
284284
#endif
285285

286+
// Whether the compiler is dynamically configurable (ie at runtime)
287+
#ifndef MICROPY_DYNAMIC_COMPILER
288+
#define MICROPY_DYNAMIC_COMPILER (0)
289+
#endif
290+
291+
// Configure dynamic compiler macros
292+
#if MICROPY_DYNAMIC_COMPILER
293+
#define MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE_DYNAMIC (mp_dynamic_compiler.opt_cache_map_lookup_in_bytecode)
294+
#define MICROPY_PY_BUILTINS_STR_UNICODE_DYNAMIC (mp_dynamic_compiler.py_builtins_str_unicode)
295+
#else
296+
#define MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE_DYNAMIC MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE
297+
#define MICROPY_PY_BUILTINS_STR_UNICODE_DYNAMIC MICROPY_PY_BUILTINS_STR_UNICODE
298+
#endif
299+
286300
// Whether to enable constant folding; eg 1+2 rewritten as 3
287301
#ifndef MICROPY_COMP_CONST_FOLDING
288302
#define MICROPY_COMP_CONST_FOLDING (1)
@@ -342,9 +356,31 @@
342356
#define MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE (0)
343357
#endif
344358

359+
// Whether to use fast versions of bitwise operations (and, or, xor) when the
360+
// arguments are both positive. Increases Thumb2 code size by about 250 bytes.
361+
#ifndef MICROPY_OPT_MPZ_BITWISE
362+
#define MICROPY_OPT_MPZ_BITWISE (0)
363+
#endif
364+
345365
/*****************************************************************************/
346366
/* Python internal features */
347367

368+
// Hook for the VM at the start of the opcode loop (can contain variable
369+
// definitions usable by the other hook functions)
370+
#ifndef MICROPY_VM_HOOK_INIT
371+
#define MICROPY_VM_HOOK_INIT
372+
#endif
373+
374+
// Hook for the VM during the opcode loop (but only after jump opcodes)
375+
#ifndef MICROPY_VM_HOOK_LOOP
376+
#define MICROPY_VM_HOOK_LOOP
377+
#endif
378+
379+
// Hook for the VM just before return opcode is finished being interpreted
380+
#ifndef MICROPY_VM_HOOK_RETURN
381+
#define MICROPY_VM_HOOK_RETURN
382+
#endif
383+
348384
// Whether to include the garbage collector
349385
#ifndef MICROPY_ENABLE_GC
350386
#define MICROPY_ENABLE_GC (0)
@@ -711,6 +747,11 @@ typedef double mp_float_t;
711747
#define MICROPY_PY_IO_BYTESIO (1)
712748
#endif
713749

750+
// Whether to provide "io.BufferedWriter" class
751+
#ifndef MICROPY_PY_IO_BUFFEREDWRITER
752+
#define MICROPY_PY_IO_BUFFEREDWRITER (0)
753+
#endif
754+
714755
// Whether to provide "struct" module
715756
#ifndef MICROPY_PY_STRUCT
716757
#define MICROPY_PY_STRUCT (1)
@@ -800,6 +841,10 @@ typedef double mp_float_t;
800841
#define MICROPY_PY_USSL (0)
801842
#endif
802843

844+
#ifndef MICROPY_PY_WEBSOCKET
845+
#define MICROPY_PY_WEBSOCKET (0)
846+
#endif
847+
803848
/*****************************************************************************/
804849
/* Hooks for a port to add builtins */
805850

inc/py/mpstate.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,16 @@
3939
// memory system, runtime and virtual machine. The state is a global
4040
// variable, but in the future it is hoped that the state can become local.
4141

42+
// This structure contains dynamic configuration for the compiler.
43+
#if MICROPY_DYNAMIC_COMPILER
44+
typedef struct mp_dynamic_compiler_t {
45+
uint8_t small_int_bits; // must be <= host small_int_bits
46+
bool opt_cache_map_lookup_in_bytecode;
47+
bool py_builtins_str_unicode;
48+
} mp_dynamic_compiler_t;
49+
extern mp_dynamic_compiler_t mp_dynamic_compiler;
50+
#endif
51+
4252
// This structure hold information about the memory allocation system.
4353
typedef struct _mp_state_mem_t {
4454
#if MICROPY_MEM_STATS
@@ -132,6 +142,11 @@ typedef struct _mp_state_vm_t {
132142
mp_obj_t lwip_slip_stream;
133143
#endif
134144

145+
#if MICROPY_FSUSERMOUNT
146+
// for user-mountable block device (max fixed at compile time)
147+
struct _fs_user_mount_t *fs_user_mount[MICROPY_FATFS_VOLUMES];
148+
#endif
149+
135150
//
136151
// END ROOT POINTER SECTION
137152
////////////////////////////////////////////////////////////

inc/py/obj.h

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,8 @@ typedef mp_obj_t (*mp_fun_1_t)(mp_obj_t);
425425
typedef mp_obj_t (*mp_fun_2_t)(mp_obj_t, mp_obj_t);
426426
typedef mp_obj_t (*mp_fun_3_t)(mp_obj_t, mp_obj_t, mp_obj_t);
427427
typedef mp_obj_t (*mp_fun_var_t)(size_t n, const mp_obj_t *);
428+
// mp_fun_kw_t takes mp_map_t* (and not const mp_map_t*) to ease passing
429+
// this arg to mp_map_lookup().
428430
typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *);
429431

430432
typedef enum {
@@ -452,7 +454,7 @@ typedef struct _mp_buffer_info_t {
452454
//int ver; // ?
453455

454456
void *buf; // can be NULL if len == 0
455-
mp_uint_t len; // in bytes
457+
size_t len; // in bytes
456458
int typecode; // as per binary.h
457459

458460
// Rationale: to load arbitrary-sized sprites directly to LCD
@@ -469,7 +471,6 @@ bool mp_get_buffer(mp_obj_t obj, mp_buffer_info_t *bufinfo, mp_uint_t flags);
469471
void mp_get_buffer_raise(mp_obj_t obj, mp_buffer_info_t *bufinfo, mp_uint_t flags);
470472

471473
// Stream protocol
472-
#define MP_STREAM_ERROR ((mp_uint_t)-1)
473474
typedef struct _mp_stream_p_t {
474475
// On error, functions should return MP_STREAM_ERROR and fill in *errcode (values
475476
// are implementation-dependent, but will be exposed to user, e.g. via exception).
@@ -479,17 +480,6 @@ typedef struct _mp_stream_p_t {
479480
mp_uint_t is_text : 1; // default is bytes, set this for text stream
480481
} mp_stream_p_t;
481482

482-
// Stream ioctl request codes
483-
#define MP_STREAM_FLUSH (1)
484-
#define MP_STREAM_SEEK (2)
485-
#define MP_STREAM_POLL (3)
486-
487-
// Argument structure for MP_STREAM_SEEK
488-
struct mp_stream_seek_t {
489-
mp_off_t offset;
490-
int whence;
491-
};
492-
493483
struct _mp_obj_type_t {
494484
mp_obj_base_t base;
495485
qstr name;
@@ -737,6 +727,8 @@ mp_obj_t mp_obj_float_binary_op(mp_uint_t op, mp_float_t lhs_val, mp_obj_t rhs);
737727
// complex
738728
void mp_obj_complex_get(mp_obj_t self_in, mp_float_t *real, mp_float_t *imag);
739729
mp_obj_t mp_obj_complex_binary_op(mp_uint_t op, mp_float_t lhs_real, mp_float_t lhs_imag, mp_obj_t rhs_in); // can return MP_OBJ_NULL if op not supported
730+
#else
731+
#define mp_obj_is_float(o) (false)
740732
#endif
741733

742734
// tuple

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy