Mercurial > octave
annotate libinterp/parse-tree/pt-colon.cc @ 27923:bd51beb6205e
update formatting of copyright notices
* Use <https://octave.org/copyright/> instead of
<https://octave.org/COPYRIGHT.html/>.
* For consistency with other comments in the Octave sources, use
C++-style comments for copyright blocks in C and C++ files.
* Use delimiters above and below copyright blocks that are appropriate
for the language used in the file.
* Eliminate extra spacing inside copyright blocks.
* lex.ll (looks_like_copyright): Also allow newlines and carriage
returns before the word "Copyright".
* scripts/mk-doc.pl (gethelp): Also skip empty comment lines.
* bp-table.cc, type.m: Adjust tests.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 08 Jan 2020 11:59:41 -0500 |
parents | 1891570abac8 |
children | d4563c5d4060 0a5b15007766 |
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 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
3 // Copyright (C) 1996-2020 The Octave Project Developers |
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 //////////////////////////////////////////////////////////////////////// |
2980 | 25 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
26 #if defined (HAVE_CONFIG_H) |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21200
diff
changeset
|
27 # include "config.h" |
2980 | 28 #endif |
29 | |
27371
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
30 #include "interpreter.h" |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
31 #include "parse.h" |
2980 | 32 #include "pt-colon.h" |
27371
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
33 #include "pt-eval.h" |
2980 | 34 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
35 namespace octave |
2980 | 36 { |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
37 // Colon expressions. |
2980 | 38 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
39 tree_expression * |
24270
bc3819b7cca1
don't use symbol_table:: nesting for symbol_record, symbol_scope, or fcn_info
John W. Eaton <jwe@octave.org>
parents:
23795
diff
changeset
|
40 tree_colon_expression::dup (symbol_scope& scope) const |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
41 { |
23655
bbcc1e08aaed
improve colon expression construction and avoid possible memory leak
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
42 tree_colon_expression *new_ce |
24846
7620f1f5290d
use m_ prefix for member variables in parse tree classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
43 = new tree_colon_expression (m_base ? m_base->dup (scope) : nullptr, |
7620f1f5290d
use m_ prefix for member variables in parse tree classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
44 m_limit ? m_limit->dup (scope) : nullptr, |
7620f1f5290d
use m_ prefix for member variables in parse tree classes
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
45 m_increment ? m_increment->dup (scope) : nullptr, |
23655
bbcc1e08aaed
improve colon expression construction and avoid possible memory leak
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
46 line (), column ()); |
5861 | 47 |
25814
a8a72d1c21dd
correctly copy base class for colon and funcall parse tree objects (bug #47091)
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
48 new_ce->copy_base (*this); |
5861 | 49 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
50 return new_ce; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
51 } |
27371
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
52 |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
53 octave_value tree_colon_expression::evaluate (tree_evaluator& tw, int) |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
54 { |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
55 octave_value val; |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
56 |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
57 if (! m_base || ! m_limit) |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
58 return val; |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
59 |
27374
d171d356767b
don't apply std::move to temporary values
John W. Eaton <jwe@octave.org>
parents:
27371
diff
changeset
|
60 octave_value ov_base = m_base->evaluate (tw); |
27371
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
61 |
27374
d171d356767b
don't apply std::move to temporary values
John W. Eaton <jwe@octave.org>
parents:
27371
diff
changeset
|
62 octave_value ov_limit = m_limit->evaluate (tw); |
27371
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
63 |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
64 if (ov_base.isobject () || ov_limit.isobject ()) |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
65 { |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
66 octave_value_list tmp1; |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
67 |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
68 if (m_increment) |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
69 { |
27374
d171d356767b
don't apply std::move to temporary values
John W. Eaton <jwe@octave.org>
parents:
27371
diff
changeset
|
70 octave_value ov_increment = m_increment->evaluate (tw); |
27371
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
71 |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
72 tmp1(2) = ov_limit; |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
73 tmp1(1) = ov_increment; |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
74 tmp1(0) = ov_base; |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
75 } |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
76 else |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
77 { |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
78 tmp1(1) = ov_limit; |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
79 tmp1(0) = ov_base; |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
80 } |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
81 |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
82 interpreter& interp = tw.get_interpreter (); |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
83 |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
84 symbol_table& symtab = interp.get_symbol_table (); |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
85 |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
86 octave_value fcn = symtab.find_function ("colon", tmp1); |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
87 |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
88 if (! fcn.is_defined ()) |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
89 error ("can not find overloaded colon function"); |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
90 |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
91 octave_value_list tmp2 = feval (fcn, tmp1, 1); |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
92 |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
93 val = tmp2 (0); |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
94 } |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
95 else |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
96 { |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
97 octave_value ov_increment = 1.0; |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
98 |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
99 if (m_increment) |
27374
d171d356767b
don't apply std::move to temporary values
John W. Eaton <jwe@octave.org>
parents:
27371
diff
changeset
|
100 ov_increment = m_increment->evaluate (tw); |
27371
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
101 |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
102 val = do_colon_op (ov_base, ov_increment, ov_limit, |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
103 is_for_cmd_expr ()); |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
104 } |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
105 |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
106 return val; |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
107 } |
2980 | 108 } |