Octave-Forge - Extra packages for GNU Octave | |
Home · Packages · Developers · Documentation · FAQ · Bugs · Mailing Lists · Links · Code |
00001 /* 00002 00003 Copyright (C) 2009 John W. Eaton 00004 00005 This file is part of Octave. 00006 00007 Octave is free software; you can redistribute it and/or modify it 00008 under the terms of the GNU General Public License as published by the 00009 Free Software Foundation; either version 3 of the License, or (at your 00010 option) any later version. 00011 00012 Octave is distributed in the hope that it will be useful, but WITHOUT 00013 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00014 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 00015 for more details. 00016 00017 You should have received a copy of the GNU General Public License 00018 along with Octave; see the file COPYING. If not, see 00019 <http://www.gnu.org/licenses/>. 00020 00021 */ 00022 00023 #if !defined (octave_tree_eval_h) 00024 #define octave_tree_eval_h 1 00025 00026 #include <stack> 00027 #include <string> 00028 00029 #include "comment-list.h" 00030 #include "oct-obj.h" 00031 #include "pt-walk.h" 00032 00033 class tree_expression; 00034 00035 // How to evaluate the code that the parse trees represent. 00036 00037 class 00038 OCTINTERP_API 00039 tree_evaluator : public tree_walker 00040 { 00041 public: 00042 00043 typedef void (*decl_elt_init_fcn) (tree_decl_elt&); 00044 00045 tree_evaluator (void) { } 00046 00047 ~tree_evaluator (void) { } 00048 00049 void visit_anon_fcn_handle (tree_anon_fcn_handle&); 00050 00051 void visit_argument_list (tree_argument_list&); 00052 00053 void visit_binary_expression (tree_binary_expression&); 00054 00055 void visit_break_command (tree_break_command&); 00056 00057 void visit_colon_expression (tree_colon_expression&); 00058 00059 void visit_continue_command (tree_continue_command&); 00060 00061 void visit_global_command (tree_global_command&); 00062 00063 void visit_static_command (tree_static_command&); 00064 00065 void visit_decl_elt (tree_decl_elt&); 00066 00067 void visit_decl_init_list (tree_decl_init_list&); 00068 00069 void visit_simple_for_command (tree_simple_for_command&); 00070 00071 void visit_complex_for_command (tree_complex_for_command&); 00072 00073 void visit_octave_user_script (octave_user_script&); 00074 00075 void visit_octave_user_function (octave_user_function&); 00076 00077 void visit_octave_user_function_header (octave_user_function&); 00078 00079 void visit_octave_user_function_trailer (octave_user_function&); 00080 00081 void visit_function_def (tree_function_def&); 00082 00083 void visit_identifier (tree_identifier&); 00084 00085 void visit_if_clause (tree_if_clause&); 00086 00087 void visit_if_command (tree_if_command&); 00088 00089 void visit_if_command_list (tree_if_command_list&); 00090 00091 void visit_index_expression (tree_index_expression&); 00092 00093 void visit_matrix (tree_matrix&); 00094 00095 void visit_cell (tree_cell&); 00096 00097 void visit_multi_assignment (tree_multi_assignment&); 00098 00099 void visit_no_op_command (tree_no_op_command&); 00100 00101 void visit_constant (tree_constant&); 00102 00103 void visit_fcn_handle (tree_fcn_handle&); 00104 00105 void visit_parameter_list (tree_parameter_list&); 00106 00107 void visit_postfix_expression (tree_postfix_expression&); 00108 00109 void visit_prefix_expression (tree_prefix_expression&); 00110 00111 void visit_return_command (tree_return_command&); 00112 00113 void visit_return_list (tree_return_list&); 00114 00115 void visit_simple_assignment (tree_simple_assignment&); 00116 00117 void visit_statement (tree_statement&); 00118 00119 void visit_statement_list (tree_statement_list&); 00120 00121 void visit_switch_case (tree_switch_case&); 00122 00123 void visit_switch_case_list (tree_switch_case_list&); 00124 00125 void visit_switch_command (tree_switch_command&); 00126 00127 void visit_try_catch_command (tree_try_catch_command&); 00128 00129 void visit_unwind_protect_command (tree_unwind_protect_command&); 00130 00131 void visit_while_command (tree_while_command&); 00132 00133 void visit_do_until_command (tree_do_until_command&); 00134 00135 // If > 0, stop executing at the (N-1)th stopping point, counting 00136 // from the the current execution point in the current frame. 00137 // 00138 // If < 0, stop executing at the next possible stopping point. 00139 static int dbstep_flag; 00140 00141 // The number of the stack frame we are currently debugging. 00142 static size_t current_frame; 00143 00144 static bool debug_mode; 00145 00146 // TRUE means we are evaluating a function or script body. 00147 static bool in_fcn_or_script_body; 00148 00149 // TRUE means we are evaluating some kind of looping construct. 00150 static bool in_loop_command; 00151 00152 private: 00153 00154 void do_decl_init_list (decl_elt_init_fcn fcn, 00155 tree_decl_init_list *init_list); 00156 00157 void do_breakpoint (tree_statement& stmt) const; 00158 00159 void do_breakpoint (bool is_breakpoint, 00160 bool is_end_of_fcn_or_script = false) const; 00161 00162 // No copying! 00163 00164 tree_evaluator (const tree_evaluator&); 00165 00166 tree_evaluator& operator = (const tree_evaluator&); 00167 }; 00168 00169 extern tree_evaluator *current_evaluator; 00170 00171 #endif 00172 00173 /* 00174 ;;; Local Variables: *** 00175 ;;; mode: C++ *** 00176 ;;; End: *** 00177 */