aboutsummaryrefslogtreecommitdiff
path: root/py/mpconfig.h
diff options
context:
space:
mode:
authorDamien George2015-10-08 14:58:15 +0100
committerDamien George2015-10-12 12:58:45 +0100
commit64f2b213bb5be33f06ee7ab755d9344cd7e5958c (patch)
tree8be9542ce68d3a91503e75669ba547740b3b65e1 /py/mpconfig.h
parent91fc075a33a6f0bf8e1a07b797f6fd01207a5e17 (diff)
py: Move constant folding from compiler to parser.
It makes much more sense to do constant folding in the parser while the parse tree is being built. This eliminates the need to create parse nodes that will just be folded away. The code is slightly simpler and a bit smaller as well. Constant folding now has a configuration option, MICROPY_COMP_CONST_FOLDING, which is enabled by default.
Diffstat (limited to 'py/mpconfig.h')
-rw-r--r--py/mpconfig.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/py/mpconfig.h b/py/mpconfig.h
index 4b986eef9..500af5e76 100644
--- a/py/mpconfig.h
+++ b/py/mpconfig.h
@@ -215,6 +215,11 @@
/*****************************************************************************/
/* Compiler configuration */
+// Whether to enable constant folding; eg 1+2 rewritten as 3
+#ifndef MICROPY_COMP_CONST_FOLDING
+#define MICROPY_COMP_CONST_FOLDING (1)
+#endif
+
// Whether to enable lookup of constants in modules; eg module.CONST
#ifndef MICROPY_COMP_MODULE_CONST
#define MICROPY_COMP_MODULE_CONST (0)