From ffae48d7507d398806bd935b054b7ca19bc01161 Mon Sep 17 00:00:00 2001 From: Damien George Date: Thu, 8 May 2014 15:58:39 +0000 Subject: py, compiler: Add basic support for A=const(123). You can now do: X = const(123) Y = const(456 + X) and the compiler will replace X and Y with their values. See discussion in issue #266 and issue #573. --- tests/micropython/const.py | 11 +++++++++++ tests/micropython/const.py.exp | 2 ++ 2 files changed, 13 insertions(+) create mode 100644 tests/micropython/const.py create mode 100644 tests/micropython/const.py.exp (limited to 'tests/micropython') diff --git a/tests/micropython/const.py b/tests/micropython/const.py new file mode 100644 index 000000000..457365c50 --- /dev/null +++ b/tests/micropython/const.py @@ -0,0 +1,11 @@ +# test constant optimisation + +X = const(123) +Y = const(X + 456) + +print(X, Y + 1) + +def f(): + print(X, Y + 1) + +f() diff --git a/tests/micropython/const.py.exp b/tests/micropython/const.py.exp new file mode 100644 index 000000000..c447aaf8c --- /dev/null +++ b/tests/micropython/const.py.exp @@ -0,0 +1,2 @@ +123 580 +123 580 -- cgit v1.2.3