From eb4ed6a6bcfcc283cca3622cc08f944c9996e682 Mon Sep 17 00:00:00 2001 From: Chris Pressey Date: Wed, 25 Apr 2018 16:58:21 +0100 Subject: [PATCH] Extract locations from context appropriately. All tests pass. --- src/sixtypical/analyzer.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/sixtypical/analyzer.py b/src/sixtypical/analyzer.py index 3a17c2a..ecb3b57 100644 --- a/src/sixtypical/analyzer.py +++ b/src/sixtypical/analyzer.py @@ -293,23 +293,23 @@ class Context(object): self.set_written(dest.ref) def extract(self, location): - """Used in `save`.""" + """Sets the given location as writeable in the context, and returns a 'baton' representing + the previous state of context for that location. This 'baton' can be used to later restore + this state of context.""" + # Used in `save`. baton = ( location, location in self._touched, self._range.get(location, None), location in self._writeable, ) - - if location in self._touched: - self._touched.remove(location) - self.set_unmeaningful(location) self.set_writeable(location) - return baton def re_introduce(self, baton): - """Used in `save`.""" + """Given a 'baton' produced by `extract()`, restores the context for that saved location + to what it was before `extract()` was called.""" + # Used in `save`. location, was_touched, was_range, was_writeable = baton if was_touched: