1.1 --- a/common.py Mon Aug 03 00:06:08 2020 +0200
1.2 +++ b/common.py Mon Aug 03 00:06:46 2020 +0200
1.3 @@ -563,6 +563,8 @@
1.4 self.next_temporary()
1.5 t2 = self.get_temporary_name()
1.6 self.next_temporary()
1.7 + t3 = self.get_temporary_name()
1.8 + self.next_temporary()
1.9
1.10 node = compiler.ast.Stmt([
1.11
1.12 @@ -583,9 +585,10 @@
1.13 # try:
1.14 # while True:
1.15 # try:
1.16 - # <var>... = <t2>()
1.17 + # <t3> = <t2>()
1.18 # except StopIteration:
1.19 # raise LoopExit
1.20 + # <var>... = <t3>
1.21 # {n.body}
1.22 # except LoopExit:
1.23 # {n.else_}
1.24 @@ -595,21 +598,47 @@
1.25 [compiler.ast.AssName(t2, "OP_ASSIGN")],
1.26 compiler.ast.Getattr(compiler.ast.Name(t1), "next")),
1.27
1.28 + # try:
1.29 +
1.30 compiler.ast.TryExcept(
1.31 +
1.32 + # while True:
1.33 +
1.34 compiler.ast.While(
1.35 compiler.ast.Name("True"),
1.36 compiler.ast.Stmt([
1.37 +
1.38 + # try:
1.39 +
1.40 compiler.ast.TryExcept(
1.41 +
1.42 + # <t3> = <t2>()
1.43 +
1.44 compiler.ast.Assign(
1.45 - [n.assign],
1.46 + [compiler.ast.AssName(t3, "OP_ASSIGN")],
1.47 compiler.ast.CallFunc(
1.48 compiler.ast.Name(t2),
1.49 [])),
1.50 +
1.51 + # except StopIteration:
1.52 + # raise LoopExit
1.53 +
1.54 [(compiler.ast.Name("StopIteration"), None,
1.55 compiler.ast.Raise(compiler.ast.Name("LoopExit")))],
1.56 None),
1.57 +
1.58 + # <var>... = <t3>
1.59 +
1.60 + compiler.ast.Assign(
1.61 + [n.assign],
1.62 + compiler.ast.Name(t3)),
1.63 n.body]),
1.64 None),
1.65 +
1.66 + # except LoopExit:
1.67 + # {n.else_}
1.68 + # pass
1.69 +
1.70 [(compiler.ast.Name("LoopExit"), None, n.else_ or compiler.ast.Pass())],
1.71 None)
1.72 ])
2.1 --- a/docs/COPYING.txt Mon Aug 03 00:06:08 2020 +0200
2.2 +++ b/docs/COPYING.txt Mon Aug 03 00:06:46 2020 +0200
2.3 @@ -1,8 +1,8 @@
2.4 Licence Agreement
2.5 -----------------
2.6
2.7 -Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013,
2.8 - 2014, 2015, 2016, 2017 Paul Boddie <paul@boddie.org.uk>
2.9 +Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015,
2.10 + 2016, 2017, 2018, 2019 Paul Boddie <paul@boddie.org.uk>
2.11
2.12 This program is free software; you can redistribute it and/or modify it under
2.13 the terms of the GNU General Public License as published by the Free Software
3.1 --- a/inspector.py Mon Aug 03 00:06:08 2020 +0200
3.2 +++ b/inspector.py Mon Aug 03 00:06:46 2020 +0200
3.3 @@ -3,8 +3,8 @@
3.4 """
3.5 Inspect and obtain module structure.
3.6
3.7 -Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013,
3.8 - 2014, 2015, 2016, 2017, 2018 Paul Boddie <paul@boddie.org.uk>
3.9 +Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
3.10 + 2018, 2019 Paul Boddie <paul@boddie.org.uk>
3.11
3.12 This program is free software; you can redistribute it and/or modify it under
3.13 the terms of the GNU General Public License as published by the Free Software
3.14 @@ -659,6 +659,9 @@
3.15 self.function_defaults[function_name] = []
3.16
3.17 for argname, default in compiler.ast.get_defaults(n):
3.18 + if argname[0] == ".":
3.19 + argname = argname[1:]
3.20 +
3.21 if default:
3.22
3.23 # Obtain any reference for the default.
4.1 --- a/internal_tests/branches.py Mon Aug 03 00:06:08 2020 +0200
4.2 +++ b/internal_tests/branches.py Mon Aug 03 00:06:46 2020 +0200
4.3 @@ -687,4 +687,77 @@
4.4 bt.get_assignment_positions_for_branches("a", ar)
4.5 names.append(bt.assignments["a"])
4.6
4.7 +# This demonstrates why the assignment in a "for" loop construct must appear
4.8 +# outside the inner "try" body: null usage escapes the loop via the exception
4.9 +# handler and the raise statement, even though the assignment would only be
4.10 +# valid otherwise.
4.11 +
4.12 +# Equivalent to...
4.13 +#
4.14 +# try:
4.15 +# while ...:
4.16 +# try:
4.17 +# a = ...
4.18 +# except:
4.19 +# raise ...
4.20 +# a.p
4.21 +# except:
4.22 +# pass
4.23 +
4.24 +bt = branching.BranchTracker()
4.25 +bt.new_branchpoint() # begin (try)
4.26 +bt.new_branchpoint(True) # begin (while)
4.27 +bt.new_branch(True) # while ...
4.28 +bt.new_branchpoint() # begin (try)
4.29 +a = bt.assign_names(["a"])
4.30 +bt.resume_abandoned_branches() # except
4.31 +bt.abandon_branch() # raise
4.32 +bt.shelve_branch()
4.33 +bt.new_branch() # (null)
4.34 +bt.shelve_branch()
4.35 +bt.merge_branches() # end (try)
4.36 +ap = bt.use_attribute("a", "p")
4.37 +bt.resume_continuing_branches()
4.38 +bt.shelve_branch(True)
4.39 +bt.new_branch() # (null)
4.40 +bt.shelve_branch()
4.41 +bt.merge_branches() # end (while)
4.42 +bt.resume_broken_branches()
4.43 +bt.resume_abandoned_branches() # except
4.44 +bt.shelve_branch()
4.45 +bt.new_branch() # (null)
4.46 +bt.shelve_branch()
4.47 +bt.merge_branches() # end (try)
4.48 +
4.49 +print simple_usage(a) == \
4.50 + {'a' : set([('p',), ()])}, simple_usage(a)
4.51 +print bt.get_assignment_positions_for_branches("a", ap) == [0], \
4.52 + bt.get_assignment_positions_for_branches("a", ap)
4.53 +names.append(bt.assignments["a"])
4.54 +
4.55 +# Equivalent to...
4.56 +#
4.57 +# b = ...
4.58 +# while ...:
4.59 +# a = ...
4.60 +# a.p
4.61 +
4.62 +bt = branching.BranchTracker()
4.63 +bt.new_branchpoint(True) # begin
4.64 +b = bt.assign_names(["b"])
4.65 +bt.new_branch(True) # while ...
4.66 +a = bt.assign_names(["a"])
4.67 +ap = bt.use_attribute("a", "p")
4.68 +bt.resume_continuing_branches()
4.69 +bt.shelve_branch(True)
4.70 +bt.new_branch() # (null)
4.71 +bt.shelve_branch()
4.72 +bt.merge_branches() # end
4.73 +
4.74 +print simple_usage(a) == \
4.75 + {'a' : set([('p',)])}, simple_usage(a)
4.76 +print bt.get_assignment_positions_for_branches("a", ap) == [0], \
4.77 + bt.get_assignment_positions_for_branches("a", ap)
4.78 +names.append(bt.assignments["a"])
4.79 +
4.80 # vim: tabstop=4 expandtab shiftwidth=4
5.1 --- a/lib/__builtins__/exception/base.py Mon Aug 03 00:06:08 2020 +0200
5.2 +++ b/lib/__builtins__/exception/base.py Mon Aug 03 00:06:46 2020 +0200
5.3 @@ -71,7 +71,11 @@
5.4
5.5 "An exception signalling the end of iteration."
5.6
5.7 - pass
5.8 + def __init__(self, .iterator=None):
5.9 +
5.10 + "Initialise the exception with the given 'iterator'."
5.11 +
5.12 + pass
5.13
5.14 class ValueError(Exception):
5.15
6.1 --- a/lib/__builtins__/iteration/iterator.py Mon Aug 03 00:06:08 2020 +0200
6.2 +++ b/lib/__builtins__/iteration/iterator.py Mon Aug 03 00:06:46 2020 +0200
6.3 @@ -3,7 +3,7 @@
6.4 """
6.5 Iterator objects.
6.6
6.7 -Copyright (C) 2015, 2016 Paul Boddie <paul@boddie.org.uk>
6.8 +Copyright (C) 2015, 2016, 2019 Paul Boddie <paul@boddie.org.uk>
6.9
6.10 This program is free software; you can redistribute it and/or modify it under
6.11 the terms of the GNU General Public License as published by the Free Software
6.12 @@ -39,6 +39,6 @@
6.13 self.i += 1
6.14 return value
6.15 except IndexError:
6.16 - raise StopIteration()
6.17 + raise StopIteration, self
6.18
6.19 # vim: tabstop=4 expandtab shiftwidth=4
7.1 --- a/lib/__builtins__/set.py Mon Aug 03 00:06:08 2020 +0200
7.2 +++ b/lib/__builtins__/set.py Mon Aug 03 00:06:46 2020 +0200
7.3 @@ -3,7 +3,7 @@
7.4 """
7.5 Set objects.
7.6
7.7 -Copyright (C) 2015, 2016, 2017 Paul Boddie <paul@boddie.org.uk>
7.8 +Copyright (C) 2015, 2016, 2017, 2019 Paul Boddie <paul@boddie.org.uk>
7.9
7.10 This program is free software; you can redistribute it and/or modify it under
7.11 the terms of the GNU General Public License as published by the Free Software
7.12 @@ -323,7 +323,7 @@
7.13 try:
7.14 bucket = self.mapping.buckets[self.index]
7.15 except IndexError:
7.16 - raise StopIteration
7.17 + raise StopIteration, self
7.18
7.19 # Access the current item. If no such item exists, get another
7.20 # bucket.
8.1 --- a/lib/__builtins__/span.py Mon Aug 03 00:06:08 2020 +0200
8.2 +++ b/lib/__builtins__/span.py Mon Aug 03 00:06:46 2020 +0200
8.3 @@ -3,7 +3,7 @@
8.4 """
8.5 Span-related objects.
8.6
8.7 -Copyright (C) 2015, 2016, 2017, 2018 Paul Boddie <paul@boddie.org.uk>
8.8 +Copyright (C) 2015, 2016, 2017, 2018, 2019 Paul Boddie <paul@boddie.org.uk>
8.9
8.10 This program is free software; you can redistribute it and/or modify it under
8.11 the terms of the GNU General Public License as published by the Free Software
8.12 @@ -101,7 +101,7 @@
8.13 "Return the next item or raise a StopIteration exception."
8.14
8.15 if not self.count:
8.16 - raise StopIteration
8.17 + raise StopIteration, self
8.18
8.19 current = self.current
8.20 self.current = self.current.__add__(self.step)
9.1 --- a/templates/types.h Mon Aug 03 00:06:08 2020 +0200
9.2 +++ b/templates/types.h Mon Aug 03 00:06:46 2020 +0200
9.3 @@ -127,8 +127,8 @@
9.4
9.5 #define __INTVALUE(VALUE) ((__attr) {.intvalue=((VALUE) << __NUM_TAG_BITS) | __TAG_INT})
9.6 #define __TOINT(ATTR) ((ATTR).intvalue >> __NUM_TAG_BITS)
9.7 -#define __MAXINT ((1 << ((sizeof(__attr) * 8) - 1 - __NUM_TAG_BITS)) - 1)
9.8 -#define __MININT (-(1 << ((sizeof(__attr) * 8) - 1 - __NUM_TAG_BITS)))
9.9 +#define __MAXINT ((1 << ((sizeof(int) * 8) - 1 - __NUM_TAG_BITS)) - 1)
9.10 +#define __MININT (-(1 << ((sizeof(int) * 8) - 1 - __NUM_TAG_BITS)))
9.11
9.12 /* Argument lists. */
9.13