mirror of
https://github.com/catseye/SixtyPical.git
synced 2025-02-16 15:30:26 +00:00
Introduce yet another new error.
This commit is contained in:
parent
a53a3529ea
commit
07ec6752ee
@ -34,6 +34,11 @@ class InconsistentInitializationError(StaticAnalysisError):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class InconsistentExitError(StaticAnalysisError):
|
||||||
|
"""The type context differs at two different exit points of the routine."""
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class ForbiddenWriteError(StaticAnalysisError):
|
class ForbiddenWriteError(StaticAnalysisError):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -156,6 +161,10 @@ class Context(object):
|
|||||||
for ref in self._touched:
|
for ref in self._touched:
|
||||||
yield ref
|
yield ref
|
||||||
|
|
||||||
|
def each_writeable(self):
|
||||||
|
for ref in self._writeable:
|
||||||
|
yield ref
|
||||||
|
|
||||||
def assert_meaningful(self, *refs, **kwargs):
|
def assert_meaningful(self, *refs, **kwargs):
|
||||||
exception_class = kwargs.get('exception_class', UnmeaningfulReadError)
|
exception_class = kwargs.get('exception_class', UnmeaningfulReadError)
|
||||||
for ref in refs:
|
for ref in refs:
|
||||||
@ -419,12 +428,14 @@ class Analyzer(object):
|
|||||||
exit_context = self.exit_contexts[0]
|
exit_context = self.exit_contexts[0]
|
||||||
exit_meaningful = set(exit_context.each_meaningful())
|
exit_meaningful = set(exit_context.each_meaningful())
|
||||||
exit_touched = set(exit_context.each_touched())
|
exit_touched = set(exit_context.each_touched())
|
||||||
|
exit_writeable = set(exit_context.each_writeable())
|
||||||
for ex in self.exit_contexts[1:]:
|
for ex in self.exit_contexts[1:]:
|
||||||
if set(ex.each_meaningful()) != exit_meaningful:
|
if set(ex.each_meaningful()) != exit_meaningful:
|
||||||
raise InconsistentInitializationError('?')
|
raise InconsistentExitError("Exit contexts are not consistent")
|
||||||
if set(ex.each_touched()) != exit_touched:
|
if set(ex.each_touched()) != exit_touched:
|
||||||
raise InconsistentInitializationError('?')
|
raise InconsistentExitError("Exit contexts are not consistent")
|
||||||
# FIXME: confirm writeable sets are the same too?
|
if set(ex.each_writeable()) != exit_writeable:
|
||||||
|
raise InconsistentExitError("Exit contexts are not consistent")
|
||||||
context.update_from(exit_context)
|
context.update_from(exit_context)
|
||||||
|
|
||||||
trashed = set(context.each_touched()) - set(context.each_meaningful())
|
trashed = set(context.each_touched()) - set(context.each_meaningful())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user