Mercurial > octave-nkf
comparison libinterp/corefcn/symtab.h @ 17787:175b392e91fe
Use GNU style coding conventions for code in libinterp/
* libinterp/corefcn/Cell.h, libinterp/corefcn/__contourc__.cc,
libinterp/corefcn/__dispatch__.cc, libinterp/corefcn/__lin_interpn__.cc,
libinterp/corefcn/__pchip_deriv__.cc, libinterp/corefcn/__qp__.cc,
libinterp/corefcn/balance.cc, libinterp/corefcn/besselj.cc,
libinterp/corefcn/betainc.cc, libinterp/corefcn/bitfcns.cc,
libinterp/corefcn/bsxfun.cc, libinterp/corefcn/c-file-ptr-stream.cc,
libinterp/corefcn/c-file-ptr-stream.h, libinterp/corefcn/cellfun.cc,
libinterp/corefcn/colloc.cc, libinterp/corefcn/comment-list.h,
libinterp/corefcn/conv2.cc, libinterp/corefcn/daspk.cc,
libinterp/corefcn/dasrt.cc, libinterp/corefcn/dassl.cc,
libinterp/corefcn/data.cc, libinterp/corefcn/debug.cc,
libinterp/corefcn/defaults.cc, libinterp/corefcn/defaults.in.h,
libinterp/corefcn/defun-int.h, libinterp/corefcn/defun.cc,
libinterp/corefcn/det.cc, libinterp/corefcn/dirfns.cc,
libinterp/corefcn/display.cc, libinterp/corefcn/dlmread.cc,
libinterp/corefcn/dot.cc, libinterp/corefcn/dynamic-ld.cc,
libinterp/corefcn/dynamic-ld.h, libinterp/corefcn/eig.cc,
libinterp/corefcn/ellipj.cc, libinterp/corefcn/error.cc,
libinterp/corefcn/error.h, libinterp/corefcn/event-queue.h,
libinterp/corefcn/fft.cc, libinterp/corefcn/fft2.cc, libinterp/corefcn/fftn.cc,
libinterp/corefcn/file-io.cc, libinterp/corefcn/filter.cc,
libinterp/corefcn/find.cc, libinterp/corefcn/gammainc.cc,
libinterp/corefcn/gcd.cc, libinterp/corefcn/getgrent.cc,
libinterp/corefcn/getpwent.cc, libinterp/corefcn/getrusage.cc,
libinterp/corefcn/givens.cc, libinterp/corefcn/gl-render.cc,
libinterp/corefcn/gl2ps-renderer.cc, libinterp/corefcn/gl2ps-renderer.h,
libinterp/corefcn/graphics.cc, libinterp/corefcn/graphics.in.h,
libinterp/corefcn/gripes.cc, libinterp/corefcn/gripes.h,
libinterp/corefcn/help.cc, libinterp/corefcn/hess.cc,
libinterp/corefcn/hex2num.cc, libinterp/corefcn/input.cc,
libinterp/corefcn/input.h, libinterp/corefcn/inv.cc,
libinterp/corefcn/jit-ir.h, libinterp/corefcn/jit-typeinfo.cc,
libinterp/corefcn/jit-typeinfo.h, libinterp/corefcn/jit-util.h,
libinterp/corefcn/kron.cc, libinterp/corefcn/load-path.cc,
libinterp/corefcn/load-path.h, libinterp/corefcn/load-save.cc,
libinterp/corefcn/load-save.h, libinterp/corefcn/lookup.cc,
libinterp/corefcn/ls-ascii-helper.cc, libinterp/corefcn/ls-hdf5.cc,
libinterp/corefcn/ls-hdf5.h, libinterp/corefcn/ls-mat-ascii.cc,
libinterp/corefcn/ls-mat-ascii.h, libinterp/corefcn/ls-mat4.cc,
libinterp/corefcn/ls-mat5.cc, libinterp/corefcn/ls-mat5.h,
libinterp/corefcn/ls-oct-ascii.cc, libinterp/corefcn/lsode.cc,
libinterp/corefcn/lu.cc, libinterp/corefcn/luinc.cc,
libinterp/corefcn/mappers.cc, libinterp/corefcn/matrix_type.cc,
libinterp/corefcn/max.cc, libinterp/corefcn/md5sum.cc,
libinterp/corefcn/mex.cc, libinterp/corefcn/mexproto.h,
libinterp/corefcn/mgorth.cc, libinterp/corefcn/mxarray.in.h,
libinterp/corefcn/nproc.cc, libinterp/corefcn/oct-hist.cc,
libinterp/corefcn/oct-lvalue.h, libinterp/corefcn/oct-map.cc,
libinterp/corefcn/oct-map.h, libinterp/corefcn/oct-obj.h,
libinterp/corefcn/oct-prcstrm.h, libinterp/corefcn/oct-stdstrm.h,
libinterp/corefcn/oct-stream.cc, libinterp/corefcn/oct-stream.h,
libinterp/corefcn/octave-link.cc, libinterp/corefcn/octave-link.h,
libinterp/corefcn/pager.cc, libinterp/corefcn/pinv.cc,
libinterp/corefcn/pr-output.cc, libinterp/corefcn/procstream.h,
libinterp/corefcn/profiler.cc, libinterp/corefcn/pt-jit.cc,
libinterp/corefcn/pt-jit.h, libinterp/corefcn/quad.cc,
libinterp/corefcn/quadcc.cc, libinterp/corefcn/qz.cc,
libinterp/corefcn/rand.cc, libinterp/corefcn/rcond.cc,
libinterp/corefcn/regexp.cc, libinterp/corefcn/schur.cc,
libinterp/corefcn/sighandlers.cc, libinterp/corefcn/sighandlers.h,
libinterp/corefcn/sparse-xdiv.cc, libinterp/corefcn/sparse-xdiv.h,
libinterp/corefcn/sparse-xpow.cc, libinterp/corefcn/sparse.cc,
libinterp/corefcn/spparms.cc, libinterp/corefcn/sqrtm.cc,
libinterp/corefcn/str2double.cc, libinterp/corefcn/strfind.cc,
libinterp/corefcn/strfns.cc, libinterp/corefcn/sub2ind.cc,
libinterp/corefcn/svd.cc, libinterp/corefcn/syl.cc,
libinterp/corefcn/symtab.cc, libinterp/corefcn/symtab.h,
libinterp/corefcn/syscalls.cc, libinterp/corefcn/sysdep.cc,
libinterp/corefcn/sysdep.h, libinterp/corefcn/time.cc,
libinterp/corefcn/toplev.cc, libinterp/corefcn/toplev.h,
libinterp/corefcn/tril.cc, libinterp/corefcn/txt-eng-ft.cc,
libinterp/corefcn/txt-eng-ft.h, libinterp/corefcn/txt-eng.h,
libinterp/corefcn/typecast.cc, libinterp/corefcn/urlwrite.cc,
libinterp/corefcn/utils.cc, libinterp/corefcn/variables.cc,
libinterp/corefcn/variables.h, libinterp/corefcn/xdiv.cc,
libinterp/corefcn/xdiv.h, libinterp/corefcn/xnorm.h, libinterp/corefcn/xpow.cc,
libinterp/corefcn/xpow.h, libinterp/corefcn/zfstream.cc,
libinterp/corefcn/zfstream.h, libinterp/dldfcn/__delaunayn__.cc,
libinterp/dldfcn/__dsearchn__.cc, libinterp/dldfcn/__eigs__.cc,
libinterp/dldfcn/__fltk_uigetfile__.cc, libinterp/dldfcn/__glpk__.cc,
libinterp/dldfcn/__init_fltk__.cc, libinterp/dldfcn/__init_gnuplot__.cc,
libinterp/dldfcn/__magick_read__.cc, libinterp/dldfcn/__voronoi__.cc,
libinterp/dldfcn/amd.cc, libinterp/dldfcn/ccolamd.cc, libinterp/dldfcn/chol.cc,
libinterp/dldfcn/colamd.cc, libinterp/dldfcn/convhulln.cc,
libinterp/dldfcn/dmperm.cc, libinterp/dldfcn/fftw.cc, libinterp/dldfcn/qr.cc,
libinterp/dldfcn/symbfact.cc, libinterp/dldfcn/symrcm.cc,
libinterp/dldfcn/tsearch.cc, libinterp/octave-value/ov-base-diag.cc,
libinterp/octave-value/ov-base-diag.h, libinterp/octave-value/ov-base-int.cc,
libinterp/octave-value/ov-base-int.h, libinterp/octave-value/ov-base-mat.h,
libinterp/octave-value/ov-base-scalar.cc,
libinterp/octave-value/ov-base-scalar.h,
libinterp/octave-value/ov-base-sparse.cc,
libinterp/octave-value/ov-base-sparse.h, libinterp/octave-value/ov-base.cc,
libinterp/octave-value/ov-base.h, libinterp/octave-value/ov-bool-mat.cc,
libinterp/octave-value/ov-bool-mat.h, libinterp/octave-value/ov-bool-sparse.cc,
libinterp/octave-value/ov-bool-sparse.h, libinterp/octave-value/ov-bool.cc,
libinterp/octave-value/ov-bool.h, libinterp/octave-value/ov-builtin.cc,
libinterp/octave-value/ov-builtin.h, libinterp/octave-value/ov-cell.cc,
libinterp/octave-value/ov-cell.h, libinterp/octave-value/ov-ch-mat.cc,
libinterp/octave-value/ov-ch-mat.h, libinterp/octave-value/ov-class.cc,
libinterp/octave-value/ov-class.h, libinterp/octave-value/ov-colon.h,
libinterp/octave-value/ov-complex.cc, libinterp/octave-value/ov-complex.h,
libinterp/octave-value/ov-cx-diag.cc, libinterp/octave-value/ov-cx-diag.h,
libinterp/octave-value/ov-cx-mat.cc, libinterp/octave-value/ov-cx-mat.h,
libinterp/octave-value/ov-cx-sparse.cc, libinterp/octave-value/ov-cx-sparse.h,
libinterp/octave-value/ov-dld-fcn.h, libinterp/octave-value/ov-fcn-handle.cc,
libinterp/octave-value/ov-fcn-handle.h,
libinterp/octave-value/ov-fcn-inline.cc,
libinterp/octave-value/ov-fcn-inline.h, libinterp/octave-value/ov-fcn.h,
libinterp/octave-value/ov-float.cc, libinterp/octave-value/ov-float.h,
libinterp/octave-value/ov-flt-complex.cc,
libinterp/octave-value/ov-flt-complex.h,
libinterp/octave-value/ov-flt-cx-diag.cc,
libinterp/octave-value/ov-flt-cx-diag.h,
libinterp/octave-value/ov-flt-cx-mat.cc,
libinterp/octave-value/ov-flt-cx-mat.h,
libinterp/octave-value/ov-flt-re-diag.cc,
libinterp/octave-value/ov-flt-re-diag.h,
libinterp/octave-value/ov-flt-re-mat.cc,
libinterp/octave-value/ov-flt-re-mat.h, libinterp/octave-value/ov-int16.cc,
libinterp/octave-value/ov-int32.cc, libinterp/octave-value/ov-int64.cc,
libinterp/octave-value/ov-int8.cc, libinterp/octave-value/ov-intx.h,
libinterp/octave-value/ov-java.cc, libinterp/octave-value/ov-lazy-idx.h,
libinterp/octave-value/ov-mex-fcn.cc, libinterp/octave-value/ov-mex-fcn.h,
libinterp/octave-value/ov-null-mat.cc, libinterp/octave-value/ov-null-mat.h,
libinterp/octave-value/ov-oncleanup.cc, libinterp/octave-value/ov-perm.cc,
libinterp/octave-value/ov-perm.h, libinterp/octave-value/ov-range.cc,
libinterp/octave-value/ov-range.h, libinterp/octave-value/ov-re-diag.cc,
libinterp/octave-value/ov-re-diag.h, libinterp/octave-value/ov-re-mat.cc,
libinterp/octave-value/ov-re-mat.h, libinterp/octave-value/ov-re-sparse.cc,
libinterp/octave-value/ov-re-sparse.h, libinterp/octave-value/ov-scalar.cc,
libinterp/octave-value/ov-scalar.h, libinterp/octave-value/ov-str-mat.cc,
libinterp/octave-value/ov-str-mat.h, libinterp/octave-value/ov-struct.cc,
libinterp/octave-value/ov-struct.h, libinterp/octave-value/ov-type-conv.h,
libinterp/octave-value/ov-typeinfo.cc, libinterp/octave-value/ov-typeinfo.h,
libinterp/octave-value/ov-uint16.cc, libinterp/octave-value/ov-uint32.cc,
libinterp/octave-value/ov-uint64.cc, libinterp/octave-value/ov-uint8.cc,
libinterp/octave-value/ov-usr-fcn.cc, libinterp/octave-value/ov-usr-fcn.h,
libinterp/octave-value/ov.cc, libinterp/octave-value/ov.h, libinterp/octave.cc,
libinterp/operators/op-b-bm.cc, libinterp/operators/op-b-sbm.cc,
libinterp/operators/op-bm-b.cc, libinterp/operators/op-bm-bm.cc,
libinterp/operators/op-cdm-cdm.cc, libinterp/operators/op-chm.cc,
libinterp/operators/op-class.cc, libinterp/operators/op-cm-cm.cc,
libinterp/operators/op-cm-cs.cc, libinterp/operators/op-cm-s.cc,
libinterp/operators/op-cm-scm.cc, libinterp/operators/op-cm-sm.cc,
libinterp/operators/op-cs-cm.cc, libinterp/operators/op-cs-cs.cc,
libinterp/operators/op-cs-scm.cc, libinterp/operators/op-cs-sm.cc,
libinterp/operators/op-dm-dm.cc, libinterp/operators/op-dm-scm.cc,
libinterp/operators/op-double-conv.cc, libinterp/operators/op-fcdm-fcdm.cc,
libinterp/operators/op-fcm-fcm.cc, libinterp/operators/op-fcm-fcs.cc,
libinterp/operators/op-fcm-fm.cc, libinterp/operators/op-fcm-fs.cc,
libinterp/operators/op-fcs-fcm.cc, libinterp/operators/op-fcs-fcs.cc,
libinterp/operators/op-fcs-fm.cc, libinterp/operators/op-fcs-fs.cc,
libinterp/operators/op-fdm-fdm.cc, libinterp/operators/op-float-conv.cc,
libinterp/operators/op-fm-fcm.cc, libinterp/operators/op-fm-fcs.cc,
libinterp/operators/op-fm-fm.cc, libinterp/operators/op-fm-fs.cc,
libinterp/operators/op-fs-fcm.cc, libinterp/operators/op-fs-fcs.cc,
libinterp/operators/op-fs-fm.cc, libinterp/operators/op-fs-fs.cc,
libinterp/operators/op-m-cm.cc, libinterp/operators/op-m-cs.cc,
libinterp/operators/op-m-m.cc, libinterp/operators/op-m-s.cc,
libinterp/operators/op-m-scm.cc, libinterp/operators/op-m-sm.cc,
libinterp/operators/op-pm-scm.cc, libinterp/operators/op-range.cc,
libinterp/operators/op-s-cm.cc, libinterp/operators/op-s-cs.cc,
libinterp/operators/op-s-scm.cc, libinterp/operators/op-sbm-b.cc,
libinterp/operators/op-sbm-bm.cc, libinterp/operators/op-sbm-sbm.cc,
libinterp/operators/op-scm-cm.cc, libinterp/operators/op-scm-cs.cc,
libinterp/operators/op-scm-m.cc, libinterp/operators/op-scm-s.cc,
libinterp/operators/op-scm-scm.cc, libinterp/operators/op-scm-sm.cc,
libinterp/operators/op-sm-cm.cc, libinterp/operators/op-sm-m.cc,
libinterp/operators/op-sm-s.cc, libinterp/operators/op-sm-scm.cc,
libinterp/operators/op-sm-sm.cc, libinterp/operators/op-str-m.cc,
libinterp/operators/op-str-s.cc, libinterp/operators/op-str-str.cc,
libinterp/operators/ops.h, libinterp/parse-tree/lex.h,
libinterp/parse-tree/parse.h, libinterp/parse-tree/pt-arg-list.cc,
libinterp/parse-tree/pt-arg-list.h, libinterp/parse-tree/pt-assign.cc,
libinterp/parse-tree/pt-assign.h, libinterp/parse-tree/pt-binop.cc,
libinterp/parse-tree/pt-binop.h, libinterp/parse-tree/pt-bp.h,
libinterp/parse-tree/pt-cbinop.cc, libinterp/parse-tree/pt-check.cc,
libinterp/parse-tree/pt-colon.cc, libinterp/parse-tree/pt-colon.h,
libinterp/parse-tree/pt-const.cc, libinterp/parse-tree/pt-decl.cc,
libinterp/parse-tree/pt-decl.h, libinterp/parse-tree/pt-eval.cc,
libinterp/parse-tree/pt-except.h, libinterp/parse-tree/pt-exp.h,
libinterp/parse-tree/pt-fcn-handle.cc, libinterp/parse-tree/pt-id.cc,
libinterp/parse-tree/pt-id.h, libinterp/parse-tree/pt-idx.cc,
libinterp/parse-tree/pt-idx.h, libinterp/parse-tree/pt-loop.h,
libinterp/parse-tree/pt-mat.cc, libinterp/parse-tree/pt-misc.cc,
libinterp/parse-tree/pt-misc.h, libinterp/parse-tree/pt-pr-code.cc,
libinterp/parse-tree/pt-select.h, libinterp/parse-tree/pt-stmt.h,
libinterp/parse-tree/token.h, libinterp/version.cc:
Use GNU style coding conventions for code in libinterp/
author | Rik <rik@octave.org> |
---|---|
date | Mon, 28 Oct 2013 19:51:46 -0700 |
parents | d63878346099 |
children | 97e49b588f5d |
comparison
equal
deleted
inserted
replaced
17786:34d9812a943b | 17787:175b392e91fe |
---|---|
260 { | 260 { |
261 symbol_table::global_table_iterator p | 261 symbol_table::global_table_iterator p |
262 = symbol_table::global_table.find (name); | 262 = symbol_table::global_table.find (name); |
263 | 263 |
264 return (p == symbol_table::global_table.end ()) | 264 return (p == symbol_table::global_table.end ()) |
265 ? symbol_table::global_table[name] : p->second; | 265 ? symbol_table::global_table[name] : p->second; |
266 } | 266 } |
267 else if (is_persistent ()) | 267 else if (is_persistent ()) |
268 { | 268 { |
269 static octave_value foobar; | 269 static octave_value foobar; |
270 | 270 |
426 { | 426 { |
427 mark_persistent (); | 427 mark_persistent (); |
428 | 428 |
429 assign (symbol_table::persistent_varval (name)); | 429 assign (symbol_table::persistent_varval (name)); |
430 } | 430 } |
431 // FIXME -- this causes trouble with recursive calls. | 431 // FIXME: this causes trouble with recursive calls. |
432 // else | 432 // else |
433 // error ("unable to declare existing variable persistent"); | 433 // error ("unable to declare existing variable persistent"); |
434 } | 434 } |
435 | 435 |
436 void invalidate (void) | 436 void invalidate (void) |
735 { | 735 { |
736 public: | 736 public: |
737 | 737 |
738 typedef std::map<std::string, std::string> dispatch_map_type; | 738 typedef std::map<std::string, std::string> dispatch_map_type; |
739 | 739 |
740 typedef std::map<scope_id, octave_value>::const_iterator scope_val_const_iterator; | 740 typedef std::map<scope_id, octave_value>::const_iterator |
741 scope_val_const_iterator; | |
741 typedef std::map<scope_id, octave_value>::iterator scope_val_iterator; | 742 typedef std::map<scope_id, octave_value>::iterator scope_val_iterator; |
742 | 743 |
743 typedef std::map<std::string, octave_value>::const_iterator str_val_const_iterator; | 744 typedef std::map<std::string, octave_value>::const_iterator |
745 str_val_const_iterator; | |
744 typedef std::map<std::string, octave_value>::iterator str_val_iterator; | 746 typedef std::map<std::string, octave_value>::iterator str_val_iterator; |
745 | 747 |
746 typedef dispatch_map_type::const_iterator dispatch_map_const_iterator; | 748 typedef dispatch_map_type::const_iterator dispatch_map_const_iterator; |
747 typedef dispatch_map_type::iterator dispatch_map_iterator; | 749 typedef dispatch_map_type::iterator dispatch_map_iterator; |
748 | 750 |
778 bool is_user_function_defined (void) const | 780 bool is_user_function_defined (void) const |
779 { | 781 { |
780 return function_on_path.is_defined (); | 782 return function_on_path.is_defined (); |
781 } | 783 } |
782 | 784 |
783 octave_value find_function (const octave_value_list& args, bool local_funcs) | 785 octave_value find_function (const octave_value_list& args, |
786 bool local_funcs) | |
784 { | 787 { |
785 return find (args, local_funcs); | 788 return find (args, local_funcs); |
786 } | 789 } |
787 | 790 |
788 void lock_subfunction (scope_id scope) | 791 void lock_subfunction (scope_id scope) |
805 subfunction_defined_in_scope (scope_id scope) const | 808 subfunction_defined_in_scope (scope_id scope) const |
806 { | 809 { |
807 scope_val_const_iterator p = subfunctions.find (scope); | 810 scope_val_const_iterator p = subfunctions.find (scope); |
808 | 811 |
809 return p == subfunctions.end () | 812 return p == subfunctions.end () |
810 ? std::pair<std::string, octave_value> () | 813 ? std::pair<std::string, octave_value> () |
811 : std::pair<std::string, octave_value> (name, p->second); | 814 : std::pair<std::string, octave_value> (name, p->second); |
812 } | 815 } |
813 | 816 |
814 void erase_subfunction (scope_id scope) | 817 void erase_subfunction (scope_id scope) |
815 { | 818 { |
816 scope_val_iterator p = subfunctions.find (scope); | 819 scope_val_iterator p = subfunctions.find (scope); |
1021 bool is_user_function_defined (void) const | 1024 bool is_user_function_defined (void) const |
1022 { | 1025 { |
1023 return rep->is_user_function_defined (); | 1026 return rep->is_user_function_defined (); |
1024 } | 1027 } |
1025 | 1028 |
1026 octave_value find_function (const octave_value_list& args = octave_value_list (), | 1029 octave_value find_function (const octave_value_list& args |
1030 = octave_value_list (), | |
1027 bool local_funcs = true) | 1031 bool local_funcs = true) |
1028 { | 1032 { |
1029 return rep->find_function (args, local_funcs); | 1033 return rep->find_function (args, local_funcs); |
1030 } | 1034 } |
1031 | 1035 |
1103 void print_dispatch (std::ostream& os) const | 1107 void print_dispatch (std::ostream& os) const |
1104 { | 1108 { |
1105 rep->print_dispatch (os); | 1109 rep->print_dispatch (os); |
1106 } | 1110 } |
1107 | 1111 |
1108 std::string help_for_dispatch (void) const { return rep->help_for_dispatch (); } | 1112 std::string help_for_dispatch (void) const |
1113 { return rep->help_for_dispatch (); } | |
1109 | 1114 |
1110 dispatch_map_type get_dispatch (void) const | 1115 dispatch_map_type get_dispatch (void) const |
1111 { | 1116 { |
1112 return rep->get_dispatch (); | 1117 return rep->get_dispatch (); |
1113 } | 1118 } |
1199 } | 1204 } |
1200 } | 1205 } |
1201 | 1206 |
1202 static void erase_subfunctions_in_scope (scope_id scope) | 1207 static void erase_subfunctions_in_scope (scope_id scope) |
1203 { | 1208 { |
1204 for (fcn_table_iterator q = fcn_table.begin (); | 1209 for (fcn_table_iterator q = fcn_table.begin (); q != fcn_table.end (); q++) |
1205 q != fcn_table.end (); q++) | |
1206 q->second.erase_subfunction (scope); | 1210 q->second.erase_subfunction (scope); |
1207 } | 1211 } |
1208 | 1212 |
1209 static void | 1213 static void |
1210 mark_subfunctions_in_scope_as_private (scope_id scope, | 1214 mark_subfunctions_in_scope_as_private (scope_id scope, |
1211 const std::string& class_name) | 1215 const std::string& class_name) |
1212 { | 1216 { |
1213 for (fcn_table_iterator q = fcn_table.begin (); | 1217 for (fcn_table_iterator q = fcn_table.begin (); q != fcn_table.end (); q++) |
1214 q != fcn_table.end (); q++) | |
1215 q->second.mark_subfunction_in_scope_as_private (scope, class_name); | 1218 q->second.mark_subfunction_in_scope_as_private (scope, class_name); |
1216 } | 1219 } |
1217 | 1220 |
1218 static scope_id dup_scope (scope_id scope) | 1221 static scope_id dup_scope (scope_id scope) |
1219 { | 1222 { |
1489 find_built_in_function (const std::string& name) | 1492 find_built_in_function (const std::string& name) |
1490 { | 1493 { |
1491 fcn_table_const_iterator p = fcn_table.find (name); | 1494 fcn_table_const_iterator p = fcn_table.find (name); |
1492 | 1495 |
1493 return (p != fcn_table.end ()) | 1496 return (p != fcn_table.end ()) |
1494 ? p->second.find_built_in_function () : octave_value (); | 1497 ? p->second.find_built_in_function () : octave_value (); |
1495 } | 1498 } |
1496 | 1499 |
1497 static octave_value | 1500 static octave_value |
1498 find_autoload (const std::string& name) | 1501 find_autoload (const std::string& name) |
1499 { | 1502 { |
1500 fcn_table_iterator p = fcn_table.find (name); | 1503 fcn_table_iterator p = fcn_table.find (name); |
1501 | 1504 |
1502 return (p != fcn_table.end ()) | 1505 return (p != fcn_table.end ()) |
1503 ? p->second.find_autoload () : octave_value (); | 1506 ? p->second.find_autoload () : octave_value (); |
1504 } | 1507 } |
1505 | 1508 |
1506 static octave_value | 1509 static octave_value |
1507 find_function (const std::string& name, | 1510 find_function (const std::string& name, |
1508 const octave_value_list& args = octave_value_list (), | 1511 const octave_value_list& args = octave_value_list (), |
1511 static octave_value find_user_function (const std::string& name) | 1514 static octave_value find_user_function (const std::string& name) |
1512 { | 1515 { |
1513 fcn_table_iterator p = fcn_table.find (name); | 1516 fcn_table_iterator p = fcn_table.find (name); |
1514 | 1517 |
1515 return (p != fcn_table.end ()) | 1518 return (p != fcn_table.end ()) |
1516 ? p->second.find_user_function () : octave_value (); | 1519 ? p->second.find_user_function () : octave_value (); |
1517 } | 1520 } |
1518 | 1521 |
1519 static void install_cmdline_function (const std::string& name, | 1522 static void install_cmdline_function (const std::string& name, |
1520 const octave_value& fcn) | 1523 const octave_value& fcn) |
1521 { | 1524 { |
1678 inst->do_clear_variable (name); | 1681 inst->do_clear_variable (name); |
1679 } | 1682 } |
1680 | 1683 |
1681 static void clear_symbol (const std::string& name) | 1684 static void clear_symbol (const std::string& name) |
1682 { | 1685 { |
1683 // FIXME -- are we supposed to do both here? | 1686 // FIXME: are we supposed to do both here? |
1684 | 1687 |
1685 clear_variable (name); | 1688 clear_variable (name); |
1686 clear_function (name); | 1689 clear_function (name); |
1687 } | 1690 } |
1688 | 1691 |
1721 inst->do_clear_variable_regexp (pat); | 1724 inst->do_clear_variable_regexp (pat); |
1722 } | 1725 } |
1723 | 1726 |
1724 static void clear_symbol_pattern (const std::string& pat) | 1727 static void clear_symbol_pattern (const std::string& pat) |
1725 { | 1728 { |
1726 // FIXME -- are we supposed to do both here? | 1729 // FIXME: are we supposed to do both here? |
1727 | 1730 |
1728 clear_variable_pattern (pat); | 1731 clear_variable_pattern (pat); |
1729 clear_function_pattern (pat); | 1732 clear_function_pattern (pat); |
1730 } | 1733 } |
1731 | 1734 |
1737 { | 1740 { |
1738 fcn_info& finfo = p->second; | 1741 fcn_info& finfo = p->second; |
1739 | 1742 |
1740 finfo.clear_user_function (); | 1743 finfo.clear_user_function (); |
1741 } | 1744 } |
1742 // FIXME -- is this necessary, or even useful? | 1745 // FIXME: is this necessary, or even useful? |
1743 // else | 1746 // else |
1744 // error ("clear: no such function '%s'", name.c_str ()); | 1747 // error ("clear: no such function '%s'", name.c_str ()); |
1745 } | 1748 } |
1746 | 1749 |
1747 // This clears oct and mex files, incl. autoloads. | 1750 // This clears oct and mex files, incl. autoloads. |
1928 unsigned int exclude = symbol_record::hidden) | 1931 unsigned int exclude = symbol_record::hidden) |
1929 { | 1932 { |
1930 symbol_table *inst = get_instance (scope); | 1933 symbol_table *inst = get_instance (scope); |
1931 | 1934 |
1932 return inst | 1935 return inst |
1933 ? inst->do_all_variables (context, defined_only, exclude) | 1936 ? inst->do_all_variables (context, defined_only, exclude) |
1934 : std::list<symbol_record> (); | 1937 : std::list<symbol_record> (); |
1935 } | 1938 } |
1936 | 1939 |
1937 static std::list<symbol_record> glob (const std::string& pattern) | 1940 static std::list<symbol_record> glob (const std::string& pattern) |
1938 { | 1941 { |
1939 symbol_table *inst = get_instance (xcurrent_scope); | 1942 symbol_table *inst = get_instance (xcurrent_scope); |
1975 // We generate a list of symbol_record objects so that | 1978 // We generate a list of symbol_record objects so that |
1976 // the results from glob_variables and glob_global_variables | 1979 // the results from glob_variables and glob_global_variables |
1977 // may be handled the same way. | 1980 // may be handled the same way. |
1978 | 1981 |
1979 if (pat.match (p->first)) | 1982 if (pat.match (p->first)) |
1980 retval.push_back (symbol_record (xglobal_scope, | 1983 retval.push_back (symbol_record (xglobal_scope, |
1981 p->first, p->second, | 1984 p->first, p->second, |
1982 symbol_record::global)); | 1985 symbol_record::global)); |
1983 } | 1986 } |
1984 | 1987 |
1985 return retval; | 1988 return retval; |
2150 static std::list<workspace_element> workspace_info (void) | 2153 static std::list<workspace_element> workspace_info (void) |
2151 { | 2154 { |
2152 symbol_table *inst = get_instance (xcurrent_scope); | 2155 symbol_table *inst = get_instance (xcurrent_scope); |
2153 | 2156 |
2154 return inst | 2157 return inst |
2155 ? inst->do_workspace_info () : std::list<workspace_element> (); | 2158 ? inst->do_workspace_info () : std::list<workspace_element> (); |
2156 } | 2159 } |
2157 | 2160 |
2158 static void dump (std::ostream& os, scope_id scope = xcurrent_scope); | 2161 static void dump (std::ostream& os, scope_id scope = xcurrent_scope); |
2159 | 2162 |
2160 static void dump_global (std::ostream& os); | 2163 static void dump_global (std::ostream& os); |
2233 for (std::list<std::string>::const_iterator lit = retval.begin (); | 2236 for (std::list<std::string>::const_iterator lit = retval.begin (); |
2234 lit != retval.end (); lit++) | 2237 lit != retval.end (); lit++) |
2235 { | 2238 { |
2236 // Search for parents of parents and append them to the list. | 2239 // Search for parents of parents and append them to the list. |
2237 | 2240 |
2238 // FIXME -- should we worry about a circular inheritance graph? | 2241 // FIXME: should we worry about a circular inheritance graph? |
2239 | 2242 |
2240 std::list<std::string> parents = parent_classes (*lit); | 2243 std::list<std::string> parents = parent_classes (*lit); |
2241 | 2244 |
2242 if (! parents.empty ()) | 2245 if (! parents.empty ()) |
2243 retval.insert (retval.end (), parents.begin (), parents.end ()); | 2246 retval.insert (retval.end (), parents.begin (), parents.end ()); |
2245 | 2248 |
2246 return retval; | 2249 return retval; |
2247 } | 2250 } |
2248 | 2251 |
2249 static octave_user_function *get_curr_fcn (scope_id scope = xcurrent_scope) | 2252 static octave_user_function *get_curr_fcn (scope_id scope = xcurrent_scope) |
2250 { | 2253 { |
2251 symbol_table *inst = get_instance (scope); | 2254 symbol_table *inst = get_instance (scope); |
2252 return inst->curr_fcn; | 2255 return inst->curr_fcn; |
2253 } | 2256 } |
2254 | 2257 |
2255 static void set_curr_fcn (octave_user_function *curr_fcn, | 2258 static void set_curr_fcn (octave_user_function *curr_fcn, |
2256 scope_id scope = xcurrent_scope) | 2259 scope_id scope = xcurrent_scope) |
2257 { | 2260 { |
2258 assert (scope != xtop_scope && scope != xglobal_scope); | 2261 assert (scope != xtop_scope && scope != xglobal_scope); |
2259 symbol_table *inst = get_instance (scope); | 2262 symbol_table *inst = get_instance (scope); |
2260 // FIXME: normally, functions should not usurp each other's scope. | 2263 // FIXME: normally, functions should not usurp each other's scope. |
2261 // If for any incredible reason this is needed, call | 2264 // If for any incredible reason this is needed, call |
2262 // set_user_function (0, scope) first. This may cause problems with | 2265 // set_user_function (0, scope) first. This may cause problems with |
2263 // nested functions, as the curr_fcn of symbol_records must be updated. | 2266 // nested functions, as the curr_fcn of symbol_records must be updated. |
2264 assert (inst->curr_fcn == 0 || curr_fcn == 0); | 2267 assert (inst->curr_fcn == 0 || curr_fcn == 0); |
2265 inst->curr_fcn = curr_fcn; | 2268 inst->curr_fcn = curr_fcn; |
2266 } | 2269 } |
2267 | 2270 |
2268 static void cleanup (void); | 2271 static void cleanup (void); |
2269 | 2272 |
2270 private: | 2273 private: |
2271 | 2274 |
2273 | 2276 |
2274 symbol_table (const symbol_table&); | 2277 symbol_table (const symbol_table&); |
2275 | 2278 |
2276 symbol_table& operator = (const symbol_table&); | 2279 symbol_table& operator = (const symbol_table&); |
2277 | 2280 |
2278 typedef std::map<std::string, symbol_record>::const_iterator table_const_iterator; | 2281 typedef std::map<std::string, symbol_record>::const_iterator |
2279 typedef std::map<std::string, symbol_record>::iterator table_iterator; | 2282 table_const_iterator; |
2280 | 2283 typedef std::map<std::string, symbol_record>::iterator |
2281 typedef std::map<std::string, octave_value>::const_iterator global_table_const_iterator; | 2284 table_iterator; |
2282 typedef std::map<std::string, octave_value>::iterator global_table_iterator; | 2285 |
2283 | 2286 typedef std::map<std::string, octave_value>::const_iterator |
2284 typedef std::map<std::string, octave_value>::const_iterator persistent_table_const_iterator; | 2287 global_table_const_iterator; |
2285 typedef std::map<std::string, octave_value>::iterator persistent_table_iterator; | 2288 typedef std::map<std::string, octave_value>::iterator |
2286 | 2289 global_table_iterator; |
2287 typedef std::map<scope_id, symbol_table*>::const_iterator all_instances_const_iterator; | 2290 |
2288 typedef std::map<scope_id, symbol_table*>::iterator all_instances_iterator; | 2291 typedef std::map<std::string, octave_value>::const_iterator |
2289 | 2292 persistent_table_const_iterator; |
2290 typedef std::map<std::string, fcn_info>::const_iterator fcn_table_const_iterator; | 2293 typedef std::map<std::string, octave_value>::iterator |
2291 typedef std::map<std::string, fcn_info>::iterator fcn_table_iterator; | 2294 persistent_table_iterator; |
2292 | 2295 |
2296 typedef std::map<scope_id, symbol_table*>::const_iterator | |
2297 all_instances_const_iterator; | |
2298 typedef std::map<scope_id, symbol_table*>::iterator | |
2299 all_instances_iterator; | |
2300 | |
2301 typedef std::map<std::string, fcn_info>::const_iterator | |
2302 fcn_table_const_iterator; | |
2303 typedef std::map<std::string, fcn_info>::iterator | |
2304 fcn_table_iterator; | |
2305 | |
2293 // The scope of this symbol table. | 2306 // The scope of this symbol table. |
2294 scope_id my_scope; | 2307 scope_id my_scope; |
2295 | 2308 |
2296 // Name for this table (usually the file name of the function | 2309 // Name for this table (usually the file name of the function |
2297 // corresponding to the scope); | 2310 // corresponding to the scope); |
2330 | 2343 |
2331 // Mape from class names to set of classes that have lower | 2344 // Mape from class names to set of classes that have lower |
2332 // precedence. | 2345 // precedence. |
2333 static std::map<std::string, std::set<std::string> > class_precedence_table; | 2346 static std::map<std::string, std::set<std::string> > class_precedence_table; |
2334 | 2347 |
2335 typedef std::map<std::string, std::set<std::string> >::const_iterator class_precedence_table_const_iterator; | 2348 typedef std::map<std::string, std::set<std::string> >::const_iterator |
2336 typedef std::map<std::string, std::set<std::string> >::iterator class_precedence_table_iterator; | 2349 class_precedence_table_const_iterator; |
2350 typedef std::map<std::string, std::set<std::string> >::iterator | |
2351 class_precedence_table_iterator; | |
2337 | 2352 |
2338 // Map from class names to parent class names. | 2353 // Map from class names to parent class names. |
2339 static std::map<std::string, std::list<std::string> > parent_map; | 2354 static std::map<std::string, std::list<std::string> > parent_map; |
2340 | 2355 |
2341 typedef std::map<std::string, std::list<std::string> >::const_iterator const_parent_map_iterator; | 2356 typedef std::map<std::string, std::list<std::string> >::const_iterator |
2342 typedef std::map<std::string, std::list<std::string> >::iterator parent_map_iterator; | 2357 const_parent_map_iterator; |
2358 typedef std::map<std::string, std::list<std::string> >::iterator | |
2359 parent_map_iterator; | |
2343 | 2360 |
2344 static const scope_id xglobal_scope; | 2361 static const scope_id xglobal_scope; |
2345 static const scope_id xtop_scope; | 2362 static const scope_id xtop_scope; |
2346 | 2363 |
2347 static scope_id xcurrent_scope; | 2364 static scope_id xcurrent_scope; |
2349 static context_id xcurrent_context; | 2366 static context_id xcurrent_context; |
2350 | 2367 |
2351 static const context_id xdefault_context = static_cast<context_id> (-1); | 2368 static const context_id xdefault_context = static_cast<context_id> (-1); |
2352 | 2369 |
2353 symbol_table (scope_id scope) | 2370 symbol_table (scope_id scope) |
2354 : my_scope (scope), table_name (), table (), nest_children (), nest_parent (0), | 2371 : my_scope (scope), table_name (), table (), nest_children (), |
2355 curr_fcn (0), static_workspace (false), persistent_table () { } | 2372 nest_parent (0), curr_fcn (0), static_workspace (false), |
2373 persistent_table () { } | |
2356 | 2374 |
2357 ~symbol_table (void) { } | 2375 ~symbol_table (void) { } |
2358 | 2376 |
2359 static symbol_table *get_instance (scope_id scope, bool create = true) | 2377 static symbol_table *get_instance (scope_id scope, bool create = true) |
2360 { | 2378 { |
2428 | 2446 |
2429 void | 2447 void |
2430 do_dup_scope (symbol_table& new_symbol_table) const | 2448 do_dup_scope (symbol_table& new_symbol_table) const |
2431 { | 2449 { |
2432 for (table_const_iterator p = table.begin (); p != table.end (); p++) | 2450 for (table_const_iterator p = table.begin (); p != table.end (); p++) |
2433 new_symbol_table.insert_symbol_record (p->second.dup (new_symbol_table.my_scope)); | 2451 new_symbol_table.insert_symbol_record (p->second.dup (new_symbol_table |
2452 .my_scope)); | |
2434 } | 2453 } |
2435 | 2454 |
2436 symbol_record do_find_symbol (const std::string& name) | 2455 symbol_record do_find_symbol (const std::string& name) |
2437 { | 2456 { |
2438 table_iterator p = table.find (name); | 2457 table_iterator p = table.find (name); |
2467 } | 2486 } |
2468 } | 2487 } |
2469 } | 2488 } |
2470 | 2489 |
2471 static fcn_info *get_fcn_info (const std::string& name) | 2490 static fcn_info *get_fcn_info (const std::string& name) |
2472 { | 2491 { |
2473 fcn_table_iterator p = fcn_table.find (name); | 2492 fcn_table_iterator p = fcn_table.find (name); |
2474 return p != fcn_table.end () ? &p->second : 0; | 2493 return p != fcn_table.end () ? &p->second : 0; |
2475 } | 2494 } |
2476 | 2495 |
2477 octave_value | 2496 octave_value |
2478 do_find (const std::string& name, const octave_value_list& args, | 2497 do_find (const std::string& name, const octave_value_list& args, |
2479 bool skip_variables, bool local_funcs); | 2498 bool skip_variables, bool local_funcs); |
2480 | 2499 |
2555 table_const_iterator p = table.find (name); | 2574 table_const_iterator p = table.find (name); |
2556 | 2575 |
2557 return (p != table.end ()) ? p->second.varval (context) : octave_value (); | 2576 return (p != table.end ()) ? p->second.varval (context) : octave_value (); |
2558 } | 2577 } |
2559 | 2578 |
2560 void do_persistent_assign (const std::string& name, | 2579 void do_persistent_assign (const std::string& name, const octave_value& value) |
2561 const octave_value& value) | |
2562 { | 2580 { |
2563 persistent_table_iterator p = persistent_table.find (name); | 2581 persistent_table_iterator p = persistent_table.find (name); |
2564 | 2582 |
2565 if (p == persistent_table.end ()) | 2583 if (p == persistent_table.end ()) |
2566 persistent_table[name] = value; | 2584 persistent_table[name] = value; |
2573 octave_value& do_persistent_varref (const std::string& name) | 2591 octave_value& do_persistent_varref (const std::string& name) |
2574 { | 2592 { |
2575 persistent_table_iterator p = persistent_table.find (name); | 2593 persistent_table_iterator p = persistent_table.find (name); |
2576 | 2594 |
2577 return (p == persistent_table.end ()) | 2595 return (p == persistent_table.end ()) |
2578 ? persistent_table[name] : p->second; | 2596 ? persistent_table[name] : p->second; |
2579 } | 2597 } |
2580 | 2598 |
2581 octave_value do_persistent_varval (const std::string& name) | 2599 octave_value do_persistent_varval (const std::string& name) |
2582 { | 2600 { |
2583 persistent_table_const_iterator p = persistent_table.find (name); | 2601 persistent_table_const_iterator p = persistent_table.find (name); |