From 7419ac49824f50c4ab61b3e3b60477b9512e11c5 Mon Sep 17 00:00:00 2001 From: Sei Lisa Date: Sat, 28 Jan 2017 06:36:49 +0100 Subject: [PATCH] Don't run dead code removal when in calc mode. Add TODO item. Running 'main.py -O expr' without disabling DCR led to an immediate crash, due to it trying to access the default state. --- lslopt/lsldeadcode.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lslopt/lsldeadcode.py b/lslopt/lsldeadcode.py index afdc02a..8e767f8 100644 --- a/lslopt/lsldeadcode.py +++ b/lslopt/lsldeadcode.py @@ -475,6 +475,14 @@ class deadcode(object): # sophisticated (yet). # TODO: Inlining of functions that are a single 'return' line. + # TODO: Remove empty events if they are side effect-free. + # Note that e.g. touch/* events are not SEF, because their presence + # causes the hand to be shown, so we need a list of SEF events. + + if lslfuncs.lslcommon.IsCalc: + # Do nothing if in calculator mode (there's no default event + # and it crashes without this) + return statedef = self.tree[self.symtab[0]['default']['Loc']] assert statedef['nt'] == 'STDEF' and statedef['name'] == 'default'