annotate libinterp/parse-tree/pt-funcall.cc @ 20441:83792dd9bcc1

Use in-place operators in m-files where possible. * scripts/audio/@audioplayer/set.m, scripts/audio/@audiorecorder/set.m, scripts/audio/mu2lin.m, scripts/elfun/cosd.m, scripts/general/del2.m, scripts/general/profexplore.m, scripts/general/quadl.m, scripts/general/rat.m, scripts/general/rotdim.m, scripts/help/get_first_help_sentence.m, scripts/help/private/__strip_html_tags__.m, scripts/image/cubehelix.m, scripts/io/textread.m, scripts/linear-algebra/duplication_matrix.m, scripts/linear-algebra/housh.m, scripts/linear-algebra/krylov.m, scripts/linear-algebra/logm.m, scripts/linear-algebra/normest.m, scripts/linear-algebra/onenormest.m, scripts/optimization/fminsearch.m, scripts/optimization/lsqnonneg.m, scripts/optimization/qp.m, scripts/plot/appearance/annotation.m, scripts/plot/appearance/axis.m, scripts/plot/appearance/legend.m, scripts/plot/appearance/specular.m, scripts/plot/draw/colorbar.m, scripts/plot/draw/hist.m, scripts/plot/draw/plotmatrix.m, scripts/plot/draw/private/__stem__.m, scripts/plot/util/__actual_axis_position__.m, scripts/plot/util/__gnuplot_drawnow__.m, scripts/plot/util/findobj.m, scripts/plot/util/print.m, scripts/plot/util/private/__go_draw_axes__.m, scripts/plot/util/private/__print_parse_opts__.m, scripts/plot/util/rotate.m, scripts/polynomial/pchip.m, scripts/polynomial/polyaffine.m, scripts/polynomial/polyder.m, scripts/polynomial/private/__splinefit__.m, scripts/polynomial/residue.m, scripts/signal/arch_fit.m, scripts/signal/arch_rnd.m, scripts/signal/bartlett.m, scripts/signal/blackman.m, scripts/signal/freqz.m, scripts/signal/hamming.m, scripts/signal/hanning.m, scripts/signal/spectral_adf.m, scripts/signal/spectral_xdf.m, scripts/signal/stft.m, scripts/sparse/bicgstab.m, scripts/sparse/cgs.m, scripts/sparse/private/__sprand_impl__.m, scripts/sparse/qmr.m, scripts/sparse/sprandsym.m, scripts/sparse/svds.m, scripts/specfun/legendre.m, scripts/special-matrix/gallery.m, scripts/statistics/base/gls.m, scripts/statistics/models/logistic_regression.m, scripts/statistics/tests/kruskal_wallis_test.m, scripts/statistics/tests/manova.m, scripts/statistics/tests/wilcoxon_test.m, scripts/time/datevec.m: Use in-place operators in m-files where possible.
author Rik <rik@octave.org>
date Tue, 26 May 2015 21:07:42 -0700
parents 4197fc428c7d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15035
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1 /*
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2
19898
4197fc428c7d maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents: 18590
diff changeset
3 Copyright (C) 2012-2015 John W. Eaton
15035
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
4
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
5 This file is part of Octave.
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
6
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
7 Octave is free software; you can redistribute it and/or modify it
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
9 Free Software Foundation; either version 3 of the License, or (at your
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
10 option) any later version.
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
11
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
12 Octave is distributed in the hope that it will be useful, but WITHOUT
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
15 for more details.
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
16
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
18 along with Octave; see the file COPYING. If not, see
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
19 <http://www.gnu.org/licenses/>.
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
20
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
21 */
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
22
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
23 #ifdef HAVE_CONFIG_H
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
24 #include <config.h>
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
25 #endif
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
26
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
27 #include "ov-fcn.h"
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
28 #include "pt-funcall.h"
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
29 #include "pt-walk.h"
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
30
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
31 // Function call objects.
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
32
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
33 void
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
34 tree_funcall::print (std::ostream& os, bool pr_as_read_syntax,
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
35 bool pr_orig_text)
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
36 {
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
37 print_raw (os, pr_as_read_syntax, pr_orig_text);
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
38 }
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
39
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
40 void
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
41 tree_funcall::print_raw (std::ostream& os, bool pr_as_read_syntax,
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
42 bool pr_orig_text)
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
43 {
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
44 if (pr_orig_text)
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
45 {
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
46 os << original_text ();
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
47 }
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
48 else
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
49 {
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
50 octave_function *fp = fcn.function_value ();
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
51 std::string nm = fp ? fp->name () : std::string ("<invalid-function>");
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
52
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
53 os << nm << " (";
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
54
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
55 octave_idx_type len = args.length ();
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
56 for (octave_idx_type i = 0; i < len; i++)
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
57 {
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
58 args(i).print_raw (os, pr_as_read_syntax);
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
59
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
60 if (i < len - 1)
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
61 os << ", ";
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
62 }
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
63
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
64 os << ")";
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
65 }
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
66 }
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
67
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
68 tree_funcall *
18590
bae00174787c avoid GCC warnings
Lasse Schuirmann <lasse@schuirmann.net> and Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 18423
diff changeset
69 tree_funcall::dup (symbol_table::scope_id, symbol_table::context_id) const
15035
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
70 {
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
71 tree_funcall *new_fc = new tree_funcall (fcn, args, line (), column ());
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
72
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
73 new_fc->copy_base (*new_fc);
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
74
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
75 return new_fc;
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
76 }
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
77
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
78 void
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
79 tree_funcall::accept (tree_walker& tw)
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
80 {
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
81 tw.visit_funcall (*this);
a820a990968e new tree_funcall class
John W. Eaton <jwe@octave.org>
parents:
diff changeset
82 }
18423
9ca314e79956 Allow to call superclass constructor without arguments.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17746
diff changeset
83
9ca314e79956 Allow to call superclass constructor without arguments.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17746
diff changeset
84 octave_value_list
9ca314e79956 Allow to call superclass constructor without arguments.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17746
diff changeset
85 tree_funcall::rvalue (int nargout)
9ca314e79956 Allow to call superclass constructor without arguments.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17746
diff changeset
86 {
9ca314e79956 Allow to call superclass constructor without arguments.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17746
diff changeset
87 octave_value_list retval;
9ca314e79956 Allow to call superclass constructor without arguments.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17746
diff changeset
88
9ca314e79956 Allow to call superclass constructor without arguments.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17746
diff changeset
89 retval = feval (fcn.function_value (), args, nargout);
9ca314e79956 Allow to call superclass constructor without arguments.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17746
diff changeset
90
9ca314e79956 Allow to call superclass constructor without arguments.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17746
diff changeset
91 if (retval.length () == 1 && retval(0).is_function ())
9ca314e79956 Allow to call superclass constructor without arguments.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17746
diff changeset
92 {
9ca314e79956 Allow to call superclass constructor without arguments.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17746
diff changeset
93 // The return object is a function. We may need to re-index it using the
9ca314e79956 Allow to call superclass constructor without arguments.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17746
diff changeset
94 // same logic as for identifier. This is primarily used for superclass
9ca314e79956 Allow to call superclass constructor without arguments.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17746
diff changeset
95 // references in classdef.
9ca314e79956 Allow to call superclass constructor without arguments.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17746
diff changeset
96
9ca314e79956 Allow to call superclass constructor without arguments.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17746
diff changeset
97 octave_value val = retval(0);
9ca314e79956 Allow to call superclass constructor without arguments.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17746
diff changeset
98 octave_function *f = val.function_value (true);
9ca314e79956 Allow to call superclass constructor without arguments.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17746
diff changeset
99
9ca314e79956 Allow to call superclass constructor without arguments.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17746
diff changeset
100 if (f && ! (is_postfix_indexed ()
9ca314e79956 Allow to call superclass constructor without arguments.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17746
diff changeset
101 && f->is_postfix_index_handled (postfix_index ())))
9ca314e79956 Allow to call superclass constructor without arguments.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17746
diff changeset
102 {
9ca314e79956 Allow to call superclass constructor without arguments.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17746
diff changeset
103 octave_value_list tmp_args;
9ca314e79956 Allow to call superclass constructor without arguments.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17746
diff changeset
104
9ca314e79956 Allow to call superclass constructor without arguments.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17746
diff changeset
105 retval = val.do_multi_index_op (nargout, tmp_args);
9ca314e79956 Allow to call superclass constructor without arguments.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17746
diff changeset
106 }
9ca314e79956 Allow to call superclass constructor without arguments.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17746
diff changeset
107 }
9ca314e79956 Allow to call superclass constructor without arguments.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17746
diff changeset
108
9ca314e79956 Allow to call superclass constructor without arguments.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17746
diff changeset
109 return retval;
9ca314e79956 Allow to call superclass constructor without arguments.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 17746
diff changeset
110 }