Mercurial > hg > octave-nkf
annotate src/pt-stmt.h @ 7734:2dee19385d32
eliminate tree_statement_stack; handle current statement info in octave_call_stack
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 25 Apr 2008 12:16:42 -0400 |
parents | 6070c3bd69c4 |
children | a059b5679fbb |
rev | line source |
---|---|
2982 | 1 /* |
2 | |
7017 | 3 Copyright (C) 1996, 1997, 2000, 2001, 2002, 2004, 2005, 2006, 2007 |
4 John W. Eaton | |
2982 | 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. | |
2982 | 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/>. | |
2982 | 21 |
22 */ | |
23 | |
24 #if !defined (octave_tree_stmt_h) | |
25 #define octave_tree_stmt_h 1 | |
26 | |
27 class octave_value_list; | |
28 | |
29 class tree_command; | |
30 class tree_expression; | |
31 | |
32 class tree_walker; | |
33 | |
7552
6070c3bd69c4
Arbitrary call stack access for external debuggers changeset
ryanru@PrinceHumperdinck
parents:
7336
diff
changeset
|
34 #include <deque> |
6070c3bd69c4
Arbitrary call stack access for external debuggers changeset
ryanru@PrinceHumperdinck
parents:
7336
diff
changeset
|
35 |
4219 | 36 #include "base-list.h" |
3665 | 37 #include "comment-list.h" |
7336 | 38 #include "symtab.h" |
3665 | 39 |
2982 | 40 // A statement is either a command to execute or an expression to |
41 // evaluate. | |
42 | |
43 class | |
44 tree_statement | |
45 { | |
46 public: | |
47 | |
48 tree_statement (void) | |
3665 | 49 : cmd (0), expr (0), comm (0), print_flag (true) { } |
2982 | 50 |
3665 | 51 tree_statement (tree_command *c, octave_comment_list *cl) |
52 : cmd (c), expr (0), comm (cl), print_flag (true) { } | |
2982 | 53 |
3665 | 54 tree_statement (tree_expression *e, octave_comment_list *cl) |
55 : cmd (0), expr (e), comm (cl), print_flag (true) { } | |
2982 | 56 |
57 ~tree_statement (void); | |
58 | |
3933 | 59 void set_print_flag (bool print) { print_flag = print; } |
2982 | 60 |
3933 | 61 bool is_command (void) { return cmd != 0; } |
2982 | 62 |
3933 | 63 bool is_expression (void) { return expr != 0; } |
2982 | 64 |
65 int line (void); | |
66 int column (void); | |
67 | |
68 void maybe_echo_code (bool in_function_body); | |
69 | |
70 bool print_result (void) { return print_flag; } | |
71 | |
72 tree_command *command (void) { return cmd; } | |
73 | |
74 octave_value_list eval (bool silent, int nargout, bool in_function_body); | |
75 | |
76 tree_expression *expression (void) { return expr; } | |
77 | |
3665 | 78 octave_comment_list *comment_text (void) { return comm; } |
79 | |
4935 | 80 // Allow modification of this statement. Note that there is no |
81 // checking. If you use these, are you sure you knwo what you are | |
82 // doing? | |
83 | |
84 void set_command (tree_command *c) { cmd = c; } | |
85 | |
86 void set_expression (tree_expression *e) { expr = e; } | |
87 | |
7336 | 88 tree_statement *dup (symbol_table::scope_id scope); |
5861 | 89 |
2982 | 90 void accept (tree_walker& tw); |
91 | |
92 private: | |
93 | |
94 // Only one of cmd or expr can be valid at once. | |
95 | |
96 // Command to execute. | |
97 tree_command *cmd; | |
98 | |
99 // Expression to evaluate. | |
100 tree_expression *expr; | |
101 | |
3665 | 102 // Comment associated with this statement. |
103 octave_comment_list *comm; | |
104 | |
2982 | 105 // Print result of eval for this command? |
106 bool print_flag; | |
2988 | 107 |
108 // No copying! | |
109 tree_statement (const tree_statement&); | |
110 | |
111 tree_statement& operator = (const tree_statement&); | |
2982 | 112 }; |
113 | |
114 // A list of statements to evaluate. | |
115 | |
116 class | |
4219 | 117 tree_statement_list : public octave_base_list<tree_statement *> |
2982 | 118 { |
119 public: | |
120 | |
121 tree_statement_list (void) | |
4219 | 122 : function_body (false) { } |
2982 | 123 |
124 tree_statement_list (tree_statement *s) | |
4219 | 125 : function_body (false) { append (s); } |
2982 | 126 |
127 ~tree_statement_list (void) | |
128 { | |
4219 | 129 while (! empty ()) |
2982 | 130 { |
4219 | 131 iterator p = begin (); |
132 delete *p; | |
133 erase (p); | |
2982 | 134 } |
135 } | |
136 | |
137 void mark_as_function_body (void) { function_body = true; } | |
138 | |
139 octave_value_list eval (bool silent = false, int nargout = 0); | |
140 | |
3770 | 141 int set_breakpoint (int line); |
142 | |
143 void delete_breakpoint (int line); | |
144 | |
145 octave_value_list list_breakpoints (void); | |
146 | |
7336 | 147 tree_statement_list *dup (symbol_table::scope_id scope); |
5861 | 148 |
2982 | 149 void accept (tree_walker& tw); |
150 | |
151 private: | |
152 | |
153 // Does this list of statements make up the body of a function? | |
154 bool function_body; | |
2988 | 155 |
156 // No copying! | |
157 | |
158 tree_statement_list (const tree_statement_list&); | |
159 | |
160 tree_statement_list& operator = (const tree_statement_list&); | |
2982 | 161 }; |
162 | |
163 #endif | |
164 | |
165 /* | |
166 ;;; Local Variables: *** | |
167 ;;; mode: C++ *** | |
168 ;;; End: *** | |
169 */ |