00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #if !defined (octave_tree_stmt_h)
00025 #define octave_tree_stmt_h 1
00026
00027 class octave_value_list;
00028
00029 class tree_command;
00030 class tree_expression;
00031
00032 class tree_walker;
00033
00034 #include <deque>
00035
00036 #include "base-list.h"
00037 #include "comment-list.h"
00038 #include "symtab.h"
00039
00040
00041
00042
00043 class
00044 tree_statement
00045 {
00046 public:
00047
00048 tree_statement (void)
00049 : cmd (0), expr (0), comm (0) { }
00050
00051 tree_statement (tree_command *c, octave_comment_list *cl)
00052 : cmd (c), expr (0), comm (cl) { }
00053
00054 tree_statement (tree_expression *e, octave_comment_list *cl)
00055 : cmd (0), expr (e), comm (cl) { }
00056
00057 ~tree_statement (void);
00058
00059 void set_print_flag (bool print_flag);
00060
00061 bool print_result (void);
00062
00063 bool is_command (void) const { return cmd != 0; }
00064
00065 bool is_expression (void) const { return expr != 0; }
00066
00067 void set_breakpoint (void);
00068
00069 void delete_breakpoint (void);
00070
00071 bool is_breakpoint (void) const;
00072
00073 int line (void) const;
00074 int column (void) const;
00075
00076 void echo_code (void);
00077
00078 tree_command *command (void) { return cmd; }
00079
00080 tree_expression *expression (void) { return expr; }
00081
00082 octave_comment_list *comment_text (void) { return comm; }
00083
00084 bool is_null_statement (void) const { return ! (cmd || expr || comm); }
00085
00086 bool is_end_of_fcn_or_script (void) const;
00087
00088
00089
00090
00091
00092 void set_command (tree_command *c) { cmd = c; }
00093
00094 void set_expression (tree_expression *e) { expr = e; }
00095
00096 tree_statement *dup (symbol_table::scope_id scope,
00097 symbol_table::context_id context) const;
00098
00099 void accept (tree_walker& tw);
00100
00101 private:
00102
00103
00104
00105
00106 tree_command *cmd;
00107
00108
00109 tree_expression *expr;
00110
00111
00112 octave_comment_list *comm;
00113
00114
00115 tree_statement (const tree_statement&);
00116
00117 tree_statement& operator = (const tree_statement&);
00118 };
00119
00120
00121
00122 class
00123 tree_statement_list : public octave_base_list<tree_statement *>
00124 {
00125 public:
00126
00127 tree_statement_list (void)
00128 : function_body (false), anon_function_body (false),
00129 script_body (false) { }
00130
00131 tree_statement_list (tree_statement *s)
00132 : function_body (false), anon_function_body (false),
00133 script_body (false) { append (s); }
00134
00135 ~tree_statement_list (void)
00136 {
00137 while (! empty ())
00138 {
00139 iterator p = begin ();
00140 delete *p;
00141 erase (p);
00142 }
00143 }
00144
00145 void mark_as_function_body (void) { function_body = true; }
00146
00147 void mark_as_anon_function_body (void) { anon_function_body = true; }
00148
00149 void mark_as_script_body (void) { script_body = true; }
00150
00151 bool is_function_body (void) const { return function_body; }
00152
00153 bool is_anon_function_body (void) const { return anon_function_body; }
00154
00155 bool is_script_body (void) const { return script_body; }
00156
00157 int set_breakpoint (int line);
00158
00159 void delete_breakpoint (int line);
00160
00161 octave_value_list list_breakpoints (void);
00162
00163 tree_statement_list *dup (symbol_table::scope_id scope,
00164 symbol_table::context_id context) const;
00165
00166 void accept (tree_walker& tw);
00167
00168 private:
00169
00170
00171 bool function_body;
00172
00173
00174 bool anon_function_body;
00175
00176
00177 bool script_body;
00178
00179
00180
00181 tree_statement_list (const tree_statement_list&);
00182
00183 tree_statement_list& operator = (const tree_statement_list&);
00184 };
00185
00186 #endif
00187
00188
00189
00190
00191
00192