git @ Cat's Eye Technologies SixtyPical / a736573
Even if we `goto` another routine, we can't trash an output. Chris Pressey 7 years ago
3 changed file(s) with 21 addition(s) and 7 deletion(s). Raw diff Collapse all Expand all
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.
88 * Implements the "union rule for trashes" when analyzing `if` blocks.
9 * Even if we `goto` another routine, we can't trash an output.
910 * Fixed bug where `trash` was not marking the location as being virtually altered.
1011
1112 0.11
3434 actor_pos, actor_delta, actor_logic,
3535 screen, screen1, screen2, screen3, screen4, colormap1, colormap2, colormap3, colormap4
3636 outputs button_down, dispatch_game_state,
37 actor_pos, pos, new_pos, actor_delta, delta, actor_logic,
37 actor_pos, actor_delta, actor_logic,
3838 screen, screen1, screen2, screen3, screen4, colormap1, colormap2, colormap3, colormap4
39 trashes a, x, y, c, z, n, v, ptr, save_x, compare_target, dispatch_logic
39 trashes a, x, y, c, z, n, v, pos, new_pos, delta, ptr, save_x, compare_target, dispatch_logic
4040 game_state_routine
4141
4242 //
401401
402402 if c {
403403 call clear_screen
404
405 // FIXME: this seems wrong and we need to investigate it.
406 // init_game trashes `pos` (this is reasonable.) But pos is declared
407 // as an output to `game_state_routine`. This should be an error...
408404 call init_game
409
410405 copy forward game_state_play, dispatch_game_state
411406 }
412407
201201 return
202202 type_ = routine.location.type
203203 context = Context(self.routines, routine, type_.inputs, type_.outputs, type_.trashes)
204
204205 if self.debug:
205206 print "at start of routine `{}`:".format(routine.name)
206207 print context
208
207209 self.analyze_block(routine.block, context)
210 trashed = set(context.each_touched()) - context._meaningful
211
208212 if self.debug:
209213 print "at end of routine `{}`:".format(routine.name)
210214 print context
215 print "trashed: ", LocationRef.format_set(trashed)
216 print "outputs: ", LocationRef.format_set(type_.outputs)
217 trashed_outputs = type_.outputs & trashed
218 if trashed_outputs:
219 print "TRASHED OUTPUTS: ", LocationRef.format_set(trashed_outputs)
220 print ''
221 print '-' * 79
222 print ''
223
224 # even if we goto another routine, we can't trash an output.
225 for ref in trashed:
226 if ref in type_.outputs:
227 raise UnmeaningfulOutputError('%s in %s' % (ref.name, routine.name))
228
211229 if not self.has_encountered_goto:
212230 for ref in type_.outputs:
213231 context.assert_meaningful(ref, exception_class=UnmeaningfulOutputError)