1.1 --- a/micropython/rsvp.py Sun Oct 26 02:14:29 2008 +0200
1.2 +++ b/micropython/rsvp.py Mon Oct 27 01:19:06 2008 +0100
1.3 @@ -19,7 +19,7 @@
1.4 this program. If not, see <http://www.gnu.org/licenses/>.
1.5 """
1.6
1.7 -from micropython.common import Label
1.8 +from micropython.common import Block
1.9 from micropython.data import Attr, Class, Const, Function, Module
1.10
1.11 def raw(code, objtable, paramtable):
1.12 @@ -30,6 +30,7 @@
1.13 """
1.14
1.15 new_code = []
1.16 +
1.17 for item in code:
1.18
1.19 if isinstance(item, Attr):
1.20 @@ -38,6 +39,9 @@
1.21 item.value and item.value.location # no useful context is provided
1.22 ))
1.23
1.24 + elif isinstance(item, Block):
1.25 + new_code += raw_block(item, len(new_code))
1.26 +
1.27 # Using classcode, attrcode, codeaddr, codedetails, instance.
1.28
1.29 elif isinstance(item, Class):
1.30 @@ -90,6 +94,18 @@
1.31
1.32 return new_code
1.33
1.34 +def raw_block(block, location):
1.35 +
1.36 + """
1.37 + Return the code for the given 'block', appearing at the given location.
1.38 + """
1.39 +
1.40 + block.location = location
1.41 + for i, item in enumerate(block.code):
1.42 + if hasattr(item, "location"):
1.43 + item.location = location + i
1.44 + return block.code
1.45 +
1.46 def name(attr):
1.47 if isinstance(attr, Attr):
1.48 return attr.name or "<unnamed>"
1.49 @@ -186,8 +202,6 @@
1.50 position = self.attr.name
1.51 result = None
1.52 return location, position, result
1.53 - elif isinstance(self.attr, Label):
1.54 - return None, None, self.attr.location
1.55 else:
1.56 return None, None, self.attr.location
1.57