1.1 --- a/micropython/data.py Sat Oct 10 03:09:29 2009 +0200
1.2 +++ b/micropython/data.py Sun Oct 11 02:40:20 2009 +0200
1.3 @@ -431,14 +431,6 @@
1.4 l.append("(c=%s, v=%s)" % (shortrepr(c), shortrepr(v)))
1.5 return ", ".join(l)
1.6
1.7 - def as_raw(self, objtable, paramtable):
1.8 - return [
1.9 - DataValue(
1.10 - self.get_context() and self.get_context().location,
1.11 - self.get_value() and self.get_value().location
1.12 - )
1.13 - ]
1.14 -
1.15 # Instances are special in that they need to be wrapped together with context in
1.16 # a running program, but they are not generally constant.
1.17
1.18 @@ -475,7 +467,7 @@
1.19 self.value = value
1.20
1.21 def get_value(self):
1.22 - return value
1.23 + return self.value
1.24
1.25 def __repr__(self):
1.26 if self.location is not None:
1.27 @@ -485,25 +477,6 @@
1.28
1.29 __shortrepr__ = __repr__
1.30
1.31 - def as_raw(self, objtable, paramtable):
1.32 - # NOTE: Need class details!
1.33 - return [
1.34 - DataObject(
1.35 - objtable.as_list().get_code(self.value_type_name()),
1.36 - objtable.get_index(self.value_type_name()), # is instance
1.37 - None,
1.38 - self.value_type_name(),
1.39 - 1 # size
1.40 - )
1.41 - ] + self.raw_data()
1.42 -
1.43 - def raw_data(self):
1.44 - # NOTE: Start simple and use single entries for most types.
1.45 - if self.value_type_name() in ("__builtins__.tuple", "__builtins__.list"):
1.46 - return [len(self.value)] + list(self.value)
1.47 - else:
1.48 - return [self.value]
1.49 -
1.50 # Support constants as dictionary keys in order to build constant tables.
1.51
1.52 def __eq__(self, other):
1.53 @@ -578,51 +551,6 @@
1.54 def __shortrepr__(self):
1.55 return "Class(%r, %s)" % (self.name, shortrepr(self.parent))
1.56
1.57 - def as_raw(self, objtable, paramtable, with_instantiator=1):
1.58 - classcode = objtable.as_list().get_code(self.full_name())
1.59 - attrcode = objtable.get_index(self.full_name())
1.60 -
1.61 - # Include a template of an instance for use when instantiating classes.
1.62 -
1.63 - call_method = self.all_class_attributes().get("__call__")
1.64 - call_method_value = call_method and call_method.get_value()
1.65 - call_method_code_location = call_method_value and call_method_value.code_location
1.66 - call_method_funccode = call_method_value and paramtable.as_list().get_code(call_method_value.full_name())
1.67 -
1.68 - instantiator_funccode = paramtable.as_list().get_code(self.get_instantiator().full_name())
1.69 -
1.70 - # NOTE: The instantiator code is the first block of the class.
1.71 -
1.72 - if not with_instantiator:
1.73 - instantiator_code_location = self.full_name()
1.74 - else:
1.75 - instantiator_code_location = self.get_instantiator().blocks[0].location
1.76 -
1.77 - return [
1.78 -
1.79 - # Template instance...
1.80 -
1.81 - DataObject(
1.82 - classcode,
1.83 - attrcode, # is instance
1.84 - call_method_code_location,
1.85 - self.full_name(),
1.86 - len(self.instance_attributes()) + 1, # size
1.87 - call_method_funccode # funccode
1.88 - ),
1.89 -
1.90 - # Class...
1.91 -
1.92 - DataObject(
1.93 - classcode,
1.94 - None, # is not instance
1.95 - instantiator_code_location,
1.96 - self.full_name(),
1.97 - len(self.class_attributes()) + 1, # size
1.98 - instantiator_funccode # funccode
1.99 - )
1.100 - ]
1.101 -
1.102 def get_body_block(self):
1.103 return self.get_instantiator().blocks[0]
1.104
1.105 @@ -995,19 +923,6 @@
1.106 self.name, shortrepr(self.parent)
1.107 )
1.108
1.109 - def as_raw(self, objtable, paramtable):
1.110 - # NOTE: Need class and parameter details! Should arguably be an instance of types.FunctionType.
1.111 - return [
1.112 - DataObject(
1.113 - objtable.as_list().get_code("__builtins__.function"),
1.114 - objtable.get_index("__builtins__.function"), # is instance
1.115 - self.code_location,
1.116 - "__builtins__.function",
1.117 - len(self.defaults) + 1, # size (not accurate for lambda functions before instantiation)
1.118 - paramtable.as_list().get_code(self.full_name()) # funccode
1.119 - )
1.120 - ]
1.121 -
1.122 def get_body_block(self):
1.123 return self.body_block
1.124
1.125 @@ -1200,17 +1115,6 @@
1.126 def __shortrepr__(self):
1.127 return "Module(%r)" % self.name
1.128
1.129 - def as_raw(self, objtable, paramtable):
1.130 - return [
1.131 - DataObject(
1.132 - objtable.as_list().get_code(self.full_name()),
1.133 - None, # modules treated like classes
1.134 - None,
1.135 - self.full_name(),
1.136 - len(self.module_attributes()) + 1 # size
1.137 - )
1.138 - ]
1.139 -
1.140 # Attribute methods.
1.141
1.142 "Return the module attribute names provided by the module."