# HG changeset patch # User Paul Boddie # Date 1219099290 -7200 # Node ID dd607ca6396812e8ea2eb7d7db3c4eb7f3d10378 # Parent c01f2307b19e578d5ef895c4bb114b4803b742c9 Added raw table generation, at least for object tables. diff -r c01f2307b19e -r dd607ca63968 micropython/table.py --- a/micropython/table.py Mon Aug 18 01:46:21 2008 +0200 +++ b/micropython/table.py Tue Aug 19 00:41:30 2008 +0200 @@ -132,6 +132,33 @@ if attr is not None: self.displaced[offset+i] = offset, attr + # Image production. + + def as_raw(self): + + "Return the raw contents of the table as a list of values." + + result = [] + for entry in self.displaced: + if entry is None: + result.append(None) + else: + offset, attr = entry + if attr.parent is not None: + location = attr.parent.location or 0 + else: + location = 0 + if attr.position is not None: + position = attr.position + location + 1 # skip structure header + else: + position = None # NOTE: Should fix unpositioned attributes. + + # Class offset/code, context instance override flag, location/position. + + result.append((offset, attr.defined_within_hierarchy(), position)) + + return result + class Table: "A lookup table."