Mercurial > hg > octave-lyh
annotate src/pt-cmd.cc @ 7755:ea9cb4d68dbf
avoid installing subfunctions twice
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Sun, 04 May 2008 23:36:31 -0400 |
parents | e26d0931c044 |
children | 71f068b22fcc |
rev | line source |
---|---|
494 | 1 /* |
2 | |
7017 | 3 Copyright (C) 1994, 1995, 1996, 1997, 2002, 2004, 2005, 2006, 2007 |
4 John W. Eaton | |
494 | 5 |
6 This file is part of Octave. | |
7 | |
8 Octave is free software; you can redistribute it and/or modify it | |
9 under the terms of the GNU General Public License as published by the | |
7016 | 10 Free Software Foundation; either version 3 of the License, or (at your |
11 option) any later version. | |
494 | 12 |
13 Octave is distributed in the hope that it will be useful, but WITHOUT | |
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
7016 | 19 along with Octave; see the file COPYING. If not, see |
20 <http://www.gnu.org/licenses/>. | |
494 | 21 |
22 */ | |
23 | |
24 #ifdef HAVE_CONFIG_H | |
1192 | 25 #include <config.h> |
494 | 26 #endif |
27 | |
2956 | 28 #include "pt-cmd.h" |
2124 | 29 #include "pt-walk.h" |
916 | 30 |
2620 | 31 // No-op. |
32 | |
5861 | 33 tree_command * |
7336 | 34 tree_no_op_command::dup (symbol_table::scope_id) |
5861 | 35 { |
36 return new tree_no_op_command (orig_cmd, line (), column ()); | |
37 } | |
38 | |
2620 | 39 void |
40 tree_no_op_command::accept (tree_walker& tw) | |
41 { | |
42 tw.visit_no_op_command (*this); | |
43 } | |
44 | |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
45 // Function definition. |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
46 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
47 void |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
48 tree_function_def::eval (void) |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
49 { |
7755
ea9cb4d68dbf
avoid installing subfunctions twice
John W. Eaton <jwe@octave.org>
parents:
7754
diff
changeset
|
50 octave_function *f = function (); |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
51 |
7755
ea9cb4d68dbf
avoid installing subfunctions twice
John W. Eaton <jwe@octave.org>
parents:
7754
diff
changeset
|
52 if (f) |
ea9cb4d68dbf
avoid installing subfunctions twice
John W. Eaton <jwe@octave.org>
parents:
7754
diff
changeset
|
53 { |
ea9cb4d68dbf
avoid installing subfunctions twice
John W. Eaton <jwe@octave.org>
parents:
7754
diff
changeset
|
54 std::string nm = f->name (); |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
55 |
7755
ea9cb4d68dbf
avoid installing subfunctions twice
John W. Eaton <jwe@octave.org>
parents:
7754
diff
changeset
|
56 symbol_table::install_cmdline_function (nm, fcn); |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
57 |
7755
ea9cb4d68dbf
avoid installing subfunctions twice
John W. Eaton <jwe@octave.org>
parents:
7754
diff
changeset
|
58 // Make sure that any variable with the same name as the new |
ea9cb4d68dbf
avoid installing subfunctions twice
John W. Eaton <jwe@octave.org>
parents:
7754
diff
changeset
|
59 // function is cleared. |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
60 |
7755
ea9cb4d68dbf
avoid installing subfunctions twice
John W. Eaton <jwe@octave.org>
parents:
7754
diff
changeset
|
61 symbol_table::varref (nm) = octave_value (); |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
62 } |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
63 } |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
64 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
65 tree_command * |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
66 tree_function_def::dup (symbol_table::scope_id) |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
67 { |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
68 return new tree_function_def (fcn, line (), column ()); |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
69 } |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
70 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
71 void |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
72 tree_function_def::accept (tree_walker& tw) |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
73 { |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
74 tw.visit_function_def (*this); |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
75 } |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
76 |
494 | 77 /* |
78 ;;; Local Variables: *** | |
79 ;;; mode: C++ *** | |
80 ;;; End: *** | |
81 */ |