Mercurial > hg > octave-nkf
annotate src/pt-cmd.h @ 8658:73c4516fae10
New evaluator and debugger derived from tree-walker class
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 04 Feb 2009 00:47:53 -0500 |
parents | 71f068b22fcc |
children | c84a5b6377c4 |
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 | |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
48 virtual tree_command *dup (symbol_table::scope_id, |
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
49 symbol_table::context_id context) = 0; |
5861 | 50 |
2988 | 51 private: |
52 | |
53 // No copying! | |
54 | |
55 tree_command (const tree_command&); | |
56 | |
57 tree_command& operator = (const tree_command&); | |
494 | 58 }; |
59 | |
2620 | 60 // No-op. |
61 | |
62 class | |
63 tree_no_op_command : public tree_command | |
64 { | |
65 public: | |
66 | |
3523 | 67 tree_no_op_command (const std::string& cmd = "no_op", int l = -1, int c = -1) |
2620 | 68 : tree_command (l, c), orig_cmd (cmd) { } |
69 | |
70 ~tree_no_op_command (void) { } | |
71 | |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
72 tree_command *dup (symbol_table::scope_id scope, |
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
73 symbol_table::context_id context); |
5861 | 74 |
2620 | 75 void accept (tree_walker& tw); |
76 | |
3523 | 77 std::string original_command (void) { return orig_cmd; } |
2620 | 78 |
79 private: | |
80 | |
3523 | 81 std::string orig_cmd; |
2988 | 82 |
83 // No copying! | |
84 | |
85 tree_no_op_command (const tree_no_op_command&); | |
86 | |
87 tree_no_op_command& operator = (const tree_no_op_command&); | |
2620 | 88 }; |
89 | |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
90 // Function definition. |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
91 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
92 class |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
93 tree_function_def : public tree_command |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
94 { |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
95 public: |
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 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
|
98 : tree_command (l, c), fcn (f) { } |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
99 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
100 ~tree_function_def (void) { } |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
101 |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
102 tree_command *dup (symbol_table::scope_id scope, |
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
103 symbol_table::context_id context); |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
104 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
105 void accept (tree_walker& tw); |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
106 |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
7767
diff
changeset
|
107 octave_value function (void) { return fcn; } |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
108 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
109 private: |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
110 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
111 octave_value fcn; |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
112 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
113 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
|
114 : tree_command (l, c), fcn (v) { } |
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 // No copying! |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
117 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
118 tree_function_def (const tree_function_def&); |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
119 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
120 tree_function_def& operator = (const tree_function_def&); |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
121 }; |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
122 |
494 | 123 #endif |
124 | |
125 /* | |
126 ;;; Local Variables: *** | |
127 ;;; mode: C++ *** | |
128 ;;; End: *** | |
129 */ |