summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-04-25 23:52:57 +0100
committerDamien George <damien.p.george@gmail.com>2014-04-25 23:52:57 +0100
commit1463c1fa82e930edfef9df9b70c6b8c12cdcb1c1 (patch)
treee8a578738b3a90c917e7f35ccce74eba1c50a706
parentc492cf1f442653019b287bf0e8bd0c43f2abd837 (diff)
downloadmicropython-1463c1fa82e930edfef9df9b70c6b8c12cdcb1c1.tar.gz
micropython-1463c1fa82e930edfef9df9b70c6b8c12cdcb1c1.zip
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 #521.
-rw-r--r--py/compile.c12
-rw-r--r--py/mpconfig.h5
2 files changed, 12 insertions, 5 deletions
diff --git a/py/compile.c b/py/compile.c
index 3ab377f897..ee735a872f 100644
--- a/py/compile.c
+++ b/py/compile.c
@@ -91,7 +91,7 @@ STATIC const mp_map_t mp_constants_map = {
.table = (mp_map_elem_t*)mp_constants_table,
};
-mp_parse_node_t fold_constants(mp_parse_node_t pn) {
+STATIC mp_parse_node_t fold_constants(mp_parse_node_t pn) {
if (MP_PARSE_NODE_IS_STRUCT(pn)) {
mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)pn;
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
}
}
-void check_for_doc_string(compiler_t *comp, mp_parse_node_t pn) {
+STATIC void check_for_doc_string(compiler_t *comp, mp_parse_node_t pn) {
+#if MICROPY_EMIT_CPYTHON || MICROPY_ENABLE_DOC_STRING
// see http://www.python.org/dev/peps/pep-0257/
// look for the first statement
@@ -2960,9 +2961,10 @@ void check_for_doc_string(compiler_t *comp, mp_parse_node_t pn) {
}
}
}
+#endif
}
-void compile_scope(compiler_t *comp, scope_t *scope, pass_kind_t pass) {
+STATIC void compile_scope(compiler_t *comp, scope_t *scope, pass_kind_t pass) {
comp->pass = pass;
comp->scope_cur = scope;
comp->next_label = 1;
@@ -3117,7 +3119,7 @@ void compile_scope(compiler_t *comp, scope_t *scope, pass_kind_t pass) {
}
#if MICROPY_EMIT_INLINE_THUMB
-void compile_scope_inline_asm(compiler_t *comp, scope_t *scope, pass_kind_t pass) {
+STATIC void compile_scope_inline_asm(compiler_t *comp, scope_t *scope, pass_kind_t pass) {
comp->pass = pass;
comp->scope_cur = scope;
comp->next_label = 1;
@@ -3232,7 +3234,7 @@ void compile_scope_inline_asm(compiler_t *comp, scope_t *scope, pass_kind_t pass
}
#endif
-void compile_scope_compute_things(compiler_t *comp, scope_t *scope) {
+STATIC void compile_scope_compute_things(compiler_t *comp, scope_t *scope) {
// in functions, turn implicit globals into explicit globals
// compute the index of each local
scope->num_locals = 0;
diff --git a/py/mpconfig.h b/py/mpconfig.h
index 4c3e0706a7..b669128ea0 100644
--- a/py/mpconfig.h
+++ b/py/mpconfig.h
@@ -89,6 +89,11 @@ typedef long long mp_longint_impl_t;
#define MICROPY_ENABLE_SOURCE_LINE (0)
#endif
+// Whether to include doc strings (increases RAM usage)
+#ifndef MICROPY_ENABLE_DOC_STRING
+#define MICROPY_ENABLE_DOC_STRING (0)
+#endif
+
// Float and complex implementation
#define MICROPY_FLOAT_IMPL_NONE (0)
#define MICROPY_FLOAT_IMPL_FLOAT (1)