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