annotate libinterp/parse-tree/anon-fcn-validator.cc @ 30564:796f54d4ddbf stable

update Octave Project Developers copyright for the new year In files that have the "Octave Project Developers" copyright notice, update for 2021. In all .txi and .texi files except gpl.txi and gpl.texi in the doc/liboctave and doc/interpreter directories, change the copyright to "Octave Project Developers", the same as used for other source files. Update copyright notices for 2022 (not done since 2019). For gpl.txi and gpl.texi, change the copyright notice to be "Free Software Foundation, Inc." and leave the date at 2007 only because this file only contains the text of the GPL, not anything created by the Octave Project Developers. Add Paul Thomas to contributors.in.
author John W. Eaton <jwe@octave.org>
date Tue, 28 Dec 2021 18:22:40 -0500
parents 0a5b15007766
children e88a07dec498
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
1 ////////////////////////////////////////////////////////////////////////
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
2 //
30564
796f54d4ddbf update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
3 // Copyright (C) 2019-2022 The Octave Project Developers
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
4 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
5 // See the file COPYRIGHT.md in the top-level directory of this
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
6 // distribution or <https://octave.org/copyright/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
7 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
8 // This file is part of Octave.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
9 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
10 // Octave is free software: you can redistribute it and/or modify it
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
11 // under the terms of the GNU General Public License as published by
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
12 // the Free Software Foundation, either version 3 of the License, or
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
13 // (at your option) any later version.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
14 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
15 // Octave is distributed in the hope that it will be useful, but
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
18 // GNU General Public License for more details.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
19 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
20 // You should have received a copy of the GNU General Public License
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
21 // along with Octave; see the file COPYING. If not, see
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
22 // <https://www.gnu.org/licenses/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
23 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
24 ////////////////////////////////////////////////////////////////////////
27728
5e92bff668d6 disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
25
5e92bff668d6 disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
26 #if defined (HAVE_CONFIG_H)
5e92bff668d6 disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
27 # include "config.h"
5e92bff668d6 disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
28 #endif
5e92bff668d6 disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
29
5e92bff668d6 disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
30 #include <string>
5e92bff668d6 disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
31
5e92bff668d6 disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
32 #include "anon-fcn-validator.h"
5e92bff668d6 disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
33 #include "ov.h"
5e92bff668d6 disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
34 #include "pt-all.h"
5e92bff668d6 disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
35
5e92bff668d6 disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
36 namespace octave
5e92bff668d6 disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
37 {
5e92bff668d6 disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
38 anon_fcn_validator::anon_fcn_validator (tree_parameter_list *,
5e92bff668d6 disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
39 tree_expression *expr)
5e92bff668d6 disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
40 : m_ok (true), m_line (-1), m_column (-1), m_message ()
5e92bff668d6 disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
41 {
5e92bff668d6 disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
42 expr->accept (*this);
5e92bff668d6 disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
43 }
5e92bff668d6 disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
44
5e92bff668d6 disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
45 void anon_fcn_validator::visit_postfix_expression (tree_postfix_expression& expr)
5e92bff668d6 disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
46 {
5e92bff668d6 disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
47 octave_value::unary_op op = expr.op_type ();
5e92bff668d6 disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
48
5e92bff668d6 disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
49 if (op == octave_value::op_incr || op == octave_value::op_decr)
5e92bff668d6 disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
50 error (expr);
5e92bff668d6 disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
51 else
5e92bff668d6 disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
52 tree_walker::visit_postfix_expression (expr);
5e92bff668d6 disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
53 }
5e92bff668d6 disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
54
5e92bff668d6 disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
55 void anon_fcn_validator::visit_prefix_expression (tree_prefix_expression& expr)
5e92bff668d6 disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
56 {
5e92bff668d6 disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
57 octave_value::unary_op op = expr.op_type ();
5e92bff668d6 disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
58
5e92bff668d6 disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
59 if (op == octave_value::op_incr || op == octave_value::op_decr)
5e92bff668d6 disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
60 error (expr);
5e92bff668d6 disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
61 else
5e92bff668d6 disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
62 tree_walker::visit_prefix_expression (expr);
5e92bff668d6 disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
63 }
5e92bff668d6 disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
64
5e92bff668d6 disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
65 void anon_fcn_validator::visit_multi_assignment (tree_multi_assignment& expr)
5e92bff668d6 disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
66 {
5e92bff668d6 disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
67 error (expr);
5e92bff668d6 disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
68 }
5e92bff668d6 disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
69
5e92bff668d6 disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
70 void anon_fcn_validator::visit_simple_assignment (tree_simple_assignment& expr)
5e92bff668d6 disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
71 {
5e92bff668d6 disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
72 error (expr);
5e92bff668d6 disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
73 }
5e92bff668d6 disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
74
5e92bff668d6 disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
75 void anon_fcn_validator::error (tree_expression& expr)
5e92bff668d6 disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
76 {
5e92bff668d6 disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
77 m_ok = false;
5e92bff668d6 disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
78 m_line = expr.line ();
5e92bff668d6 disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
79 m_column = expr.column ();
5e92bff668d6 disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
80 m_message
5e92bff668d6 disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
81 = "invalid use of operator " + expr.oper () + " in anonymous function";
5e92bff668d6 disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
82 }
5e92bff668d6 disallow lvalue references in anonymous functions (bug #57255)
John W. Eaton <jwe@octave.org>
parents:
diff changeset
83 }