1.1 --- a/common.py Mon Jul 02 17:53:15 2018 +0200
1.2 +++ b/common.py Mon Jul 02 19:19:54 2018 +0200
1.3 @@ -4,7 +4,7 @@
1.4 Common functions.
1.5
1.6 Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013,
1.7 - 2014, 2015, 2016, 2017 Paul Boddie <paul@boddie.org.uk>
1.8 + 2014, 2015, 2016, 2017, 2018 Paul Boddie <paul@boddie.org.uk>
1.9
1.10 This program is free software; you can redistribute it and/or modify it under
1.11 the terms of the GNU General Public License as published by the Free Software
1.12 @@ -433,7 +433,7 @@
1.13 variable.
1.14 """
1.15
1.16 - assignments = []
1.17 + statements = []
1.18
1.19 # Employ existing names to access the sequence.
1.20 # Literal sequences do not provide names of accessible objects.
1.21 @@ -447,19 +447,25 @@
1.22 temp = self.get_temporary_name()
1.23 self.next_temporary()
1.24
1.25 - assignments.append(
1.26 + statements.append(
1.27 compiler.ast.Assign([compiler.ast.AssName(temp, "OP_ASSIGN")], expr)
1.28 )
1.29
1.30 + # Generate a test for the length of the expression object.
1.31 +
1.32 + statements.append(compiler.ast.Discard(
1.33 + compiler.ast.CallFunc(compiler.ast.Name("$seq_test_length"),
1.34 + [compiler.ast.Name(temp), compiler.ast.Const(len(n.nodes))])))
1.35 +
1.36 # Assign the items to the target nodes.
1.37
1.38 for i, node in enumerate(n.nodes):
1.39 - assignments.append(
1.40 + statements.append(
1.41 compiler.ast.Assign([node], compiler.ast.Subscript(
1.42 compiler.ast.Name(temp), "OP_APPLY", [compiler.ast.Const(i, str(i))]))
1.43 )
1.44
1.45 - return self.process_structure_node(compiler.ast.Stmt(assignments))
1.46 + return self.process_structure_node(compiler.ast.Stmt(statements))
1.47
1.48 def process_literal_sequence_items(self, n, name_ref):
1.49