1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/micropython/program.py Mon Apr 20 01:50:00 2009 +0200
1.3 @@ -0,0 +1,40 @@
1.4 +#!/usr/bin/env python
1.5 +
1.6 +"""
1.7 +Program code and data representations.
1.8 +"""
1.9 +
1.10 +class Block:
1.11 +
1.12 + "A code block."
1.13 +
1.14 + def __init__(self):
1.15 + self.code = []
1.16 + self.location = None
1.17 +
1.18 + def __repr__(self):
1.19 + return "Block(%r, location=%r)" % (id(self), self.location)
1.20 +
1.21 + def as_raw(self, objtable, paramtable):
1.22 + for i, item in enumerate(self.code):
1.23 + if hasattr(item, "location"):
1.24 + item.location = location + i
1.25 + return self.code
1.26 +
1.27 +class DataObject:
1.28 +
1.29 + "A representation of a raw program data object."
1.30 +
1.31 + def __init__(self, classcode, attrcode, codeaddr, codedetails, instance, name, funccode=None):
1.32 + self.classcode = classcode
1.33 + self.attrcode = attrcode
1.34 + self.codeaddr = codeaddr
1.35 + self.codedetails = codedetails
1.36 + self.instance = instance
1.37 + self.name = name
1.38 + self.funccode = funccode
1.39 +
1.40 + def __repr__(self):
1.41 + return "%r # %s" % ((self.classcode, self.attrcode, self.codeaddr, self.codedetails, self.instance, self.funccode), self.name)
1.42 +
1.43 +# vim: tabstop=4 expandtab shiftwidth=4