Commit b3a50f0f authored by Damien George's avatar Damien George
Browse files

Merge branch 'master' into unicode

Conflicts:
	py/mpconfig.h
parents ed07d035 8993fb6c
...@@ -22,7 +22,7 @@ else ...@@ -22,7 +22,7 @@ else
CFLAGS += -Os -DNDEBUG CFLAGS += -Os -DNDEBUG
endif endif
LDFLAGS = -nostdlib -T stm32f405.ld LDFLAGS = -nostdlib -T stm32f405.ld -Map=$@.map --cref
LIBS = LIBS =
SRC_C = \ SRC_C = \
......
...@@ -12,10 +12,12 @@ ...@@ -12,10 +12,12 @@
#define MICROPY_HELPER_REPL (0) #define MICROPY_HELPER_REPL (0)
#define MICROPY_HELPER_LEXER_UNIX (0) #define MICROPY_HELPER_LEXER_UNIX (0)
#define MICROPY_ENABLE_SOURCE_LINE (0) #define MICROPY_ENABLE_SOURCE_LINE (0)
#define MICROPY_PY_BUILTINS_BYTEARRAY (0)
#define MICROPY_PY_BUILTINS_FROZENSET (0) #define MICROPY_PY_BUILTINS_FROZENSET (0)
#define MICROPY_PY_BUILTINS_SET (0) #define MICROPY_PY_BUILTINS_SET (0)
#define MICROPY_PY_BUILTINS_SLICE (0) #define MICROPY_PY_BUILTINS_SLICE (0)
#define MICROPY_PY_BUILTINS_PROPERTY (0) #define MICROPY_PY_BUILTINS_PROPERTY (0)
#define MICROPY_PY_ARRAY (0)
#define MICROPY_PY_COLLECTIONS (0) #define MICROPY_PY_COLLECTIONS (0)
#define MICROPY_PY_MATH (0) #define MICROPY_PY_MATH (0)
#define MICROPY_PY_CMATH (0) #define MICROPY_PY_CMATH (0)
...@@ -26,6 +28,8 @@ ...@@ -26,6 +28,8 @@
#define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_NONE) #define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_NONE)
#define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_NONE) #define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_NONE)
//#define MICROPY_ERROR_REPORTING (MICROPY_ERROR_REPORTING_TERSE)
// type definitions for the specific machine // type definitions for the specific machine
#define BYTES_PER_WORD (4) #define BYTES_PER_WORD (4)
......
...@@ -43,7 +43,9 @@ STATIC const mp_map_elem_t mp_builtin_object_table[] = { ...@@ -43,7 +43,9 @@ STATIC const mp_map_elem_t mp_builtin_object_table[] = {
// built-in types // built-in types
{ MP_OBJ_NEW_QSTR(MP_QSTR_bool), (mp_obj_t)&mp_type_bool }, { MP_OBJ_NEW_QSTR(MP_QSTR_bool), (mp_obj_t)&mp_type_bool },
{ MP_OBJ_NEW_QSTR(MP_QSTR_bytes), (mp_obj_t)&mp_type_bytes }, { MP_OBJ_NEW_QSTR(MP_QSTR_bytes), (mp_obj_t)&mp_type_bytes },
#if MICROPY_PY_BUILTINS_BYTEARRAY
{ MP_OBJ_NEW_QSTR(MP_QSTR_bytearray), (mp_obj_t)&mp_type_bytearray }, { MP_OBJ_NEW_QSTR(MP_QSTR_bytearray), (mp_obj_t)&mp_type_bytearray },
#endif
#if MICROPY_PY_BUILTINS_COMPLEX #if MICROPY_PY_BUILTINS_COMPLEX
{ MP_OBJ_NEW_QSTR(MP_QSTR_complex), (mp_obj_t)&mp_type_complex }, { MP_OBJ_NEW_QSTR(MP_QSTR_complex), (mp_obj_t)&mp_type_complex },
#endif #endif
...@@ -160,7 +162,9 @@ STATIC const mp_map_elem_t mp_builtin_module_table[] = { ...@@ -160,7 +162,9 @@ STATIC const mp_map_elem_t mp_builtin_module_table[] = {
{ MP_OBJ_NEW_QSTR(MP_QSTR___main__), (mp_obj_t)&mp_module___main__ }, { MP_OBJ_NEW_QSTR(MP_QSTR___main__), (mp_obj_t)&mp_module___main__ },
{ MP_OBJ_NEW_QSTR(MP_QSTR_micropython), (mp_obj_t)&mp_module_micropython }, { MP_OBJ_NEW_QSTR(MP_QSTR_micropython), (mp_obj_t)&mp_module_micropython },
#if MICROPY_PY_ARRAY
{ MP_OBJ_NEW_QSTR(MP_QSTR_array), (mp_obj_t)&mp_module_array }, { MP_OBJ_NEW_QSTR(MP_QSTR_array), (mp_obj_t)&mp_module_array },
#endif
#if MICROPY_PY_IO #if MICROPY_PY_IO
{ MP_OBJ_NEW_QSTR(MP_QSTR__io), (mp_obj_t)&mp_module_io }, { MP_OBJ_NEW_QSTR(MP_QSTR__io), (mp_obj_t)&mp_module_io },
#endif #endif
......
...@@ -30,6 +30,8 @@ ...@@ -30,6 +30,8 @@
#include "obj.h" #include "obj.h"
#include "builtin.h" #include "builtin.h"
#if MICROPY_PY_ARRAY
STATIC const mp_map_elem_t mp_module_array_globals_table[] = { STATIC const mp_map_elem_t mp_module_array_globals_table[] = {
{ MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR_array) }, { MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR_array) },
{ MP_OBJ_NEW_QSTR(MP_QSTR_array), (mp_obj_t)&mp_type_array }, { MP_OBJ_NEW_QSTR(MP_QSTR_array), (mp_obj_t)&mp_type_array },
...@@ -51,3 +53,5 @@ const mp_obj_module_t mp_module_array = { ...@@ -51,3 +53,5 @@ const mp_obj_module_t mp_module_array = {
.name = MP_QSTR_array, .name = MP_QSTR_array,
.globals = (mp_obj_dict_t*)&mp_module_array_globals, .globals = (mp_obj_dict_t*)&mp_module_array_globals,
}; };
#endif
...@@ -252,6 +252,10 @@ typedef double mp_float_t; ...@@ -252,6 +252,10 @@ typedef double mp_float_t;
// Whether str object is proper unicode // Whether str object is proper unicode
#ifndef MICROPY_PY_BUILTINS_STR_UNICODE #ifndef MICROPY_PY_BUILTINS_STR_UNICODE
#define MICROPY_PY_BUILTINS_STR_UNICODE (0) #define MICROPY_PY_BUILTINS_STR_UNICODE (0)
// Whether to support bytearray object
#ifndef MICROPY_PY_BUILTINS_BYTEARRAY
#define MICROPY_PY_BUILTINS_BYTEARRAY (1)
#endif #endif
// Whether to support set object // Whether to support set object
...@@ -274,6 +278,13 @@ typedef double mp_float_t; ...@@ -274,6 +278,13 @@ typedef double mp_float_t;
#define MICROPY_PY_BUILTINS_PROPERTY (1) #define MICROPY_PY_BUILTINS_PROPERTY (1)
#endif #endif
// Whether to provide "array" module. Note that large chunk of the
// underlying code is shared with "bytearray" builtin type, so to
// get real savings, it should be disabled too.
#ifndef MICROPY_PY_ARRAY
#define MICROPY_PY_ARRAY (1)
#endif
// Whether to provide "collections" module // Whether to provide "collections" module
#ifndef MICROPY_PY_COLLECTIONS #ifndef MICROPY_PY_COLLECTIONS
#define MICROPY_PY_COLLECTIONS (1) #define MICROPY_PY_COLLECTIONS (1)
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include "obj.h" #include "obj.h"
#include "runtime0.h" #include "runtime0.h"
#include "runtime.h" #include "runtime.h"
#include "stackctrl.h"
mp_obj_type_t *mp_obj_get_type(mp_const_obj_t o_in) { mp_obj_type_t *mp_obj_get_type(mp_const_obj_t o_in) {
if (MP_OBJ_IS_SMALL_INT(o_in)) { if (MP_OBJ_IS_SMALL_INT(o_in)) {
...@@ -59,6 +60,8 @@ void printf_wrapper(void *env, const char *fmt, ...) { ...@@ -59,6 +60,8 @@ void printf_wrapper(void *env, const char *fmt, ...) {
} }
void mp_obj_print_helper(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t o_in, mp_print_kind_t kind) { void mp_obj_print_helper(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t o_in, mp_print_kind_t kind) {
// There can be data structures nested too deep, or just recursive
STACK_CHECK();
#if !NDEBUG #if !NDEBUG
if (o_in == NULL) { if (o_in == NULL) {
print(env, "(nil)"); print(env, "(nil)");
......
...@@ -37,6 +37,8 @@ ...@@ -37,6 +37,8 @@
#include "runtime.h" #include "runtime.h"
#include "binary.h" #include "binary.h"
#if MICROPY_PY_ARRAY || MICROPY_PY_BUILTINS_BYTEARRAY
typedef struct _mp_obj_array_t { typedef struct _mp_obj_array_t {
mp_obj_base_t base; mp_obj_base_t base;
machine_uint_t typecode : 8; machine_uint_t typecode : 8;
...@@ -310,3 +312,5 @@ STATIC mp_obj_t array_iterator_new(mp_obj_t array_in) { ...@@ -310,3 +312,5 @@ STATIC mp_obj_t array_iterator_new(mp_obj_t array_in) {
o->cur = 0; o->cur = 0;
return o; return o;
} }
#endif // MICROPY_PY_ARRAY || MICROPY_PY_BUILTINS_BYTEARRAY
...@@ -45,6 +45,7 @@ ...@@ -45,6 +45,7 @@
#include "smallint.h" #include "smallint.h"
#include "objgenerator.h" #include "objgenerator.h"
#include "lexer.h" #include "lexer.h"
#include "stackctrl.h"
#if 0 // print debugging info #if 0 // print debugging info
#define DEBUG_PRINT (1) #define DEBUG_PRINT (1)
...@@ -69,6 +70,8 @@ const mp_obj_module_t mp_module___main__ = { ...@@ -69,6 +70,8 @@ const mp_obj_module_t mp_module___main__ = {
}; };
void mp_init(void) { void mp_init(void) {
stack_ctrl_init();
// call port specific initialization if any // call port specific initialization if any
#ifdef MICROPY_PORT_INIT_FUNC #ifdef MICROPY_PORT_INIT_FUNC
MICROPY_PORT_INIT_FUNC; MICROPY_PORT_INIT_FUNC;
......
#define HYDRABUSV10 #define HYDRABUSV10
#define MICROPY_HW_BOARD_NAME "HydraBus1.0" #define MICROPY_HW_BOARD_NAME "HydraBus1.0"
#define MICROPY_HW_MCU_NAME "STM32F4"
#define MICROPY_HW_HAS_SWITCH (1) #define MICROPY_HW_HAS_SWITCH (1)
#define MICROPY_HW_HAS_SDCARD (1) #define MICROPY_HW_HAS_SDCARD (1)
......
#define NETDUINO_PLUS_2 #define NETDUINO_PLUS_2
#define MICROPY_HW_BOARD_NAME "NetduinoPlus2" #define MICROPY_HW_BOARD_NAME "NetduinoPlus2"
#define MICROPY_HW_MCU_NAME "STM32F405RG"
#define MICROPY_HW_HAS_SWITCH (1) #define MICROPY_HW_HAS_SWITCH (1)
......
#define PYBV10 #define PYBV10
#define MICROPY_HW_BOARD_NAME "PYBv1.0" #define MICROPY_HW_BOARD_NAME "PYBv1.0"
#define MICROPY_HW_MCU_NAME "STM32F405RG"
#define MICROPY_HW_HAS_SWITCH (1) #define MICROPY_HW_HAS_SWITCH (1)
#define MICROPY_HW_HAS_SDCARD (1) #define MICROPY_HW_HAS_SDCARD (1)
......
#define PYBV3 #define PYBV3
#define MICROPY_HW_BOARD_NAME "PYBv3" #define MICROPY_HW_BOARD_NAME "PYBv3"
#define MICROPY_HW_MCU_NAME "STM32F405RG"
#define MICROPY_HW_HAS_SWITCH (1) #define MICROPY_HW_HAS_SWITCH (1)
#define MICROPY_HW_HAS_SDCARD (1) #define MICROPY_HW_HAS_SDCARD (1)
......
#define PYBV4 #define PYBV4
#define MICROPY_HW_BOARD_NAME "PYBv4" #define MICROPY_HW_BOARD_NAME "PYBv4"
#define MICROPY_HW_MCU_NAME "STM32F405RG"
#define MICROPY_HW_HAS_SWITCH (1) #define MICROPY_HW_HAS_SWITCH (1)
#define MICROPY_HW_HAS_SDCARD (1) #define MICROPY_HW_HAS_SDCARD (1)
......
#define STM32F4DISC #define STM32F4DISC
#define MICROPY_HW_BOARD_NAME "F4DISC" #define MICROPY_HW_BOARD_NAME "F4DISC"
#define MICROPY_HW_MCU_NAME "STM32F407"
#define MICROPY_HW_HAS_SWITCH (1) #define MICROPY_HW_HAS_SWITCH (1)
#define MICROPY_HW_HAS_SDCARD (0) #define MICROPY_HW_HAS_SDCARD (0)
......
...@@ -187,7 +187,6 @@ static const char fresh_readme_txt[] = ...@@ -187,7 +187,6 @@ static const char fresh_readme_txt[] =
int main(void) { int main(void) {
// TODO disable JTAG // TODO disable JTAG
stack_ctrl_init();
// Stack limit should be less than real stack size, so we // Stack limit should be less than real stack size, so we
// had chance to recover from limit hit. // had chance to recover from limit hit.
stack_set_limit(&_ram_end - &_heap_end - 512); stack_set_limit(&_ram_end - &_heap_end - 512);
......
...@@ -185,7 +185,7 @@ int pyexec_friendly_repl(void) { ...@@ -185,7 +185,7 @@ int pyexec_friendly_repl(void) {
#endif #endif
friendly_repl_reset: friendly_repl_reset:
stdout_tx_str("Micro Python " MICROPY_GIT_TAG " on " MICROPY_BUILD_DATE "; " MICROPY_HW_BOARD_NAME " with STM32F405RG\r\n"); stdout_tx_str("Micro Python " MICROPY_GIT_TAG " on " MICROPY_BUILD_DATE "; " MICROPY_HW_BOARD_NAME " with " MICROPY_HW_MCU_NAME "\r\n");
stdout_tx_str("Type \"help()\" for more information.\r\n"); stdout_tx_str("Type \"help()\" for more information.\r\n");
// to test ctrl-C // to test ctrl-C
......
# This tests that printing recursive data structure doesn't lead to segfault.
# Unfortunately, print() so far doesn't support "file "kwarg, so variable-len
# output of this test cannot be redirected, and this test cannot be validated.
l = [1, 2, 3, None]
l[-1] = l
try:
print(l)
except RuntimeError:
print("RuntimeError")
...@@ -41,8 +41,6 @@ ...@@ -41,8 +41,6 @@
#include <readline/history.h> #include <readline/history.h>
#endif #endif
#define CTRL_D '\x04'
char *prompt(char *p) { char *prompt(char *p) {
#if MICROPY_USE_READLINE #if MICROPY_USE_READLINE
char *line = readline(p); char *line = readline(p);
......
...@@ -265,7 +265,6 @@ void pre_process_options(int argc, char **argv) { ...@@ -265,7 +265,6 @@ void pre_process_options(int argc, char **argv) {
#endif #endif
int main(int argc, char **argv) { int main(int argc, char **argv) {
stack_ctrl_init();
stack_set_limit(32768); stack_set_limit(32768);
pre_process_options(argc, argv); pre_process_options(argc, argv);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment