1.1 --- a/micropython/data.py Sat May 09 02:54:18 2009 +0200
1.2 +++ b/micropython/data.py Sat May 09 03:21:15 2009 +0200
1.3 @@ -556,9 +556,12 @@
1.4
1.5 # Include a template of an instance for use when instantiating classes.
1.6
1.7 - call_method = self.get("__call__")
1.8 + call_method = self.all_class_attributes().get("__call__")
1.9 call_method_value = call_method and call_method.get_value()
1.10 call_method_code_location = call_method_value and call_method_value.code_location
1.11 + call_method_funccode = call_method_value and paramtable.as_list().get_code(call_method_value.full_name())
1.12 +
1.13 + instantiator_funccode = paramtable.as_list().get_code(self.get_instantiator().full_name())
1.14
1.15 # NOTE: The instantiator code is the first block of the class.
1.16
1.17 @@ -580,7 +583,8 @@
1.18 call_method_value and len(call_method_value.defaults)
1.19 ),
1.20 self.full_name(),
1.21 - len(self.instance_attributes()) + 1 # size
1.22 + len(self.instance_attributes()) + 1, # size
1.23 + call_method_funccode # funccode
1.24 ),
1.25
1.26 # Class...
1.27 @@ -594,7 +598,8 @@
1.28 len(self.get_instantiator().defaults)
1.29 ),
1.30 self.full_name(),
1.31 - len(self.class_attributes()) + 1 # size
1.32 + len(self.class_attributes()) + 1, # size
1.33 + instantiator_funccode # funccode
1.34 )
1.35 ]
1.36
1.37 @@ -639,7 +644,7 @@
1.38 "Return a function which can be used to instantiate the class."
1.39
1.40 if self.instantiator is None:
1.41 - self.instantiator = self.get_init_method().function_from_method()
1.42 + self.instantiator = self.get_init_method().as_instantiator()
1.43 return self.instantiator
1.44
1.45 def get_init_method(self):
1.46 @@ -974,7 +979,7 @@
1.47 ),
1.48 "__builtins__.function",
1.49 len(self.defaults) + 1, # size
1.50 - paramtable.as_list().get_code(self.full_name())
1.51 + paramtable.as_list().get_code(self.full_name()) # funccode
1.52 )
1.53 ]
1.54
1.55 @@ -1079,11 +1084,11 @@
1.56 self.all_local_usage = nparams + nothers
1.57 self.finalised = 1
1.58
1.59 - def function_from_method(self):
1.60 + def as_instantiator(self):
1.61
1.62 - "Make a function from a method."
1.63 + "Make an instantiator function from a method."
1.64
1.65 - function = Function(self.name + " (function)", self.parent, self.argnames[1:], self.defaults,
1.66 + function = Function(self.parent.name, self.parent.parent, self.argnames[1:], self.defaults,
1.67 self.has_star, self.has_dstar, self.module, self.astnode)
1.68 function.default_attrs = self.default_attrs
1.69 return function