Not making any promises, but reduce the errors under Python 3.
Chris Pressey
6 years ago
371 | 371 |
context = Context(self.routines, routine, type_.inputs, type_.outputs, type_.trashes)
|
372 | 372 |
|
373 | 373 |
if self.debug:
|
374 | |
print "at start of routine `{}`:".format(routine.name)
|
375 | |
print context
|
|
374 |
print("at start of routine `{}`:".format(routine.name))
|
|
375 |
print(context)
|
376 | 376 |
|
377 | 377 |
self.analyze_block(routine.block, context)
|
378 | 378 |
trashed = set(context.each_touched()) - set(context.each_meaningful())
|
379 | 379 |
|
380 | 380 |
if self.debug:
|
381 | |
print "at end of routine `{}`:".format(routine.name)
|
382 | |
print context
|
383 | |
print "trashed: ", LocationRef.format_set(trashed)
|
384 | |
print "outputs: ", LocationRef.format_set(type_.outputs)
|
|
381 |
print("at end of routine `{}`:".format(routine.name))
|
|
382 |
print(context)
|
|
383 |
print("trashed: ", LocationRef.format_set(trashed))
|
|
384 |
print("outputs: ", LocationRef.format_set(type_.outputs))
|
385 | 385 |
trashed_outputs = type_.outputs & trashed
|
386 | 386 |
if trashed_outputs:
|
387 | |
print "TRASHED OUTPUTS: ", LocationRef.format_set(trashed_outputs)
|
388 | |
print ''
|
389 | |
print '-' * 79
|
390 | |
print ''
|
|
387 |
print("TRASHED OUTPUTS: ", LocationRef.format_set(trashed_outputs))
|
|
388 |
print('')
|
|
389 |
print('-' * 79)
|
|
390 |
print('')
|
391 | 391 |
|
392 | 392 |
# even if we goto another routine, we can't trash an output.
|
393 | 393 |
for ref in trashed:
|
111 | 111 |
routine_name = roster_row[-1]
|
112 | 112 |
self.compile_routine(self.routines[routine_name])
|
113 | 113 |
|
114 | |
for location, label in self.trampolines.iteritems():
|
|
114 |
for location, label in self.trampolines.items():
|
115 | 115 |
self.emitter.resolve_label(label)
|
116 | 116 |
self.emitter.emit(JMP(Indirect(self.get_label(location.name))))
|
117 | 117 |
self.emitter.emit(RTS())
|
12 | 12 |
|
13 | 13 |
class Byte(Emittable):
|
14 | 14 |
def __init__(self, value):
|
15 | |
if isinstance(value, basestring):
|
|
15 |
if isinstance(value, str):
|
16 | 16 |
value = ord(value)
|
17 | 17 |
if value < -127 or value > 255:
|
18 | 18 |
raise IndexError(value)
|
19 | 19 |
|
20 | 20 |
def backpatch_constraint_labels(self, resolver):
|
21 | 21 |
def resolve(w):
|
22 | |
if not isinstance(w, basestring):
|
|
22 |
if not isinstance(w, str):
|
23 | 23 |
return w
|
24 | 24 |
return resolver(w)
|
25 | 25 |
if isinstance(self, TableType):
|
89 | 89 |
self.scanner.check_type('EOF')
|
90 | 90 |
|
91 | 91 |
# now backpatch the executable types.
|
92 | |
#for type_name, type_ in self.context.typedefs.iteritems():
|
|
92 |
#for type_name, type_ in self.context.typedefs.items():
|
93 | 93 |
# type_.backpatch_constraint_labels(lambda w: self.lookup(w))
|
94 | 94 |
for defn in defns:
|
95 | 95 |
defn.location.type.backpatch_constraint_labels(lambda w: self.lookup(w))
|
|
102 | 102 |
if not isinstance(model.type, (RoutineType, VectorType)):
|
103 | 103 |
self.syntax_error('Illegal call of non-executable "%s"' % name)
|
104 | 104 |
instr.location = model
|
105 | |
if instr.opcode in ('copy',) and isinstance(instr.src, basestring):
|
|
105 |
if instr.opcode in ('copy',) and isinstance(instr.src, str):
|
106 | 106 |
name = instr.src
|
107 | 107 |
model = self.lookup(name)
|
108 | 108 |
if not isinstance(model.type, (RoutineType, VectorType)):
|
|
358 | 358 |
|
359 | 359 |
def indexed_locexpr(self, forward=False):
|
360 | 360 |
loc = self.locexpr(forward=forward)
|
361 | |
if not isinstance(loc, basestring):
|
|
361 |
if not isinstance(loc, str):
|
362 | 362 |
index = None
|
363 | 363 |
if self.scanner.consume('+'):
|
364 | 364 |
index = self.locexpr()
|