annotate libinterp/corefcn/symtab.cc @ 31605:e88a07dec498 stable

maint: Use macros to begin/end C++ namespaces. * oct-conf-post-public.in.h: Define two macros (OCTAVE_BEGIN_NAMESPACE, OCTAVE_END_NAMESPACE) that can be used to start/end a namespace. * mk-opts.pl, build-env.h, build-env.in.cc, __betainc__.cc, __contourc__.cc, __dsearchn__.cc, __eigs__.cc, __expint__.cc, __ftp__.cc, __gammainc__.cc, __ichol__.cc, __ilu__.cc, __isprimelarge__.cc, __lin_interpn__.cc, __magick_read__.cc, __pchip_deriv__.cc, __qp__.cc, amd.cc, auto-shlib.cc, auto-shlib.h, balance.cc, base-text-renderer.cc, base-text-renderer.h, besselj.cc, bitfcns.cc, bsxfun.cc, c-file-ptr-stream.cc, c-file-ptr-stream.h, call-stack.cc, call-stack.h, ccolamd.cc, cellfun.cc, chol.cc, colamd.cc, colloc.cc, conv2.cc, daspk.cc, dasrt.cc, dassl.cc, data.cc, data.h, debug.cc, defaults.cc, defaults.h, defun-int.h, defun.cc, det.cc, dirfns.cc, display.cc, display.h, dlmread.cc, dmperm.cc, dot.cc, dynamic-ld.cc, dynamic-ld.h, eig.cc, ellipj.cc, environment.cc, environment.h, error.cc, error.h, errwarn.h, event-manager.cc, event-manager.h, event-queue.cc, event-queue.h, fcn-info.cc, fcn-info.h, fft.cc, fft2.cc, fftn.cc, file-io.cc, filter.cc, find.cc, ft-text-renderer.cc, ft-text-renderer.h, gcd.cc, getgrent.cc, getpwent.cc, getrusage.cc, givens.cc, gl-render.cc, gl-render.h, gl2ps-print.cc, gl2ps-print.h, graphics-toolkit.cc, graphics-toolkit.h, graphics.cc, graphics.in.h, gsvd.cc, gtk-manager.cc, gtk-manager.h, hash.cc, help.cc, help.h, hess.cc, hex2num.cc, hook-fcn.cc, hook-fcn.h, input.cc, input.h, interpreter-private.cc, interpreter-private.h, interpreter.cc, interpreter.h, inv.cc, jsondecode.cc, jsonencode.cc, kron.cc, latex-text-renderer.cc, latex-text-renderer.h, load-path.cc, load-path.h, load-save.cc, load-save.h, lookup.cc, ls-ascii-helper.cc, ls-ascii-helper.h, ls-oct-text.cc, ls-utils.cc, ls-utils.h, lsode.cc, lu.cc, mappers.cc, matrix_type.cc, max.cc, mex-private.h, mex.cc, mgorth.cc, nproc.cc, oct-fstrm.cc, oct-fstrm.h, oct-hdf5-types.cc, oct-hdf5-types.h, oct-hist.cc, oct-hist.h, oct-iostrm.cc, oct-iostrm.h, oct-opengl.h, oct-prcstrm.cc, oct-prcstrm.h, oct-procbuf.cc, oct-procbuf.h, oct-process.cc, oct-process.h, oct-stdstrm.h, oct-stream.cc, oct-stream.h, oct-strstrm.cc, oct-strstrm.h, oct-tex-lexer.in.ll, oct-tex-parser.yy, ordqz.cc, ordschur.cc, pager.cc, pager.h, pinv.cc, pow2.cc, pr-flt-fmt.cc, pr-output.cc, procstream.cc, procstream.h, psi.cc, qr.cc, quad.cc, quadcc.cc, qz.cc, rand.cc, rcond.cc, regexp.cc, schur.cc, settings.cc, settings.h, sighandlers.cc, sighandlers.h, sparse-xdiv.cc, sparse-xdiv.h, sparse-xpow.cc, sparse-xpow.h, sparse.cc, spparms.cc, sqrtm.cc, stack-frame.cc, stack-frame.h, stream-euler.cc, strfind.cc, strfns.cc, sub2ind.cc, svd.cc, sylvester.cc, symbfact.cc, syminfo.cc, syminfo.h, symrcm.cc, symrec.cc, symrec.h, symscope.cc, symscope.h, symtab.cc, symtab.h, syscalls.cc, sysdep.cc, sysdep.h, text-engine.cc, text-engine.h, text-renderer.cc, text-renderer.h, time.cc, toplev.cc, tril.cc, tsearch.cc, typecast.cc, url-handle-manager.cc, url-handle-manager.h, urlwrite.cc, utils.cc, utils.h, variables.cc, variables.h, xdiv.cc, xdiv.h, xnorm.cc, xnorm.h, xpow.cc, xpow.h, __delaunayn__.cc, __fltk_uigetfile__.cc, __glpk__.cc, __init_fltk__.cc, __init_gnuplot__.cc, __ode15__.cc, __voronoi__.cc, audiodevinfo.cc, audioread.cc, convhulln.cc, fftw.cc, gzip.cc, mk-build-env-features.sh, mk-builtins.pl, cdef-class.cc, cdef-class.h, cdef-fwd.h, cdef-manager.cc, cdef-manager.h, cdef-method.cc, cdef-method.h, cdef-object.cc, cdef-object.h, cdef-package.cc, cdef-package.h, cdef-property.cc, cdef-property.h, cdef-utils.cc, cdef-utils.h, ov-base.cc, ov-base.h, ov-bool-mat.cc, ov-builtin.h, ov-cell.cc, ov-class.cc, ov-class.h, ov-classdef.cc, ov-classdef.h, ov-complex.cc, ov-fcn-handle.cc, ov-fcn-handle.h, ov-fcn.h, ov-java.cc, ov-java.h, ov-mex-fcn.h, ov-null-mat.cc, ov-oncleanup.cc, ov-struct.cc, ov-typeinfo.cc, ov-typeinfo.h, ov-usr-fcn.cc, ov-usr-fcn.h, ov.cc, ov.h, octave.cc, octave.h, mk-ops.sh, op-b-b.cc, op-b-bm.cc, op-b-sbm.cc, op-bm-b.cc, op-bm-bm.cc, op-bm-sbm.cc, op-cdm-cdm.cc, op-cell.cc, op-chm.cc, op-class.cc, op-cm-cm.cc, op-cm-cs.cc, op-cm-m.cc, op-cm-s.cc, op-cm-scm.cc, op-cm-sm.cc, op-cs-cm.cc, op-cs-cs.cc, op-cs-m.cc, op-cs-s.cc, op-cs-scm.cc, op-cs-sm.cc, op-dm-dm.cc, op-dm-scm.cc, op-dm-sm.cc, op-dm-template.cc, op-dms-template.cc, op-fcdm-fcdm.cc, op-fcm-fcm.cc, op-fcm-fcs.cc, op-fcm-fm.cc, op-fcm-fs.cc, op-fcn.cc, op-fcs-fcm.cc, op-fcs-fcs.cc, op-fcs-fm.cc, op-fcs-fs.cc, op-fdm-fdm.cc, op-fm-fcm.cc, op-fm-fcs.cc, op-fm-fm.cc, op-fm-fs.cc, op-fs-fcm.cc, op-fs-fcs.cc, op-fs-fm.cc, op-fs-fs.cc, op-i16-i16.cc, op-i32-i32.cc, op-i64-i64.cc, op-i8-i8.cc, op-int-concat.cc, op-m-cm.cc, op-m-cs.cc, op-m-m.cc, op-m-s.cc, op-m-scm.cc, op-m-sm.cc, op-mi.cc, op-pm-pm.cc, op-pm-scm.cc, op-pm-sm.cc, op-pm-template.cc, op-range.cc, op-s-cm.cc, op-s-cs.cc, op-s-m.cc, op-s-s.cc, op-s-scm.cc, op-s-sm.cc, op-sbm-b.cc, op-sbm-bm.cc, op-sbm-sbm.cc, op-scm-cm.cc, op-scm-cs.cc, op-scm-m.cc, op-scm-s.cc, op-scm-scm.cc, op-scm-sm.cc, op-sm-cm.cc, op-sm-cs.cc, op-sm-m.cc, op-sm-s.cc, op-sm-scm.cc, op-sm-sm.cc, op-str-m.cc, op-str-s.cc, op-str-str.cc, op-struct.cc, op-ui16-ui16.cc, op-ui32-ui32.cc, op-ui64-ui64.cc, op-ui8-ui8.cc, ops.h, anon-fcn-validator.cc, anon-fcn-validator.h, bp-table.cc, bp-table.h, comment-list.cc, comment-list.h, filepos.h, lex.h, lex.ll, oct-lvalue.cc, oct-lvalue.h, oct-parse.yy, parse.h, profiler.cc, profiler.h, pt-anon-scopes.cc, pt-anon-scopes.h, pt-arg-list.cc, pt-arg-list.h, pt-args-block.cc, pt-args-block.h, pt-array-list.cc, pt-array-list.h, pt-assign.cc, pt-assign.h, pt-binop.cc, pt-binop.h, pt-bp.cc, pt-bp.h, pt-cbinop.cc, pt-cbinop.h, pt-cell.cc, pt-cell.h, pt-check.cc, pt-check.h, pt-classdef.cc, pt-classdef.h, pt-cmd.h, pt-colon.cc, pt-colon.h, pt-const.cc, pt-const.h, pt-decl.cc, pt-decl.h, pt-eval.cc, pt-eval.h, pt-except.cc, pt-except.h, pt-exp.cc, pt-exp.h, pt-fcn-handle.cc, pt-fcn-handle.h, pt-id.cc, pt-id.h, pt-idx.cc, pt-idx.h, pt-jump.h, pt-loop.cc, pt-loop.h, pt-mat.cc, pt-mat.h, pt-misc.cc, pt-misc.h, pt-pr-code.cc, pt-pr-code.h, pt-select.cc, pt-select.h, pt-spmd.cc, pt-spmd.h, pt-stmt.cc, pt-stmt.h, pt-tm-const.cc, pt-tm-const.h, pt-unop.cc, pt-unop.h, pt-vm-eval.cc, pt-walk.cc, pt-walk.h, pt.cc, pt.h, token.cc, token.h, Range.cc, Range.h, idx-vector.cc, idx-vector.h, range-fwd.h, CollocWt.cc, CollocWt.h, aepbalance.cc, aepbalance.h, chol.cc, chol.h, gepbalance.cc, gepbalance.h, gsvd.cc, gsvd.h, hess.cc, hess.h, lo-mappers.cc, lo-mappers.h, lo-specfun.cc, lo-specfun.h, lu.cc, lu.h, oct-convn.cc, oct-convn.h, oct-fftw.cc, oct-fftw.h, oct-norm.cc, oct-norm.h, oct-rand.cc, oct-rand.h, oct-spparms.cc, oct-spparms.h, qr.cc, qr.h, qrp.cc, qrp.h, randgamma.cc, randgamma.h, randmtzig.cc, randmtzig.h, randpoisson.cc, randpoisson.h, schur.cc, schur.h, sparse-chol.cc, sparse-chol.h, sparse-lu.cc, sparse-lu.h, sparse-qr.cc, sparse-qr.h, svd.cc, svd.h, child-list.cc, child-list.h, dir-ops.cc, dir-ops.h, file-ops.cc, file-ops.h, file-stat.cc, file-stat.h, lo-sysdep.cc, lo-sysdep.h, lo-sysinfo.cc, lo-sysinfo.h, mach-info.cc, mach-info.h, oct-env.cc, oct-env.h, oct-group.cc, oct-group.h, oct-password.cc, oct-password.h, oct-syscalls.cc, oct-syscalls.h, oct-time.cc, oct-time.h, oct-uname.cc, oct-uname.h, action-container.cc, action-container.h, base-list.h, cmd-edit.cc, cmd-edit.h, cmd-hist.cc, cmd-hist.h, f77-fcn.h, file-info.cc, file-info.h, lo-array-errwarn.cc, lo-array-errwarn.h, lo-hash.cc, lo-hash.h, lo-ieee.h, lo-regexp.cc, lo-regexp.h, lo-utils.cc, lo-utils.h, oct-base64.cc, oct-base64.h, oct-glob.cc, oct-glob.h, oct-inttypes.h, oct-mutex.cc, oct-mutex.h, oct-refcount.h, oct-shlib.cc, oct-shlib.h, oct-sparse.cc, oct-sparse.h, oct-string.h, octave-preserve-stream-state.h, pathsearch.cc, pathsearch.h, quit.cc, quit.h, unwind-prot.cc, unwind-prot.h, url-transfer.cc, url-transfer.h : Use new macros to begin/end C++ namespaces.
author Rik <rik@octave.org>
date Thu, 01 Dec 2022 14:23:45 -0800
parents 32d2b6604a9f
children aac27ad79be6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
1 ////////////////////////////////////////////////////////////////////////
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
2 //
30564
796f54d4ddbf update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 29961
diff changeset
3 // Copyright (C) 1993-2022 The Octave Project Developers
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
4 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
5 // See the file COPYRIGHT.md in the top-level directory of this
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
6 // distribution or <https://octave.org/copyright/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
7 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
8 // This file is part of Octave.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
9 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
10 // Octave is free software: you can redistribute it and/or modify it
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
11 // under the terms of the GNU General Public License as published by
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
12 // the Free Software Foundation, either version 3 of the License, or
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
13 // (at your option) any later version.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
14 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
15 // Octave is distributed in the hope that it will be useful, but
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
18 // GNU General Public License for more details.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
19 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
20 // You should have received a copy of the GNU General Public License
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
21 // along with Octave; see the file COPYING. If not, see
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
22 // <https://www.gnu.org/licenses/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
23 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
24 ////////////////////////////////////////////////////////////////////////
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
25
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21660
diff changeset
26 #if defined (HAVE_CONFIG_H)
21301
40de9f8f23a6 Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents: 21264
diff changeset
27 # include "config.h"
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
28 #endif
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
29
26661
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
30 #include <iostream>
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
31
17870
1d2e709bbbda rework short_disp methods
John W. Eaton <jwe@octave.org>
parents: 17824
diff changeset
32 #include <sstream>
1d2e709bbbda rework short_disp methods
John W. Eaton <jwe@octave.org>
parents: 17824
diff changeset
33
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7081
diff changeset
34 #include "oct-time.h"
1755
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1742
diff changeset
35
23137
334119c390b3 move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents: 23127
diff changeset
36 #include "bp-table.h"
3308
7ae1928ca623 [project @ 1999-10-21 08:57:11 by jwe]
jwe
parents: 3258
diff changeset
37 #include "defun.h"
24263
3b302b2890d7 disentangle symbol_record, scope, and fcn_info from symbol_table class
John W. Eaton <jwe@octave.org>
parents: 24064
diff changeset
38 #include "fcn-info.h"
23438
d24d01273bd0 eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents: 23433
diff changeset
39 #include "interpreter-private.h"
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23581
diff changeset
40 #include "interpreter.h"
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7081
diff changeset
41 #include "load-path.h"
16048
10142aad4b9f Implement indirect method call: fun(obj, ...).
Michael Goffioul <michael.goffioul@gmail.com>
parents: 15467
diff changeset
42 #include "ov-classdef.h"
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7081
diff changeset
43 #include "ov-fcn.h"
8819
96d87674b818 also stash directory name for subfunctions
John W. Eaton <jwe@octave.org>
parents: 8785
diff changeset
44 #include "ov-usr-fcn.h"
7336
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7081
diff changeset
45 #include "pager.h"
745a8299c2b5 [project @ 2007-12-28 20:56:55 by jwe]
jwe
parents: 7081
diff changeset
46 #include "parse.h"
20207
abf85f8cbd6c Expand type() to work on command-line entered functions (bug #40462).
John W. Eaton <jwe@octave.org>
parents: 20172
diff changeset
47 #include "pt-pr-code.h"
24269
f494b87d2a93 rename scope to symbol_scope
John W. Eaton <jwe@octave.org>
parents: 24263
diff changeset
48 #include "symscope.h"
13983
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 13916
diff changeset
49 #include "symtab.h"
3355
c4983fc7318f [project @ 1999-11-18 05:20:50 by jwe]
jwe
parents: 3325
diff changeset
50
31605
e88a07dec498 maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents: 30888
diff changeset
51 OCTAVE_BEGIN_NAMESPACE(octave)
29960
939bef0b66e0 merge "namespace octave" and OCTAVE_NAMESPACE_BEGIN/END blocks
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
52
26661
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
53 symbol_table::symbol_table (interpreter& interp)
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
54 : m_interpreter (interp), m_fcn_table (), m_class_precedence_table (),
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
55 m_parent_map ()
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
56 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
57 install_builtins ();
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
58 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
59
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
60 symbol_scope symbol_table::current_scope (void) const
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
61 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
62 tree_evaluator& tw = m_interpreter.get_evaluator ();
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
63
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
64 return tw.get_current_scope ();
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
65 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
66
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
67 bool symbol_table::is_built_in_function_name (const std::string& name)
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
68 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
69 octave_value val = find_built_in_function (name);
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
70
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
71 return val.is_defined ();
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
72 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
73
28436
22e90bdcf47f make find_scoped_function available in symbol_table class
John W. Eaton <jwe@octave.org>
parents: 28435
diff changeset
74 octave_value
22e90bdcf47f make find_scoped_function available in symbol_table class
John W. Eaton <jwe@octave.org>
parents: 28435
diff changeset
75 symbol_table::find_scoped_function (const std::string& name,
22e90bdcf47f make find_scoped_function available in symbol_table class
John W. Eaton <jwe@octave.org>
parents: 28435
diff changeset
76 const symbol_scope& search_scope)
22e90bdcf47f make find_scoped_function available in symbol_table class
John W. Eaton <jwe@octave.org>
parents: 28435
diff changeset
77 {
22e90bdcf47f make find_scoped_function available in symbol_table class
John W. Eaton <jwe@octave.org>
parents: 28435
diff changeset
78 if (name.empty ())
22e90bdcf47f make find_scoped_function available in symbol_table class
John W. Eaton <jwe@octave.org>
parents: 28435
diff changeset
79 return octave_value ();
22e90bdcf47f make find_scoped_function available in symbol_table class
John W. Eaton <jwe@octave.org>
parents: 28435
diff changeset
80
22e90bdcf47f make find_scoped_function available in symbol_table class
John W. Eaton <jwe@octave.org>
parents: 28435
diff changeset
81 fcn_table_const_iterator p = m_fcn_table.find (name);
22e90bdcf47f make find_scoped_function available in symbol_table class
John W. Eaton <jwe@octave.org>
parents: 28435
diff changeset
82
22e90bdcf47f make find_scoped_function available in symbol_table class
John W. Eaton <jwe@octave.org>
parents: 28435
diff changeset
83 if (p != m_fcn_table.end ())
22e90bdcf47f make find_scoped_function available in symbol_table class
John W. Eaton <jwe@octave.org>
parents: 28435
diff changeset
84 return p->second.find_scoped_function (search_scope);
22e90bdcf47f make find_scoped_function available in symbol_table class
John W. Eaton <jwe@octave.org>
parents: 28435
diff changeset
85 else
22e90bdcf47f make find_scoped_function available in symbol_table class
John W. Eaton <jwe@octave.org>
parents: 28435
diff changeset
86 {
22e90bdcf47f make find_scoped_function available in symbol_table class
John W. Eaton <jwe@octave.org>
parents: 28435
diff changeset
87 fcn_info finfo (name);
22e90bdcf47f make find_scoped_function available in symbol_table class
John W. Eaton <jwe@octave.org>
parents: 28435
diff changeset
88
22e90bdcf47f make find_scoped_function available in symbol_table class
John W. Eaton <jwe@octave.org>
parents: 28435
diff changeset
89 octave_value fcn = finfo.find_scoped_function (search_scope);
22e90bdcf47f make find_scoped_function available in symbol_table class
John W. Eaton <jwe@octave.org>
parents: 28435
diff changeset
90
22e90bdcf47f make find_scoped_function available in symbol_table class
John W. Eaton <jwe@octave.org>
parents: 28435
diff changeset
91 if (fcn.is_defined ())
22e90bdcf47f make find_scoped_function available in symbol_table class
John W. Eaton <jwe@octave.org>
parents: 28435
diff changeset
92 m_fcn_table[name] = finfo;
22e90bdcf47f make find_scoped_function available in symbol_table class
John W. Eaton <jwe@octave.org>
parents: 28435
diff changeset
93
22e90bdcf47f make find_scoped_function available in symbol_table class
John W. Eaton <jwe@octave.org>
parents: 28435
diff changeset
94 return fcn;
22e90bdcf47f make find_scoped_function available in symbol_table class
John W. Eaton <jwe@octave.org>
parents: 28435
diff changeset
95 }
22e90bdcf47f make find_scoped_function available in symbol_table class
John W. Eaton <jwe@octave.org>
parents: 28435
diff changeset
96 }
22e90bdcf47f make find_scoped_function available in symbol_table class
John W. Eaton <jwe@octave.org>
parents: 28435
diff changeset
97
28437
8f3aedc5ab4f split search for private functions into separate function
John W. Eaton <jwe@octave.org>
parents: 28436
diff changeset
98 octave_value
8f3aedc5ab4f split search for private functions into separate function
John W. Eaton <jwe@octave.org>
parents: 28436
diff changeset
99 symbol_table::find_private_function (const std::string& dir_name,
8f3aedc5ab4f split search for private functions into separate function
John W. Eaton <jwe@octave.org>
parents: 28436
diff changeset
100 const std::string& name)
8f3aedc5ab4f split search for private functions into separate function
John W. Eaton <jwe@octave.org>
parents: 28436
diff changeset
101 {
8f3aedc5ab4f split search for private functions into separate function
John W. Eaton <jwe@octave.org>
parents: 28436
diff changeset
102 if (name.empty ())
8f3aedc5ab4f split search for private functions into separate function
John W. Eaton <jwe@octave.org>
parents: 28436
diff changeset
103 return octave_value ();
8f3aedc5ab4f split search for private functions into separate function
John W. Eaton <jwe@octave.org>
parents: 28436
diff changeset
104
8f3aedc5ab4f split search for private functions into separate function
John W. Eaton <jwe@octave.org>
parents: 28436
diff changeset
105 fcn_table_const_iterator p = m_fcn_table.find (name);
8f3aedc5ab4f split search for private functions into separate function
John W. Eaton <jwe@octave.org>
parents: 28436
diff changeset
106
8f3aedc5ab4f split search for private functions into separate function
John W. Eaton <jwe@octave.org>
parents: 28436
diff changeset
107 if (p != m_fcn_table.end ())
8f3aedc5ab4f split search for private functions into separate function
John W. Eaton <jwe@octave.org>
parents: 28436
diff changeset
108 return p->second.find_private_function (dir_name);
8f3aedc5ab4f split search for private functions into separate function
John W. Eaton <jwe@octave.org>
parents: 28436
diff changeset
109 else
8f3aedc5ab4f split search for private functions into separate function
John W. Eaton <jwe@octave.org>
parents: 28436
diff changeset
110 {
8f3aedc5ab4f split search for private functions into separate function
John W. Eaton <jwe@octave.org>
parents: 28436
diff changeset
111 fcn_info finfo (name);
8f3aedc5ab4f split search for private functions into separate function
John W. Eaton <jwe@octave.org>
parents: 28436
diff changeset
112
8f3aedc5ab4f split search for private functions into separate function
John W. Eaton <jwe@octave.org>
parents: 28436
diff changeset
113 octave_value fcn = finfo.find_private_function (dir_name);
8f3aedc5ab4f split search for private functions into separate function
John W. Eaton <jwe@octave.org>
parents: 28436
diff changeset
114
8f3aedc5ab4f split search for private functions into separate function
John W. Eaton <jwe@octave.org>
parents: 28436
diff changeset
115 if (fcn.is_defined ())
8f3aedc5ab4f split search for private functions into separate function
John W. Eaton <jwe@octave.org>
parents: 28436
diff changeset
116 m_fcn_table[name] = finfo;
8f3aedc5ab4f split search for private functions into separate function
John W. Eaton <jwe@octave.org>
parents: 28436
diff changeset
117
8f3aedc5ab4f split search for private functions into separate function
John W. Eaton <jwe@octave.org>
parents: 28436
diff changeset
118 return fcn;
8f3aedc5ab4f split search for private functions into separate function
John W. Eaton <jwe@octave.org>
parents: 28436
diff changeset
119 }
8f3aedc5ab4f split search for private functions into separate function
John W. Eaton <jwe@octave.org>
parents: 28436
diff changeset
120 }
8f3aedc5ab4f split search for private functions into separate function
John W. Eaton <jwe@octave.org>
parents: 28436
diff changeset
121
26661
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
122 // FIXME: this function only finds legacy class methods, not
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
123 // classdef methods.
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
124
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
125 octave_value symbol_table::find_method (const std::string& name,
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
126 const std::string& dispatch_type)
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
127 {
26750
a89aa5b95a59 return early if searching for function or package with empty name
John W. Eaton <jwe@octave.org>
parents: 26661
diff changeset
128 if (name.empty ())
a89aa5b95a59 return early if searching for function or package with empty name
John W. Eaton <jwe@octave.org>
parents: 26661
diff changeset
129 return octave_value ();
a89aa5b95a59 return early if searching for function or package with empty name
John W. Eaton <jwe@octave.org>
parents: 26661
diff changeset
130
26661
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
131 fcn_table_const_iterator p = m_fcn_table.find (name);
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
132
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
133 if (p != m_fcn_table.end ())
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
134 return p->second.find_method (dispatch_type);
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
135 else
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
136 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
137 fcn_info finfo (name);
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
138
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
139 octave_value fcn = finfo.find_method (dispatch_type);
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
140
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
141 if (fcn.is_defined ())
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
142 m_fcn_table[name] = finfo;
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
143
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
144 return fcn;
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
145 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
146 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
147
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
148 octave_value symbol_table::find_built_in_function (const std::string& name)
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
149 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
150 fcn_table_const_iterator p = m_fcn_table.find (name);
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
151
28435
76a9f31540e3 try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
152 if (p != m_fcn_table.end ())
76a9f31540e3 try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
153 return p->second.find_built_in_function ();
76a9f31540e3 try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
154 else
76a9f31540e3 try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
155 {
76a9f31540e3 try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
156 fcn_info finfo (name);
76a9f31540e3 try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
157
76a9f31540e3 try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
158 octave_value fcn = finfo.find_built_in_function ();
76a9f31540e3 try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
159
76a9f31540e3 try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
160 if (fcn.is_defined ())
76a9f31540e3 try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
161 m_fcn_table[name] = finfo;
76a9f31540e3 try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
162
76a9f31540e3 try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
163 return fcn;
76a9f31540e3 try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
164 }
26661
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
165 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
166
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
167 octave_value symbol_table::find_autoload (const std::string& name)
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
168 {
26750
a89aa5b95a59 return early if searching for function or package with empty name
John W. Eaton <jwe@octave.org>
parents: 26661
diff changeset
169 if (name.empty ())
a89aa5b95a59 return early if searching for function or package with empty name
John W. Eaton <jwe@octave.org>
parents: 26661
diff changeset
170 return octave_value ();
a89aa5b95a59 return early if searching for function or package with empty name
John W. Eaton <jwe@octave.org>
parents: 26661
diff changeset
171
26661
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
172 auto p = m_fcn_table.find (name);
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
173
28435
76a9f31540e3 try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
174 if (p != m_fcn_table.end ())
76a9f31540e3 try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
175 return p->second.find_autoload ();
76a9f31540e3 try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
176 else
76a9f31540e3 try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
177 {
76a9f31540e3 try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
178 fcn_info finfo (name);
76a9f31540e3 try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
179
76a9f31540e3 try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
180 octave_value fcn = finfo.find_autoload ();
76a9f31540e3 try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
181
76a9f31540e3 try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
182 if (fcn.is_defined ())
76a9f31540e3 try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
183 m_fcn_table[name] = finfo;
76a9f31540e3 try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
184
76a9f31540e3 try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
185 return fcn;
76a9f31540e3 try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
186 }
26661
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
187 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
188
26846
4ff25d9b1eec set default scope in symbol_table find functions instead of fcn_info
John W. Eaton <jwe@octave.org>
parents: 26845
diff changeset
189 octave_value
4ff25d9b1eec set default scope in symbol_table find functions instead of fcn_info
John W. Eaton <jwe@octave.org>
parents: 26845
diff changeset
190 symbol_table::builtin_find (const std::string& name,
4ff25d9b1eec set default scope in symbol_table find functions instead of fcn_info
John W. Eaton <jwe@octave.org>
parents: 26845
diff changeset
191 const symbol_scope& search_scope_arg)
26661
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
192 {
26750
a89aa5b95a59 return early if searching for function or package with empty name
John W. Eaton <jwe@octave.org>
parents: 26661
diff changeset
193 if (name.empty ())
a89aa5b95a59 return early if searching for function or package with empty name
John W. Eaton <jwe@octave.org>
parents: 26661
diff changeset
194 return octave_value ();
a89aa5b95a59 return early if searching for function or package with empty name
John W. Eaton <jwe@octave.org>
parents: 26661
diff changeset
195
26661
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
196 fcn_table_iterator p = m_fcn_table.find (name);
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
197
26846
4ff25d9b1eec set default scope in symbol_table find functions instead of fcn_info
John W. Eaton <jwe@octave.org>
parents: 26845
diff changeset
198 symbol_scope search_scope
4ff25d9b1eec set default scope in symbol_table find functions instead of fcn_info
John W. Eaton <jwe@octave.org>
parents: 26845
diff changeset
199 = (search_scope_arg ? search_scope_arg : current_scope ());
4ff25d9b1eec set default scope in symbol_table find functions instead of fcn_info
John W. Eaton <jwe@octave.org>
parents: 26845
diff changeset
200
26661
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
201 if (p != m_fcn_table.end ())
26845
6322d51c655c allow function search in arbitrary scope
John W. Eaton <jwe@octave.org>
parents: 26781
diff changeset
202 return p->second.builtin_find (search_scope);
26661
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
203 else
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
204 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
205 fcn_info finfo (name);
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
206
26845
6322d51c655c allow function search in arbitrary scope
John W. Eaton <jwe@octave.org>
parents: 26781
diff changeset
207 octave_value fcn = finfo.builtin_find (search_scope);
26661
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
208
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
209 if (fcn.is_defined ())
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
210 m_fcn_table[name] = finfo;
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
211
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
212 return fcn;
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
213 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
214
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
215 return octave_value ();
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
216 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
217
26846
4ff25d9b1eec set default scope in symbol_table find functions instead of fcn_info
John W. Eaton <jwe@octave.org>
parents: 26845
diff changeset
218 octave_value
4ff25d9b1eec set default scope in symbol_table find functions instead of fcn_info
John W. Eaton <jwe@octave.org>
parents: 26845
diff changeset
219 symbol_table::fcn_table_find (const std::string& name,
4ff25d9b1eec set default scope in symbol_table find functions instead of fcn_info
John W. Eaton <jwe@octave.org>
parents: 26845
diff changeset
220 const octave_value_list& args,
4ff25d9b1eec set default scope in symbol_table find functions instead of fcn_info
John W. Eaton <jwe@octave.org>
parents: 26845
diff changeset
221 const symbol_scope& search_scope_arg)
26661
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
222 {
26750
a89aa5b95a59 return early if searching for function or package with empty name
John W. Eaton <jwe@octave.org>
parents: 26661
diff changeset
223 if (name.empty ())
a89aa5b95a59 return early if searching for function or package with empty name
John W. Eaton <jwe@octave.org>
parents: 26661
diff changeset
224 return octave_value ();
a89aa5b95a59 return early if searching for function or package with empty name
John W. Eaton <jwe@octave.org>
parents: 26661
diff changeset
225
26661
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
226 fcn_table_iterator p = m_fcn_table.find (name);
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
227
26846
4ff25d9b1eec set default scope in symbol_table find functions instead of fcn_info
John W. Eaton <jwe@octave.org>
parents: 26845
diff changeset
228 symbol_scope search_scope
4ff25d9b1eec set default scope in symbol_table find functions instead of fcn_info
John W. Eaton <jwe@octave.org>
parents: 26845
diff changeset
229 = (search_scope_arg ? search_scope_arg : current_scope ());
4ff25d9b1eec set default scope in symbol_table find functions instead of fcn_info
John W. Eaton <jwe@octave.org>
parents: 26845
diff changeset
230
26661
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
231 if (p != m_fcn_table.end ())
26846
4ff25d9b1eec set default scope in symbol_table find functions instead of fcn_info
John W. Eaton <jwe@octave.org>
parents: 26845
diff changeset
232 return p->second.find (search_scope, args);
26661
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
233 else
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
234 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
235 fcn_info finfo (name);
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
236
26846
4ff25d9b1eec set default scope in symbol_table find functions instead of fcn_info
John W. Eaton <jwe@octave.org>
parents: 26845
diff changeset
237 octave_value fcn = finfo.find (search_scope, args);
26661
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
238
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
239 if (fcn.is_defined ())
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
240 m_fcn_table[name] = finfo;
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
241
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
242 return fcn;
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
243 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
244
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
245 return octave_value ();
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
246 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
247
26846
4ff25d9b1eec set default scope in symbol_table find functions instead of fcn_info
John W. Eaton <jwe@octave.org>
parents: 26845
diff changeset
248 octave_value
4ff25d9b1eec set default scope in symbol_table find functions instead of fcn_info
John W. Eaton <jwe@octave.org>
parents: 26845
diff changeset
249 symbol_table::find_function (const std::string& name,
4ff25d9b1eec set default scope in symbol_table find functions instead of fcn_info
John W. Eaton <jwe@octave.org>
parents: 26845
diff changeset
250 const symbol_scope& search_scope_arg)
26661
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
251 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
252 if (name.empty ())
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
253 return octave_value ();
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
254
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
255 if (name[0] == '@')
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
256 {
29572
aef11bb4e6d1 use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
257 std::size_t pos = name.find_first_of ('/');
26661
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
258
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
259 if (pos == std::string::npos)
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
260 return octave_value ();
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
261
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
262 std::string method = name.substr (pos+1);
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
263 std::string dispatch_type = name.substr (1, pos-1);
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
264
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
265 return find_method (method, dispatch_type);
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
266 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
267 else
26846
4ff25d9b1eec set default scope in symbol_table find functions instead of fcn_info
John W. Eaton <jwe@octave.org>
parents: 26845
diff changeset
268 {
4ff25d9b1eec set default scope in symbol_table find functions instead of fcn_info
John W. Eaton <jwe@octave.org>
parents: 26845
diff changeset
269 symbol_scope search_scope
4ff25d9b1eec set default scope in symbol_table find functions instead of fcn_info
John W. Eaton <jwe@octave.org>
parents: 26845
diff changeset
270 = (search_scope_arg ? search_scope_arg : current_scope ());
4ff25d9b1eec set default scope in symbol_table find functions instead of fcn_info
John W. Eaton <jwe@octave.org>
parents: 26845
diff changeset
271
4ff25d9b1eec set default scope in symbol_table find functions instead of fcn_info
John W. Eaton <jwe@octave.org>
parents: 26845
diff changeset
272 return find_function (name, ovl (), search_scope);
4ff25d9b1eec set default scope in symbol_table find functions instead of fcn_info
John W. Eaton <jwe@octave.org>
parents: 26845
diff changeset
273 }
26661
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
274 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
275
26846
4ff25d9b1eec set default scope in symbol_table find functions instead of fcn_info
John W. Eaton <jwe@octave.org>
parents: 26845
diff changeset
276 octave_value
4ff25d9b1eec set default scope in symbol_table find functions instead of fcn_info
John W. Eaton <jwe@octave.org>
parents: 26845
diff changeset
277 symbol_table::find_function (const std::string& name,
4ff25d9b1eec set default scope in symbol_table find functions instead of fcn_info
John W. Eaton <jwe@octave.org>
parents: 26845
diff changeset
278 const octave_value_list& args,
4ff25d9b1eec set default scope in symbol_table find functions instead of fcn_info
John W. Eaton <jwe@octave.org>
parents: 26845
diff changeset
279 const symbol_scope& search_scope)
26661
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
280 {
26750
a89aa5b95a59 return early if searching for function or package with empty name
John W. Eaton <jwe@octave.org>
parents: 26661
diff changeset
281 if (name.empty ())
a89aa5b95a59 return early if searching for function or package with empty name
John W. Eaton <jwe@octave.org>
parents: 26661
diff changeset
282 return octave_value ();
a89aa5b95a59 return early if searching for function or package with empty name
John W. Eaton <jwe@octave.org>
parents: 26661
diff changeset
283
26846
4ff25d9b1eec set default scope in symbol_table find functions instead of fcn_info
John W. Eaton <jwe@octave.org>
parents: 26845
diff changeset
284 return fcn_table_find (name, args, search_scope);
26661
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
285 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
286
26845
6322d51c655c allow function search in arbitrary scope
John W. Eaton <jwe@octave.org>
parents: 26781
diff changeset
287 octave_value
6322d51c655c allow function search in arbitrary scope
John W. Eaton <jwe@octave.org>
parents: 26781
diff changeset
288 symbol_table::find_user_function (const std::string& name)
26661
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
289 {
26750
a89aa5b95a59 return early if searching for function or package with empty name
John W. Eaton <jwe@octave.org>
parents: 26661
diff changeset
290 if (name.empty ())
a89aa5b95a59 return early if searching for function or package with empty name
John W. Eaton <jwe@octave.org>
parents: 26661
diff changeset
291 return octave_value ();
a89aa5b95a59 return early if searching for function or package with empty name
John W. Eaton <jwe@octave.org>
parents: 26661
diff changeset
292
26661
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
293 auto p = m_fcn_table.find (name);
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
294
28435
76a9f31540e3 try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
295 if (p != m_fcn_table.end ())
76a9f31540e3 try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
296 return p->second.find_user_function ();
76a9f31540e3 try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
297 else
76a9f31540e3 try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
298 {
76a9f31540e3 try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
299 fcn_info finfo (name);
76a9f31540e3 try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
300
76a9f31540e3 try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
301 octave_value fcn = finfo.find_user_function ();
76a9f31540e3 try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
302
76a9f31540e3 try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
303 if (fcn.is_defined ())
76a9f31540e3 try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
304 m_fcn_table[name] = finfo;
76a9f31540e3 try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
305
76a9f31540e3 try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
306 return fcn;
76a9f31540e3 try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
307 }
26661
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
308 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
309
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
310 octave_value symbol_table::find_cmdline_function (const std::string& name)
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
311 {
26750
a89aa5b95a59 return early if searching for function or package with empty name
John W. Eaton <jwe@octave.org>
parents: 26661
diff changeset
312 if (name.empty ())
a89aa5b95a59 return early if searching for function or package with empty name
John W. Eaton <jwe@octave.org>
parents: 26661
diff changeset
313 return octave_value ();
a89aa5b95a59 return early if searching for function or package with empty name
John W. Eaton <jwe@octave.org>
parents: 26661
diff changeset
314
26661
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
315 auto p = m_fcn_table.find (name);
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
316
28435
76a9f31540e3 try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
317 if (p != m_fcn_table.end ())
76a9f31540e3 try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
318 return p->second.find_cmdline_function ();
76a9f31540e3 try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
319 else
76a9f31540e3 try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
320 {
76a9f31540e3 try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
321 fcn_info finfo (name);
76a9f31540e3 try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
322
76a9f31540e3 try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
323 octave_value fcn = finfo.find_cmdline_function ();
76a9f31540e3 try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
324
76a9f31540e3 try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
325 if (fcn.is_defined ())
76a9f31540e3 try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
326 m_fcn_table[name] = finfo;
76a9f31540e3 try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
327
76a9f31540e3 try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
328 return fcn;
76a9f31540e3 try harder to find functions in some symbol_table find_* functions
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
329 }
26661
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
330 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
331
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
332 void symbol_table::install_cmdline_function (const std::string& name,
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
333 const octave_value& fcn)
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
334 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
335 auto p = m_fcn_table.find (name);
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
336
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
337 if (p != m_fcn_table.end ())
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
338 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
339 fcn_info& finfo = p->second;
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
340
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
341 finfo.install_cmdline_function (fcn);
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
342 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
343 else
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
344 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
345 fcn_info finfo (name);
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
346
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
347 finfo.install_cmdline_function (fcn);
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
348
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
349 m_fcn_table[name] = finfo;
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
350 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
351 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
352
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
353 // Install local function FCN named NAME. FILE_NAME is the name of
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
354 // the file containing the local function.
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
355
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
356 void symbol_table::install_local_function (const std::string& name,
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
357 const octave_value& fcn,
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
358 const std::string& file_name)
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
359 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
360 auto p = m_fcn_table.find (name);
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
361
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
362 if (p != m_fcn_table.end ())
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
363 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
364 fcn_info& finfo = p->second;
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
365
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
366 finfo.install_local_function (fcn, file_name);
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
367 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
368 else
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
369 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
370 fcn_info finfo (name);
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
371
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
372 finfo.install_local_function (fcn, file_name);
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
373
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
374 m_fcn_table[name] = finfo;
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
375 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
376 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
377
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
378 void symbol_table::install_user_function (const std::string& name,
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
379 const octave_value& fcn)
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
380 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
381 auto p = m_fcn_table.find (name);
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
382
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
383 if (p != m_fcn_table.end ())
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
384 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
385 fcn_info& finfo = p->second;
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
386
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
387 finfo.install_user_function (fcn);
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
388 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
389 else
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
390 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
391 fcn_info finfo (name);
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
392
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
393 finfo.install_user_function (fcn);
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
394
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
395 m_fcn_table[name] = finfo;
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
396 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
397 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
398
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
399 // FIXME: should we ensure that FCN really is a built-in function
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
400 // object?
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
401 void symbol_table::install_built_in_function (const std::string& name,
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
402 const octave_value& fcn)
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
403 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
404 auto p = m_fcn_table.find (name);
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
405
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
406 if (p != m_fcn_table.end ())
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
407 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
408 fcn_info& finfo = p->second;
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
409
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
410 finfo.install_built_in_function (fcn);
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
411 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
412 else
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
413 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
414 fcn_info finfo (name);
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
415
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
416 finfo.install_built_in_function (fcn);
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
417
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
418 m_fcn_table[name] = finfo;
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
419 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
420 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
421
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
422 // This is written as two separate functions instead of a single
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
423 // function with default values so that it will work properly with
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
424 // unwind_protect.
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
425
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
426 void symbol_table::clear_functions (bool force)
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
427 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
428 auto p = m_fcn_table.begin ();
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
429
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
430 while (p != m_fcn_table.end ())
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
431 (p++)->second.clear (force);
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
432 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
433
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
434 void symbol_table::clear_function (const std::string& name)
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
435 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
436 clear_user_function (name);
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
437 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
438
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
439 void symbol_table::clear_function_pattern (const std::string& pat)
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
440 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
441 glob_match pattern (pat);
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
442
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
443 auto p = m_fcn_table.begin ();
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
444
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
445 while (p != m_fcn_table.end ())
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
446 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
447 if (pattern.match (p->first))
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
448 (p++)->second.clear_user_function ();
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
449 else
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
450 p++;
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
451 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
452 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
453
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
454 void symbol_table::clear_function_regexp (const std::string& pat)
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
455 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
456 regexp pattern (pat);
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
457
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
458 auto p = m_fcn_table.begin ();
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
459
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
460 while (p != m_fcn_table.end ())
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
461 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
462 if (pattern.is_match (p->first))
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
463 (p++)->second.clear_user_function ();
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
464 else
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
465 p++;
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
466 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
467 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
468
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
469 void symbol_table::clear_user_function (const std::string& name)
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
470 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
471 auto p = m_fcn_table.find (name);
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
472
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
473 if (p != m_fcn_table.end ())
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
474 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
475 fcn_info& finfo = p->second;
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
476
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
477 finfo.clear_user_function ();
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
478 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
479 // FIXME: is this necessary, or even useful?
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
480 // else
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
481 // error ("clear: no such function '%s'", name.c_str ());
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
482 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
483
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
484 // This clears oct and mex files, including autoloads.
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
485 void symbol_table::clear_dld_function (const std::string& name)
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
486 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
487 auto p = m_fcn_table.find (name);
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
488
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
489 if (p != m_fcn_table.end ())
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
490 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
491 fcn_info& finfo = p->second;
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
492
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
493 finfo.clear_autoload_function ();
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
494 finfo.clear_user_function ();
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
495 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
496 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
497
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
498 void symbol_table::clear_mex_functions (void)
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
499 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
500 auto p = m_fcn_table.begin ();
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
501
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
502 while (p != m_fcn_table.end ())
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
503 (p++)->second.clear_mex_function ();
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
504 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
505
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
506 // Insert INF_CLASS in the set of class names that are considered
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
507 // inferior to SUP_CLASS. Return FALSE if INF_CLASS is currently
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
508 // marked as superior to SUP_CLASS.
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
509
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
510 bool symbol_table::set_class_relationship (const std::string& sup_class,
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
511 const std::string& inf_class)
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
512 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
513 if (is_superiorto (inf_class, sup_class))
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
514 return false;
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
515
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
516 // If sup_class doesn't have an entry in the precedence table,
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
517 // this will automatically create it, and associate to it a
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
518 // singleton set {inf_class} of inferior classes.
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
519 m_class_precedence_table[sup_class].insert (inf_class);
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
520
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
521 return true;
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
522 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
523
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
524 // Has class A been marked as superior to class B? Also returns
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
525 // TRUE if B has been marked as inferior to A, since we only keep
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
526 // one table, and convert inferiorto information to a superiorto
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
527 // relationship. Two calls are required to determine whether there
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
528 // is no relationship between two classes:
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
529 //
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
530 // if (symbol_table::is_superiorto (a, b))
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
531 // // A is superior to B, or B has been marked inferior to A.
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
532 // else if (symbol_table::is_superiorto (b, a))
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
533 // // B is superior to A, or A has been marked inferior to B.
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
534 // else
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
535 // // No relation.
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
536
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
537 bool symbol_table::is_superiorto (const std::string& a, const std::string& b)
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
538 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
539 class_precedence_table_const_iterator p = m_class_precedence_table.find (a);
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
540 // If a has no entry in the precedence table, return false
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
541 if (p == m_class_precedence_table.end ())
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
542 return false;
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
543
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
544 const std::set<std::string>& inferior_classes = p->second;
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
545 std::set<std::string>::const_iterator q = inferior_classes.find (b);
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
546 return (q != inferior_classes.end ());
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
547 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
548
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
549 void symbol_table::alias_built_in_function (const std::string& alias,
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
550 const std::string& name)
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
551 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
552 octave_value fcn = find_built_in_function (name);
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
553
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
554 if (fcn.is_defined ())
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
555 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
556 fcn_info finfo (alias);
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
557
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
558 finfo.install_built_in_function (fcn);
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
559
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
560 m_fcn_table[alias] = finfo;
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
561 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
562 else
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
563 panic ("alias: '%s' is undefined", name.c_str ());
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
564 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
565
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
566 void symbol_table::install_built_in_dispatch (const std::string& name,
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
567 const std::string& klass)
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
568 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
569 auto p = m_fcn_table.find (name);
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
570
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
571 if (p != m_fcn_table.end ())
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
572 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
573 fcn_info& finfo = p->second;
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
574
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
575 finfo.install_built_in_dispatch (klass);
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
576 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
577 else
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
578 error ("install_built_in_dispatch: '%s' is undefined", name.c_str ());
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
579 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
580
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
581 std::list<std::string> symbol_table::user_function_names (void)
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
582 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
583 std::list<std::string> retval;
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
584
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
585 for (const auto& nm_finfo : m_fcn_table)
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
586 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
587 if (nm_finfo.second.is_user_function_defined ())
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
588 retval.push_back (nm_finfo.first);
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
589 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
590
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
591 if (! retval.empty ())
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
592 retval.sort ();
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
593
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
594 return retval;
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
595 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
596
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
597 std::list<std::string> symbol_table::built_in_function_names (void)
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
598 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
599 std::list<std::string> retval;
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
600
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
601 for (const auto& nm_finfo : m_fcn_table)
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
602 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
603 octave_value fcn = nm_finfo.second.find_built_in_function ();
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
604
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
605 if (fcn.is_defined ())
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
606 retval.push_back (nm_finfo.first);
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
607 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
608
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
609 if (! retval.empty ())
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
610 retval.sort ();
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
611
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
612 return retval;
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
613 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
614
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
615 std::list<std::string> symbol_table::cmdline_function_names (void)
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
616 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
617 std::list<std::string> retval;
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
618
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
619 for (const auto& nm_finfo : m_fcn_table)
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
620 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
621 octave_value fcn = nm_finfo.second.find_cmdline_function ();
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
622
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
623 if (fcn.is_defined ())
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
624 retval.push_back (nm_finfo.first);
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
625 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
626
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
627 if (! retval.empty ())
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
628 retval.sort ();
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
629
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
630 return retval;
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
631 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
632
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
633 template <template <typename, typename...> class C, typename V,
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
634 typename... A>
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
635 static octave_value
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
636 dump_container_map (const std::map<std::string, C<V, A...>>& container_map)
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
637 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
638 if (container_map.empty ())
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
639 return octave_value (Matrix ());
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
640
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
641 std::map<std::string, octave_value> info_map;
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
642
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
643 for (const auto& nm_container : container_map)
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
644 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
645 std::string nm = nm_container.first;
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
646 const C<V, A...>& container = nm_container.second;
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
647 info_map[nm] = Cell (container);
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
648 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
649
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
650 return octave_value (info_map);
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
651 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
652
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
653 octave_value symbol_table::dump (void) const
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
654 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
655 std::map<std::string, octave_value> m
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
656 = {{ "function_info", dump_fcn_table_map () },
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
657 { "precedence_table", dump_container_map (m_class_precedence_table) },
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
658 { "parent_classes", dump_container_map (m_parent_map) }};
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
659
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
660 return octave_value (m);
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
661 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
662
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
663 void symbol_table::add_to_parent_map (const std::string& classname,
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
664 const std::list<std::string>& parent_list)
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
665 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
666 m_parent_map[classname] = parent_list;
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
667 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
668
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
669 std::list<std::string> symbol_table::parent_classes (const std::string& dispatch_type)
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
670 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
671 std::list<std::string> retval;
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
672
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
673 const_parent_map_iterator it = m_parent_map.find (dispatch_type);
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
674
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
675 if (it != m_parent_map.end ())
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
676 retval = it->second;
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
677
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
678 for (const auto& nm : retval)
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
679 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
680 // Search for parents of parents and append them to the list.
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
681
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
682 // FIXME: should we worry about a circular inheritance graph?
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
683
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
684 std::list<std::string> parents = parent_classes (nm);
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
685
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
686 if (! parents.empty ())
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
687 retval.insert (retval.end (), parents.begin (), parents.end ());
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
688 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
689
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
690 return retval;
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
691 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
692
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
693 void symbol_table::cleanup (void)
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
694 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
695 clear_functions ();
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
696
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
697 m_fcn_table.clear ();
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
698 m_class_precedence_table.clear ();
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
699 m_parent_map.clear ();
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
700 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
701
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
702 fcn_info * symbol_table::get_fcn_info (const std::string& name)
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
703 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
704 auto p = m_fcn_table.find (name);
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
705 return p != m_fcn_table.end () ? &p->second : nullptr;
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
706 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
707
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
708 octave_value symbol_table::dump_fcn_table_map (void) const
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
709 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
710 if (m_fcn_table.empty ())
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
711 return octave_value (Matrix ());
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
712
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
713 std::map<std::string, octave_value> info_map;
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
714
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
715 for (const auto& nm_finfo : m_fcn_table)
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
716 {
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
717 std::string nm = nm_finfo.first;
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
718 const fcn_info& finfo = nm_finfo.second;
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
719 info_map[nm] = finfo.dump ();
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
720 }
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
721
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
722 return octave_value (info_map);
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
723 }
27594
e091e09d26f0 restore some symbol table functions for backward compatibility
John W. Eaton <jwe@octave.org>
parents: 27336
diff changeset
724
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23581
diff changeset
725 DEFMETHOD (__dump_symtab_info__, interp, args, ,
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23581
diff changeset
726 doc: /* -*- texinfo -*-
30888
32d2b6604a9f doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents: 30565
diff changeset
727 @deftypefn {} {@var{S} =} __dump_symtab_info__ ()
32d2b6604a9f doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents: 30565
diff changeset
728 @deftypefnx {} {@var{S} =} __dump_symtab_info__ (@var{function})
32d2b6604a9f doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents: 30565
diff changeset
729 Return a structure with information from the symbol table.
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
730 @end deftypefn */)
7761
5adeea5de26c symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents: 7752
diff changeset
731 {
5adeea5de26c symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents: 7752
diff changeset
732 int nargin = args.length ();
5adeea5de26c symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents: 7752
diff changeset
733
20799
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20716
diff changeset
734 if (nargin > 1)
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20716
diff changeset
735 print_usage ();
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20716
diff changeset
736
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29960
diff changeset
737 symbol_table& symtab = interp.get_symbol_table ();
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23581
diff changeset
738
7761
5adeea5de26c symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents: 7752
diff changeset
739 if (nargin == 0)
23680
ef71711f6d64 rework __dump_symbol_table__ function
John W. Eaton <jwe@octave.org>
parents: 23667
diff changeset
740 return symtab.dump ();
20799
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20716
diff changeset
741 else
7761
5adeea5de26c symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents: 7752
diff changeset
742 {
23680
ef71711f6d64 rework __dump_symbol_table__ function
John W. Eaton <jwe@octave.org>
parents: 23667
diff changeset
743 std::string fname = args(0).xstring_value ("__dump_symtab_info__: argument must be a function name");
7761
5adeea5de26c symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents: 7752
diff changeset
744
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29960
diff changeset
745 fcn_info *finfo = symtab.get_fcn_info (fname);
7761
5adeea5de26c symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents: 7752
diff changeset
746
23680
ef71711f6d64 rework __dump_symbol_table__ function
John W. Eaton <jwe@octave.org>
parents: 23667
diff changeset
747 if (finfo)
ef71711f6d64 rework __dump_symbol_table__ function
John W. Eaton <jwe@octave.org>
parents: 23667
diff changeset
748 return finfo->dump ();
7761
5adeea5de26c symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents: 7752
diff changeset
749 }
5adeea5de26c symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents: 7752
diff changeset
750
23680
ef71711f6d64 rework __dump_symbol_table__ function
John W. Eaton <jwe@octave.org>
parents: 23667
diff changeset
751 return ovl ();
7761
5adeea5de26c symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents: 7752
diff changeset
752 }
5adeea5de26c symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents: 7752
diff changeset
753
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23581
diff changeset
754 DEFMETHOD (__get_cmdline_fcn_txt__, interp, args, ,
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23581
diff changeset
755 doc: /* -*- texinfo -*-
30888
32d2b6604a9f doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents: 30565
diff changeset
756 @deftypefn {} {@var{str} =} __get_cmdline_fcn_txt__ (@var{name})
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
757 Undocumented internal function.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
758 @end deftypefn */)
20207
abf85f8cbd6c Expand type() to work on command-line entered functions (bug #40462).
John W. Eaton <jwe@octave.org>
parents: 20172
diff changeset
759 {
20799
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20716
diff changeset
760 if (args.length () != 1)
7761
5adeea5de26c symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents: 7752
diff changeset
761 print_usage ();
5adeea5de26c symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents: 7752
diff changeset
762
27336
1fb234f01eea correct function name in error message text
John W. Eaton <jwe@octave.org>
parents: 27110
diff changeset
763 std::string name = args(0).xstring_value ("__get_cmdline_fcn_txt__: first argument must be function name");
20207
abf85f8cbd6c Expand type() to work on command-line entered functions (bug #40462).
John W. Eaton <jwe@octave.org>
parents: 20172
diff changeset
764
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29960
diff changeset
765 symbol_table& symtab = interp.get_symbol_table ();
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23581
diff changeset
766
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23581
diff changeset
767 octave_value ov = symtab.find_cmdline_function (name);
20799
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20716
diff changeset
768
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20716
diff changeset
769 octave_user_function *f = ov.user_function_value ();
20207
abf85f8cbd6c Expand type() to work on command-line entered functions (bug #40462).
John W. Eaton <jwe@octave.org>
parents: 20172
diff changeset
770
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20874
diff changeset
771 octave_value_list retval;
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20874
diff changeset
772
20799
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20716
diff changeset
773 if (f)
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20716
diff changeset
774 {
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20716
diff changeset
775 std::ostringstream buf;
20207
abf85f8cbd6c Expand type() to work on command-line entered functions (bug #40462).
John W. Eaton <jwe@octave.org>
parents: 20172
diff changeset
776
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29960
diff changeset
777 tree_print_code tpc (buf);
20582
ba2b07c13913 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20469
diff changeset
778
20799
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20716
diff changeset
779 f->accept (tpc);
c349d4c91ce2 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20716
diff changeset
780
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20874
diff changeset
781 retval = ovl (buf.str ());
20207
abf85f8cbd6c Expand type() to work on command-line entered functions (bug #40462).
John W. Eaton <jwe@octave.org>
parents: 20172
diff changeset
782 }
abf85f8cbd6c Expand type() to work on command-line entered functions (bug #40462).
John W. Eaton <jwe@octave.org>
parents: 20172
diff changeset
783
7761
5adeea5de26c symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents: 7752
diff changeset
784 return retval;
5adeea5de26c symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents: 7752
diff changeset
785 }
5adeea5de26c symbol table reporting functions
John W. Eaton <jwe@octave.org>
parents: 7752
diff changeset
786
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
787 // FIXME: should we have functions like this in Octave?
21992
03c692adf563 maint: strip trailing whitespace from files.
John W. Eaton <jwe@octave.org>
parents: 21966
diff changeset
788 //
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23581
diff changeset
789 // DEFMETHOD (set_variable, interp, args, , "set_variable (NAME, VALUE)")
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
790 // {
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
791 // if (args.length () != 2)
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
792 // print_usage ();
21992
03c692adf563 maint: strip trailing whitespace from files.
John W. Eaton <jwe@octave.org>
parents: 21966
diff changeset
793 //
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
794 // std::string name = args(0).xstring_value ("set_variable: variable NAME must be a string");
21992
03c692adf563 maint: strip trailing whitespace from files.
John W. Eaton <jwe@octave.org>
parents: 21966
diff changeset
795 //
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29960
diff changeset
796 // symbol_table& symtab = interp.get_symbol_table ();
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23581
diff changeset
797 //
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23581
diff changeset
798 // symtab.assign (name, args(1));
21992
03c692adf563 maint: strip trailing whitespace from files.
John W. Eaton <jwe@octave.org>
parents: 21966
diff changeset
799 //
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
800 // return ovl ();
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
801 // }
21992
03c692adf563 maint: strip trailing whitespace from files.
John W. Eaton <jwe@octave.org>
parents: 21966
diff changeset
802 //
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23581
diff changeset
803 // DEFMETHOD (variable_value, interp, args, , "VALUE = variable_value (NAME)")
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
804 // {
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
805 // if (args.length () != 1)
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
806 // print_usage ();
21992
03c692adf563 maint: strip trailing whitespace from files.
John W. Eaton <jwe@octave.org>
parents: 21966
diff changeset
807 //
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
808 // octave_value retval;
21992
03c692adf563 maint: strip trailing whitespace from files.
John W. Eaton <jwe@octave.org>
parents: 21966
diff changeset
809 //
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
810 // std::string name = args(0).xstring_value ("variable_value: variable NAME must be a string");
21992
03c692adf563 maint: strip trailing whitespace from files.
John W. Eaton <jwe@octave.org>
parents: 21966
diff changeset
811 //
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29960
diff changeset
812 // symbol_table& symtab = interp.get_symbol_table ();
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23581
diff changeset
813 //
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23581
diff changeset
814 // retval = symtab.varval (name);
21992
03c692adf563 maint: strip trailing whitespace from files.
John W. Eaton <jwe@octave.org>
parents: 21966
diff changeset
815 //
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
816 // if (retval.is_undefined ())
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
817 // error ("variable_value: '%s' is not a variable in the current scope",
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
818 // name.c_str ());
21992
03c692adf563 maint: strip trailing whitespace from files.
John W. Eaton <jwe@octave.org>
parents: 21966
diff changeset
819 //
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
820 // return retval;
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
821 // }
15003
1f5dbfc23fc2 'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents: 14861
diff changeset
822
1f5dbfc23fc2 'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents: 14861
diff changeset
823 /*
1f5dbfc23fc2 'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents: 14861
diff changeset
824 bug #34497: 'clear -f' does not work for command line functions
1f5dbfc23fc2 'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents: 14861
diff changeset
825
1f5dbfc23fc2 'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents: 14861
diff changeset
826 This test relies on bar being a core function that is implemented in an m-file.
1f5dbfc23fc2 'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents: 14861
diff changeset
827 If the first assert fails, this is no longer the case and the tests need to be
1f5dbfc23fc2 'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents: 14861
diff changeset
828 updated to use some other function.
1f5dbfc23fc2 'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents: 14861
diff changeset
829
22489
93ea313301f9 test: Add bug ids (<#####>) to BIST tests.
Rik <rik@octave.org>
parents: 22407
diff changeset
830 %!assert <34497> (! strcmp (which ("bar"), ""))
15003
1f5dbfc23fc2 'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents: 14861
diff changeset
831
1f5dbfc23fc2 'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents: 14861
diff changeset
832 %!function x = bar ()
1f5dbfc23fc2 'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents: 14861
diff changeset
833 %! x = 5;
1f5dbfc23fc2 'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents: 14861
diff changeset
834 %!endfunction
1f5dbfc23fc2 'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents: 14861
diff changeset
835 %!test
1f5dbfc23fc2 'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents: 14861
diff changeset
836 %! assert (bar == 5);
23295
c1362a71fb0e which.m: Return a non-empty string for built-in classes and command line fcns (bug #50541);
Rik <rik@octave.org>
parents: 23220
diff changeset
837 %! assert (strcmp (which ("bar"), "command-line function"));
15003
1f5dbfc23fc2 'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents: 14861
diff changeset
838 %! clear -f bar;
1f5dbfc23fc2 'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents: 14861
diff changeset
839 %! assert (! strcmp (which ("bar"), ""));
1f5dbfc23fc2 'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents: 14861
diff changeset
840
1f5dbfc23fc2 'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents: 14861
diff changeset
841 %!function x = bar ()
1f5dbfc23fc2 'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents: 14861
diff changeset
842 %! x = 5;
1f5dbfc23fc2 'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents: 14861
diff changeset
843 %!endfunction
1f5dbfc23fc2 'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents: 14861
diff changeset
844 %!test
1f5dbfc23fc2 'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents: 14861
diff changeset
845 %! assert (bar == 5);
23295
c1362a71fb0e which.m: Return a non-empty string for built-in classes and command line fcns (bug #50541);
Rik <rik@octave.org>
parents: 23220
diff changeset
846 %! assert (strcmp (which ("bar"), "command-line function"));
15003
1f5dbfc23fc2 'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents: 14861
diff changeset
847 %! clear bar;
1f5dbfc23fc2 'clear -f' does not work for command line functions (bug #34497)
Max Brister <max@2bass.com>
parents: 14861
diff changeset
848 %! assert (! strcmp (which ("bar"), ""));
20946
6eff66fb8a02 style fixes for comments
John W. Eaton <jwe@octave.org>
parents: 20941
diff changeset
849 */
29958
32c3a5805893 move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29954
diff changeset
850
31605
e88a07dec498 maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents: 30888
diff changeset
851 OCTAVE_END_NAMESPACE(octave)
29958
32c3a5805893 move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29954
diff changeset
852