1.1 --- a/micropython/trans.py Thu Apr 23 00:52:33 2009 +0200
1.2 +++ b/micropython/trans.py Sun Apr 26 03:24:12 2009 +0200
1.3 @@ -508,13 +508,6 @@
1.4 self.new_op(LoadContext())
1.5 self.new_op(StoreFrame(0))
1.6
1.7 - # For known instantiations, provide a new object as the first argument
1.8 - # to the __init__ method.
1.9 -
1.10 - elif isinstance(target, Class):
1.11 - self.make_object(target, len(target.instance_attributes()))
1.12 - self.new_op(StoreFrame(0))
1.13 -
1.14 # Otherwise omit the context.
1.15
1.16 else:
1.17 @@ -552,11 +545,12 @@
1.18 expect_context = 0
1.19
1.20 # Handle calls to classes.
1.21 + # The resulting target must match that used in the actual invocation.
1.22
1.23 elif isinstance(target, Class):
1.24 - ncontext = 1
1.25 + ncontext = 0
1.26 expect_context = 0
1.27 - target = target.get_init_method()
1.28 + target = target.get_instantiator()
1.29
1.30 # Method calls via classes.
1.31
1.32 @@ -771,10 +765,14 @@
1.33
1.34 "Make the invocation."
1.35
1.36 + # For classes, the target itself is used, since the instantiator will be
1.37 + # obtained via the class.
1.38 +
1.39 if isinstance(target, Class):
1.40 - self.new_op(LoadConst(target.get_init_method()))
1.41 + self.new_op(LoadConst(target))
1.42 else:
1.43 self.new_op(instruction)
1.44 +
1.45 self.new_op(LoadCallable())
1.46 self.new_op(JumpWithFrame())
1.47
1.48 @@ -789,9 +787,6 @@
1.49
1.50 "Finish the invocation and tidy up afterwards."
1.51
1.52 - if isinstance(target, Class):
1.53 - self.new_op(LoadName(target.get_init_method().all_locals()["self"])) # load the context in the invocation frame
1.54 - self.new_op(StoreResult())
1.55 self.new_op(DropFrame())
1.56 if load_result:
1.57 self.new_op(LoadResult())