Mercurial > octave
annotate src/pt-cmd.h @ 7715:5b4d278ec828
parse scripts completely before executing
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 16 Apr 2008 15:09:56 -0400 |
parents | 745a8299c2b5 |
children | 71f068b22fcc |
rev | line source |
---|---|
494 | 1 /* |
2 | |
7017 | 3 Copyright (C) 1994, 1995, 1996, 1997, 2000, 2001, 2002, 2004, 2005, |
4 2006, 2007 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 #if !defined (octave_tree_cmd_h) | |
25 #define octave_tree_cmd_h 1 | |
26 | |
2982 | 27 #include <string> |
494 | 28 |
2124 | 29 class tree_walker; |
30 | |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
31 #include "ov-fcn.h" |
2988 | 32 #include "pt.h" |
3770 | 33 #include "pt-bp.h" |
7336 | 34 #include "symtab.h" |
578 | 35 |
36 // A base class for commands. | |
37 | |
494 | 38 class |
39 tree_command : public tree | |
40 { | |
578 | 41 public: |
2124 | 42 |
2982 | 43 tree_command (int l = -1, int c = -1) |
44 : tree (l, c) { } | |
578 | 45 |
1270 | 46 virtual ~tree_command (void) { } |
47 | |
578 | 48 virtual void eval (void) = 0; |
2988 | 49 |
7336 | 50 virtual tree_command *dup (symbol_table::scope_id) = 0; |
5861 | 51 |
2988 | 52 private: |
53 | |
54 // No copying! | |
55 | |
56 tree_command (const tree_command&); | |
57 | |
58 tree_command& operator = (const tree_command&); | |
494 | 59 }; |
60 | |
2620 | 61 // No-op. |
62 | |
63 class | |
64 tree_no_op_command : public tree_command | |
65 { | |
66 public: | |
67 | |
3523 | 68 tree_no_op_command (const std::string& cmd = "no_op", int l = -1, int c = -1) |
2620 | 69 : tree_command (l, c), orig_cmd (cmd) { } |
70 | |
71 ~tree_no_op_command (void) { } | |
72 | |
3770 | 73 void eval (void) { MAYBE_DO_BREAKPOINT; } |
2620 | 74 |
7336 | 75 tree_command *dup (symbol_table::scope_id scope); |
5861 | 76 |
2620 | 77 void accept (tree_walker& tw); |
78 | |
3523 | 79 std::string original_command (void) { return orig_cmd; } |
2620 | 80 |
81 private: | |
82 | |
3523 | 83 std::string orig_cmd; |
2988 | 84 |
85 // No copying! | |
86 | |
87 tree_no_op_command (const tree_no_op_command&); | |
88 | |
89 tree_no_op_command& operator = (const tree_no_op_command&); | |
2620 | 90 }; |
91 | |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
92 // Function definition. |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
93 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
94 class |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
95 tree_function_def : public tree_command |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
96 { |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
97 public: |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
98 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
99 tree_function_def (octave_function *f, int l = -1, int c = -1) |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
100 : tree_command (l, c), fcn (f) { } |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
101 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
102 ~tree_function_def (void) { } |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
103 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
104 void eval (void); |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
105 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
106 tree_command *dup (symbol_table::scope_id scope); |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
107 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
108 void accept (tree_walker& tw); |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
109 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
110 octave_function *function (void) { return fcn.function_value (); } |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
111 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
112 private: |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
113 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
114 octave_value fcn; |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
115 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
116 tree_function_def (const octave_value& v, int l = -1, int c = -1) |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
117 : tree_command (l, c), fcn (v) { } |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
118 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
119 // No copying! |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
120 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
121 tree_function_def (const tree_function_def&); |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
122 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
123 tree_function_def& operator = (const tree_function_def&); |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
124 }; |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
125 |
494 | 126 #endif |
127 | |
128 /* | |
129 ;;; Local Variables: *** | |
130 ;;; mode: C++ *** | |
131 ;;; End: *** | |
132 */ |