8000 py: Add MICROPY_ENABLE_DOC_STRING, disabled by default. · lurch/micropython@1463c1f · GitHub
[go: up one dir, main page]

Skip to content

Commit 1463c1f

Browse files
committed
py: Add MICROPY_ENABLE_DOC_STRING, disabled by default.
Also add a few STATIC's to some compile functions that should have them. Addresses issue micropython#521.
1 parent c492cf1 commit 1463c1f

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

py/compile.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ STATIC const mp_map_t mp_constants_map = {
9191
.table = (mp_map_elem_t*)mp_constants_table,
9292
};
9393

94-
mp_parse_node_t fold_constants(mp_parse_node_t pn) {
94+
STATIC mp_parse_node_t fold_constants(mp_parse_node_t pn) {
9595
if (MP_PARSE_NODE_IS_STRUCT(pn)) {
9696
mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)pn;
9797
int n = MP_PARSE_NODE_STRUCT_NUM_NODES(pns);
@@ -2923,7 +2923,8 @@ void compile_scope_comp_iter(compiler_t *comp, mp_parse_node_t pn_iter, mp_parse
29232923
}
29242924
}
29252925

2926-
void check_for_doc_string(compiler_t *comp, mp_parse_node_t pn) {
2926+
STATIC void check_for_doc_string(compiler_t *comp, mp_parse_node_t pn) {
2927+
#if MICROPY_EMIT_CPYTHON || MICROPY_ENABLE_DOC_STRING
29272928
// see http://www.python.org/dev/peps/pep-0257/
29282929

29292930
// look for the first statement
@@ -2960,9 +2961,10 @@ void check_for_doc_string(compiler_t *comp, mp_parse_node_t pn) {
29602961
}
29612962
}
29622963
}
2964+
#endif
29632965
}
29642966

2965-
void compile_scope(compiler_t *comp, scope_t *scope, pass_kind_t pass) {
2967+
STATIC void compile_scope(compiler_t *comp, scope_t *scope, pass_kind_t pass) {
29662968
comp->pass = pass;
29672969
comp->scope_cur = scope;
29682970
comp->next_label = 1;
@@ -3117,7 +3119,7 @@ void compile_scope(compiler_t *comp, scope_t *scope, pass_kind_t pass) {
31173119
}
31183120

31193121
#if MICROPY_EMIT_INLINE_THUMB
3120-
void compile_scope_inline_asm(compiler_t *comp, scope_t *scope, pass_kind_t pass) {
3122+
STATIC void compile_scope_inline_asm(compiler_t *comp, scope_t *scope, pass_kind_t pass) {
31213123
comp->pass = pass;
31223124
comp->scope_cur = scope;
31233125
comp->next_label = 1;
@@ -3232,7 +3234,7 @@ void compile_scope_inline_asm(compiler_t *comp, scope_t *scope, pass_kind_t pass
32323234
}
32333235
#endif
32343236

3235-
void compile_scope_compute_things(compiler_t *comp, scope_t *scope) {
3237+
STATIC void compile_scope_compute_things(compiler_t *comp, scope_t *scope) {
32363238
// in functions, turn implicit globals into explicit globals
32373239
// compute the index of each local
32383240
scope->num_locals = 0;

py/mpconfig.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@ typedef long long mp_longint_impl_t;
8989
#define MICROPY_ENABLE_SOURCE_LINE (0)
9090
#endif
9191

92+
// Whether to include doc strings (increases RAM usage)
93+
#ifndef MICROPY_ENABLE_DOC_STRING
94+
#define MICROPY_ENABLE_DOC_STRING (0)
95+
#endif
96+
9297
// Float and complex implementation
9398
#define MICROPY_FLOAT_IMPL_NONE (0)
9499
#define MICROPY_FLOAT_IMPL_FLOAT (1)

0 commit comments

Comments
 (0)
0