Mercurial > octave-antonio
annotate libinterp/octave-value/ov-usr-fcn.cc @ 17787:175b392e91fe
Use GNU style coding conventions for code in libinterp/
* libinterp/corefcn/Cell.h, libinterp/corefcn/__contourc__.cc,
libinterp/corefcn/__dispatch__.cc, libinterp/corefcn/__lin_interpn__.cc,
libinterp/corefcn/__pchip_deriv__.cc, libinterp/corefcn/__qp__.cc,
libinterp/corefcn/balance.cc, libinterp/corefcn/besselj.cc,
libinterp/corefcn/betainc.cc, libinterp/corefcn/bitfcns.cc,
libinterp/corefcn/bsxfun.cc, libinterp/corefcn/c-file-ptr-stream.cc,
libinterp/corefcn/c-file-ptr-stream.h, libinterp/corefcn/cellfun.cc,
libinterp/corefcn/colloc.cc, libinterp/corefcn/comment-list.h,
libinterp/corefcn/conv2.cc, libinterp/corefcn/daspk.cc,
libinterp/corefcn/dasrt.cc, libinterp/corefcn/dassl.cc,
libinterp/corefcn/data.cc, libinterp/corefcn/debug.cc,
libinterp/corefcn/defaults.cc, libinterp/corefcn/defaults.in.h,
libinterp/corefcn/defun-int.h, libinterp/corefcn/defun.cc,
libinterp/corefcn/det.cc, libinterp/corefcn/dirfns.cc,
libinterp/corefcn/display.cc, libinterp/corefcn/dlmread.cc,
libinterp/corefcn/dot.cc, libinterp/corefcn/dynamic-ld.cc,
libinterp/corefcn/dynamic-ld.h, libinterp/corefcn/eig.cc,
libinterp/corefcn/ellipj.cc, libinterp/corefcn/error.cc,
libinterp/corefcn/error.h, libinterp/corefcn/event-queue.h,
libinterp/corefcn/fft.cc, libinterp/corefcn/fft2.cc, libinterp/corefcn/fftn.cc,
libinterp/corefcn/file-io.cc, libinterp/corefcn/filter.cc,
libinterp/corefcn/find.cc, libinterp/corefcn/gammainc.cc,
libinterp/corefcn/gcd.cc, libinterp/corefcn/getgrent.cc,
libinterp/corefcn/getpwent.cc, libinterp/corefcn/getrusage.cc,
libinterp/corefcn/givens.cc, libinterp/corefcn/gl-render.cc,
libinterp/corefcn/gl2ps-renderer.cc, libinterp/corefcn/gl2ps-renderer.h,
libinterp/corefcn/graphics.cc, libinterp/corefcn/graphics.in.h,
libinterp/corefcn/gripes.cc, libinterp/corefcn/gripes.h,
libinterp/corefcn/help.cc, libinterp/corefcn/hess.cc,
libinterp/corefcn/hex2num.cc, libinterp/corefcn/input.cc,
libinterp/corefcn/input.h, libinterp/corefcn/inv.cc,
libinterp/corefcn/jit-ir.h, libinterp/corefcn/jit-typeinfo.cc,
libinterp/corefcn/jit-typeinfo.h, libinterp/corefcn/jit-util.h,
libinterp/corefcn/kron.cc, libinterp/corefcn/load-path.cc,
libinterp/corefcn/load-path.h, libinterp/corefcn/load-save.cc,
libinterp/corefcn/load-save.h, libinterp/corefcn/lookup.cc,
libinterp/corefcn/ls-ascii-helper.cc, libinterp/corefcn/ls-hdf5.cc,
libinterp/corefcn/ls-hdf5.h, libinterp/corefcn/ls-mat-ascii.cc,
libinterp/corefcn/ls-mat-ascii.h, libinterp/corefcn/ls-mat4.cc,
libinterp/corefcn/ls-mat5.cc, libinterp/corefcn/ls-mat5.h,
libinterp/corefcn/ls-oct-ascii.cc, libinterp/corefcn/lsode.cc,
libinterp/corefcn/lu.cc, libinterp/corefcn/luinc.cc,
libinterp/corefcn/mappers.cc, libinterp/corefcn/matrix_type.cc,
libinterp/corefcn/max.cc, libinterp/corefcn/md5sum.cc,
libinterp/corefcn/mex.cc, libinterp/corefcn/mexproto.h,
libinterp/corefcn/mgorth.cc, libinterp/corefcn/mxarray.in.h,
libinterp/corefcn/nproc.cc, libinterp/corefcn/oct-hist.cc,
libinterp/corefcn/oct-lvalue.h, libinterp/corefcn/oct-map.cc,
libinterp/corefcn/oct-map.h, libinterp/corefcn/oct-obj.h,
libinterp/corefcn/oct-prcstrm.h, libinterp/corefcn/oct-stdstrm.h,
libinterp/corefcn/oct-stream.cc, libinterp/corefcn/oct-stream.h,
libinterp/corefcn/octave-link.cc, libinterp/corefcn/octave-link.h,
libinterp/corefcn/pager.cc, libinterp/corefcn/pinv.cc,
libinterp/corefcn/pr-output.cc, libinterp/corefcn/procstream.h,
libinterp/corefcn/profiler.cc, libinterp/corefcn/pt-jit.cc,
libinterp/corefcn/pt-jit.h, libinterp/corefcn/quad.cc,
libinterp/corefcn/quadcc.cc, libinterp/corefcn/qz.cc,
libinterp/corefcn/rand.cc, libinterp/corefcn/rcond.cc,
libinterp/corefcn/regexp.cc, libinterp/corefcn/schur.cc,
libinterp/corefcn/sighandlers.cc, libinterp/corefcn/sighandlers.h,
libinterp/corefcn/sparse-xdiv.cc, libinterp/corefcn/sparse-xdiv.h,
libinterp/corefcn/sparse-xpow.cc, libinterp/corefcn/sparse.cc,
libinterp/corefcn/spparms.cc, libinterp/corefcn/sqrtm.cc,
libinterp/corefcn/str2double.cc, libinterp/corefcn/strfind.cc,
libinterp/corefcn/strfns.cc, libinterp/corefcn/sub2ind.cc,
libinterp/corefcn/svd.cc, libinterp/corefcn/syl.cc,
libinterp/corefcn/symtab.cc, libinterp/corefcn/symtab.h,
libinterp/corefcn/syscalls.cc, libinterp/corefcn/sysdep.cc,
libinterp/corefcn/sysdep.h, libinterp/corefcn/time.cc,
libinterp/corefcn/toplev.cc, libinterp/corefcn/toplev.h,
libinterp/corefcn/tril.cc, libinterp/corefcn/txt-eng-ft.cc,
libinterp/corefcn/txt-eng-ft.h, libinterp/corefcn/txt-eng.h,
libinterp/corefcn/typecast.cc, libinterp/corefcn/urlwrite.cc,
libinterp/corefcn/utils.cc, libinterp/corefcn/variables.cc,
libinterp/corefcn/variables.h, libinterp/corefcn/xdiv.cc,
libinterp/corefcn/xdiv.h, libinterp/corefcn/xnorm.h, libinterp/corefcn/xpow.cc,
libinterp/corefcn/xpow.h, libinterp/corefcn/zfstream.cc,
libinterp/corefcn/zfstream.h, libinterp/dldfcn/__delaunayn__.cc,
libinterp/dldfcn/__dsearchn__.cc, libinterp/dldfcn/__eigs__.cc,
libinterp/dldfcn/__fltk_uigetfile__.cc, libinterp/dldfcn/__glpk__.cc,
libinterp/dldfcn/__init_fltk__.cc, libinterp/dldfcn/__init_gnuplot__.cc,
libinterp/dldfcn/__magick_read__.cc, libinterp/dldfcn/__voronoi__.cc,
libinterp/dldfcn/amd.cc, libinterp/dldfcn/ccolamd.cc, libinterp/dldfcn/chol.cc,
libinterp/dldfcn/colamd.cc, libinterp/dldfcn/convhulln.cc,
libinterp/dldfcn/dmperm.cc, libinterp/dldfcn/fftw.cc, libinterp/dldfcn/qr.cc,
libinterp/dldfcn/symbfact.cc, libinterp/dldfcn/symrcm.cc,
libinterp/dldfcn/tsearch.cc, libinterp/octave-value/ov-base-diag.cc,
libinterp/octave-value/ov-base-diag.h, libinterp/octave-value/ov-base-int.cc,
libinterp/octave-value/ov-base-int.h, libinterp/octave-value/ov-base-mat.h,
libinterp/octave-value/ov-base-scalar.cc,
libinterp/octave-value/ov-base-scalar.h,
libinterp/octave-value/ov-base-sparse.cc,
libinterp/octave-value/ov-base-sparse.h, libinterp/octave-value/ov-base.cc,
libinterp/octave-value/ov-base.h, libinterp/octave-value/ov-bool-mat.cc,
libinterp/octave-value/ov-bool-mat.h, libinterp/octave-value/ov-bool-sparse.cc,
libinterp/octave-value/ov-bool-sparse.h, libinterp/octave-value/ov-bool.cc,
libinterp/octave-value/ov-bool.h, libinterp/octave-value/ov-builtin.cc,
libinterp/octave-value/ov-builtin.h, libinterp/octave-value/ov-cell.cc,
libinterp/octave-value/ov-cell.h, libinterp/octave-value/ov-ch-mat.cc,
libinterp/octave-value/ov-ch-mat.h, libinterp/octave-value/ov-class.cc,
libinterp/octave-value/ov-class.h, libinterp/octave-value/ov-colon.h,
libinterp/octave-value/ov-complex.cc, libinterp/octave-value/ov-complex.h,
libinterp/octave-value/ov-cx-diag.cc, libinterp/octave-value/ov-cx-diag.h,
libinterp/octave-value/ov-cx-mat.cc, libinterp/octave-value/ov-cx-mat.h,
libinterp/octave-value/ov-cx-sparse.cc, libinterp/octave-value/ov-cx-sparse.h,
libinterp/octave-value/ov-dld-fcn.h, libinterp/octave-value/ov-fcn-handle.cc,
libinterp/octave-value/ov-fcn-handle.h,
libinterp/octave-value/ov-fcn-inline.cc,
libinterp/octave-value/ov-fcn-inline.h, libinterp/octave-value/ov-fcn.h,
libinterp/octave-value/ov-float.cc, libinterp/octave-value/ov-float.h,
libinterp/octave-value/ov-flt-complex.cc,
libinterp/octave-value/ov-flt-complex.h,
libinterp/octave-value/ov-flt-cx-diag.cc,
libinterp/octave-value/ov-flt-cx-diag.h,
libinterp/octave-value/ov-flt-cx-mat.cc,
libinterp/octave-value/ov-flt-cx-mat.h,
libinterp/octave-value/ov-flt-re-diag.cc,
libinterp/octave-value/ov-flt-re-diag.h,
libinterp/octave-value/ov-flt-re-mat.cc,
libinterp/octave-value/ov-flt-re-mat.h, libinterp/octave-value/ov-int16.cc,
libinterp/octave-value/ov-int32.cc, libinterp/octave-value/ov-int64.cc,
libinterp/octave-value/ov-int8.cc, libinterp/octave-value/ov-intx.h,
libinterp/octave-value/ov-java.cc, libinterp/octave-value/ov-lazy-idx.h,
libinterp/octave-value/ov-mex-fcn.cc, libinterp/octave-value/ov-mex-fcn.h,
libinterp/octave-value/ov-null-mat.cc, libinterp/octave-value/ov-null-mat.h,
libinterp/octave-value/ov-oncleanup.cc, libinterp/octave-value/ov-perm.cc,
libinterp/octave-value/ov-perm.h, libinterp/octave-value/ov-range.cc,
libinterp/octave-value/ov-range.h, libinterp/octave-value/ov-re-diag.cc,
libinterp/octave-value/ov-re-diag.h, libinterp/octave-value/ov-re-mat.cc,
libinterp/octave-value/ov-re-mat.h, libinterp/octave-value/ov-re-sparse.cc,
libinterp/octave-value/ov-re-sparse.h, libinterp/octave-value/ov-scalar.cc,
libinterp/octave-value/ov-scalar.h, libinterp/octave-value/ov-str-mat.cc,
libinterp/octave-value/ov-str-mat.h, libinterp/octave-value/ov-struct.cc,
libinterp/octave-value/ov-struct.h, libinterp/octave-value/ov-type-conv.h,
libinterp/octave-value/ov-typeinfo.cc, libinterp/octave-value/ov-typeinfo.h,
libinterp/octave-value/ov-uint16.cc, libinterp/octave-value/ov-uint32.cc,
libinterp/octave-value/ov-uint64.cc, libinterp/octave-value/ov-uint8.cc,
libinterp/octave-value/ov-usr-fcn.cc, libinterp/octave-value/ov-usr-fcn.h,
libinterp/octave-value/ov.cc, libinterp/octave-value/ov.h, libinterp/octave.cc,
libinterp/operators/op-b-bm.cc, libinterp/operators/op-b-sbm.cc,
libinterp/operators/op-bm-b.cc, libinterp/operators/op-bm-bm.cc,
libinterp/operators/op-cdm-cdm.cc, libinterp/operators/op-chm.cc,
libinterp/operators/op-class.cc, libinterp/operators/op-cm-cm.cc,
libinterp/operators/op-cm-cs.cc, libinterp/operators/op-cm-s.cc,
libinterp/operators/op-cm-scm.cc, libinterp/operators/op-cm-sm.cc,
libinterp/operators/op-cs-cm.cc, libinterp/operators/op-cs-cs.cc,
libinterp/operators/op-cs-scm.cc, libinterp/operators/op-cs-sm.cc,
libinterp/operators/op-dm-dm.cc, libinterp/operators/op-dm-scm.cc,
libinterp/operators/op-double-conv.cc, libinterp/operators/op-fcdm-fcdm.cc,
libinterp/operators/op-fcm-fcm.cc, libinterp/operators/op-fcm-fcs.cc,
libinterp/operators/op-fcm-fm.cc, libinterp/operators/op-fcm-fs.cc,
libinterp/operators/op-fcs-fcm.cc, libinterp/operators/op-fcs-fcs.cc,
libinterp/operators/op-fcs-fm.cc, libinterp/operators/op-fcs-fs.cc,
libinterp/operators/op-fdm-fdm.cc, libinterp/operators/op-float-conv.cc,
libinterp/operators/op-fm-fcm.cc, libinterp/operators/op-fm-fcs.cc,
libinterp/operators/op-fm-fm.cc, libinterp/operators/op-fm-fs.cc,
libinterp/operators/op-fs-fcm.cc, libinterp/operators/op-fs-fcs.cc,
libinterp/operators/op-fs-fm.cc, libinterp/operators/op-fs-fs.cc,
libinterp/operators/op-m-cm.cc, libinterp/operators/op-m-cs.cc,
libinterp/operators/op-m-m.cc, libinterp/operators/op-m-s.cc,
libinterp/operators/op-m-scm.cc, libinterp/operators/op-m-sm.cc,
libinterp/operators/op-pm-scm.cc, libinterp/operators/op-range.cc,
libinterp/operators/op-s-cm.cc, libinterp/operators/op-s-cs.cc,
libinterp/operators/op-s-scm.cc, libinterp/operators/op-sbm-b.cc,
libinterp/operators/op-sbm-bm.cc, libinterp/operators/op-sbm-sbm.cc,
libinterp/operators/op-scm-cm.cc, libinterp/operators/op-scm-cs.cc,
libinterp/operators/op-scm-m.cc, libinterp/operators/op-scm-s.cc,
libinterp/operators/op-scm-scm.cc, libinterp/operators/op-scm-sm.cc,
libinterp/operators/op-sm-cm.cc, libinterp/operators/op-sm-m.cc,
libinterp/operators/op-sm-s.cc, libinterp/operators/op-sm-scm.cc,
libinterp/operators/op-sm-sm.cc, libinterp/operators/op-str-m.cc,
libinterp/operators/op-str-s.cc, libinterp/operators/op-str-str.cc,
libinterp/operators/ops.h, libinterp/parse-tree/lex.h,
libinterp/parse-tree/parse.h, libinterp/parse-tree/pt-arg-list.cc,
libinterp/parse-tree/pt-arg-list.h, libinterp/parse-tree/pt-assign.cc,
libinterp/parse-tree/pt-assign.h, libinterp/parse-tree/pt-binop.cc,
libinterp/parse-tree/pt-binop.h, libinterp/parse-tree/pt-bp.h,
libinterp/parse-tree/pt-cbinop.cc, libinterp/parse-tree/pt-check.cc,
libinterp/parse-tree/pt-colon.cc, libinterp/parse-tree/pt-colon.h,
libinterp/parse-tree/pt-const.cc, libinterp/parse-tree/pt-decl.cc,
libinterp/parse-tree/pt-decl.h, libinterp/parse-tree/pt-eval.cc,
libinterp/parse-tree/pt-except.h, libinterp/parse-tree/pt-exp.h,
libinterp/parse-tree/pt-fcn-handle.cc, libinterp/parse-tree/pt-id.cc,
libinterp/parse-tree/pt-id.h, libinterp/parse-tree/pt-idx.cc,
libinterp/parse-tree/pt-idx.h, libinterp/parse-tree/pt-loop.h,
libinterp/parse-tree/pt-mat.cc, libinterp/parse-tree/pt-misc.cc,
libinterp/parse-tree/pt-misc.h, libinterp/parse-tree/pt-pr-code.cc,
libinterp/parse-tree/pt-select.h, libinterp/parse-tree/pt-stmt.h,
libinterp/parse-tree/token.h, libinterp/version.cc:
Use GNU style coding conventions for code in libinterp/
author | Rik <rik@octave.org> |
---|---|
date | Mon, 28 Oct 2013 19:51:46 -0700 |
parents | dae2230227a7 |
children | 97e49b588f5d ea0d4dea1a17 |
rev | line source |
---|---|
2974 | 1 /* |
2 | |
17744
d63878346099
maint: Update copyright notices for release.
John W. Eaton <jwe@octave.org>
parents:
17612
diff
changeset
|
3 Copyright (C) 1996-2013 John W. Eaton |
2974 | 4 |
5 This file is part of Octave. | |
6 | |
7 Octave is free software; you can redistribute it and/or modify it | |
8 under the terms of the GNU General Public License as published by the | |
7016 | 9 Free Software Foundation; either version 3 of the License, or (at your |
10 option) any later version. | |
2974 | 11 |
12 Octave is distributed in the hope that it will be useful, but WITHOUT | |
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
15 for more details. | |
16 | |
17 You should have received a copy of the GNU General Public License | |
7016 | 18 along with Octave; see the file COPYING. If not, see |
19 <http://www.gnu.org/licenses/>. | |
2974 | 20 |
21 */ | |
22 | |
23 #ifdef HAVE_CONFIG_H | |
24 #include <config.h> | |
25 #endif | |
26 | |
12783
ad9263d965dc
First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
12546
diff
changeset
|
27 #include <sstream> |
ad9263d965dc
First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
12546
diff
changeset
|
28 |
2974 | 29 #include "str-vec.h" |
30 | |
31 #include <defaults.h> | |
3974 | 32 #include "Cell.h" |
15427
6823ad7a25b1
implement local option for warnings
John W. Eaton <jwe@octave.org>
parents:
15337
diff
changeset
|
33 #include "builtins.h" |
2974 | 34 #include "defun.h" |
35 #include "error.h" | |
10832
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
36 #include "gripes.h" |
2974 | 37 #include "input.h" |
38 #include "oct-obj.h" | |
39 #include "ov-usr-fcn.h" | |
40 #include "ov.h" | |
41 #include "pager.h" | |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8580
diff
changeset
|
42 #include "pt-eval.h" |
15337
3f43e9d6d86e
JIT compile anonymous functions
Max Brister <max@2bass.com>
parents:
15236
diff
changeset
|
43 #include "pt-jit.h" |
2985 | 44 #include "pt-jump.h" |
2974 | 45 #include "pt-misc.h" |
46 #include "pt-pr-code.h" | |
2982 | 47 #include "pt-stmt.h" |
2974 | 48 #include "pt-walk.h" |
49 #include "symtab.h" | |
50 #include "toplev.h" | |
51 #include "unwind-prot.h" | |
52 #include "utils.h" | |
3489 | 53 #include "parse.h" |
12783
ad9263d965dc
First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
12546
diff
changeset
|
54 #include "profiler.h" |
2974 | 55 #include "variables.h" |
14136
20cb178716ee
Make nargin and nargout behave more like Matlab's (Bug #32700)
Iain Murray <iain@iainmurray.net>
parents:
12483
diff
changeset
|
56 #include "ov-fcn-handle.h" |
2974 | 57 |
9522
e79470be3ecb
implement subsasgn this-arg optimization
Jaroslav Hajek <highegg@gmail.com>
parents:
9396
diff
changeset
|
58 // Whether to optimize subsasgn method calls. |
9529
8e5009334661
partially revert e79470be3ecb
Jaroslav Hajek <highegg@gmail.com>
parents:
9522
diff
changeset
|
59 static bool Voptimize_subsasgn_calls = true; |
9522
e79470be3ecb
implement subsasgn this-arg optimization
Jaroslav Hajek <highegg@gmail.com>
parents:
9396
diff
changeset
|
60 |
16856
787de2f144d9
Use string_fill_char when creating argn automatic variable (bug #34183).
Rik <rik@octave.org>
parents:
16627
diff
changeset
|
61 // The character to fill with when creating string arrays. |
787de2f144d9
Use string_fill_char when creating argn automatic variable (bug #34183).
Rik <rik@octave.org>
parents:
16627
diff
changeset
|
62 extern char Vstring_fill_char; // see pt-mat.cc |
16596
645672f1c873
handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents:
16530
diff
changeset
|
63 |
645672f1c873
handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents:
16530
diff
changeset
|
64 std::map<std::string, octave_value> |
645672f1c873
handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents:
16530
diff
changeset
|
65 octave_user_code::subfunctions (void) const |
645672f1c873
handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents:
16530
diff
changeset
|
66 { |
645672f1c873
handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents:
16530
diff
changeset
|
67 return std::map<std::string, octave_value> (); |
645672f1c873
handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents:
16530
diff
changeset
|
68 } |
645672f1c873
handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents:
16530
diff
changeset
|
69 |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7589
diff
changeset
|
70 // User defined scripts. |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7589
diff
changeset
|
71 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7589
diff
changeset
|
72 DEFINE_OCTAVE_ALLOCATOR (octave_user_script); |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7589
diff
changeset
|
73 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7589
diff
changeset
|
74 DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_user_script, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
75 "user-defined script", |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
76 "user-defined script"); |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7589
diff
changeset
|
77 |
7731
2d2a969c731c
fix max_recursion_limit exceeded at startup with Intel C++
Jaroslav Hajek <highegg@gmail.com>
parents:
7719
diff
changeset
|
78 octave_user_script::octave_user_script (void) |
2d2a969c731c
fix max_recursion_limit exceeded at startup with Intel C++
Jaroslav Hajek <highegg@gmail.com>
parents:
7719
diff
changeset
|
79 : octave_user_code (), cmd_list (0), file_name (), |
2d2a969c731c
fix max_recursion_limit exceeded at startup with Intel C++
Jaroslav Hajek <highegg@gmail.com>
parents:
7719
diff
changeset
|
80 t_parsed (static_cast<time_t> (0)), |
2d2a969c731c
fix max_recursion_limit exceeded at startup with Intel C++
Jaroslav Hajek <highegg@gmail.com>
parents:
7719
diff
changeset
|
81 t_checked (static_cast<time_t> (0)), |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
82 call_depth (-1) |
7731
2d2a969c731c
fix max_recursion_limit exceeded at startup with Intel C++
Jaroslav Hajek <highegg@gmail.com>
parents:
7719
diff
changeset
|
83 { } |
2d2a969c731c
fix max_recursion_limit exceeded at startup with Intel C++
Jaroslav Hajek <highegg@gmail.com>
parents:
7719
diff
changeset
|
84 |
2d2a969c731c
fix max_recursion_limit exceeded at startup with Intel C++
Jaroslav Hajek <highegg@gmail.com>
parents:
7719
diff
changeset
|
85 octave_user_script::octave_user_script (const std::string& fnm, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
86 const std::string& nm, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
87 tree_statement_list *cmds, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
88 const std::string& ds) |
7731
2d2a969c731c
fix max_recursion_limit exceeded at startup with Intel C++
Jaroslav Hajek <highegg@gmail.com>
parents:
7719
diff
changeset
|
89 : octave_user_code (nm, ds), cmd_list (cmds), file_name (fnm), |
2d2a969c731c
fix max_recursion_limit exceeded at startup with Intel C++
Jaroslav Hajek <highegg@gmail.com>
parents:
7719
diff
changeset
|
90 t_parsed (static_cast<time_t> (0)), |
2d2a969c731c
fix max_recursion_limit exceeded at startup with Intel C++
Jaroslav Hajek <highegg@gmail.com>
parents:
7719
diff
changeset
|
91 t_checked (static_cast<time_t> (0)), |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
92 call_depth (-1) |
7736 | 93 { |
94 if (cmd_list) | |
95 cmd_list->mark_as_script_body (); | |
96 } | |
7731
2d2a969c731c
fix max_recursion_limit exceeded at startup with Intel C++
Jaroslav Hajek <highegg@gmail.com>
parents:
7719
diff
changeset
|
97 |
2d2a969c731c
fix max_recursion_limit exceeded at startup with Intel C++
Jaroslav Hajek <highegg@gmail.com>
parents:
7719
diff
changeset
|
98 octave_user_script::octave_user_script (const std::string& fnm, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
99 const std::string& nm, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
100 const std::string& ds) |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11558
diff
changeset
|
101 : octave_user_code (nm, ds), cmd_list (0), file_name (fnm), |
7731
2d2a969c731c
fix max_recursion_limit exceeded at startup with Intel C++
Jaroslav Hajek <highegg@gmail.com>
parents:
7719
diff
changeset
|
102 t_parsed (static_cast<time_t> (0)), |
2d2a969c731c
fix max_recursion_limit exceeded at startup with Intel C++
Jaroslav Hajek <highegg@gmail.com>
parents:
7719
diff
changeset
|
103 t_checked (static_cast<time_t> (0)), |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
104 call_depth (-1) |
7731
2d2a969c731c
fix max_recursion_limit exceeded at startup with Intel C++
Jaroslav Hajek <highegg@gmail.com>
parents:
7719
diff
changeset
|
105 { } |
2d2a969c731c
fix max_recursion_limit exceeded at startup with Intel C++
Jaroslav Hajek <highegg@gmail.com>
parents:
7719
diff
changeset
|
106 |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7589
diff
changeset
|
107 octave_user_script::~octave_user_script (void) |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7589
diff
changeset
|
108 { |
16530
7ca7e7d5eb91
remove breakpoints when clearing function
John W. Eaton <jwe@octave.org>
parents:
16442
diff
changeset
|
109 if (cmd_list) |
7ca7e7d5eb91
remove breakpoints when clearing function
John W. Eaton <jwe@octave.org>
parents:
16442
diff
changeset
|
110 cmd_list->remove_all_breakpoints (file_name); |
7ca7e7d5eb91
remove breakpoints when clearing function
John W. Eaton <jwe@octave.org>
parents:
16442
diff
changeset
|
111 |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7589
diff
changeset
|
112 delete cmd_list; |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7589
diff
changeset
|
113 } |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7589
diff
changeset
|
114 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7589
diff
changeset
|
115 octave_value_list |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7589
diff
changeset
|
116 octave_user_script::subsref (const std::string&, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
117 const std::list<octave_value_list>&, int) |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7589
diff
changeset
|
118 { |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7589
diff
changeset
|
119 octave_value_list retval; |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7589
diff
changeset
|
120 |
10001
6918d86add73
Print script filename in script indexing errors
David Grundberg <davidg@cs.umu.se>
parents:
9646
diff
changeset
|
121 ::error ("invalid use of script %s in index expression", file_name.c_str ()); |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7589
diff
changeset
|
122 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7589
diff
changeset
|
123 return retval; |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7589
diff
changeset
|
124 } |
7336 | 125 |
126 octave_value_list | |
127 octave_user_script::do_multi_index_op (int nargout, | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
128 const octave_value_list& args) |
7336 | 129 { |
130 octave_value_list retval; | |
131 | |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10001
diff
changeset
|
132 unwind_protect frame; |
8011
3100283874d7
improve backtrace error messages
John W. Eaton <jwe@octave.org>
parents:
7968
diff
changeset
|
133 |
7336 | 134 if (! error_state) |
135 { | |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7589
diff
changeset
|
136 if (args.length () == 0 && nargout == 0) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
137 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
138 if (cmd_list) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
139 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
140 frame.protect_var (call_depth); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
141 call_depth++; |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7589
diff
changeset
|
142 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
143 if (call_depth < Vmax_recursion_depth) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
144 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
145 octave_call_stack::push (this); |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7589
diff
changeset
|
146 |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10001
diff
changeset
|
147 frame.add_fcn (octave_call_stack::pop); |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7589
diff
changeset
|
148 |
11304 | 149 frame.protect_var (tree_evaluator::statement_context); |
150 tree_evaluator::statement_context = tree_evaluator::script; | |
8669
33783e94fb16
line number fixes and other evaluator tweaks
John W. Eaton <jwe@octave.org>
parents:
8658
diff
changeset
|
151 |
12960
43d78e103984
Use macro to start profiler blocks.
Daniel Kraft <d@domob.eu>
parents:
12920
diff
changeset
|
152 BEGIN_PROFILER_BLOCK (profiler_name ()) |
43d78e103984
Use macro to start profiler blocks.
Daniel Kraft <d@domob.eu>
parents:
12920
diff
changeset
|
153 cmd_list->accept (*current_evaluator); |
43d78e103984
Use macro to start profiler blocks.
Daniel Kraft <d@domob.eu>
parents:
12920
diff
changeset
|
154 END_PROFILER_BLOCK |
7336 | 155 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
156 if (tree_return_command::returning) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
157 tree_return_command::returning = 0; |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7589
diff
changeset
|
158 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
159 if (tree_break_command::breaking) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
160 tree_break_command::breaking--; |
8013
b3e667f1ab4c
call backtrace_error_message in eval functions, not when popping stack
John W. Eaton <jwe@octave.org>
parents:
8011
diff
changeset
|
161 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
162 if (error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
163 octave_call_stack::backtrace_error_message (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
164 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
165 else |
10578
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10315
diff
changeset
|
166 ::error ("max_recursion_depth exceeded"); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
167 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
168 } |
7336 | 169 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
170 error ("invalid call to script %s", file_name.c_str ()); |
7336 | 171 } |
172 | |
173 return retval; | |
174 } | |
175 | |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7589
diff
changeset
|
176 void |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7589
diff
changeset
|
177 octave_user_script::accept (tree_walker& tw) |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7589
diff
changeset
|
178 { |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7589
diff
changeset
|
179 tw.visit_octave_user_script (*this); |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7589
diff
changeset
|
180 } |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7589
diff
changeset
|
181 |
2974 | 182 // User defined functions. |
183 | |
3219 | 184 DEFINE_OCTAVE_ALLOCATOR (octave_user_function); |
2974 | 185 |
3219 | 186 DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_user_function, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
187 "user-defined function", |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
188 "user-defined function"); |
2974 | 189 |
190 // Ugh. This really needs to be simplified (code/data? | |
191 // extrinsic/intrinsic state?). | |
192 | |
193 octave_user_function::octave_user_function | |
7336 | 194 (symbol_table::scope_id sid, tree_parameter_list *pl, |
195 tree_parameter_list *rl, tree_statement_list *cl) | |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
196 : octave_user_code (std::string (), std::string ()), |
2974 | 197 param_list (pl), ret_list (rl), cmd_list (cl), |
7336 | 198 lead_comm (), trail_comm (), file_name (), |
12783
ad9263d965dc
First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
12546
diff
changeset
|
199 location_line (0), location_column (0), |
6323 | 200 parent_name (), t_parsed (static_cast<time_t> (0)), |
3255 | 201 t_checked (static_cast<time_t> (0)), |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
202 system_fcn_file (false), call_depth (-1), |
7589
90fb25a5a3fa
minor cleanup in octave_user_function constructor
John W. Eaton <jwe@octave.org>
parents:
7552
diff
changeset
|
203 num_named_args (param_list ? param_list->length () : 0), |
11461
2b8531a6a3c9
Change mentions of "nested function" to the less misleading "subfunction"
David Grundberg <individ@acc.umu.se>
parents:
11431
diff
changeset
|
204 subfunction (false), inline_function (false), |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14573
diff
changeset
|
205 anonymous_function (false), nested_function (false), |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14366
diff
changeset
|
206 class_constructor (false), class_method (false), |
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14366
diff
changeset
|
207 parent_scope (-1), local_scope (sid), |
10637
9cd5aa83fa62
implement 'local' parameter to pseudo-variables
Jaroslav Hajek <highegg@gmail.com>
parents:
10578
diff
changeset
|
208 curr_unwind_protect_frame (0) |
15337
3f43e9d6d86e
JIT compile anonymous functions
Max Brister <max@2bass.com>
parents:
15236
diff
changeset
|
209 #ifdef HAVE_LLVM |
3f43e9d6d86e
JIT compile anonymous functions
Max Brister <max@2bass.com>
parents:
15236
diff
changeset
|
210 , jit_info (0) |
3f43e9d6d86e
JIT compile anonymous functions
Max Brister <max@2bass.com>
parents:
15236
diff
changeset
|
211 #endif |
7736 | 212 { |
213 if (cmd_list) | |
214 cmd_list->mark_as_function_body (); | |
9639
8d79f36ebdde
store scope->function pointer
Jaroslav Hajek <highegg@gmail.com>
parents:
9529
diff
changeset
|
215 |
8d79f36ebdde
store scope->function pointer
Jaroslav Hajek <highegg@gmail.com>
parents:
9529
diff
changeset
|
216 if (local_scope >= 0) |
8d79f36ebdde
store scope->function pointer
Jaroslav Hajek <highegg@gmail.com>
parents:
9529
diff
changeset
|
217 symbol_table::set_curr_fcn (this, local_scope); |
7736 | 218 } |
2974 | 219 |
220 octave_user_function::~octave_user_function (void) | |
221 { | |
16530
7ca7e7d5eb91
remove breakpoints when clearing function
John W. Eaton <jwe@octave.org>
parents:
16442
diff
changeset
|
222 if (cmd_list) |
7ca7e7d5eb91
remove breakpoints when clearing function
John W. Eaton <jwe@octave.org>
parents:
16442
diff
changeset
|
223 cmd_list->remove_all_breakpoints (file_name); |
7ca7e7d5eb91
remove breakpoints when clearing function
John W. Eaton <jwe@octave.org>
parents:
16442
diff
changeset
|
224 |
2974 | 225 delete param_list; |
226 delete ret_list; | |
227 delete cmd_list; | |
3665 | 228 delete lead_comm; |
229 delete trail_comm; | |
7336 | 230 |
15337
3f43e9d6d86e
JIT compile anonymous functions
Max Brister <max@2bass.com>
parents:
15236
diff
changeset
|
231 #ifdef HAVE_LLVM |
3f43e9d6d86e
JIT compile anonymous functions
Max Brister <max@2bass.com>
parents:
15236
diff
changeset
|
232 delete jit_info; |
3f43e9d6d86e
JIT compile anonymous functions
Max Brister <max@2bass.com>
parents:
15236
diff
changeset
|
233 #endif |
3f43e9d6d86e
JIT compile anonymous functions
Max Brister <max@2bass.com>
parents:
15236
diff
changeset
|
234 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17757
diff
changeset
|
235 // FIXME: this is really playing with fire. |
7336 | 236 symbol_table::erase_scope (local_scope); |
2974 | 237 } |
238 | |
239 octave_user_function * | |
240 octave_user_function::define_ret_list (tree_parameter_list *t) | |
241 { | |
242 ret_list = t; | |
243 | |
244 return this; | |
245 } | |
246 | |
247 void | |
4343 | 248 octave_user_function::stash_fcn_file_name (const std::string& nm) |
2974 | 249 { |
4343 | 250 file_name = nm; |
2974 | 251 } |
252 | |
16627
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16605
diff
changeset
|
253 // If there is no explicit end statement at the end of the function, |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16605
diff
changeset
|
254 // relocate the no_op that was generated for the end of file condition |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16605
diff
changeset
|
255 // to appear on the next line after the last statement in the file, or |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16605
diff
changeset
|
256 // the next line after the function keyword if there are no statements. |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16605
diff
changeset
|
257 // More precisely, the new location should probably be on the next line |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16605
diff
changeset
|
258 // after the end of the parameter list, but we aren't tracking that |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16605
diff
changeset
|
259 // information (yet). |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16605
diff
changeset
|
260 |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16605
diff
changeset
|
261 void |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16605
diff
changeset
|
262 octave_user_function::maybe_relocate_end_internal (void) |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16605
diff
changeset
|
263 { |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16605
diff
changeset
|
264 if (cmd_list && ! cmd_list->empty ()) |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16605
diff
changeset
|
265 { |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16605
diff
changeset
|
266 tree_statement *last_stmt = cmd_list->back (); |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16605
diff
changeset
|
267 |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16605
diff
changeset
|
268 if (last_stmt && last_stmt->is_end_of_fcn_or_script () |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16605
diff
changeset
|
269 && last_stmt->is_end_of_file ()) |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16605
diff
changeset
|
270 { |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16605
diff
changeset
|
271 tree_statement_list::reverse_iterator |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16605
diff
changeset
|
272 next_to_last_elt = cmd_list->rbegin (); |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16605
diff
changeset
|
273 |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16605
diff
changeset
|
274 next_to_last_elt++; |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16605
diff
changeset
|
275 |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16605
diff
changeset
|
276 int new_eof_line; |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16605
diff
changeset
|
277 int new_eof_col; |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16605
diff
changeset
|
278 |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16605
diff
changeset
|
279 if (next_to_last_elt == cmd_list->rend ()) |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16605
diff
changeset
|
280 { |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16605
diff
changeset
|
281 new_eof_line = beginning_line (); |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16605
diff
changeset
|
282 new_eof_col = beginning_column (); |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16605
diff
changeset
|
283 } |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16605
diff
changeset
|
284 else |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16605
diff
changeset
|
285 { |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16605
diff
changeset
|
286 tree_statement *next_to_last_stmt = *next_to_last_elt; |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16605
diff
changeset
|
287 |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16605
diff
changeset
|
288 new_eof_line = next_to_last_stmt->line (); |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16605
diff
changeset
|
289 new_eof_col = next_to_last_stmt->column (); |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16605
diff
changeset
|
290 } |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16605
diff
changeset
|
291 |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16605
diff
changeset
|
292 last_stmt->set_location (new_eof_line + 1, new_eof_col); |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16605
diff
changeset
|
293 } |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16605
diff
changeset
|
294 } |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16605
diff
changeset
|
295 } |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16605
diff
changeset
|
296 |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16605
diff
changeset
|
297 void |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16605
diff
changeset
|
298 octave_user_function::maybe_relocate_end (void) |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16605
diff
changeset
|
299 { |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16605
diff
changeset
|
300 std::map<std::string, octave_value> fcns = subfunctions (); |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16605
diff
changeset
|
301 |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16605
diff
changeset
|
302 if (! fcns.empty ()) |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16605
diff
changeset
|
303 { |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16605
diff
changeset
|
304 for (std::map<std::string, octave_value>::iterator p = fcns.begin (); |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16605
diff
changeset
|
305 p != fcns.end (); p++) |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16605
diff
changeset
|
306 { |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16605
diff
changeset
|
307 octave_user_function *f = (p->second).user_function_value (); |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16605
diff
changeset
|
308 |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16605
diff
changeset
|
309 if (f) |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16605
diff
changeset
|
310 f->maybe_relocate_end_internal (); |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16605
diff
changeset
|
311 } |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16605
diff
changeset
|
312 } |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16605
diff
changeset
|
313 |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16605
diff
changeset
|
314 maybe_relocate_end_internal (); |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16605
diff
changeset
|
315 } |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16605
diff
changeset
|
316 |
12783
ad9263d965dc
First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
12546
diff
changeset
|
317 std::string |
ad9263d965dc
First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
12546
diff
changeset
|
318 octave_user_function::profiler_name (void) const |
ad9263d965dc
First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
12546
diff
changeset
|
319 { |
ad9263d965dc
First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
12546
diff
changeset
|
320 std::ostringstream result; |
ad9263d965dc
First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
12546
diff
changeset
|
321 |
ad9263d965dc
First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
12546
diff
changeset
|
322 if (is_inline_function ()) |
13241
2a8dcb5b3a00
improve default indexing for objects
John W. Eaton <jwe@octave.org>
parents:
12960
diff
changeset
|
323 result << "inline@" << fcn_file_name () |
2a8dcb5b3a00
improve default indexing for objects
John W. Eaton <jwe@octave.org>
parents:
12960
diff
changeset
|
324 << ":" << location_line << ":" << location_column; |
2a8dcb5b3a00
improve default indexing for objects
John W. Eaton <jwe@octave.org>
parents:
12960
diff
changeset
|
325 else if (is_anonymous_function ()) |
12783
ad9263d965dc
First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
12546
diff
changeset
|
326 result << "anonymous@" << fcn_file_name () |
ad9263d965dc
First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
12546
diff
changeset
|
327 << ":" << location_line << ":" << location_column; |
ad9263d965dc
First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
12546
diff
changeset
|
328 else if (is_subfunction ()) |
ad9263d965dc
First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
12546
diff
changeset
|
329 result << parent_fcn_name () << ">" << name (); |
ad9263d965dc
First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
12546
diff
changeset
|
330 else |
ad9263d965dc
First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
12546
diff
changeset
|
331 result << name (); |
ad9263d965dc
First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
12546
diff
changeset
|
332 |
ad9263d965dc
First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
12546
diff
changeset
|
333 return result.str (); |
ad9263d965dc
First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
12546
diff
changeset
|
334 } |
ad9263d965dc
First experimental profiler implementation with flat profile.
Daniel Kraft <d@domob.eu>
parents:
12546
diff
changeset
|
335 |
2974 | 336 void |
337 octave_user_function::mark_as_system_fcn_file (void) | |
338 { | |
339 if (! file_name.empty ()) | |
340 { | |
341 // We really should stash the whole path to the file we found, | |
342 // when we looked it up, to avoid possible race conditions... | |
5775 | 343 // FIXME |
2974 | 344 // |
345 // We probably also don't need to get the library directory | |
346 // every time, but since this function is only called when the | |
347 // function file is parsed, it probably doesn't matter that | |
348 // much. | |
349 | |
3523 | 350 std::string ff_name = fcn_file_in_path (file_name); |
2974 | 351 |
3565 | 352 if (Vfcn_file_dir == ff_name.substr (0, Vfcn_file_dir.length ())) |
14866
2309812f428e
Use explicit false and true instead of 0 and 1
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
14861
diff
changeset
|
353 system_fcn_file = true; |
2974 | 354 } |
355 else | |
14866
2309812f428e
Use explicit false and true instead of 0 and 1
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
14861
diff
changeset
|
356 system_fcn_file = false; |
2974 | 357 } |
358 | |
359 bool | |
360 octave_user_function::takes_varargs (void) const | |
361 { | |
362 return (param_list && param_list->takes_varargs ()); | |
363 } | |
364 | |
5848 | 365 bool |
366 octave_user_function::takes_var_return (void) const | |
2974 | 367 { |
5848 | 368 return (ret_list && ret_list->takes_varargs ()); |
2974 | 369 } |
370 | |
7761
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
371 void |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
372 octave_user_function::lock_subfunctions (void) |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
373 { |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
374 symbol_table::lock_subfunctions (local_scope); |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
375 } |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
376 |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
377 void |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
378 octave_user_function::unlock_subfunctions (void) |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
379 { |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
380 symbol_table::unlock_subfunctions (local_scope); |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
381 } |
5adeea5de26c
symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents:
7752
diff
changeset
|
382 |
16596
645672f1c873
handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents:
16530
diff
changeset
|
383 std::map<std::string, octave_value> |
645672f1c873
handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents:
16530
diff
changeset
|
384 octave_user_function::subfunctions (void) const |
645672f1c873
handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents:
16530
diff
changeset
|
385 { |
645672f1c873
handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents:
16530
diff
changeset
|
386 return symbol_table::subfunctions_defined_in_scope (local_scope); |
645672f1c873
handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents:
16530
diff
changeset
|
387 } |
645672f1c873
handle setting breakpoints in subfunctions in GUI editor
John W. Eaton <jwe@octave.org>
parents:
16530
diff
changeset
|
388 |
16627
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16605
diff
changeset
|
389 bool |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16605
diff
changeset
|
390 octave_user_function::has_subfunctions (void) const |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16605
diff
changeset
|
391 { |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16605
diff
changeset
|
392 return ! subfcn_names.empty (); |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16605
diff
changeset
|
393 } |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16605
diff
changeset
|
394 |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16605
diff
changeset
|
395 void |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16605
diff
changeset
|
396 octave_user_function::stash_subfunction_names |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16605
diff
changeset
|
397 (const std::list<std::string>& names) |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16605
diff
changeset
|
398 { |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16605
diff
changeset
|
399 subfcn_names = names; |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16605
diff
changeset
|
400 } |
de91b1621260
adjust location of eof marker for files with subfunctions but no explicit end statements
John W. Eaton <jwe@octave.org>
parents:
16605
diff
changeset
|
401 |
2974 | 402 octave_value_list |
9522
e79470be3ecb
implement subsasgn this-arg optimization
Jaroslav Hajek <highegg@gmail.com>
parents:
9396
diff
changeset
|
403 octave_user_function::all_va_args (const octave_value_list& args) |
2974 | 404 { |
405 octave_value_list retval; | |
406 | |
9522
e79470be3ecb
implement subsasgn this-arg optimization
Jaroslav Hajek <highegg@gmail.com>
parents:
9396
diff
changeset
|
407 octave_idx_type n = args.length () - num_named_args; |
2974 | 408 |
3178 | 409 if (n > 0) |
9522
e79470be3ecb
implement subsasgn this-arg optimization
Jaroslav Hajek <highegg@gmail.com>
parents:
9396
diff
changeset
|
410 retval = args.slice (num_named_args, n); |
2974 | 411 |
412 return retval; | |
413 } | |
414 | |
415 octave_value_list | |
4247 | 416 octave_user_function::subsref (const std::string& type, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
417 const std::list<octave_value_list>& idx, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
418 int nargout) |
3933 | 419 { |
10832
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
420 return octave_user_function::subsref (type, idx, nargout, 0); |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
421 } |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
422 |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
423 octave_value_list |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
424 octave_user_function::subsref (const std::string& type, |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
425 const std::list<octave_value_list>& idx, |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17757
diff
changeset
|
426 int nargout, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17757
diff
changeset
|
427 const std::list<octave_lvalue>* lvalue_list) |
10832
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
428 { |
3933 | 429 octave_value_list retval; |
430 | |
431 switch (type[0]) | |
432 { | |
433 case '(': | |
5154 | 434 { |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
435 int tmp_nargout = (type.length () > 1 && nargout == 0) ? 1 : nargout; |
5154 | 436 |
10832
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
437 retval = do_multi_index_op (tmp_nargout, idx.front (), |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
438 idx.size () == 1 ? lvalue_list : 0); |
5154 | 439 } |
3933 | 440 break; |
441 | |
442 case '{': | |
443 case '.': | |
444 { | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
445 std::string nm = type_name (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
446 error ("%s cannot be indexed with %c", nm.c_str (), type[0]); |
3933 | 447 } |
448 break; | |
449 | |
450 default: | |
451 panic_impossible (); | |
452 } | |
453 | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17757
diff
changeset
|
454 // FIXME: perhaps there should be an |
4059 | 455 // octave_value_list::next_subsref member function? See also |
456 // octave_builtin::subsref. | |
3933 | 457 |
4219 | 458 if (idx.size () > 1) |
4994 | 459 retval = retval(0).next_subsref (nargout, type, idx); |
4059 | 460 |
461 return retval; | |
3933 | 462 } |
463 | |
464 octave_value_list | |
3544 | 465 octave_user_function::do_multi_index_op (int nargout, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
466 const octave_value_list& args) |
2974 | 467 { |
10832
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
468 return do_multi_index_op (nargout, args, 0); |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
469 } |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
470 |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
471 octave_value_list |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
472 octave_user_function::do_multi_index_op (int nargout, |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
473 const octave_value_list& args, |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
474 const std::list<octave_lvalue>* lvalue_list) |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
475 { |
2974 | 476 octave_value_list retval; |
477 | |
478 if (error_state) | |
479 return retval; | |
480 | |
481 if (! cmd_list) | |
482 return retval; | |
483 | |
15337
3f43e9d6d86e
JIT compile anonymous functions
Max Brister <max@2bass.com>
parents:
15236
diff
changeset
|
484 #ifdef HAVE_LLVM |
15582
52df2e7baabe
Disable JIT when breakpoints are present
Max Brister <max@2bass.com>
parents:
15427
diff
changeset
|
485 if (is_special_expr () |
15337
3f43e9d6d86e
JIT compile anonymous functions
Max Brister <max@2bass.com>
parents:
15236
diff
changeset
|
486 && tree_jit::execute (*this, args, retval)) |
3f43e9d6d86e
JIT compile anonymous functions
Max Brister <max@2bass.com>
parents:
15236
diff
changeset
|
487 return retval; |
3f43e9d6d86e
JIT compile anonymous functions
Max Brister <max@2bass.com>
parents:
15236
diff
changeset
|
488 #endif |
3f43e9d6d86e
JIT compile anonymous functions
Max Brister <max@2bass.com>
parents:
15236
diff
changeset
|
489 |
2974 | 490 int nargin = args.length (); |
491 | |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10001
diff
changeset
|
492 unwind_protect frame; |
2974 | 493 |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10001
diff
changeset
|
494 frame.protect_var (call_depth); |
2974 | 495 call_depth++; |
496 | |
7752
40c428ea3408
initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
497 if (call_depth >= Vmax_recursion_depth) |
3131 | 498 { |
10578
cb0883127251
limit on recursion via calls to source function
John W. Eaton <jwe@octave.org>
parents:
10315
diff
changeset
|
499 ::error ("max_recursion_depth exceeded"); |
3131 | 500 return retval; |
501 } | |
502 | |
7336 | 503 // Save old and set current symbol table context, for |
504 // eval_undefined_error(). | |
505 | |
14544
be18c9e359bf
Nested function support (bug #35772)
Max Brister <max@2bass.com>
parents:
14366
diff
changeset
|
506 int context = active_context (); |
14328
19078011cdc3
fix problem with recursion and anonymous functions (bug #31371)
John W. Eaton <jwe@octave.org>
parents:
14139
diff
changeset
|
507 |
19078011cdc3
fix problem with recursion and anonymous functions (bug #31371)
John W. Eaton <jwe@octave.org>
parents:
14139
diff
changeset
|
508 octave_call_stack::push (this, local_scope, context); |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10001
diff
changeset
|
509 frame.add_fcn (octave_call_stack::pop); |
7901 | 510 |
14328
19078011cdc3
fix problem with recursion and anonymous functions (bug #31371)
John W. Eaton <jwe@octave.org>
parents:
14139
diff
changeset
|
511 if (call_depth > 0 && ! is_anonymous_function ()) |
2974 | 512 { |
7336 | 513 symbol_table::push_context (); |
2974 | 514 |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10001
diff
changeset
|
515 frame.add_fcn (symbol_table::pop_context); |
7336 | 516 } |
2974 | 517 |
518 string_vector arg_names = args.name_tags (); | |
519 | |
520 if (param_list && ! param_list->varargs_only ()) | |
521 { | |
522 param_list->define_from_arg_vector (args); | |
523 if (error_state) | |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10001
diff
changeset
|
524 return retval; |
2974 | 525 } |
526 | |
3239 | 527 // Force parameter list to be undefined when this function exits. |
528 // Doing so decrements the reference counts on the values of local | |
529 // variables that are also named function parameters. | |
530 | |
9396
17af7cce7d1b
yet more unwind_protect improvements
Jaroslav Hajek <highegg@gmail.com>
parents:
9377
diff
changeset
|
531 if (param_list) |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10001
diff
changeset
|
532 frame.add_method (param_list, &tree_parameter_list::undefine); |
3239 | 533 |
534 // Force return list to be undefined when this function exits. | |
535 // Doing so decrements the reference counts on the values of local | |
536 // variables that are also named values returned by this function. | |
537 | |
9396
17af7cce7d1b
yet more unwind_protect improvements
Jaroslav Hajek <highegg@gmail.com>
parents:
9377
diff
changeset
|
538 if (ret_list) |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10001
diff
changeset
|
539 frame.add_method (ret_list, &tree_parameter_list::undefine); |
3239 | 540 |
8142
54b41376e381
ov-usr-fcn.cc (octave_user_function::do_multi_index_op): add symbol_table::clear_variables cleanup function to the unwind_protect stack after the parameter list cleanup functions
John W. Eaton <jwe@octave.org>
parents:
8013
diff
changeset
|
541 if (call_depth == 0) |
54b41376e381
ov-usr-fcn.cc (octave_user_function::do_multi_index_op): add symbol_table::clear_variables cleanup function to the unwind_protect stack after the parameter list cleanup functions
John W. Eaton <jwe@octave.org>
parents:
8013
diff
changeset
|
542 { |
54b41376e381
ov-usr-fcn.cc (octave_user_function::do_multi_index_op): add symbol_table::clear_variables cleanup function to the unwind_protect stack after the parameter list cleanup functions
John W. Eaton <jwe@octave.org>
parents:
8013
diff
changeset
|
543 // Force symbols to be undefined again when this function |
54b41376e381
ov-usr-fcn.cc (octave_user_function::do_multi_index_op): add symbol_table::clear_variables cleanup function to the unwind_protect stack after the parameter list cleanup functions
John W. Eaton <jwe@octave.org>
parents:
8013
diff
changeset
|
544 // exits. |
54b41376e381
ov-usr-fcn.cc (octave_user_function::do_multi_index_op): add symbol_table::clear_variables cleanup function to the unwind_protect stack after the parameter list cleanup functions
John W. Eaton <jwe@octave.org>
parents:
8013
diff
changeset
|
545 // |
54b41376e381
ov-usr-fcn.cc (octave_user_function::do_multi_index_op): add symbol_table::clear_variables cleanup function to the unwind_protect stack after the parameter list cleanup functions
John W. Eaton <jwe@octave.org>
parents:
8013
diff
changeset
|
546 // This cleanup function is added to the unwind_protect stack |
54b41376e381
ov-usr-fcn.cc (octave_user_function::do_multi_index_op): add symbol_table::clear_variables cleanup function to the unwind_protect stack after the parameter list cleanup functions
John W. Eaton <jwe@octave.org>
parents:
8013
diff
changeset
|
547 // after the calls to clear the parameter lists so that local |
54b41376e381
ov-usr-fcn.cc (octave_user_function::do_multi_index_op): add symbol_table::clear_variables cleanup function to the unwind_protect stack after the parameter list cleanup functions
John W. Eaton <jwe@octave.org>
parents:
8013
diff
changeset
|
548 // variables will be cleared before the parameter lists are |
54b41376e381
ov-usr-fcn.cc (octave_user_function::do_multi_index_op): add symbol_table::clear_variables cleanup function to the unwind_protect stack after the parameter list cleanup functions
John W. Eaton <jwe@octave.org>
parents:
8013
diff
changeset
|
549 // cleared. That way, any function parameters that have been |
54b41376e381
ov-usr-fcn.cc (octave_user_function::do_multi_index_op): add symbol_table::clear_variables cleanup function to the unwind_protect stack after the parameter list cleanup functions
John W. Eaton <jwe@octave.org>
parents:
8013
diff
changeset
|
550 // declared global will be unmarked as global before they are |
54b41376e381
ov-usr-fcn.cc (octave_user_function::do_multi_index_op): add symbol_table::clear_variables cleanup function to the unwind_protect stack after the parameter list cleanup functions
John W. Eaton <jwe@octave.org>
parents:
8013
diff
changeset
|
551 // undefined by the clear_param_list cleanup function. |
54b41376e381
ov-usr-fcn.cc (octave_user_function::do_multi_index_op): add symbol_table::clear_variables cleanup function to the unwind_protect stack after the parameter list cleanup functions
John W. Eaton <jwe@octave.org>
parents:
8013
diff
changeset
|
552 |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10001
diff
changeset
|
553 frame.add_fcn (symbol_table::clear_variables); |
8142
54b41376e381
ov-usr-fcn.cc (octave_user_function::do_multi_index_op): add symbol_table::clear_variables cleanup function to the unwind_protect stack after the parameter list cleanup functions
John W. Eaton <jwe@octave.org>
parents:
8013
diff
changeset
|
554 } |
54b41376e381
ov-usr-fcn.cc (octave_user_function::do_multi_index_op): add symbol_table::clear_variables cleanup function to the unwind_protect stack after the parameter list cleanup functions
John W. Eaton <jwe@octave.org>
parents:
8013
diff
changeset
|
555 |
10832
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
556 bind_automatic_vars (arg_names, nargin, nargout, all_va_args (args), |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
557 lvalue_list); |
2974 | 558 |
15427
6823ad7a25b1
implement local option for warnings
John W. Eaton <jwe@octave.org>
parents:
15337
diff
changeset
|
559 frame.add_method (this, &octave_user_function::restore_warning_states); |
6823ad7a25b1
implement local option for warnings
John W. Eaton <jwe@octave.org>
parents:
15337
diff
changeset
|
560 |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10001
diff
changeset
|
561 bool echo_commands = (Vecho_executing_commands & ECHO_FUNCTIONS); |
2974 | 562 |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10001
diff
changeset
|
563 if (echo_commands) |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10001
diff
changeset
|
564 print_code_function_header (); |
2974 | 565 |
10637
9cd5aa83fa62
implement 'local' parameter to pseudo-variables
Jaroslav Hajek <highegg@gmail.com>
parents:
10578
diff
changeset
|
566 // Set pointer to the current unwind_protect frame to allow |
9cd5aa83fa62
implement 'local' parameter to pseudo-variables
Jaroslav Hajek <highegg@gmail.com>
parents:
10578
diff
changeset
|
567 // certain builtins register simple cleanup in a very optimized manner. |
9cd5aa83fa62
implement 'local' parameter to pseudo-variables
Jaroslav Hajek <highegg@gmail.com>
parents:
10578
diff
changeset
|
568 // This is *not* intended as a general-purpose on-cleanup mechanism, |
9cd5aa83fa62
implement 'local' parameter to pseudo-variables
Jaroslav Hajek <highegg@gmail.com>
parents:
10578
diff
changeset
|
569 frame.protect_var (curr_unwind_protect_frame); |
9cd5aa83fa62
implement 'local' parameter to pseudo-variables
Jaroslav Hajek <highegg@gmail.com>
parents:
10578
diff
changeset
|
570 curr_unwind_protect_frame = &frame; |
9cd5aa83fa62
implement 'local' parameter to pseudo-variables
Jaroslav Hajek <highegg@gmail.com>
parents:
10578
diff
changeset
|
571 |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10001
diff
changeset
|
572 // Evaluate the commands that make up the function. |
2974 | 573 |
11304 | 574 frame.protect_var (tree_evaluator::statement_context); |
575 tree_evaluator::statement_context = tree_evaluator::function; | |
3489 | 576 |
12960
43d78e103984
Use macro to start profiler blocks.
Daniel Kraft <d@domob.eu>
parents:
12920
diff
changeset
|
577 BEGIN_PROFILER_BLOCK (profiler_name ()) |
6657 | 578 |
15337
3f43e9d6d86e
JIT compile anonymous functions
Max Brister <max@2bass.com>
parents:
15236
diff
changeset
|
579 if (is_special_expr ()) |
12960
43d78e103984
Use macro to start profiler blocks.
Daniel Kraft <d@domob.eu>
parents:
12920
diff
changeset
|
580 { |
15337
3f43e9d6d86e
JIT compile anonymous functions
Max Brister <max@2bass.com>
parents:
15236
diff
changeset
|
581 tree_expression *expr = special_expr (); |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
8580
diff
changeset
|
582 |
15337
3f43e9d6d86e
JIT compile anonymous functions
Max Brister <max@2bass.com>
parents:
15236
diff
changeset
|
583 if (expr) |
16091
1785493171ac
pass lvalue_list to more subsref calls (bug #38374)
John W. Eaton <jwe@octave.org>
parents:
15582
diff
changeset
|
584 retval = (lvalue_list |
1785493171ac
pass lvalue_list to more subsref calls (bug #38374)
John W. Eaton <jwe@octave.org>
parents:
15582
diff
changeset
|
585 ? expr->rvalue (nargout, lvalue_list) |
1785493171ac
pass lvalue_list to more subsref calls (bug #38374)
John W. Eaton <jwe@octave.org>
parents:
15582
diff
changeset
|
586 : expr->rvalue (nargout)); |
12960
43d78e103984
Use macro to start profiler blocks.
Daniel Kraft <d@domob.eu>
parents:
12920
diff
changeset
|
587 } |
43d78e103984
Use macro to start profiler blocks.
Daniel Kraft <d@domob.eu>
parents:
12920
diff
changeset
|
588 else |
43d78e103984
Use macro to start profiler blocks.
Daniel Kraft <d@domob.eu>
parents:
12920
diff
changeset
|
589 cmd_list->accept (*current_evaluator); |
43d78e103984
Use macro to start profiler blocks.
Daniel Kraft <d@domob.eu>
parents:
12920
diff
changeset
|
590 |
43d78e103984
Use macro to start profiler blocks.
Daniel Kraft <d@domob.eu>
parents:
12920
diff
changeset
|
591 END_PROFILER_BLOCK |
2974 | 592 |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10001
diff
changeset
|
593 if (echo_commands) |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10001
diff
changeset
|
594 print_code_function_trailer (); |
2974 | 595 |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10001
diff
changeset
|
596 if (tree_return_command::returning) |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10001
diff
changeset
|
597 tree_return_command::returning = 0; |
2974 | 598 |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10001
diff
changeset
|
599 if (tree_break_command::breaking) |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10001
diff
changeset
|
600 tree_break_command::breaking--; |
2974 | 601 |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10001
diff
changeset
|
602 if (error_state) |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10001
diff
changeset
|
603 { |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10001
diff
changeset
|
604 octave_call_stack::backtrace_error_message (); |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10001
diff
changeset
|
605 return retval; |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10001
diff
changeset
|
606 } |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11558
diff
changeset
|
607 |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10001
diff
changeset
|
608 // Copy return values out. |
2974 | 609 |
15337
3f43e9d6d86e
JIT compile anonymous functions
Max Brister <max@2bass.com>
parents:
15236
diff
changeset
|
610 if (ret_list && ! is_special_expr ()) |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10001
diff
changeset
|
611 { |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10001
diff
changeset
|
612 ret_list->initialize_undefined_elements (my_name, nargout, Matrix ()); |
5848 | 613 |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10001
diff
changeset
|
614 Cell varargout; |
6591 | 615 |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10001
diff
changeset
|
616 if (ret_list->takes_varargs ()) |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10001
diff
changeset
|
617 { |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10001
diff
changeset
|
618 octave_value varargout_varval = symbol_table::varval ("varargout"); |
5848 | 619 |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10001
diff
changeset
|
620 if (varargout_varval.is_defined ()) |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10001
diff
changeset
|
621 { |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10001
diff
changeset
|
622 varargout = varargout_varval.cell_value (); |
5848 | 623 |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10001
diff
changeset
|
624 if (error_state) |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10001
diff
changeset
|
625 error ("expecting varargout to be a cell array object"); |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10001
diff
changeset
|
626 } |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10001
diff
changeset
|
627 } |
2974 | 628 |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10001
diff
changeset
|
629 if (! error_state) |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10001
diff
changeset
|
630 retval = ret_list->convert_to_const_vector (nargout, varargout); |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10001
diff
changeset
|
631 } |
2974 | 632 |
633 return retval; | |
634 } | |
635 | |
636 void | |
637 octave_user_function::accept (tree_walker& tw) | |
638 { | |
639 tw.visit_octave_user_function (*this); | |
640 } | |
641 | |
15337
3f43e9d6d86e
JIT compile anonymous functions
Max Brister <max@2bass.com>
parents:
15236
diff
changeset
|
642 tree_expression * |
3f43e9d6d86e
JIT compile anonymous functions
Max Brister <max@2bass.com>
parents:
15236
diff
changeset
|
643 octave_user_function::special_expr (void) |
3f43e9d6d86e
JIT compile anonymous functions
Max Brister <max@2bass.com>
parents:
15236
diff
changeset
|
644 { |
3f43e9d6d86e
JIT compile anonymous functions
Max Brister <max@2bass.com>
parents:
15236
diff
changeset
|
645 assert (is_special_expr ()); |
3f43e9d6d86e
JIT compile anonymous functions
Max Brister <max@2bass.com>
parents:
15236
diff
changeset
|
646 assert (cmd_list->length () == 1); |
3f43e9d6d86e
JIT compile anonymous functions
Max Brister <max@2bass.com>
parents:
15236
diff
changeset
|
647 |
3f43e9d6d86e
JIT compile anonymous functions
Max Brister <max@2bass.com>
parents:
15236
diff
changeset
|
648 tree_statement *stmt = cmd_list->front (); |
3f43e9d6d86e
JIT compile anonymous functions
Max Brister <max@2bass.com>
parents:
15236
diff
changeset
|
649 return stmt->expression (); |
3f43e9d6d86e
JIT compile anonymous functions
Max Brister <max@2bass.com>
parents:
15236
diff
changeset
|
650 } |
3f43e9d6d86e
JIT compile anonymous functions
Max Brister <max@2bass.com>
parents:
15236
diff
changeset
|
651 |
9522
e79470be3ecb
implement subsasgn this-arg optimization
Jaroslav Hajek <highegg@gmail.com>
parents:
9396
diff
changeset
|
652 bool |
e79470be3ecb
implement subsasgn this-arg optimization
Jaroslav Hajek <highegg@gmail.com>
parents:
9396
diff
changeset
|
653 octave_user_function::subsasgn_optimization_ok (void) |
e79470be3ecb
implement subsasgn this-arg optimization
Jaroslav Hajek <highegg@gmail.com>
parents:
9396
diff
changeset
|
654 { |
e79470be3ecb
implement subsasgn this-arg optimization
Jaroslav Hajek <highegg@gmail.com>
parents:
9396
diff
changeset
|
655 bool retval = false; |
e79470be3ecb
implement subsasgn this-arg optimization
Jaroslav Hajek <highegg@gmail.com>
parents:
9396
diff
changeset
|
656 if (Voptimize_subsasgn_calls |
e79470be3ecb
implement subsasgn this-arg optimization
Jaroslav Hajek <highegg@gmail.com>
parents:
9396
diff
changeset
|
657 && param_list->length () > 0 && ! param_list->varargs_only () |
e79470be3ecb
implement subsasgn this-arg optimization
Jaroslav Hajek <highegg@gmail.com>
parents:
9396
diff
changeset
|
658 && ret_list->length () == 1 && ! ret_list->takes_varargs ()) |
e79470be3ecb
implement subsasgn this-arg optimization
Jaroslav Hajek <highegg@gmail.com>
parents:
9396
diff
changeset
|
659 { |
e79470be3ecb
implement subsasgn this-arg optimization
Jaroslav Hajek <highegg@gmail.com>
parents:
9396
diff
changeset
|
660 tree_identifier *par1 = param_list->front ()->ident (); |
e79470be3ecb
implement subsasgn this-arg optimization
Jaroslav Hajek <highegg@gmail.com>
parents:
9396
diff
changeset
|
661 tree_identifier *ret1 = ret_list->front ()->ident (); |
e79470be3ecb
implement subsasgn this-arg optimization
Jaroslav Hajek <highegg@gmail.com>
parents:
9396
diff
changeset
|
662 retval = par1->name () == ret1->name (); |
e79470be3ecb
implement subsasgn this-arg optimization
Jaroslav Hajek <highegg@gmail.com>
parents:
9396
diff
changeset
|
663 } |
e79470be3ecb
implement subsasgn this-arg optimization
Jaroslav Hajek <highegg@gmail.com>
parents:
9396
diff
changeset
|
664 |
e79470be3ecb
implement subsasgn this-arg optimization
Jaroslav Hajek <highegg@gmail.com>
parents:
9396
diff
changeset
|
665 return retval; |
e79470be3ecb
implement subsasgn this-arg optimization
Jaroslav Hajek <highegg@gmail.com>
parents:
9396
diff
changeset
|
666 } |
e79470be3ecb
implement subsasgn this-arg optimization
Jaroslav Hajek <highegg@gmail.com>
parents:
9396
diff
changeset
|
667 |
7336 | 668 #if 0 |
2974 | 669 void |
3933 | 670 octave_user_function::print_symtab_info (std::ostream& os) const |
671 { | |
7336 | 672 symbol_table::print_info (os, local_scope); |
3933 | 673 } |
7336 | 674 #endif |
3933 | 675 |
676 void | |
2974 | 677 octave_user_function::print_code_function_header (void) |
678 { | |
5794 | 679 tree_print_code tpc (octave_stdout, VPS4); |
2974 | 680 |
681 tpc.visit_octave_user_function_header (*this); | |
682 } | |
683 | |
684 void | |
685 octave_user_function::print_code_function_trailer (void) | |
686 { | |
5794 | 687 tree_print_code tpc (octave_stdout, VPS4); |
2974 | 688 |
689 tpc.visit_octave_user_function_trailer (*this); | |
690 } | |
691 | |
692 void | |
693 octave_user_function::bind_automatic_vars | |
3974 | 694 (const string_vector& arg_names, int nargin, int nargout, |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17757
diff
changeset
|
695 const octave_value_list& va_args, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17757
diff
changeset
|
696 const std::list<octave_lvalue> *lvalue_list) |
2974 | 697 { |
698 if (! arg_names.empty ()) | |
11557
e9d72a3caa46
mark automatic variables as automatic
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
699 { |
11558
1e4dfc7a9487
use .argn. to store argument names for inputname function
John W. Eaton <jwe@octave.org>
parents:
11557
diff
changeset
|
700 // It is better to save this in the hidden variable .argn. and |
1e4dfc7a9487
use .argn. to store argument names for inputname function
John W. Eaton <jwe@octave.org>
parents:
11557
diff
changeset
|
701 // then use that in the inputname function instead of using argn, |
1e4dfc7a9487
use .argn. to store argument names for inputname function
John W. Eaton <jwe@octave.org>
parents:
11557
diff
changeset
|
702 // which might be redefined in a function. Keep the old argn name |
1e4dfc7a9487
use .argn. to store argument names for inputname function
John W. Eaton <jwe@octave.org>
parents:
11557
diff
changeset
|
703 // for backward compatibility of functions that use it directly. |
1e4dfc7a9487
use .argn. to store argument names for inputname function
John W. Eaton <jwe@octave.org>
parents:
11557
diff
changeset
|
704 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17757
diff
changeset
|
705 symbol_table::force_assign ("argn", |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17757
diff
changeset
|
706 charMatrix (arg_names, Vstring_fill_char)); |
16442
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16091
diff
changeset
|
707 symbol_table::force_assign (".argn.", Cell (arg_names)); |
11558
1e4dfc7a9487
use .argn. to store argument names for inputname function
John W. Eaton <jwe@octave.org>
parents:
11557
diff
changeset
|
708 |
1e4dfc7a9487
use .argn. to store argument names for inputname function
John W. Eaton <jwe@octave.org>
parents:
11557
diff
changeset
|
709 symbol_table::mark_hidden (".argn."); |
11557
e9d72a3caa46
mark automatic variables as automatic
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
710 |
e9d72a3caa46
mark automatic variables as automatic
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
711 symbol_table::mark_automatic ("argn"); |
11558
1e4dfc7a9487
use .argn. to store argument names for inputname function
John W. Eaton <jwe@octave.org>
parents:
11557
diff
changeset
|
712 symbol_table::mark_automatic (".argn."); |
11557
e9d72a3caa46
mark automatic variables as automatic
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
713 } |
2974 | 714 |
16442
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16091
diff
changeset
|
715 symbol_table::force_assign (".nargin.", nargin); |
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16091
diff
changeset
|
716 symbol_table::force_assign (".nargout.", nargout); |
7336 | 717 |
718 symbol_table::mark_hidden (".nargin."); | |
719 symbol_table::mark_hidden (".nargout."); | |
3974 | 720 |
11557
e9d72a3caa46
mark automatic variables as automatic
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
721 symbol_table::mark_automatic (".nargin."); |
e9d72a3caa46
mark automatic variables as automatic
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
722 symbol_table::mark_automatic (".nargout."); |
e9d72a3caa46
mark automatic variables as automatic
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
723 |
16442
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16091
diff
changeset
|
724 symbol_table::assign (".saved_warning_states."); |
15427
6823ad7a25b1
implement local option for warnings
John W. Eaton <jwe@octave.org>
parents:
15337
diff
changeset
|
725 |
6823ad7a25b1
implement local option for warnings
John W. Eaton <jwe@octave.org>
parents:
15337
diff
changeset
|
726 symbol_table::mark_automatic (".saved_warning_states."); |
6823ad7a25b1
implement local option for warnings
John W. Eaton <jwe@octave.org>
parents:
15337
diff
changeset
|
727 symbol_table::mark_automatic (".saved_warning_states."); |
6823ad7a25b1
implement local option for warnings
John W. Eaton <jwe@octave.org>
parents:
15337
diff
changeset
|
728 |
3974 | 729 if (takes_varargs ()) |
16442
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16091
diff
changeset
|
730 symbol_table::assign ("varargin", va_args.cell_value ()); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11558
diff
changeset
|
731 |
14571
6131fead3135
ensure isargout is not sticky
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
732 // Force .ignored. variable to be undefined by default. |
16442
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16091
diff
changeset
|
733 symbol_table::assign (".ignored."); |
14571
6131fead3135
ensure isargout is not sticky
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
734 |
10832
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
735 if (lvalue_list) |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
736 { |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
737 octave_idx_type nbh = 0; |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
738 for (std::list<octave_lvalue>::const_iterator p = lvalue_list->begin (); |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
739 p != lvalue_list->end (); p++) |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
740 nbh += p->is_black_hole (); |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
741 |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
742 if (nbh > 0) |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
743 { |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
744 // Only assign the hidden variable if black holes actually present. |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
745 Matrix bh (1, nbh); |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
746 octave_idx_type k = 0, l = 0; |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17757
diff
changeset
|
747 for (std::list<octave_lvalue>::const_iterator |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17757
diff
changeset
|
748 p = lvalue_list->begin (); p != lvalue_list->end (); p++) |
10832
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
749 { |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
750 if (p->is_black_hole ()) |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
751 bh(l++) = k+1; |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
752 k += p->numel (); |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
753 } |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
754 |
16442
302157614308
deprecate symbol_table::varref functions
John W. Eaton <jwe@octave.org>
parents:
16091
diff
changeset
|
755 symbol_table::assign (".ignored.", bh); |
10832
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
756 } |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
757 } |
14571
6131fead3135
ensure isargout is not sticky
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
758 |
6131fead3135
ensure isargout is not sticky
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
759 symbol_table::mark_hidden (".ignored."); |
6131fead3135
ensure isargout is not sticky
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
760 symbol_table::mark_automatic (".ignored."); |
2974 | 761 } |
762 | |
15427
6823ad7a25b1
implement local option for warnings
John W. Eaton <jwe@octave.org>
parents:
15337
diff
changeset
|
763 void |
6823ad7a25b1
implement local option for warnings
John W. Eaton <jwe@octave.org>
parents:
15337
diff
changeset
|
764 octave_user_function::restore_warning_states (void) |
6823ad7a25b1
implement local option for warnings
John W. Eaton <jwe@octave.org>
parents:
15337
diff
changeset
|
765 { |
6823ad7a25b1
implement local option for warnings
John W. Eaton <jwe@octave.org>
parents:
15337
diff
changeset
|
766 octave_value val = symbol_table::varval (".saved_warning_states."); |
6823ad7a25b1
implement local option for warnings
John W. Eaton <jwe@octave.org>
parents:
15337
diff
changeset
|
767 |
6823ad7a25b1
implement local option for warnings
John W. Eaton <jwe@octave.org>
parents:
15337
diff
changeset
|
768 if (val.is_defined ()) |
6823ad7a25b1
implement local option for warnings
John W. Eaton <jwe@octave.org>
parents:
15337
diff
changeset
|
769 { |
17612
4669cfca69a0
avoid crash when restoring warning states (bug #40199)
John W. Eaton <jwe@octave.org>
parents:
17281
diff
changeset
|
770 // Don't use the usual approach of attempting to extract a value |
4669cfca69a0
avoid crash when restoring warning states (bug #40199)
John W. Eaton <jwe@octave.org>
parents:
17281
diff
changeset
|
771 // and then checking error_state since this code might be |
4669cfca69a0
avoid crash when restoring warning states (bug #40199)
John W. Eaton <jwe@octave.org>
parents:
17281
diff
changeset
|
772 // executing when error_state is already set. But do fail |
4669cfca69a0
avoid crash when restoring warning states (bug #40199)
John W. Eaton <jwe@octave.org>
parents:
17281
diff
changeset
|
773 // spectacularly if .saved_warning_states. is not an octave_map |
4669cfca69a0
avoid crash when restoring warning states (bug #40199)
John W. Eaton <jwe@octave.org>
parents:
17281
diff
changeset
|
774 // (or octave_scalar_map) object. |
15427
6823ad7a25b1
implement local option for warnings
John W. Eaton <jwe@octave.org>
parents:
15337
diff
changeset
|
775 |
17612
4669cfca69a0
avoid crash when restoring warning states (bug #40199)
John W. Eaton <jwe@octave.org>
parents:
17281
diff
changeset
|
776 if (! val.is_map ()) |
15427
6823ad7a25b1
implement local option for warnings
John W. Eaton <jwe@octave.org>
parents:
15337
diff
changeset
|
777 panic_impossible (); |
6823ad7a25b1
implement local option for warnings
John W. Eaton <jwe@octave.org>
parents:
15337
diff
changeset
|
778 |
17612
4669cfca69a0
avoid crash when restoring warning states (bug #40199)
John W. Eaton <jwe@octave.org>
parents:
17281
diff
changeset
|
779 octave_map m = val.map_value (); |
4669cfca69a0
avoid crash when restoring warning states (bug #40199)
John W. Eaton <jwe@octave.org>
parents:
17281
diff
changeset
|
780 |
15427
6823ad7a25b1
implement local option for warnings
John W. Eaton <jwe@octave.org>
parents:
15337
diff
changeset
|
781 Cell ids = m.contents ("identifier"); |
6823ad7a25b1
implement local option for warnings
John W. Eaton <jwe@octave.org>
parents:
15337
diff
changeset
|
782 Cell states = m.contents ("state"); |
6823ad7a25b1
implement local option for warnings
John W. Eaton <jwe@octave.org>
parents:
15337
diff
changeset
|
783 |
6823ad7a25b1
implement local option for warnings
John W. Eaton <jwe@octave.org>
parents:
15337
diff
changeset
|
784 for (octave_idx_type i = 0; i < m.numel (); i++) |
6823ad7a25b1
implement local option for warnings
John W. Eaton <jwe@octave.org>
parents:
15337
diff
changeset
|
785 Fwarning (ovl (states(i), ids(i))); |
6823ad7a25b1
implement local option for warnings
John W. Eaton <jwe@octave.org>
parents:
15337
diff
changeset
|
786 } |
6823ad7a25b1
implement local option for warnings
John W. Eaton <jwe@octave.org>
parents:
15337
diff
changeset
|
787 } |
6823ad7a25b1
implement local option for warnings
John W. Eaton <jwe@octave.org>
parents:
15337
diff
changeset
|
788 |
4700 | 789 DEFUN (nargin, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17757
diff
changeset
|
790 "-*- texinfo -*-\n\ |
10840 | 791 @deftypefn {Built-in Function} {} nargin ()\n\ |
14136
20cb178716ee
Make nargin and nargout behave more like Matlab's (Bug #32700)
Iain Murray <iain@iainmurray.net>
parents:
12483
diff
changeset
|
792 @deftypefnx {Built-in Function} {} nargin (@var{fcn})\n\ |
4700 | 793 Within a function, return the number of arguments passed to the function.\n\ |
794 At the top level, return the number of command line arguments passed to\n\ | |
14136
20cb178716ee
Make nargin and nargout behave more like Matlab's (Bug #32700)
Iain Murray <iain@iainmurray.net>
parents:
12483
diff
changeset
|
795 Octave.\n\ |
20cb178716ee
Make nargin and nargout behave more like Matlab's (Bug #32700)
Iain Murray <iain@iainmurray.net>
parents:
12483
diff
changeset
|
796 \n\ |
20cb178716ee
Make nargin and nargout behave more like Matlab's (Bug #32700)
Iain Murray <iain@iainmurray.net>
parents:
12483
diff
changeset
|
797 If called with the optional argument @var{fcn}, a function name or handle,\n\ |
20cb178716ee
Make nargin and nargout behave more like Matlab's (Bug #32700)
Iain Murray <iain@iainmurray.net>
parents:
12483
diff
changeset
|
798 return the declared number of arguments that the function can accept.\n\ |
20cb178716ee
Make nargin and nargout behave more like Matlab's (Bug #32700)
Iain Murray <iain@iainmurray.net>
parents:
12483
diff
changeset
|
799 If the last argument is @var{varargin} the returned value is negative.\n\ |
20cb178716ee
Make nargin and nargout behave more like Matlab's (Bug #32700)
Iain Murray <iain@iainmurray.net>
parents:
12483
diff
changeset
|
800 This feature does not work on builtin functions.\n\ |
13749
62d1f56b0be7
New nthargout function
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
13241
diff
changeset
|
801 @seealso{nargout, varargin, isargout, varargout, nthargout}\n\ |
4700 | 802 @end deftypefn") |
803 { | |
804 octave_value retval; | |
805 | |
806 int nargin = args.length (); | |
807 | |
808 if (nargin == 1) | |
809 { | |
14136
20cb178716ee
Make nargin and nargout behave more like Matlab's (Bug #32700)
Iain Murray <iain@iainmurray.net>
parents:
12483
diff
changeset
|
810 octave_value func = args(0); |
4700 | 811 |
14136
20cb178716ee
Make nargin and nargout behave more like Matlab's (Bug #32700)
Iain Murray <iain@iainmurray.net>
parents:
12483
diff
changeset
|
812 if (func.is_string ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
813 { |
14136
20cb178716ee
Make nargin and nargout behave more like Matlab's (Bug #32700)
Iain Murray <iain@iainmurray.net>
parents:
12483
diff
changeset
|
814 std::string name = func.string_value (); |
20cb178716ee
Make nargin and nargout behave more like Matlab's (Bug #32700)
Iain Murray <iain@iainmurray.net>
parents:
12483
diff
changeset
|
815 func = symbol_table::find_function (name); |
20cb178716ee
Make nargin and nargout behave more like Matlab's (Bug #32700)
Iain Murray <iain@iainmurray.net>
parents:
12483
diff
changeset
|
816 if (func.is_undefined ()) |
20cb178716ee
Make nargin and nargout behave more like Matlab's (Bug #32700)
Iain Murray <iain@iainmurray.net>
parents:
12483
diff
changeset
|
817 error ("nargout: invalid function name: %s", name.c_str ()); |
20cb178716ee
Make nargin and nargout behave more like Matlab's (Bug #32700)
Iain Murray <iain@iainmurray.net>
parents:
12483
diff
changeset
|
818 } |
13785
daf81e42960c
allow nargin to work for functions that are not already loaded
John W. Eaton <jwe@octave.org>
parents:
13749
diff
changeset
|
819 |
14136
20cb178716ee
Make nargin and nargout behave more like Matlab's (Bug #32700)
Iain Murray <iain@iainmurray.net>
parents:
12483
diff
changeset
|
820 octave_function *fcn_val = func.function_value (); |
20cb178716ee
Make nargin and nargout behave more like Matlab's (Bug #32700)
Iain Murray <iain@iainmurray.net>
parents:
12483
diff
changeset
|
821 if (fcn_val) |
20cb178716ee
Make nargin and nargout behave more like Matlab's (Bug #32700)
Iain Murray <iain@iainmurray.net>
parents:
12483
diff
changeset
|
822 { |
20cb178716ee
Make nargin and nargout behave more like Matlab's (Bug #32700)
Iain Murray <iain@iainmurray.net>
parents:
12483
diff
changeset
|
823 octave_user_function *fcn = fcn_val->user_function_value (true); |
4700 | 824 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
825 if (fcn) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
826 { |
14136
20cb178716ee
Make nargin and nargout behave more like Matlab's (Bug #32700)
Iain Murray <iain@iainmurray.net>
parents:
12483
diff
changeset
|
827 tree_parameter_list *param_list = fcn->parameter_list (); |
20cb178716ee
Make nargin and nargout behave more like Matlab's (Bug #32700)
Iain Murray <iain@iainmurray.net>
parents:
12483
diff
changeset
|
828 |
20cb178716ee
Make nargin and nargout behave more like Matlab's (Bug #32700)
Iain Murray <iain@iainmurray.net>
parents:
12483
diff
changeset
|
829 retval = param_list ? param_list->length () : 0; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
830 if (fcn->takes_varargs ()) |
14136
20cb178716ee
Make nargin and nargout behave more like Matlab's (Bug #32700)
Iain Murray <iain@iainmurray.net>
parents:
12483
diff
changeset
|
831 retval = -1 - retval; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
832 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
833 else |
13785
daf81e42960c
allow nargin to work for functions that are not already loaded
John W. Eaton <jwe@octave.org>
parents:
13749
diff
changeset
|
834 { |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17757
diff
changeset
|
835 // Matlab gives up for histc, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17757
diff
changeset
|
836 // so maybe it's ok that that we give up somtimes too? |
14136
20cb178716ee
Make nargin and nargout behave more like Matlab's (Bug #32700)
Iain Murray <iain@iainmurray.net>
parents:
12483
diff
changeset
|
837 error ("nargin: nargin information not available for builtin functions"); |
13785
daf81e42960c
allow nargin to work for functions that are not already loaded
John W. Eaton <jwe@octave.org>
parents:
13749
diff
changeset
|
838 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
839 } |
4700 | 840 else |
14136
20cb178716ee
Make nargin and nargout behave more like Matlab's (Bug #32700)
Iain Murray <iain@iainmurray.net>
parents:
12483
diff
changeset
|
841 error ("nargin: FCN must be a string or function handle"); |
4700 | 842 } |
843 else if (nargin == 0) | |
844 { | |
7336 | 845 retval = symbol_table::varval (".nargin."); |
4700 | 846 |
7336 | 847 if (retval.is_undefined ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
848 retval = 0; |
4700 | 849 } |
850 else | |
5823 | 851 print_usage (); |
4700 | 852 |
853 return retval; | |
854 } | |
855 | |
856 DEFUN (nargout, args, , | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17757
diff
changeset
|
857 "-*- texinfo -*-\n\ |
10840 | 858 @deftypefn {Built-in Function} {} nargout ()\n\ |
14136
20cb178716ee
Make nargin and nargout behave more like Matlab's (Bug #32700)
Iain Murray <iain@iainmurray.net>
parents:
12483
diff
changeset
|
859 @deftypefnx {Built-in Function} {} nargout (@var{fcn})\n\ |
4700 | 860 Within a function, return the number of values the caller expects to\n\ |
14136
20cb178716ee
Make nargin and nargout behave more like Matlab's (Bug #32700)
Iain Murray <iain@iainmurray.net>
parents:
12483
diff
changeset
|
861 receive. If called with the optional argument @var{fcn}, a function\n\ |
20cb178716ee
Make nargin and nargout behave more like Matlab's (Bug #32700)
Iain Murray <iain@iainmurray.net>
parents:
12483
diff
changeset
|
862 name or handle, return the number of declared output values that the\n\ |
14366
b76f0740940e
doc: Periodic grammar check of documentation.
Rik <octave@nomad.inbox5.com>
parents:
14328
diff
changeset
|
863 function can produce. If the final output argument is @var{varargout}\n\ |
14136
20cb178716ee
Make nargin and nargout behave more like Matlab's (Bug #32700)
Iain Murray <iain@iainmurray.net>
parents:
12483
diff
changeset
|
864 the returned value is negative.\n\ |
4700 | 865 \n\ |
866 For example,\n\ | |
867 \n\ | |
868 @example\n\ | |
869 f ()\n\ | |
870 @end example\n\ | |
871 \n\ | |
872 @noindent\n\ | |
4704 | 873 will cause @code{nargout} to return 0 inside the function @code{f} and\n\ |
4700 | 874 \n\ |
875 @example\n\ | |
876 [s, t] = f ()\n\ | |
877 @end example\n\ | |
878 \n\ | |
879 @noindent\n\ | |
880 will cause @code{nargout} to return 2 inside the function\n\ | |
881 @code{f}.\n\ | |
882 \n\ | |
14136
20cb178716ee
Make nargin and nargout behave more like Matlab's (Bug #32700)
Iain Murray <iain@iainmurray.net>
parents:
12483
diff
changeset
|
883 In the second usage,\n\ |
20cb178716ee
Make nargin and nargout behave more like Matlab's (Bug #32700)
Iain Murray <iain@iainmurray.net>
parents:
12483
diff
changeset
|
884 \n\ |
20cb178716ee
Make nargin and nargout behave more like Matlab's (Bug #32700)
Iain Murray <iain@iainmurray.net>
parents:
12483
diff
changeset
|
885 @example\n\ |
17757
dae2230227a7
doc: Use double-quote in preference to single quote in code examples.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
886 nargout (@@histc) \% or nargout (\"histc\")\n\ |
14136
20cb178716ee
Make nargin and nargout behave more like Matlab's (Bug #32700)
Iain Murray <iain@iainmurray.net>
parents:
12483
diff
changeset
|
887 @end example\n\ |
20cb178716ee
Make nargin and nargout behave more like Matlab's (Bug #32700)
Iain Murray <iain@iainmurray.net>
parents:
12483
diff
changeset
|
888 \n\ |
14366
b76f0740940e
doc: Periodic grammar check of documentation.
Rik <octave@nomad.inbox5.com>
parents:
14328
diff
changeset
|
889 @noindent\n\ |
14136
20cb178716ee
Make nargin and nargout behave more like Matlab's (Bug #32700)
Iain Murray <iain@iainmurray.net>
parents:
12483
diff
changeset
|
890 will return 2, because @code{histc} has two outputs, whereas\n\ |
20cb178716ee
Make nargin and nargout behave more like Matlab's (Bug #32700)
Iain Murray <iain@iainmurray.net>
parents:
12483
diff
changeset
|
891 \n\ |
20cb178716ee
Make nargin and nargout behave more like Matlab's (Bug #32700)
Iain Murray <iain@iainmurray.net>
parents:
12483
diff
changeset
|
892 @example\n\ |
20cb178716ee
Make nargin and nargout behave more like Matlab's (Bug #32700)
Iain Murray <iain@iainmurray.net>
parents:
12483
diff
changeset
|
893 nargout (@@deal)\n\ |
20cb178716ee
Make nargin and nargout behave more like Matlab's (Bug #32700)
Iain Murray <iain@iainmurray.net>
parents:
12483
diff
changeset
|
894 @end example\n\ |
20cb178716ee
Make nargin and nargout behave more like Matlab's (Bug #32700)
Iain Murray <iain@iainmurray.net>
parents:
12483
diff
changeset
|
895 \n\ |
14366
b76f0740940e
doc: Periodic grammar check of documentation.
Rik <octave@nomad.inbox5.com>
parents:
14328
diff
changeset
|
896 @noindent\n\ |
14136
20cb178716ee
Make nargin and nargout behave more like Matlab's (Bug #32700)
Iain Murray <iain@iainmurray.net>
parents:
12483
diff
changeset
|
897 will return -1, because @code{deal} has a variable number of outputs.\n\ |
20cb178716ee
Make nargin and nargout behave more like Matlab's (Bug #32700)
Iain Murray <iain@iainmurray.net>
parents:
12483
diff
changeset
|
898 \n\ |
20cb178716ee
Make nargin and nargout behave more like Matlab's (Bug #32700)
Iain Murray <iain@iainmurray.net>
parents:
12483
diff
changeset
|
899 At the top level, @code{nargout} with no argument is undefined.\n\ |
20cb178716ee
Make nargin and nargout behave more like Matlab's (Bug #32700)
Iain Murray <iain@iainmurray.net>
parents:
12483
diff
changeset
|
900 @code{nargout} does not work on builtin functions.\n\ |
20cb178716ee
Make nargin and nargout behave more like Matlab's (Bug #32700)
Iain Murray <iain@iainmurray.net>
parents:
12483
diff
changeset
|
901 @code{nargout} returns -1 for all anonymous functions.\n\ |
13749
62d1f56b0be7
New nthargout function
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
13241
diff
changeset
|
902 @seealso{nargin, varargin, isargout, varargout, nthargout}\n\ |
4700 | 903 @end deftypefn") |
904 { | |
905 octave_value retval; | |
906 | |
907 int nargin = args.length (); | |
908 | |
909 if (nargin == 1) | |
910 { | |
14136
20cb178716ee
Make nargin and nargout behave more like Matlab's (Bug #32700)
Iain Murray <iain@iainmurray.net>
parents:
12483
diff
changeset
|
911 octave_value func = args(0); |
4700 | 912 |
14136
20cb178716ee
Make nargin and nargout behave more like Matlab's (Bug #32700)
Iain Murray <iain@iainmurray.net>
parents:
12483
diff
changeset
|
913 if (func.is_string ()) |
20cb178716ee
Make nargin and nargout behave more like Matlab's (Bug #32700)
Iain Murray <iain@iainmurray.net>
parents:
12483
diff
changeset
|
914 { |
20cb178716ee
Make nargin and nargout behave more like Matlab's (Bug #32700)
Iain Murray <iain@iainmurray.net>
parents:
12483
diff
changeset
|
915 std::string name = func.string_value (); |
20cb178716ee
Make nargin and nargout behave more like Matlab's (Bug #32700)
Iain Murray <iain@iainmurray.net>
parents:
12483
diff
changeset
|
916 func = symbol_table::find_function (name); |
20cb178716ee
Make nargin and nargout behave more like Matlab's (Bug #32700)
Iain Murray <iain@iainmurray.net>
parents:
12483
diff
changeset
|
917 if (func.is_undefined ()) |
20cb178716ee
Make nargin and nargout behave more like Matlab's (Bug #32700)
Iain Murray <iain@iainmurray.net>
parents:
12483
diff
changeset
|
918 error ("nargout: invalid function name: %s", name.c_str ()); |
20cb178716ee
Make nargin and nargout behave more like Matlab's (Bug #32700)
Iain Murray <iain@iainmurray.net>
parents:
12483
diff
changeset
|
919 } |
20cb178716ee
Make nargin and nargout behave more like Matlab's (Bug #32700)
Iain Murray <iain@iainmurray.net>
parents:
12483
diff
changeset
|
920 |
20cb178716ee
Make nargin and nargout behave more like Matlab's (Bug #32700)
Iain Murray <iain@iainmurray.net>
parents:
12483
diff
changeset
|
921 if (func.is_inline_function ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
922 { |
14136
20cb178716ee
Make nargin and nargout behave more like Matlab's (Bug #32700)
Iain Murray <iain@iainmurray.net>
parents:
12483
diff
changeset
|
923 retval = 1; |
20cb178716ee
Make nargin and nargout behave more like Matlab's (Bug #32700)
Iain Murray <iain@iainmurray.net>
parents:
12483
diff
changeset
|
924 return retval; |
20cb178716ee
Make nargin and nargout behave more like Matlab's (Bug #32700)
Iain Murray <iain@iainmurray.net>
parents:
12483
diff
changeset
|
925 } |
20cb178716ee
Make nargin and nargout behave more like Matlab's (Bug #32700)
Iain Murray <iain@iainmurray.net>
parents:
12483
diff
changeset
|
926 |
20cb178716ee
Make nargin and nargout behave more like Matlab's (Bug #32700)
Iain Murray <iain@iainmurray.net>
parents:
12483
diff
changeset
|
927 if (func.is_function_handle ()) |
20cb178716ee
Make nargin and nargout behave more like Matlab's (Bug #32700)
Iain Murray <iain@iainmurray.net>
parents:
12483
diff
changeset
|
928 { |
20cb178716ee
Make nargin and nargout behave more like Matlab's (Bug #32700)
Iain Murray <iain@iainmurray.net>
parents:
12483
diff
changeset
|
929 octave_fcn_handle *fh = func.fcn_handle_value (); |
20cb178716ee
Make nargin and nargout behave more like Matlab's (Bug #32700)
Iain Murray <iain@iainmurray.net>
parents:
12483
diff
changeset
|
930 std::string fh_nm = fh->fcn_name (); |
4930 | 931 |
14136
20cb178716ee
Make nargin and nargout behave more like Matlab's (Bug #32700)
Iain Murray <iain@iainmurray.net>
parents:
12483
diff
changeset
|
932 if (fh_nm == octave_fcn_handle::anonymous) |
20cb178716ee
Make nargin and nargout behave more like Matlab's (Bug #32700)
Iain Murray <iain@iainmurray.net>
parents:
12483
diff
changeset
|
933 { |
20cb178716ee
Make nargin and nargout behave more like Matlab's (Bug #32700)
Iain Murray <iain@iainmurray.net>
parents:
12483
diff
changeset
|
934 retval = -1; |
20cb178716ee
Make nargin and nargout behave more like Matlab's (Bug #32700)
Iain Murray <iain@iainmurray.net>
parents:
12483
diff
changeset
|
935 return retval; |
20cb178716ee
Make nargin and nargout behave more like Matlab's (Bug #32700)
Iain Murray <iain@iainmurray.net>
parents:
12483
diff
changeset
|
936 } |
20cb178716ee
Make nargin and nargout behave more like Matlab's (Bug #32700)
Iain Murray <iain@iainmurray.net>
parents:
12483
diff
changeset
|
937 } |
20cb178716ee
Make nargin and nargout behave more like Matlab's (Bug #32700)
Iain Murray <iain@iainmurray.net>
parents:
12483
diff
changeset
|
938 |
20cb178716ee
Make nargin and nargout behave more like Matlab's (Bug #32700)
Iain Murray <iain@iainmurray.net>
parents:
12483
diff
changeset
|
939 octave_function *fcn_val = func.function_value (); |
20cb178716ee
Make nargin and nargout behave more like Matlab's (Bug #32700)
Iain Murray <iain@iainmurray.net>
parents:
12483
diff
changeset
|
940 if (fcn_val) |
20cb178716ee
Make nargin and nargout behave more like Matlab's (Bug #32700)
Iain Murray <iain@iainmurray.net>
parents:
12483
diff
changeset
|
941 { |
20cb178716ee
Make nargin and nargout behave more like Matlab's (Bug #32700)
Iain Murray <iain@iainmurray.net>
parents:
12483
diff
changeset
|
942 octave_user_function *fcn = fcn_val->user_function_value (true); |
4700 | 943 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
944 if (fcn) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
945 { |
14136
20cb178716ee
Make nargin and nargout behave more like Matlab's (Bug #32700)
Iain Murray <iain@iainmurray.net>
parents:
12483
diff
changeset
|
946 tree_parameter_list *ret_list = fcn->return_list (); |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17757
diff
changeset
|
947 |
14136
20cb178716ee
Make nargin and nargout behave more like Matlab's (Bug #32700)
Iain Murray <iain@iainmurray.net>
parents:
12483
diff
changeset
|
948 retval = ret_list ? ret_list->length () : 0; |
20cb178716ee
Make nargin and nargout behave more like Matlab's (Bug #32700)
Iain Murray <iain@iainmurray.net>
parents:
12483
diff
changeset
|
949 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
950 if (fcn->takes_var_return ()) |
14136
20cb178716ee
Make nargin and nargout behave more like Matlab's (Bug #32700)
Iain Murray <iain@iainmurray.net>
parents:
12483
diff
changeset
|
951 retval = -1 - retval; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
952 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
953 else |
14136
20cb178716ee
Make nargin and nargout behave more like Matlab's (Bug #32700)
Iain Murray <iain@iainmurray.net>
parents:
12483
diff
changeset
|
954 { |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17757
diff
changeset
|
955 // JWE said this information is not available (2011-03-10) |
14136
20cb178716ee
Make nargin and nargout behave more like Matlab's (Bug #32700)
Iain Murray <iain@iainmurray.net>
parents:
12483
diff
changeset
|
956 // without making intrusive changes to Octave. |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17757
diff
changeset
|
957 // Matlab gives up for histc, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17757
diff
changeset
|
958 // so maybe it's ok that we give up somtimes too? |
14136
20cb178716ee
Make nargin and nargout behave more like Matlab's (Bug #32700)
Iain Murray <iain@iainmurray.net>
parents:
12483
diff
changeset
|
959 error ("nargout: nargout information not available for builtin functions."); |
20cb178716ee
Make nargin and nargout behave more like Matlab's (Bug #32700)
Iain Murray <iain@iainmurray.net>
parents:
12483
diff
changeset
|
960 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
961 } |
4700 | 962 else |
14136
20cb178716ee
Make nargin and nargout behave more like Matlab's (Bug #32700)
Iain Murray <iain@iainmurray.net>
parents:
12483
diff
changeset
|
963 error ("nargout: FCN must be a string or function handle"); |
4700 | 964 } |
965 else if (nargin == 0) | |
966 { | |
7336 | 967 if (! symbol_table::at_top_level ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
968 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
969 retval = symbol_table::varval (".nargout."); |
4700 | 970 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
971 if (retval.is_undefined ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
972 retval = 0; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
973 } |
4700 | 974 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
975 error ("nargout: invalid call at top level"); |
4700 | 976 } |
977 else | |
5823 | 978 print_usage (); |
4700 | 979 |
980 return retval; | |
981 } | |
982 | |
9522
e79470be3ecb
implement subsasgn this-arg optimization
Jaroslav Hajek <highegg@gmail.com>
parents:
9396
diff
changeset
|
983 DEFUN (optimize_subsasgn_calls, args, nargout, |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17757
diff
changeset
|
984 "-*- texinfo -*-\n\ |
10840 | 985 @deftypefn {Built-in Function} {@var{val} =} optimize_subsasgn_calls ()\n\ |
986 @deftypefnx {Built-in Function} {@var{old_val} =} optimize_subsasgn_calls (@var{new_val})\n\ | |
13951
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
13785
diff
changeset
|
987 @deftypefnx {Built-in Function} {} optimize_subsasgn_calls (@var{new_val}, \"local\")\n\ |
9522
e79470be3ecb
implement subsasgn this-arg optimization
Jaroslav Hajek <highegg@gmail.com>
parents:
9396
diff
changeset
|
988 Query or set the internal flag for subsasgn method call optimizations.\n\ |
e79470be3ecb
implement subsasgn this-arg optimization
Jaroslav Hajek <highegg@gmail.com>
parents:
9396
diff
changeset
|
989 If true, Octave will attempt to eliminate the redundant copying when calling\n\ |
e79470be3ecb
implement subsasgn this-arg optimization
Jaroslav Hajek <highegg@gmail.com>
parents:
9396
diff
changeset
|
990 subsasgn method of a user-defined class.\n\ |
13951
79aa00a94e9e
doc: Document "local" option for configuration variables.
Rik <octave@nomad.inbox5.com>
parents:
13785
diff
changeset
|
991 \n\ |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
16856
diff
changeset
|
992 When called from inside a function with the @qcode{\"local\"} option, the\n\ |
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
16856
diff
changeset
|
993 variable is changed locally for the function and any subroutines it calls. \n\ |
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
16856
diff
changeset
|
994 The original variable value is restored when exiting the function.\n\ |
9522
e79470be3ecb
implement subsasgn this-arg optimization
Jaroslav Hajek <highegg@gmail.com>
parents:
9396
diff
changeset
|
995 @end deftypefn") |
e79470be3ecb
implement subsasgn this-arg optimization
Jaroslav Hajek <highegg@gmail.com>
parents:
9396
diff
changeset
|
996 { |
e79470be3ecb
implement subsasgn this-arg optimization
Jaroslav Hajek <highegg@gmail.com>
parents:
9396
diff
changeset
|
997 return SET_INTERNAL_VARIABLE (optimize_subsasgn_calls); |
e79470be3ecb
implement subsasgn this-arg optimization
Jaroslav Hajek <highegg@gmail.com>
parents:
9396
diff
changeset
|
998 } |
10832
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
999 |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
1000 static bool val_in_table (const Matrix& table, double val) |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
1001 { |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
1002 if (table.is_empty ()) |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
1003 return false; |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
1004 |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
1005 octave_idx_type i = table.lookup (val, ASCENDING); |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
1006 return (i > 0 && table(i-1) == val); |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
1007 } |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
1008 |
10847
7fa3c8e43357
change is_ignored_output to isargout
Jaroslav Hajek <highegg@gmail.com>
parents:
10846
diff
changeset
|
1009 static bool isargout1 (int nargout, const Matrix& ignored, double k) |
7fa3c8e43357
change is_ignored_output to isargout
Jaroslav Hajek <highegg@gmail.com>
parents:
10846
diff
changeset
|
1010 { |
7fa3c8e43357
change is_ignored_output to isargout
Jaroslav Hajek <highegg@gmail.com>
parents:
10846
diff
changeset
|
1011 if (k != xround (k) || k <= 0) |
7fa3c8e43357
change is_ignored_output to isargout
Jaroslav Hajek <highegg@gmail.com>
parents:
10846
diff
changeset
|
1012 { |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
1013 error ("isargout: K must be a positive integer"); |
10847
7fa3c8e43357
change is_ignored_output to isargout
Jaroslav Hajek <highegg@gmail.com>
parents:
10846
diff
changeset
|
1014 return false; |
7fa3c8e43357
change is_ignored_output to isargout
Jaroslav Hajek <highegg@gmail.com>
parents:
10846
diff
changeset
|
1015 } |
7fa3c8e43357
change is_ignored_output to isargout
Jaroslav Hajek <highegg@gmail.com>
parents:
10846
diff
changeset
|
1016 else |
7fa3c8e43357
change is_ignored_output to isargout
Jaroslav Hajek <highegg@gmail.com>
parents:
10846
diff
changeset
|
1017 return (k == 1 || k <= nargout) && ! val_in_table (ignored, k); |
7fa3c8e43357
change is_ignored_output to isargout
Jaroslav Hajek <highegg@gmail.com>
parents:
10846
diff
changeset
|
1018 } |
7fa3c8e43357
change is_ignored_output to isargout
Jaroslav Hajek <highegg@gmail.com>
parents:
10846
diff
changeset
|
1019 |
7fa3c8e43357
change is_ignored_output to isargout
Jaroslav Hajek <highegg@gmail.com>
parents:
10846
diff
changeset
|
1020 DEFUN (isargout, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17757
diff
changeset
|
1021 "-*- texinfo -*-\n\ |
10847
7fa3c8e43357
change is_ignored_output to isargout
Jaroslav Hajek <highegg@gmail.com>
parents:
10846
diff
changeset
|
1022 @deftypefn {Built-in Function} {} isargout (@var{k})\n\ |
11431
0d9640d755b1
Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents:
11304
diff
changeset
|
1023 Within a function, return a logical value indicating whether the argument\n\ |
0d9640d755b1
Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents:
11304
diff
changeset
|
1024 @var{k} will be assigned on output to a variable. If the result is false,\n\ |
0d9640d755b1
Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents:
11304
diff
changeset
|
1025 the argument has been ignored during the function call through the use of\n\ |
0d9640d755b1
Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents:
11304
diff
changeset
|
1026 the tilde (~) special output argument. Functions can use @code{isargout} to\n\ |
0d9640d755b1
Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents:
11304
diff
changeset
|
1027 avoid performing unnecessary calculations for outputs which are unwanted.\n\ |
0d9640d755b1
Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents:
11304
diff
changeset
|
1028 \n\ |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14573
diff
changeset
|
1029 If @var{k} is outside the range @code{1:max (nargout)}, the function returns\n\ |
11431
0d9640d755b1
Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents:
11304
diff
changeset
|
1030 false. @var{k} can also be an array, in which case the function works\n\ |
0d9640d755b1
Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents:
11304
diff
changeset
|
1031 element-by-element and a logical array is returned. At the top level,\n\ |
0d9640d755b1
Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents:
11304
diff
changeset
|
1032 @code{isargout} returns an error.\n\ |
13749
62d1f56b0be7
New nthargout function
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
13241
diff
changeset
|
1033 @seealso{nargout, nargin, varargin, varargout, nthargout}\n\ |
10832
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
1034 @end deftypefn") |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
1035 { |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
1036 octave_value retval; |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
1037 |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
1038 int nargin = args.length (); |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
1039 |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
1040 if (nargin == 1) |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
1041 { |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
1042 if (! symbol_table::at_top_level ()) |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
1043 { |
10847
7fa3c8e43357
change is_ignored_output to isargout
Jaroslav Hajek <highegg@gmail.com>
parents:
10846
diff
changeset
|
1044 int nargout1 = symbol_table::varval (".nargout.").int_value (); |
7fa3c8e43357
change is_ignored_output to isargout
Jaroslav Hajek <highegg@gmail.com>
parents:
10846
diff
changeset
|
1045 if (error_state) |
7fa3c8e43357
change is_ignored_output to isargout
Jaroslav Hajek <highegg@gmail.com>
parents:
10846
diff
changeset
|
1046 { |
7fa3c8e43357
change is_ignored_output to isargout
Jaroslav Hajek <highegg@gmail.com>
parents:
10846
diff
changeset
|
1047 error ("isargout: internal error"); |
7fa3c8e43357
change is_ignored_output to isargout
Jaroslav Hajek <highegg@gmail.com>
parents:
10846
diff
changeset
|
1048 return retval; |
7fa3c8e43357
change is_ignored_output to isargout
Jaroslav Hajek <highegg@gmail.com>
parents:
10846
diff
changeset
|
1049 } |
7fa3c8e43357
change is_ignored_output to isargout
Jaroslav Hajek <highegg@gmail.com>
parents:
10846
diff
changeset
|
1050 |
10832
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
1051 Matrix ignored; |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
1052 octave_value tmp = symbol_table::varval (".ignored."); |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
1053 if (tmp.is_defined ()) |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
1054 ignored = tmp.matrix_value (); |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
1055 |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
1056 if (args(0).is_scalar_type ()) |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
1057 { |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
1058 double k = args(0).double_value (); |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
1059 if (! error_state) |
10847
7fa3c8e43357
change is_ignored_output to isargout
Jaroslav Hajek <highegg@gmail.com>
parents:
10846
diff
changeset
|
1060 retval = isargout1 (nargout1, ignored, k); |
10832
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
1061 } |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
1062 else if (args(0).is_numeric_type ()) |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
1063 { |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
1064 const NDArray ka = args(0).array_value (); |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
1065 if (! error_state) |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
1066 { |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
1067 boolNDArray r (ka.dims ()); |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17757
diff
changeset
|
1068 for (octave_idx_type i = 0; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17757
diff
changeset
|
1069 i < ka.numel () && ! error_state; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17757
diff
changeset
|
1070 i++) |
10847
7fa3c8e43357
change is_ignored_output to isargout
Jaroslav Hajek <highegg@gmail.com>
parents:
10846
diff
changeset
|
1071 r(i) = isargout1 (nargout1, ignored, ka(i)); |
10832
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
1072 |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
1073 retval = r; |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
1074 } |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
1075 } |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
1076 else |
10847
7fa3c8e43357
change is_ignored_output to isargout
Jaroslav Hajek <highegg@gmail.com>
parents:
10846
diff
changeset
|
1077 gripe_wrong_type_arg ("isargout", args(0)); |
10832
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
1078 } |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
1079 else |
10847
7fa3c8e43357
change is_ignored_output to isargout
Jaroslav Hajek <highegg@gmail.com>
parents:
10846
diff
changeset
|
1080 error ("isargout: invalid call at top level"); |
10832
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
1081 } |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
1082 else |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
1083 print_usage (); |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
1084 |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
1085 return retval; |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10637
diff
changeset
|
1086 } |
14571
6131fead3135
ensure isargout is not sticky
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
1087 |
6131fead3135
ensure isargout is not sticky
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
1088 /* |
6131fead3135
ensure isargout is not sticky
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
1089 %!function [x, y] = try_isargout () |
6131fead3135
ensure isargout is not sticky
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
1090 %! if (isargout (1)) |
6131fead3135
ensure isargout is not sticky
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
1091 %! if (isargout (2)) |
6131fead3135
ensure isargout is not sticky
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
1092 %! x = 1; y = 2; |
6131fead3135
ensure isargout is not sticky
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
1093 %! else |
6131fead3135
ensure isargout is not sticky
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
1094 %! x = -1; |
6131fead3135
ensure isargout is not sticky
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
1095 %! endif |
6131fead3135
ensure isargout is not sticky
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
1096 %! else |
6131fead3135
ensure isargout is not sticky
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
1097 %! if (isargout (2)) |
6131fead3135
ensure isargout is not sticky
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
1098 %! y = -2; |
6131fead3135
ensure isargout is not sticky
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
1099 %! else |
6131fead3135
ensure isargout is not sticky
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
1100 %! error ("no outputs requested"); |
6131fead3135
ensure isargout is not sticky
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
1101 %! endif |
6131fead3135
ensure isargout is not sticky
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
1102 %! endif |
6131fead3135
ensure isargout is not sticky
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
1103 %!endfunction |
6131fead3135
ensure isargout is not sticky
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
1104 %! |
6131fead3135
ensure isargout is not sticky
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
1105 %!test |
6131fead3135
ensure isargout is not sticky
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
1106 %! [x, y] = try_isargout (); |
6131fead3135
ensure isargout is not sticky
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
1107 %! assert ([x, y], [1, 2]); |
6131fead3135
ensure isargout is not sticky
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
1108 %! |
6131fead3135
ensure isargout is not sticky
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
1109 %!test |
6131fead3135
ensure isargout is not sticky
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
1110 %! [x, ~] = try_isargout (); |
6131fead3135
ensure isargout is not sticky
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
1111 %! assert (x, -1); |
6131fead3135
ensure isargout is not sticky
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
1112 %! |
6131fead3135
ensure isargout is not sticky
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
1113 %!test |
6131fead3135
ensure isargout is not sticky
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
1114 %! [~, y] = try_isargout (); |
6131fead3135
ensure isargout is not sticky
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
1115 %! assert (y, -2); |
6131fead3135
ensure isargout is not sticky
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
1116 %! |
6131fead3135
ensure isargout is not sticky
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
1117 %!error [~, ~] = try_isargout (); |
6131fead3135
ensure isargout is not sticky
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
1118 %! |
6131fead3135
ensure isargout is not sticky
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
1119 %% Check to see that isargout isn't sticky: |
6131fead3135
ensure isargout is not sticky
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
1120 %!test |
6131fead3135
ensure isargout is not sticky
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
1121 %! [x, y] = try_isargout (); |
6131fead3135
ensure isargout is not sticky
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
1122 %! assert ([x, y], [1, 2]); |
16091
1785493171ac
pass lvalue_list to more subsref calls (bug #38374)
John W. Eaton <jwe@octave.org>
parents:
15582
diff
changeset
|
1123 %! |
1785493171ac
pass lvalue_list to more subsref calls (bug #38374)
John W. Eaton <jwe@octave.org>
parents:
15582
diff
changeset
|
1124 %% It should work without (): |
1785493171ac
pass lvalue_list to more subsref calls (bug #38374)
John W. Eaton <jwe@octave.org>
parents:
15582
diff
changeset
|
1125 %!test |
1785493171ac
pass lvalue_list to more subsref calls (bug #38374)
John W. Eaton <jwe@octave.org>
parents:
15582
diff
changeset
|
1126 %! [~, y] = try_isargout; |
1785493171ac
pass lvalue_list to more subsref calls (bug #38374)
John W. Eaton <jwe@octave.org>
parents:
15582
diff
changeset
|
1127 %! assert (y, -2); |
1785493171ac
pass lvalue_list to more subsref calls (bug #38374)
John W. Eaton <jwe@octave.org>
parents:
15582
diff
changeset
|
1128 %! |
1785493171ac
pass lvalue_list to more subsref calls (bug #38374)
John W. Eaton <jwe@octave.org>
parents:
15582
diff
changeset
|
1129 %% It should work in function handles, anonymous functions, and cell |
1785493171ac
pass lvalue_list to more subsref calls (bug #38374)
John W. Eaton <jwe@octave.org>
parents:
15582
diff
changeset
|
1130 %% arrays of handles or anonymous functions. |
1785493171ac
pass lvalue_list to more subsref calls (bug #38374)
John W. Eaton <jwe@octave.org>
parents:
15582
diff
changeset
|
1131 %!test |
1785493171ac
pass lvalue_list to more subsref calls (bug #38374)
John W. Eaton <jwe@octave.org>
parents:
15582
diff
changeset
|
1132 %! fh = @try_isargout; |
1785493171ac
pass lvalue_list to more subsref calls (bug #38374)
John W. Eaton <jwe@octave.org>
parents:
15582
diff
changeset
|
1133 %! af = @() try_isargout; |
1785493171ac
pass lvalue_list to more subsref calls (bug #38374)
John W. Eaton <jwe@octave.org>
parents:
15582
diff
changeset
|
1134 %! c = {fh, af}; |
1785493171ac
pass lvalue_list to more subsref calls (bug #38374)
John W. Eaton <jwe@octave.org>
parents:
15582
diff
changeset
|
1135 %! [~, y] = fh (); |
1785493171ac
pass lvalue_list to more subsref calls (bug #38374)
John W. Eaton <jwe@octave.org>
parents:
15582
diff
changeset
|
1136 %! assert (y, -2); |
1785493171ac
pass lvalue_list to more subsref calls (bug #38374)
John W. Eaton <jwe@octave.org>
parents:
15582
diff
changeset
|
1137 %! [~, y] = af (); |
1785493171ac
pass lvalue_list to more subsref calls (bug #38374)
John W. Eaton <jwe@octave.org>
parents:
15582
diff
changeset
|
1138 %! assert (y, -2); |
1785493171ac
pass lvalue_list to more subsref calls (bug #38374)
John W. Eaton <jwe@octave.org>
parents:
15582
diff
changeset
|
1139 %! [~, y] = c{1}(); |
1785493171ac
pass lvalue_list to more subsref calls (bug #38374)
John W. Eaton <jwe@octave.org>
parents:
15582
diff
changeset
|
1140 %! assert (y, -2); |
1785493171ac
pass lvalue_list to more subsref calls (bug #38374)
John W. Eaton <jwe@octave.org>
parents:
15582
diff
changeset
|
1141 %! [~, y] = c{2}(); |
1785493171ac
pass lvalue_list to more subsref calls (bug #38374)
John W. Eaton <jwe@octave.org>
parents:
15582
diff
changeset
|
1142 %! assert (y, -2); |
14571
6131fead3135
ensure isargout is not sticky
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
1143 */ |