1.1 --- a/micropython/rsvp.py Mon Sep 29 01:30:39 2008 +0200
1.2 +++ b/micropython/rsvp.py Fri Oct 10 00:56:20 2008 +0200
1.3 @@ -20,7 +20,7 @@
1.4 """
1.5
1.6 from micropython.common import Label
1.7 -from micropython.data import Attr, Class, Const, Function
1.8 +from micropython.data import Attr, Class, Const, Function, Module
1.9
1.10 def raw(code, objtable, paramtable):
1.11
1.12 @@ -76,6 +76,15 @@
1.13 0
1.14 ))
1.15
1.16 + elif isinstance(item, Module):
1.17 + new_code.append((
1.18 + objtable.as_list().get_code(item.full_name()),
1.19 + None, # module name not used as an attribute
1.20 + None,
1.21 + None,
1.22 + 0
1.23 + ))
1.24 +
1.25 else:
1.26 new_code.append(item)
1.27
2.1 --- a/rsvp.py Mon Sep 29 01:30:39 2008 +0200
2.2 +++ b/rsvp.py Fri Oct 10 00:56:20 2008 +0200
2.3 @@ -107,6 +107,8 @@
2.4 self.attr_error = attr_error
2.5 self.type_error = type_error
2.6
2.7 + # Debugging methods.
2.8 +
2.9 def dump(self):
2.10 print "PC", self.pc, "->", self.load(self.pc)
2.11 print "PC stack", self.pc_stack
2.12 @@ -126,9 +128,31 @@
2.13 print "Result", self.result
2.14 print "Exception", self.exception
2.15
2.16 - def step(self):
2.17 + def show(self):
2.18 + self.show_memory(self.memory, 0)
2.19 +
2.20 + def show_pc(self, run_in=10):
2.21 + start = max(0, self.pc - run_in)
2.22 + end = self.pc + run_in
2.23 + memory = self.memory[start:end]
2.24 + self.show_memory(memory, start)
2.25 +
2.26 + def show_memory(self, memory, start):
2.27 + for i, x in enumerate(memory):
2.28 + location = start + i
2.29 + if location == self.pc:
2.30 + print "->",
2.31 + else:
2.32 + print " ",
2.33 + print "%5d %r" % (location, x)
2.34 +
2.35 + def step(self, dump=0):
2.36 self.execute()
2.37 - self.dump()
2.38 + self.show_pc()
2.39 + if dump:
2.40 + self.dump()
2.41 +
2.42 + # Internal operations.
2.43
2.44 def load(self, address):
2.45