summaryrefslogtreecommitdiffstatshomepage
path: root/py
diff options
context:
space:
mode:
Diffstat (limited to 'py')
-rw-r--r--py/lexer.c9
-rw-r--r--py/lexer.h2
-rw-r--r--py/runtime.c5
-rw-r--r--py/runtime.h2
4 files changed, 7 insertions, 11 deletions
diff --git a/py/lexer.c b/py/lexer.c
index 4a7ac071b4..26993922eb 100644
--- a/py/lexer.c
+++ b/py/lexer.c
@@ -64,12 +64,7 @@ struct _mp_lexer_t {
mp_token_t tok_cur;
};
-// debug flag for __debug__ constant
-STATIC mp_token_kind_t mp_debug_value;
-
-void mp_set_debug(bool value) {
- mp_debug_value = value ? MP_TOKEN_KW_TRUE : MP_TOKEN_KW_FALSE;
-}
+uint mp_optimise_value;
// TODO replace with a call to a standard function
bool str_strn_equal(const char *str, const char *strn, int len) {
@@ -703,7 +698,7 @@ STATIC void mp_lexer_next_token_into(mp_lexer_t *lex, mp_token_t *tok, bool firs
if (str_strn_equal(tok_kw[i], tok->str, tok->len)) {
if (i == ARRAY_SIZE(tok_kw) - 1) {
// tok_kw[ARRAY_SIZE(tok_kw) - 1] == "__debug__"
- tok->kind = mp_debug_value;
+ tok->kind = (mp_optimise_value == 0 ? MP_TOKEN_KW_TRUE : MP_TOKEN_KW_FALSE);
} else {
tok->kind = MP_TOKEN_KW_FALSE + i;
}
diff --git a/py/lexer.h b/py/lexer.h
index b302cb2db1..24cae1e252 100644
--- a/py/lexer.h
+++ b/py/lexer.h
@@ -176,3 +176,5 @@ typedef enum {
mp_import_stat_t mp_import_stat(const char *path);
mp_lexer_t *mp_lexer_new_from_file(const char *filename);
+
+extern uint mp_optimise_value;
diff --git a/py/runtime.c b/py/runtime.c
index ecaf40deb4..27a5ed5439 100644
--- a/py/runtime.c
+++ b/py/runtime.c
@@ -45,6 +45,7 @@
#include "bc.h"
#include "smallint.h"
#include "objgenerator.h"
+#include "lexer.h"
#if 0 // print debugging info
#define DEBUG_PRINT (1)
@@ -74,8 +75,8 @@ void mp_init(void) {
MICROPY_PORT_INIT_FUNC;
#endif
- // __debug__ enabled by default
- mp_set_debug(true);
+ // optimization disabled by default
+ mp_optimise_value = 0;
// init global module stuff
mp_module_init();
diff --git a/py/runtime.h b/py/runtime.h
index 3c79b48ed0..dbd413180b 100644
--- a/py/runtime.h
+++ b/py/runtime.h
@@ -54,8 +54,6 @@ typedef struct _mp_arg_t {
void mp_init(void);
void mp_deinit(void);
-void mp_set_debug(bool value); // sets the value of __debug__; see lexer.c
-
void mp_arg_check_num(uint n_args, uint n_kw, uint n_args_min, uint n_args_max, bool takes_kw);
void mp_arg_parse_all(uint n_pos, const mp_obj_t *pos, mp_map_t *kws, uint n_allowed, const mp_arg_t *allowed, mp_arg_val_t *out_vals);
void mp_arg_parse_all_kw_array(uint n_pos, uint n_kw, const mp_obj_t *args, uint n_allowed, const mp_arg_t *allowed, mp_arg_val_t *out_vals);