1.1 --- a/micropython/program.py Tue Jun 02 20:17:59 2009 +0200
1.2 +++ b/micropython/program.py Wed Jun 03 00:48:57 2009 +0200
1.3 @@ -44,4 +44,32 @@
1.4 (self.classcode, self.attrcode, self.codeaddr, self.funccode, self.size), self.name
1.5 )
1.6
1.7 +class Context:
1.8 +
1.9 + """
1.10 + A representation of a context used in a program, providing the special
1.11 + context value types.
1.12 + """
1.13 +
1.14 + def __init__(self, truth_value, repr):
1.15 + self.truth_value = truth_value
1.16 + self.repr = repr
1.17 +
1.18 + def __repr__(self):
1.19 + return self.repr
1.20 +
1.21 + def __nonzero__(self):
1.22 + return self.truth_value
1.23 +
1.24 +# A representation of a context that is replaced upon certain assignment
1.25 +# operations.
1.26 +
1.27 +ReplaceableContext = Context(0, "Replace")
1.28 +
1.29 +# A representation of a context that is employed by classes so that
1.30 +# instantiators have enough slots in the invocation frame, yet does not cause
1.31 +# testing of the context or adjustment of the frame.
1.32 +
1.33 +PlaceholderContext = Context(0, "Placeholder")
1.34 +
1.35 # vim: tabstop=4 expandtab shiftwidth=4