1
0
mirror of https://github.com/catseye/SixtyPical.git synced 2024-05-31 21:41:29 +00:00

Set a location as touched when trashed with a trash instruction.

This commit is contained in:
Chris Pressey 2018-02-08 13:43:06 +00:00
parent f4befb45d3
commit 3f1f3bf16e
3 changed files with 8 additions and 6 deletions

View File

@ -6,6 +6,7 @@ History of SixtyPical
* `copy` is now understood to trash `a`, thus `copy ..., a` is not valid.
Indirect addressing is supported in `ld`, as in `ld a, [ptr] + y`, to compensate.
* Fixed bug where `trash` was not marking the location as being virtually altered.
0.11
----

View File

@ -207,8 +207,8 @@ class Analyzer(object):
if routine.block is None:
# it's an extern, that's fine
return
type = routine.location.type
context = Context(self.routines, routine, type.inputs, type.outputs, type.trashes)
type_ = routine.location.type
context = Context(self.routines, routine, type_.inputs, type_.outputs, type_.trashes)
if self.debug:
print "at start of routine `{}`:".format(routine.name)
print context
@ -217,10 +217,10 @@ class Analyzer(object):
print "at end of routine `{}`:".format(routine.name)
print context
if not self.has_encountered_goto:
for ref in type.outputs:
for ref in type_.outputs:
context.assert_meaningful(ref, exception_class=UnmeaningfulOutputError)
for ref in context.each_touched():
if ref not in type.outputs and ref not in type.trashes:
if ref not in type_.outputs and ref not in type_.trashes:
message = '%s in %s' % (ref.name, routine.name)
raise ForbiddenWriteError(message)
self.current_routine = None
@ -466,6 +466,7 @@ class Analyzer(object):
self.has_encountered_goto = True
elif opcode == 'trash':
context.set_touched(instr.dest)
context.set_unmeaningful(instr.dest)
else:
raise NotImplementedError(opcode)

View File

@ -127,7 +127,7 @@ If a routine trashes a location, this must be declared.
| {
| trash x
| }
? UnmeaningfulOutputError: x in foo
? ForbiddenWriteError: x in foo
| routine foo
| outputs x
@ -162,7 +162,7 @@ If a routine causes a location to be trashed, this must be declared in the calle
| {
| call trash_x
| }
? UnmeaningfulOutputError: x in foo
? ForbiddenWriteError: x in foo
| routine trash_x
| trashes x, z, n