3
Copyright (C) 1996, 1997, 2000, 2001, 2002, 2004, 2005, 2006, 2007
6
This file is part of Octave.
8
Octave is free software; you can redistribute it and/or modify it
9
under the terms of the GNU General Public License as published by the
10
Free Software Foundation; either version 3 of the License, or (at your
11
option) any later version.
13
Octave is distributed in the hope that it will be useful, but WITHOUT
14
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18
You should have received a copy of the GNU General Public License
19
along with Octave; see the file COPYING. If not, see
20
<http://www.gnu.org/licenses/>.
24
#if !defined (octave_tree_stmt_h)
25
#define octave_tree_stmt_h 1
27
class octave_value_list;
30
class tree_expression;
34
#include "base-list.h"
35
#include "comment-list.h"
37
// A statement is either a command to execute or an expression to
46
: cmd (0), expr (0), comm (0), print_flag (true) { }
48
tree_statement (tree_command *c, octave_comment_list *cl)
49
: cmd (c), expr (0), comm (cl), print_flag (true) { }
51
tree_statement (tree_expression *e, octave_comment_list *cl)
52
: cmd (0), expr (e), comm (cl), print_flag (true) { }
54
~tree_statement (void);
56
void set_print_flag (bool print) { print_flag = print; }
58
bool is_command (void) { return cmd != 0; }
60
bool is_expression (void) { return expr != 0; }
65
void maybe_echo_code (bool in_function_body);
67
bool print_result (void) { return print_flag; }
69
tree_command *command (void) { return cmd; }
71
octave_value_list eval (bool silent, int nargout, bool in_function_body);
73
tree_expression *expression (void) { return expr; }
75
octave_comment_list *comment_text (void) { return comm; }
77
// Allow modification of this statement. Note that there is no
78
// checking. If you use these, are you sure you knwo what you are
81
void set_command (tree_command *c) { cmd = c; }
83
void set_expression (tree_expression *e) { expr = e; }
85
tree_statement *dup (symbol_table *sym_tab);
87
void accept (tree_walker& tw);
91
// Only one of cmd or expr can be valid at once.
93
// Command to execute.
96
// Expression to evaluate.
97
tree_expression *expr;
99
// Comment associated with this statement.
100
octave_comment_list *comm;
102
// Print result of eval for this command?
106
tree_statement (const tree_statement&);
108
tree_statement& operator = (const tree_statement&);
111
// A list of statements to evaluate.
114
tree_statement_list : public octave_base_list<tree_statement *>
118
tree_statement_list (void)
119
: function_body (false) { }
121
tree_statement_list (tree_statement *s)
122
: function_body (false) { append (s); }
124
~tree_statement_list (void)
128
iterator p = begin ();
134
void mark_as_function_body (void) { function_body = true; }
136
octave_value_list eval (bool silent = false, int nargout = 0);
138
int set_breakpoint (int line);
140
void delete_breakpoint (int line);
142
octave_value_list list_breakpoints (void);
144
tree_statement_list *dup (symbol_table *sym_tab);
146
void accept (tree_walker& tw);
150
// Does this list of statements make up the body of a function?
155
tree_statement_list (const tree_statement_list&);
157
tree_statement_list& operator = (const tree_statement_list&);
160
// Pointer to the current statement being executed.
161
extern tree_statement *curr_statement;
163
// Pointer to the current statement being executed in the calling function.
164
extern tree_statement *curr_caller_statement;
169
;;; Local Variables: ***