1.1 --- a/micropython/common.py Tue Apr 07 00:57:04 2009 +0200
1.2 +++ b/micropython/common.py Mon Apr 20 01:50:00 2009 +0200
1.3 @@ -71,104 +71,6 @@
1.4
1.5 pass
1.6
1.7 -# Program code representations.
1.8 -
1.9 -class Block:
1.10 -
1.11 - "A code block."
1.12 -
1.13 - def __init__(self):
1.14 - self.code = []
1.15 - self.location = None
1.16 -
1.17 - def __repr__(self):
1.18 - return "Block(%r, location=%r)" % (id(self), self.location)
1.19 -
1.20 - def as_raw(self, objtable, paramtable):
1.21 - for i, item in enumerate(self.code):
1.22 - if hasattr(item, "location"):
1.23 - item.location = location + i
1.24 - return self.code
1.25 -
1.26 -# Program data representations.
1.27 -
1.28 -class DataObject:
1.29 -
1.30 - "A representation of a raw program data object."
1.31 -
1.32 - def __init__(self, classcode, attrcode, codeaddr, codedetails, instance, name, funccode=None):
1.33 - self.classcode = classcode
1.34 - self.attrcode = attrcode
1.35 - self.codeaddr = codeaddr
1.36 - self.codedetails = codedetails
1.37 - self.instance = instance
1.38 - self.name = name
1.39 - self.funccode = funccode
1.40 -
1.41 - def __repr__(self):
1.42 - return "%r # %s" % ((self.classcode, self.attrcode, self.codeaddr, self.codedetails, self.instance, self.funccode), self.name)
1.43 -
1.44 -# Inspection representations.
1.45 -
1.46 -class AtLeast:
1.47 -
1.48 - "A special representation for numbers of a given value or greater."
1.49 -
1.50 - def __init__(self, count):
1.51 - self.count = count
1.52 -
1.53 - def __eq__(self, other):
1.54 - return 0
1.55 -
1.56 - __lt__ = __le__ = __eq__
1.57 -
1.58 - def __ne__(self, other):
1.59 - return 1
1.60 -
1.61 - def __gt__(self, other):
1.62 - if isinstance(other, AtLeast):
1.63 - return 0
1.64 - else:
1.65 - return self.count > other
1.66 -
1.67 - def __ge__(self, other):
1.68 - if isinstance(other, AtLeast):
1.69 - return 0
1.70 - else:
1.71 - return self.count >= other
1.72 -
1.73 - def __iadd__(self, other):
1.74 - if isinstance(other, AtLeast):
1.75 - self.count += other.count
1.76 - else:
1.77 - self.count += other
1.78 - return self
1.79 -
1.80 - def __radd__(self, other):
1.81 - if isinstance(other, AtLeast):
1.82 - return AtLeast(self.count + other.count)
1.83 - else:
1.84 - return AtLeast(self.count + other)
1.85 -
1.86 - def __repr__(self):
1.87 - return "AtLeast(%r)" % self.count
1.88 -
1.89 -class Naming:
1.90 -
1.91 - "A mix-in providing naming conveniences."
1.92 -
1.93 - def full_name(self):
1.94 - if self.name is not None:
1.95 - return self.parent.full_name() + "." + self.name
1.96 - else:
1.97 - return self.parent.full_name()
1.98 -
1.99 -class Undefined:
1.100 -
1.101 - "A special class of undefined values."
1.102 -
1.103 - pass
1.104 -
1.105 # Useful data.
1.106
1.107 comparison_methods = {