2982
|
1 /* |
|
2 |
|
3 Copyright (C) 1996, 1997 John W. Eaton |
|
4 |
|
5 This file is part of Octave. |
|
6 |
|
7 Octave is free software; you can redistribute it and/or modify it |
|
8 under the terms of the GNU General Public License as published by the |
|
9 Free Software Foundation; either version 2, or (at your option) any |
|
10 later version. |
|
11 |
|
12 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
15 for more details. |
|
16 |
|
17 You should have received a copy of the GNU General Public License |
|
18 along with Octave; see the file COPYING. If not, write to the Free |
|
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
20 |
|
21 */ |
|
22 |
|
23 #if !defined (octave_tree_stmt_h) |
|
24 #define octave_tree_stmt_h 1 |
|
25 |
|
26 #if defined (__GNUG__) |
|
27 #pragma interface |
|
28 #endif |
|
29 |
|
30 #include <SLList.h> |
|
31 |
|
32 class octave_value_list; |
|
33 |
|
34 class tree_command; |
|
35 class tree_expression; |
|
36 |
|
37 class tree_walker; |
|
38 |
3665
|
39 #include "comment-list.h" |
|
40 |
2982
|
41 // A statement is either a command to execute or an expression to |
|
42 // evaluate. |
|
43 |
|
44 class |
|
45 tree_statement |
|
46 { |
|
47 public: |
|
48 |
|
49 tree_statement (void) |
3665
|
50 : cmd (0), expr (0), comm (0), print_flag (true) { } |
2982
|
51 |
3665
|
52 tree_statement (tree_command *c, octave_comment_list *cl) |
|
53 : cmd (c), expr (0), comm (cl), print_flag (true) { } |
2982
|
54 |
3665
|
55 tree_statement (tree_expression *e, octave_comment_list *cl) |
|
56 : cmd (0), expr (e), comm (cl), print_flag (true) { } |
2982
|
57 |
|
58 ~tree_statement (void); |
|
59 |
3933
|
60 void set_print_flag (bool print) { print_flag = print; } |
2982
|
61 |
3933
|
62 bool is_command (void) { return cmd != 0; } |
2982
|
63 |
3933
|
64 bool is_expression (void) { return expr != 0; } |
2982
|
65 |
|
66 int line (void); |
|
67 int column (void); |
|
68 |
|
69 void maybe_echo_code (bool in_function_body); |
|
70 |
|
71 bool print_result (void) { return print_flag; } |
|
72 |
|
73 tree_command *command (void) { return cmd; } |
|
74 |
|
75 octave_value_list eval (bool silent, int nargout, bool in_function_body); |
|
76 |
|
77 tree_expression *expression (void) { return expr; } |
|
78 |
3665
|
79 octave_comment_list *comment_text (void) { return comm; } |
|
80 |
2982
|
81 void accept (tree_walker& tw); |
|
82 |
|
83 private: |
|
84 |
|
85 // Only one of cmd or expr can be valid at once. |
|
86 |
|
87 // Command to execute. |
|
88 tree_command *cmd; |
|
89 |
|
90 // Expression to evaluate. |
|
91 tree_expression *expr; |
|
92 |
3665
|
93 // Comment associated with this statement. |
|
94 octave_comment_list *comm; |
|
95 |
2982
|
96 // Print result of eval for this command? |
|
97 bool print_flag; |
2988
|
98 |
|
99 // No copying! |
|
100 tree_statement (const tree_statement&); |
|
101 |
|
102 tree_statement& operator = (const tree_statement&); |
2982
|
103 }; |
|
104 |
|
105 // A list of statements to evaluate. |
|
106 |
|
107 class |
|
108 tree_statement_list : public SLList<tree_statement *> |
|
109 { |
|
110 public: |
|
111 |
|
112 tree_statement_list (void) |
|
113 : SLList<tree_statement *> (), function_body (false) { } |
|
114 |
|
115 tree_statement_list (tree_statement *s) |
|
116 : SLList<tree_statement *> (), function_body (false) { append (s); } |
|
117 |
|
118 ~tree_statement_list (void) |
|
119 { |
|
120 while (! empty ()) |
|
121 { |
|
122 tree_statement *t = remove_front (); |
|
123 delete t; |
|
124 } |
|
125 } |
|
126 |
|
127 void mark_as_function_body (void) { function_body = true; } |
|
128 |
|
129 octave_value_list eval (bool silent = false, int nargout = 0); |
|
130 |
3770
|
131 int set_breakpoint (int line); |
|
132 |
|
133 void delete_breakpoint (int line); |
|
134 |
|
135 octave_value_list list_breakpoints (void); |
|
136 |
2982
|
137 void accept (tree_walker& tw); |
|
138 |
|
139 private: |
|
140 |
|
141 // Does this list of statements make up the body of a function? |
|
142 bool function_body; |
2988
|
143 |
|
144 // No copying! |
|
145 |
|
146 tree_statement_list (const tree_statement_list&); |
|
147 |
|
148 tree_statement_list& operator = (const tree_statement_list&); |
2982
|
149 }; |
|
150 |
3707
|
151 // Pointer to the current statement being executed. |
|
152 extern tree_statement *curr_statement; |
|
153 |
2982
|
154 #endif |
|
155 |
|
156 /* |
|
157 ;;; Local Variables: *** |
|
158 ;;; mode: C++ *** |
|
159 ;;; End: *** |
|
160 */ |