1
0
mirror of https://github.com/catseye/SixtyPical.git synced 2024-06-07 06:29:32 +00:00

Not making any promises, but reduce the errors under Python 3.

This commit is contained in:
Chris Pressey 2018-09-05 21:45:58 +01:00
parent fca00ff127
commit c11869f322
5 changed files with 16 additions and 16 deletions

View File

@ -372,23 +372,23 @@ class Analyzer(object):
context = Context(self.routines, routine, type_.inputs, type_.outputs, type_.trashes)
if self.debug:
print "at start of routine `{}`:".format(routine.name)
print context
print("at start of routine `{}`:".format(routine.name))
print(context)
self.analyze_block(routine.block, context)
trashed = set(context.each_touched()) - set(context.each_meaningful())
if self.debug:
print "at end of routine `{}`:".format(routine.name)
print context
print "trashed: ", LocationRef.format_set(trashed)
print "outputs: ", LocationRef.format_set(type_.outputs)
print("at end of routine `{}`:".format(routine.name))
print(context)
print("trashed: ", LocationRef.format_set(trashed))
print("outputs: ", LocationRef.format_set(type_.outputs))
trashed_outputs = type_.outputs & trashed
if trashed_outputs:
print "TRASHED OUTPUTS: ", LocationRef.format_set(trashed_outputs)
print ''
print '-' * 79
print ''
print("TRASHED OUTPUTS: ", LocationRef.format_set(trashed_outputs))
print('')
print('-' * 79)
print('')
# even if we goto another routine, we can't trash an output.
for ref in trashed:

View File

@ -112,7 +112,7 @@ class Compiler(object):
routine_name = roster_row[-1]
self.compile_routine(self.routines[routine_name])
for location, label in self.trampolines.iteritems():
for location, label in self.trampolines.items():
self.emitter.resolve_label(label)
self.emitter.emit(JMP(Indirect(self.get_label(location.name))))
self.emitter.emit(RTS())

View File

@ -13,7 +13,7 @@ class Emittable(object):
class Byte(Emittable):
def __init__(self, value):
if isinstance(value, basestring):
if isinstance(value, str):
value = ord(value)
if value < -127 or value > 255:
raise IndexError(value)

View File

@ -20,7 +20,7 @@ class Type(object):
def backpatch_constraint_labels(self, resolver):
def resolve(w):
if not isinstance(w, basestring):
if not isinstance(w, str):
return w
return resolver(w)
if isinstance(self, TableType):

View File

@ -90,7 +90,7 @@ class Parser(object):
self.scanner.check_type('EOF')
# now backpatch the executable types.
#for type_name, type_ in self.context.typedefs.iteritems():
#for type_name, type_ in self.context.typedefs.items():
# type_.backpatch_constraint_labels(lambda w: self.lookup(w))
for defn in defns:
defn.location.type.backpatch_constraint_labels(lambda w: self.lookup(w))
@ -103,7 +103,7 @@ class Parser(object):
if not isinstance(model.type, (RoutineType, VectorType)):
self.syntax_error('Illegal call of non-executable "%s"' % name)
instr.location = model
if instr.opcode in ('copy',) and isinstance(instr.src, basestring):
if instr.opcode in ('copy',) and isinstance(instr.src, str):
name = instr.src
model = self.lookup(name)
if not isinstance(model.type, (RoutineType, VectorType)):
@ -359,7 +359,7 @@ class Parser(object):
def indexed_locexpr(self, forward=False):
loc = self.locexpr(forward=forward)
if not isinstance(loc, basestring):
if not isinstance(loc, str):
index = None
if self.scanner.consume('+'):
index = self.locexpr()