1.1 --- a/micropython/__init__.py Tue Dec 02 01:13:19 2008 +0100
1.2 +++ b/micropython/__init__.py Fri Dec 12 00:59:44 2008 +0100
1.3 @@ -315,6 +315,8 @@
1.4 pos += 1
1.5 if isinstance(item, micropython.data.Function):
1.6 item.code_location = pos
1.7 + elif isinstance(item, micropython.data.Const):
1.8 + pos += len(self.raw_data(item))
1.9 else:
1.10 pos += 1
1.11
1.12 @@ -331,7 +333,7 @@
1.13 ))
1.14
1.15 elif isinstance(item, Block):
1.16 - self.raw_code += self.raw_block(item, len(self.raw_code))
1.17 + self.raw_code += self.raw_block(item)
1.18
1.19 # Using classcode, attrcode, codeaddr, codedetails, instance.
1.20
1.21 @@ -366,6 +368,8 @@
1.22 1
1.23 ))
1.24
1.25 + self.raw_code += self.raw_data(item)
1.26 +
1.27 elif isinstance(item, micropython.data.Function):
1.28 assert item.location == len(self.raw_code)
1.29
1.30 @@ -409,19 +413,29 @@
1.31 self.code_location = self.modules["__main__"].code_location
1.32 return self.raw_code
1.33
1.34 - def raw_block(self, block, location):
1.35 + def raw_block(self, block):
1.36
1.37 - """
1.38 - Return the code for the given 'block', appearing at the given
1.39 - 'location'.
1.40 - """
1.41 + "Return the code for the given 'block'."
1.42
1.43 - assert block.location == location
1.44 + assert block.location == len(self.raw_code)
1.45 for i, item in enumerate(block.code):
1.46 if hasattr(item, "location"):
1.47 item.location = location + i
1.48 return block.code
1.49
1.50 + def raw_data(self, item):
1.51 +
1.52 + "Return the data for the given 'item'."
1.53 +
1.54 + datatype = item.value_type_name()
1.55 +
1.56 + # NOTE: Start simple and use single entries for most types.
1.57 +
1.58 + if datatype in ("__builtins__.tuple", "__builtins__.list"):
1.59 + return [len(item.value)] + list(item.value)
1.60 + else:
1.61 + return [item.value]
1.62 +
1.63 def get_object_table(self):
1.64
1.65 "Return a table with details of attributes for classes and modules."
2.1 --- a/rsvp.py Tue Dec 02 01:13:19 2008 +0100
2.2 +++ b/rsvp.py Fri Dec 12 00:59:44 2008 +0100
2.3 @@ -257,9 +257,11 @@
2.4 instructions would otherwise have.
2.5 """
2.6
2.7 - for input in (self.instruction.input, self.instruction.source):
2.8 - if input is not None:
2.9 - self.perform(input)
2.10 + if self.instruction.source is not None:
2.11 + self.perform(self.instruction.source)
2.12 + self.source = self.value
2.13 + if self.instruction.input is not None:
2.14 + self.perform(self.instruction.input)
2.15
2.16 def jump(self, addr, next):
2.17
2.18 @@ -318,12 +320,12 @@
2.19 def LoadAttr(self):
2.20 context, ref = self.value
2.21 # Retrieved context should already be appropriate for the instance.
2.22 - self.value = self.load(ref + self.operand)
2.23 + self.value = self.load(ref + self.operand + 1)
2.24
2.25 def StoreAttr(self):
2.26 context, ref = self.value
2.27 # Target should already be an instance.
2.28 - self.save(ref + self.operand, self.source)
2.29 + self.save(ref + self.operand + 1, self.source)
2.30
2.31 def LoadAttrIndex(self):
2.32 context, ref = self.value