mirror of
https://github.com/catseye/SixtyPical.git
synced 2025-02-10 08:30:38 +00:00
Not making any promises, but reduce the errors under Python 3.
This commit is contained in:
parent
fca00ff127
commit
c11869f322
@ -372,23 +372,23 @@ class Analyzer(object):
|
|||||||
context = Context(self.routines, routine, type_.inputs, type_.outputs, type_.trashes)
|
context = Context(self.routines, routine, type_.inputs, type_.outputs, type_.trashes)
|
||||||
|
|
||||||
if self.debug:
|
if self.debug:
|
||||||
print "at start of routine `{}`:".format(routine.name)
|
print("at start of routine `{}`:".format(routine.name))
|
||||||
print context
|
print(context)
|
||||||
|
|
||||||
self.analyze_block(routine.block, context)
|
self.analyze_block(routine.block, context)
|
||||||
trashed = set(context.each_touched()) - set(context.each_meaningful())
|
trashed = set(context.each_touched()) - set(context.each_meaningful())
|
||||||
|
|
||||||
if self.debug:
|
if self.debug:
|
||||||
print "at end of routine `{}`:".format(routine.name)
|
print("at end of routine `{}`:".format(routine.name))
|
||||||
print context
|
print(context)
|
||||||
print "trashed: ", LocationRef.format_set(trashed)
|
print("trashed: ", LocationRef.format_set(trashed))
|
||||||
print "outputs: ", LocationRef.format_set(type_.outputs)
|
print("outputs: ", LocationRef.format_set(type_.outputs))
|
||||||
trashed_outputs = type_.outputs & trashed
|
trashed_outputs = type_.outputs & trashed
|
||||||
if trashed_outputs:
|
if trashed_outputs:
|
||||||
print "TRASHED OUTPUTS: ", LocationRef.format_set(trashed_outputs)
|
print("TRASHED OUTPUTS: ", LocationRef.format_set(trashed_outputs))
|
||||||
print ''
|
print('')
|
||||||
print '-' * 79
|
print('-' * 79)
|
||||||
print ''
|
print('')
|
||||||
|
|
||||||
# even if we goto another routine, we can't trash an output.
|
# even if we goto another routine, we can't trash an output.
|
||||||
for ref in trashed:
|
for ref in trashed:
|
||||||
|
@ -112,7 +112,7 @@ class Compiler(object):
|
|||||||
routine_name = roster_row[-1]
|
routine_name = roster_row[-1]
|
||||||
self.compile_routine(self.routines[routine_name])
|
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.resolve_label(label)
|
||||||
self.emitter.emit(JMP(Indirect(self.get_label(location.name))))
|
self.emitter.emit(JMP(Indirect(self.get_label(location.name))))
|
||||||
self.emitter.emit(RTS())
|
self.emitter.emit(RTS())
|
||||||
|
@ -13,7 +13,7 @@ class Emittable(object):
|
|||||||
|
|
||||||
class Byte(Emittable):
|
class Byte(Emittable):
|
||||||
def __init__(self, value):
|
def __init__(self, value):
|
||||||
if isinstance(value, basestring):
|
if isinstance(value, str):
|
||||||
value = ord(value)
|
value = ord(value)
|
||||||
if value < -127 or value > 255:
|
if value < -127 or value > 255:
|
||||||
raise IndexError(value)
|
raise IndexError(value)
|
||||||
|
@ -20,7 +20,7 @@ class Type(object):
|
|||||||
|
|
||||||
def backpatch_constraint_labels(self, resolver):
|
def backpatch_constraint_labels(self, resolver):
|
||||||
def resolve(w):
|
def resolve(w):
|
||||||
if not isinstance(w, basestring):
|
if not isinstance(w, str):
|
||||||
return w
|
return w
|
||||||
return resolver(w)
|
return resolver(w)
|
||||||
if isinstance(self, TableType):
|
if isinstance(self, TableType):
|
||||||
|
@ -90,7 +90,7 @@ class Parser(object):
|
|||||||
self.scanner.check_type('EOF')
|
self.scanner.check_type('EOF')
|
||||||
|
|
||||||
# now backpatch the executable types.
|
# 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))
|
# type_.backpatch_constraint_labels(lambda w: self.lookup(w))
|
||||||
for defn in defns:
|
for defn in defns:
|
||||||
defn.location.type.backpatch_constraint_labels(lambda w: self.lookup(w))
|
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)):
|
if not isinstance(model.type, (RoutineType, VectorType)):
|
||||||
self.syntax_error('Illegal call of non-executable "%s"' % name)
|
self.syntax_error('Illegal call of non-executable "%s"' % name)
|
||||||
instr.location = model
|
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
|
name = instr.src
|
||||||
model = self.lookup(name)
|
model = self.lookup(name)
|
||||||
if not isinstance(model.type, (RoutineType, VectorType)):
|
if not isinstance(model.type, (RoutineType, VectorType)):
|
||||||
@ -359,7 +359,7 @@ class Parser(object):
|
|||||||
|
|
||||||
def indexed_locexpr(self, forward=False):
|
def indexed_locexpr(self, forward=False):
|
||||||
loc = self.locexpr(forward=forward)
|
loc = self.locexpr(forward=forward)
|
||||||
if not isinstance(loc, basestring):
|
if not isinstance(loc, str):
|
||||||
index = None
|
index = None
|
||||||
if self.scanner.consume('+'):
|
if self.scanner.consume('+'):
|
||||||
index = self.locexpr()
|
index = self.locexpr()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user