git @ Cat's Eye Technologies SixtyPical / 0e0a3d5
Implement Context.copy_range(), ranges for constants. Progress! Chris Pressey 4 years ago
2 changed file(s) with 16 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
187187
188188 def set_meaningful(self, *refs):
189189 for ref in refs:
190 self._range[ref] = ref.max_range()
190 if ref not in self._range:
191 self._range[ref] = ref.max_range()
191192
192193 def set_top_of_range(self, ref, top):
193194 self.assert_meaningful(ref)
200201 self.assert_meaningful(ref)
201202 (_, top) = self._range[ref]
202203 return top
204
205 def copy_range(self, src, dest):
206 self.assert_meaningful(src)
207 if src in self._range:
208 src_range = self._range[src]
209 else:
210 src_range = src.max_range()
211 self._range[dest] = src_range
203212
204213 def set_unmeaningful(self, *refs):
205214 for ref in refs:
330339 )
331340 else:
332341 context.assert_meaningful(src)
342 context.copy_range(src, dest)
333343 context.set_written(dest, FLAG_Z, FLAG_N)
334344 elif opcode == 'st':
335345 if isinstance(dest, IndexedRef):
130130 """read-only means that the program cannot change the value
131131 of a location. constant means that the value of the location
132132 will not change during the lifetime of the program."""
133 raise NotImplementedError
133 raise NotImplementedError("class {} must implement is_constant()".format(self.__class__.__name__))
134134
135135 def max_range(self):
136 raise NotImplementedError
136 raise NotImplementedError("class {} must implement max_range()".format(self.__class__.__name__))
137137
138138
139139 class LocationRef(Ref):
286286 def is_constant(self):
287287 return True
288288
289 def max_range(self):
290 return (self.value, self.value)
291
289292 def high_byte(self):
290293 return (self.value >> 8) & 255
291294