1.1 --- a/micropython/data.py Sun May 11 18:43:58 2008 +0200
1.2 +++ b/micropython/data.py Sun May 11 21:50:30 2008 +0200
1.3 @@ -25,7 +25,6 @@
1.4 * Class
1.5 * Function
1.6 * Module
1.7 - * InspectedModule (derived from Module)
1.8
1.9 All of the above support the Naming interface either explicitly or through
1.10 general conformance, meaning that all can be asked to provide their 'full_name'
1.11 @@ -151,7 +150,11 @@
1.12 for i, attr in enumerate(self.values()):
1.13 attr.position = i
1.14
1.15 -# Program data structures.
1.16 +# Program data structures. There are two separate kinds of structures: those
1.17 +# with context, which are the values manipulated by programs, and those without
1.18 +# context, which are typically constant things which are stored alongside the
1.19 +# program but which are wrapped in context-dependent structures in the running
1.20 +# program.
1.21
1.22 class Attr:
1.23
1.24 @@ -194,7 +197,13 @@
1.25 def __repr__(self):
1.26 return "Attr(%r, %r, %r, %r, %r)" % (self.position, self.parent, self.name, self.value, self.assignments)
1.27
1.28 -class Const:
1.29 +class Constant:
1.30 +
1.31 + "A superclass for all constant or context-free structures."
1.32 +
1.33 + pass
1.34 +
1.35 +class Const(Constant):
1.36
1.37 "A constant object with no context."
1.38
1.39 @@ -222,7 +231,7 @@
1.40 def value_type_name(self):
1.41 return "__builtins__." + self.value.__class__.__name__
1.42
1.43 -class Class(NamespaceDict, Naming):
1.44 +class Class(NamespaceDict, Naming, Constant):
1.45
1.46 "An inspected class."
1.47
1.48 @@ -521,7 +530,7 @@
1.49 self.allattr[name] = attr
1.50 return self.allattr
1.51
1.52 -class Function(NamespaceDict, Naming):
1.53 +class Function(NamespaceDict, Naming, Constant):
1.54
1.55 "An inspected function."
1.56
1.57 @@ -689,7 +698,7 @@
1.58 function.default_attrs = self.default_attrs
1.59 return function
1.60
1.61 -class UnresolvedName(NamespaceDict):
1.62 +class UnresolvedName(NamespaceDict, Constant):
1.63
1.64 "A module, class or function which was mentioned but could not be imported."
1.65
1.66 @@ -713,14 +722,7 @@
1.67 else:
1.68 return self.parent_name
1.69
1.70 -class Instance:
1.71 -
1.72 - "A placeholder indicating the involvement of an instance."
1.73 -
1.74 - def __repr__(self):
1.75 - return "Instance()"
1.76 -
1.77 -class Module(NamespaceDict):
1.78 +class Module(NamespaceDict, Constant):
1.79
1.80 "An inspected module's core details."
1.81
1.82 @@ -772,4 +774,14 @@
1.83
1.84 return dict(self)
1.85
1.86 +# Instances are special in that they need to be wrapped together with context in
1.87 +# a running program, but they are not generally constant.
1.88 +
1.89 +class Instance:
1.90 +
1.91 + "A placeholder indicating the involvement of an instance."
1.92 +
1.93 + def __repr__(self):
1.94 + return "Instance()"
1.95 +
1.96 # vim: tabstop=4 expandtab shiftwidth=4