git @ Cat's Eye Technologies SixtyPical / 3f1f3bf
Set a location as touched when trashed with a `trash` instruction. Chris Pressey 3 years ago
3 changed file(s) with 8 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
55
66 * `copy` is now understood to trash `a`, thus `copy ..., a` is not valid.
77 Indirect addressing is supported in `ld`, as in `ld a, [ptr] + y`, to compensate.
8 * Fixed bug where `trash` was not marking the location as being virtually altered.
89
910 0.11
1011 ----
206206 if routine.block is None:
207207 # it's an extern, that's fine
208208 return
209 type = routine.location.type
210 context = Context(self.routines, routine, type.inputs, type.outputs, type.trashes)
209 type_ = routine.location.type
210 context = Context(self.routines, routine, type_.inputs, type_.outputs, type_.trashes)
211211 if self.debug:
212212 print "at start of routine `{}`:".format(routine.name)
213213 print context
216216 print "at end of routine `{}`:".format(routine.name)
217217 print context
218218 if not self.has_encountered_goto:
219 for ref in type.outputs:
219 for ref in type_.outputs:
220220 context.assert_meaningful(ref, exception_class=UnmeaningfulOutputError)
221221 for ref in context.each_touched():
222 if ref not in type.outputs and ref not in type.trashes:
222 if ref not in type_.outputs and ref not in type_.trashes:
223223 message = '%s in %s' % (ref.name, routine.name)
224224 raise ForbiddenWriteError(message)
225225 self.current_routine = None
465465
466466 self.has_encountered_goto = True
467467 elif opcode == 'trash':
468 context.set_touched(instr.dest)
468469 context.set_unmeaningful(instr.dest)
469470 else:
470471 raise NotImplementedError(opcode)
126126 | {
127127 | trash x
128128 | }
129 ? UnmeaningfulOutputError: x in foo
129 ? ForbiddenWriteError: x in foo
130130
131131 | routine foo
132132 | outputs x
161161 | {
162162 | call trash_x
163163 | }
164 ? UnmeaningfulOutputError: x in foo
164 ? ForbiddenWriteError: x in foo
165165
166166 | routine trash_x
167167 | trashes x, z, n