1.1 --- a/micropython/ast.py Fri May 01 01:02:20 2009 +0200
1.2 +++ b/micropython/ast.py Fri May 01 02:38:05 2009 +0200
1.3 @@ -152,7 +152,7 @@
1.4 if unit.astnode is not None:
1.5 self.dispatch(unit.astnode)
1.6
1.7 - self.unit.temp_usage = self.max_temp_position + 1
1.8 + self.unit.temp_usage = self.max_temp_position + 2 # include space for instantiators to expand backwards
1.9 self.unit.blocks = self.blocks
1.10 return self.blocks
1.11
1.12 @@ -191,6 +191,10 @@
1.13
1.14 self.new_op(LoadName(init_method.all_locals()["self"])) # load the context in the invocation frame
1.15 self.new_op(StoreResult())
1.16 +
1.17 + # Fix the current frame to release the storage slot at the beginning.
1.18 +
1.19 + self.new_op(AdjustFrame(1))
1.20 self.new_op(Return())
1.21
1.22 self.unit.blocks = self.blocks
2.1 --- a/micropython/trans.py Fri May 01 01:02:20 2009 +0200
2.2 +++ b/micropython/trans.py Fri May 01 02:38:05 2009 +0200
2.3 @@ -235,7 +235,7 @@
2.4 on the 'extend' instruction.
2.5 """
2.6
2.7 - ntemp = self.max_temp_position + 1
2.8 + ntemp = self.max_temp_position + 2 # include space for instantiators to expand backwards
2.9 extend.attr = ntemp + node.unit.local_usage # NOTE: See get_code for similar code.
2.10
2.11 # Code writing methods.
3.1 --- a/rsvp.py Fri May 01 01:02:20 2009 +0200
3.2 +++ b/rsvp.py Fri May 01 02:38:05 2009 +0200
3.3 @@ -540,12 +540,7 @@
3.4 self.frame_stack.extend([None] * self.operand)
3.5
3.6 def AdjustFrame(self):
3.7 - if self.operand > 0:
3.8 - self.frame_stack.append([None] * self.operand)
3.9 - elif self.operand == -1:
3.10 - self.invocation_sp_stack[-1] -= 1
3.11 - else:
3.12 - raise Exception, "AdjustFrame %r" % self.operand
3.13 + self.invocation_sp_stack[-1] += self.operand
3.14
3.15 def Return(self):
3.16 return self.pull_pc()
3.17 @@ -720,11 +715,15 @@
3.18
3.19 self.result = list, list
3.20
3.21 + def builtins_object_init(self):
3.22 + pass
3.23 +
3.24 native_functions = {
3.25 "__builtins__.int.__add__" : builtins_int_add,
3.26 "__builtins__.int.__bool__" : builtins_int_bool,
3.27 "__builtins__.bool.__bool__" : builtins_bool_bool,
3.28 "__builtins__.list" : builtins_list_new,
3.29 + "__builtins__.object.__init__" : builtins_object_init,
3.30 }
3.31
3.32 # vim: tabstop=4 expandtab shiftwidth=4
4.1 --- a/tests/call_method.py Fri May 01 01:02:20 2009 +0200
4.2 +++ b/tests/call_method.py Fri May 01 02:38:05 2009 +0200
4.3 @@ -2,23 +2,8 @@
4.4
4.5 class C:
4.6 def __init__(self, x):
4.7 - pass
4.8 -
4.9 - def f(self, a, b, c):
4.10 - self.g(a)
4.11 - m = self.g
4.12 - m(b)
4.13 -
4.14 - def g(self, x):
4.15 - C.h(self, x)
4.16 -
4.17 - def h(self, p):
4.18 - pass
4.19 + self.x = x
4.20
4.21 c = C(123)
4.22 -c.f(1, 2, 3)
4.23 -
4.24 -f = c.f
4.25 -f(1, 2, 3)
4.26
4.27 # vim: tabstop=4 expandtab shiftwidth=4
5.1 --- a/tests/call_method2.py Fri May 01 01:02:20 2009 +0200
5.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
5.3 @@ -1,15 +0,0 @@
5.4 -#!/usr/bin/env python
5.5 -
5.6 -class C:
5.7 - def f(self, a, b, c):
5.8 - pass
5.9 -
5.10 -c = C()
5.11 -
5.12 -f = c.f
5.13 -f(1, 2, 3)
5.14 -
5.15 -f = C.f
5.16 -f(c, 1, 2, 3)
5.17 -
5.18 -# vim: tabstop=4 expandtab shiftwidth=4
6.1 --- a/tests/call_method3.py Fri May 01 01:02:20 2009 +0200
6.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
6.3 @@ -1,12 +0,0 @@
6.4 -#!/usr/bin/env python
6.5 -
6.6 -class C:
6.7 - def f(self, a, b, c):
6.8 - pass
6.9 -
6.10 -c = C()
6.11 -
6.12 -f = C.f
6.13 -f(c, 1, 2, 3) # test self argument
6.14 -
6.15 -# vim: tabstop=4 expandtab shiftwidth=4
7.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
7.2 +++ b/tests/call_method_ref.py Fri May 01 02:38:05 2009 +0200
7.3 @@ -0,0 +1,14 @@
7.4 +#!/usr/bin/env python
7.5 +
7.6 +class C:
7.7 + def f(self, a, b, c):
7.8 + self.a = a
7.9 + self.b = b
7.10 + self.c = c
7.11 +
7.12 +c = C()
7.13 +
7.14 +f = c.f
7.15 +f(1, 2, 3)
7.16 +
7.17 +# vim: tabstop=4 expandtab shiftwidth=4
8.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
8.2 +++ b/tests/call_method_ref_internal.py Fri May 01 02:38:05 2009 +0200
8.3 @@ -0,0 +1,16 @@
8.4 +#!/usr/bin/env python
8.5 +
8.6 +class C:
8.7 + def f(self, a, b, c):
8.8 + m = self.g
8.9 + m(a, b, c)
8.10 +
8.11 + def g(self, a, b, c):
8.12 + self.a = a
8.13 + self.b = b
8.14 + self.c = c
8.15 +
8.16 +c = C()
8.17 +c.f(1, 2, 3)
8.18 +
8.19 +# vim: tabstop=4 expandtab shiftwidth=4
9.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
9.2 +++ b/tests/call_method_self.py Fri May 01 02:38:05 2009 +0200
9.3 @@ -0,0 +1,15 @@
9.4 +#!/usr/bin/env python
9.5 +
9.6 +class C:
9.7 + def f(self, a, b, c):
9.8 + self.g(a, b, c)
9.9 +
9.10 + def g(self, a, b, c):
9.11 + self.a = a
9.12 + self.b = b
9.13 + self.c = c
9.14 +
9.15 +c = C()
9.16 +c.f(1, 2, 3)
9.17 +
9.18 +# vim: tabstop=4 expandtab shiftwidth=4
10.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
10.2 +++ b/tests/call_method_via_class.py Fri May 01 02:38:05 2009 +0200
10.3 @@ -0,0 +1,14 @@
10.4 +#!/usr/bin/env python
10.5 +
10.6 +class C:
10.7 + def f(self, a, b, c):
10.8 + self.a = a
10.9 + self.b = b
10.10 + self.c = c
10.11 +
10.12 +c = C()
10.13 +
10.14 +f = C.f
10.15 +f(c, 1, 2, 3) # test self argument
10.16 +
10.17 +# vim: tabstop=4 expandtab shiftwidth=4
11.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
11.2 +++ b/tests/call_method_via_class_internal.py Fri May 01 02:38:05 2009 +0200
11.3 @@ -0,0 +1,15 @@
11.4 +#!/usr/bin/env python
11.5 +
11.6 +class C:
11.7 + def f(self, a, b, c):
11.8 + C.h(self, a, b, c)
11.9 +
11.10 + def h(self, a, b, c):
11.11 + self.a = a
11.12 + self.b = b
11.13 + self.c = c
11.14 +
11.15 +c = C()
11.16 +c.f(1, 2, 3)
11.17 +
11.18 +# vim: tabstop=4 expandtab shiftwidth=4