comparison libinterp/parse-tree/pt-eval.h @ 15195:2fc554ffbc28

split libinterp from src * libinterp: New directory. Move all files from src directory here except Makefile.am, main.cc, main-cli.cc, mkoctfile.in.cc, mkoctfilr.in.sh, octave-config.in.cc, octave-config.in.sh. * libinterp/Makefile.am: New file, extracted from src/Makefile.am. * src/Makefile.am: Delete everything except targets and definitions needed to build and link main and utility programs. * Makefile.am (SUBDIRS): Include libinterp in the list. * autogen.sh: Run config-module.sh in libinterp/dldfcn directory, not src/dldfcn directory. * configure.ac (AC_CONFIG_SRCDIR): Use libinterp/octave.cc, not src/octave.cc. (DL_LDFLAGS, LIBOCTINTERP): Use libinterp, not src. (AC_CONFIG_FILES): Include libinterp/Makefile in the list. * find-docstring-files.sh: Look in libinterp, not src. * gui/src/Makefile.am (liboctgui_la_CPPFLAGS): Find header files in libinterp, not src.
author John W. Eaton <jwe@octave.org>
date Sat, 18 Aug 2012 16:23:39 -0400
parents src/parse-tree/pt-eval.h@46b19589b593
children 947cf10c94da fb9dffe5fbfb
comparison
equal deleted inserted replaced
15194:0f0b795044c3 15195:2fc554ffbc28
1 /*
2
3 Copyright (C) 2009-2012 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 3 of the License, or (at your
10 option) any 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, see
19 <http://www.gnu.org/licenses/>.
20
21 */
22
23 #if !defined (octave_tree_eval_h)
24 #define octave_tree_eval_h 1
25
26 #include <stack>
27 #include <string>
28
29 #include "comment-list.h"
30 #include "oct-obj.h"
31 #include "pt-walk.h"
32
33 class tree_expression;
34
35 // How to evaluate the code that the parse trees represent.
36
37 class
38 OCTINTERP_API
39 tree_evaluator : public tree_walker
40 {
41 public:
42
43 typedef void (*decl_elt_init_fcn) (tree_decl_elt&);
44
45 tree_evaluator (void) { }
46
47 ~tree_evaluator (void) { }
48
49 void visit_anon_fcn_handle (tree_anon_fcn_handle&);
50
51 void visit_argument_list (tree_argument_list&);
52
53 void visit_binary_expression (tree_binary_expression&);
54
55 void visit_break_command (tree_break_command&);
56
57 void visit_colon_expression (tree_colon_expression&);
58
59 void visit_continue_command (tree_continue_command&);
60
61 void visit_global_command (tree_global_command&);
62
63 void visit_persistent_command (tree_persistent_command&);
64
65 void visit_decl_elt (tree_decl_elt&);
66
67 void visit_decl_init_list (tree_decl_init_list&);
68
69 void visit_simple_for_command (tree_simple_for_command&);
70
71 void visit_complex_for_command (tree_complex_for_command&);
72
73 void visit_octave_user_script (octave_user_script&);
74
75 void visit_octave_user_function (octave_user_function&);
76
77 void visit_octave_user_function_header (octave_user_function&);
78
79 void visit_octave_user_function_trailer (octave_user_function&);
80
81 void visit_function_def (tree_function_def&);
82
83 void visit_identifier (tree_identifier&);
84
85 void visit_if_clause (tree_if_clause&);
86
87 void visit_if_command (tree_if_command&);
88
89 void visit_if_command_list (tree_if_command_list&);
90
91 void visit_index_expression (tree_index_expression&);
92
93 void visit_matrix (tree_matrix&);
94
95 void visit_cell (tree_cell&);
96
97 void visit_multi_assignment (tree_multi_assignment&);
98
99 void visit_no_op_command (tree_no_op_command&);
100
101 void visit_constant (tree_constant&);
102
103 void visit_fcn_handle (tree_fcn_handle&);
104
105 void visit_parameter_list (tree_parameter_list&);
106
107 void visit_postfix_expression (tree_postfix_expression&);
108
109 void visit_prefix_expression (tree_prefix_expression&);
110
111 void visit_return_command (tree_return_command&);
112
113 void visit_return_list (tree_return_list&);
114
115 void visit_simple_assignment (tree_simple_assignment&);
116
117 void visit_statement (tree_statement&);
118
119 void visit_statement_list (tree_statement_list&);
120
121 void visit_switch_case (tree_switch_case&);
122
123 void visit_switch_case_list (tree_switch_case_list&);
124
125 void visit_switch_command (tree_switch_command&);
126
127 void visit_try_catch_command (tree_try_catch_command&);
128
129 void do_unwind_protect_cleanup_code (tree_statement_list *list);
130
131 void visit_unwind_protect_command (tree_unwind_protect_command&);
132
133 void visit_while_command (tree_while_command&);
134
135 void visit_do_until_command (tree_do_until_command&);
136
137 static void reset_debug_state (void);
138
139 // If > 0, stop executing at the (N-1)th stopping point, counting
140 // from the the current execution point in the current frame.
141 //
142 // If < 0, stop executing at the next possible stopping point.
143 static int dbstep_flag;
144
145 // The number of the stack frame we are currently debugging.
146 static size_t current_frame;
147
148 static bool debug_mode;
149
150 // Possible types of evaluation contexts.
151 enum stmt_list_type
152 {
153 function, // function body
154 script, // script file
155 other // command-line input or eval string
156 };
157
158 // The context for the current evaluation.
159 static stmt_list_type statement_context;
160
161 // TRUE means we are evaluating some kind of looping construct.
162 static bool in_loop_command;
163
164 private:
165
166 void do_decl_init_list (decl_elt_init_fcn fcn,
167 tree_decl_init_list *init_list);
168
169 void do_breakpoint (tree_statement& stmt) const;
170
171 void do_breakpoint (bool is_breakpoint,
172 bool is_end_of_fcn_or_script = false) const;
173
174 virtual octave_value
175 do_keyboard (const octave_value_list& args = octave_value_list ()) const;
176
177 // No copying!
178
179 tree_evaluator (const tree_evaluator&);
180
181 tree_evaluator& operator = (const tree_evaluator&);
182 };
183
184 extern tree_evaluator *current_evaluator;
185
186 // Maximum nesting level for functions, scripts, or sourced files called
187 // recursively.
188 extern int Vmax_recursion_depth;
189
190 #endif