Mercurial > octave
annotate libinterp/parse-tree/pt-colon.cc @ 31225:3eab70385569
sparse-xpow.cc: Use faster multiplication technique, this time for complex
author | Arun Giridhar <arungiridhar@gmail.com> |
---|---|
date | Sun, 11 Sep 2022 13:53:38 -0400 |
parents | 83f9f8bda883 |
children | e88a07dec498 |
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:
29359
diff
changeset
|
3 // Copyright (C) 1996-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 //////////////////////////////////////////////////////////////////////// |
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, |
30346
91c6288781ba
maint: Shorten some long lines in libinterp to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
45 m_increment ? m_increment->dup (scope) |
91c6288781ba
maint: Shorten some long lines in libinterp to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
46 : nullptr, |
23655
bbcc1e08aaed
improve colon expression construction and avoid possible memory leak
John W. Eaton <jwe@octave.org>
parents:
23602
diff
changeset
|
47 line (), column ()); |
5861 | 48 |
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
|
49 new_ce->copy_base (*this); |
5861 | 50 |
23075
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
51 return new_ce; |
4e3d47dc7e25
move parse tree classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
52 } |
27371
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
53 |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
54 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
|
55 { |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
56 octave_value val; |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
57 |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
58 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
|
59 return val; |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
60 |
28519
d4563c5d4060
handle all dispatching for colon operator in do_colon_op function
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
61 octave_value ov_base; |
d4563c5d4060
handle all dispatching for colon operator in do_colon_op function
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
62 octave_value ov_increment; |
d4563c5d4060
handle all dispatching for colon operator in do_colon_op function
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
63 octave_value ov_limit; |
27371
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
64 |
28519
d4563c5d4060
handle all dispatching for colon operator in do_colon_op function
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
65 if (m_increment) |
d4563c5d4060
handle all dispatching for colon operator in do_colon_op function
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
66 { |
d4563c5d4060
handle all dispatching for colon operator in do_colon_op function
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
67 ov_base = m_base->evaluate (tw); |
d4563c5d4060
handle all dispatching for colon operator in do_colon_op function
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
68 ov_increment = m_increment->evaluate (tw); |
d4563c5d4060
handle all dispatching for colon operator in do_colon_op function
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
69 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
|
70 } |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
71 else |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
72 { |
28519
d4563c5d4060
handle all dispatching for colon operator in do_colon_op function
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
73 ov_base = m_base->evaluate (tw); |
d4563c5d4060
handle all dispatching for colon operator in do_colon_op function
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
74 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
|
75 } |
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
76 |
28631
70cdf8de553d
move non-member octave_value operator functions to octave namespace
John W. Eaton <jwe@octave.org>
parents:
28519
diff
changeset
|
77 return colon_op (ov_base, ov_increment, ov_limit, is_for_cmd_expr ()); |
27371
fcaecdbc8d8a
don't use visitor pattern for expression evaluation (bug #56752)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
78 } |
2980 | 79 } |