1.1 --- a/micropython/ast.py Sun May 17 23:50:20 2009 +0200
1.2 +++ b/micropython/ast.py Mon May 18 23:56:12 2009 +0200
1.3 @@ -608,7 +608,7 @@
1.4 ndefaults = len(fn.defaults)
1.5
1.6 self.new_op(CheckFrame((nparams, ndefaults, fn.has_star)))
1.7 - self.new_op(FillDefaults((nparams, ndefaults)))
1.8 + self.new_op(FillDefaults((nparams, ndefaults, fn)))
1.9
1.10 # Produce the body.
1.11
1.12 @@ -677,7 +677,7 @@
1.13 ndefaults = len(fn.defaults)
1.14
1.15 self.new_op(CheckFrame((nparams, ndefaults, fn.has_star)))
1.16 - self.new_op(FillDefaults((nparams, ndefaults)))
1.17 + self.new_op(FillDefaults((nparams, ndefaults, fn)))
1.18
1.19 # Produce the body.
1.20
2.1 --- a/rsvp.py Sun May 17 23:50:20 2009 +0200
2.2 +++ b/rsvp.py Mon May 18 23:56:12 2009 +0200
2.3 @@ -484,7 +484,9 @@
2.4
2.5 def LoadContext(self):
2.6 context, ref = self.value
2.7 - self.value = None, context # context of context is not interesting
2.8 + # NOTE: Omission of the context of the context would make things like
2.9 + # NOTE: self() inside methods impossible.
2.10 + self.value = context, context
2.11
2.12 def CheckFrame(self):
2.13 (nargs, ndefaults, has_star) = self.operand
2.14 @@ -514,7 +516,9 @@
2.15 raise Exception, "CheckFrame %r (%r <= %r <= %r)" % (self.operand, nargs - ndefaults, nlocals, nargs)
2.16
2.17 def FillDefaults(self):
2.18 - (nargs, ndefaults) = self.operand
2.19 + # NOTE: Make the get_operand method of the instruction provide the
2.20 + # NOTE: function location.
2.21 + (nargs, ndefaults, fn) = self.operand
2.22
2.23 # The frame is actually installed as the locals.
2.24
2.25 @@ -527,6 +531,7 @@
2.26 default = nlocals - (nargs - ndefaults)
2.27 self.frame_stack.extend([None] * (nargs - nlocals))
2.28 pos = nlocals
2.29 + ref = fn.location
2.30
2.31 while pos < nargs:
2.32 self.frame_stack[frame + pos] = self.load(ref + default + 1) # skip header
3.1 --- a/tests/call_func_default_keyword.py Sun May 17 23:50:20 2009 +0200
3.2 +++ b/tests/call_func_default_keyword.py Mon May 18 23:56:12 2009 +0200
3.3 @@ -1,11 +1,11 @@
3.4 #!/usr/bin/env python
3.5
3.6 def f(a, b, c=4):
3.7 - pass
3.8 + return c
3.9
3.10 -f(1, 2, 3)
3.11 -f(1, b=2, c=3)
3.12 -f(c=3, b=2, a=1)
3.13 -f(1, 2)
3.14 +p = f(1, 2, 3)
3.15 +q = f(1, b=2, c=3)
3.16 +r = f(c=3, b=2, a=1)
3.17 +s = f(1, 2)
3.18
3.19 # vim: tabstop=4 expandtab shiftwidth=4
4.1 --- a/tests/call_func_default_redefine.py Sun May 17 23:50:20 2009 +0200
4.2 +++ b/tests/call_func_default_redefine.py Mon May 18 23:56:12 2009 +0200
4.3 @@ -4,13 +4,13 @@
4.4 return c
4.5
4.6 g = f
4.7 -r1 = g(1, c=3, b=2)
4.8 -r2 = g(1, 2)
4.9 +r1 = g(1, c=3, b=2) # -> 3
4.10 +r2 = g(1, 2) # -> 4
4.11
4.12 def g(a, c, b=5):
4.13 return b
4.14
4.15 -r3 = g(1, c=3, b=2)
4.16 -r4 = g(1, 3)
4.17 +r3 = g(1, c=3, b=2) # -> 2
4.18 +r4 = g(1, 3) # -> 5
4.19
4.20 # vim: tabstop=4 expandtab shiftwidth=4