GNU Octave  4.0.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
pt-stmt.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 1996-2015 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_pt_stmt_h)
24 #define octave_pt_stmt_h 1
25 
26 class octave_value_list;
27 
28 class tree_command;
29 class tree_expression;
30 
31 class tree_walker;
32 
33 #include <deque>
34 
35 #include "base-list.h"
36 #include "comment-list.h"
37 #include "debug.h"
38 #include "symtab.h"
39 #include "pt.h"
40 
41 // A statement is either a command to execute or an expression to
42 // evaluate.
43 
44 class
45 tree_statement : public tree
46 {
47 public:
48 
50  : cmd (0), expr (0), comm (0) { }
51 
53  : cmd (c), expr (0), comm (cl) { }
54 
56  : cmd (0), expr (e), comm (cl) { }
57 
58  ~tree_statement (void);
59 
60  void set_print_flag (bool print_flag);
61 
62  bool print_result (void);
63 
64  bool is_command (void) const { return cmd != 0; }
65 
66  bool is_expression (void) const { return expr != 0; }
67 
68  void set_breakpoint (void);
69 
70  void delete_breakpoint (void);
71 
72  bool is_breakpoint (void) const;
73 
74  int line (void) const;
75  int column (void) const;
76 
77  void set_location (int l, int c);
78 
79  void echo_code (void);
80 
81  tree_command *command (void) { return cmd; }
82 
83  tree_expression *expression (void) { return expr; }
84 
85  octave_comment_list *comment_text (void) { return comm; }
86 
87  bool is_null_statement (void) const { return ! (cmd || expr || comm); }
88 
89  bool is_end_of_fcn_or_script (void) const;
90 
91  bool is_end_of_file (void) const;
92 
93  // Allow modification of this statement. Note that there is no
94  // checking. If you use these, are you sure you knwo what you are
95  // doing?
96 
97  void set_command (tree_command *c) { cmd = c; }
98 
99  void set_expression (tree_expression *e) { expr = e; }
100 
103 
104  void accept (tree_walker& tw);
105 
106 private:
107 
108  // Only one of cmd or expr can be valid at once.
109 
110  // Command to execute.
112 
113  // Expression to evaluate.
115 
116  // Comment associated with this statement.
118 
119  // No copying!
121 
123 };
124 
125 // A list of statements to evaluate.
126 
127 class
129 {
130 public:
131 
133  : function_body (false), anon_function_body (false),
134  script_body (false) { }
135 
137  : function_body (false), anon_function_body (false),
138  script_body (false) { append (s); }
139 
141  {
142  while (! empty ())
143  {
144  iterator p = begin ();
145  delete *p;
146  erase (p);
147  }
148  }
149 
150  void mark_as_function_body (void) { function_body = true; }
151 
152  void mark_as_anon_function_body (void) { anon_function_body = true; }
153 
154  void mark_as_script_body (void) { script_body = true; }
155 
156  bool is_function_body (void) const { return function_body; }
157 
158  bool is_anon_function_body (void) const { return anon_function_body; }
159 
160  bool is_script_body (void) const { return script_body; }
161 
162  int set_breakpoint (int line);
163 
164  void delete_breakpoint (int line);
165 
166  octave_value_list list_breakpoints (void);
167 
168  bp_table::intmap add_breakpoint (const std::string& file,
169  const bp_table::intmap& line);
170 
171  bp_table::intmap remove_all_breakpoints (const std::string& file);
172 
175 
176  void accept (tree_walker& tw);
177 
178 private:
179 
180  // Does this list of statements make up the body of a function?
182 
183  // Does this list of statements make up the body of a function?
185 
186  // Does this list of statements make up the body of a script?
188 
189  // No copying!
190 
192 
194 };
195 
196 #endif
octave_comment_list * comment_text(void)
Definition: pt-stmt.h:85
bool anon_function_body
Definition: pt-stmt.h:184
tree_statement(void)
Definition: pt-stmt.h:49
tree_statement(tree_expression *e, octave_comment_list *cl)
Definition: pt-stmt.h:55
tree_command * cmd
Definition: pt-stmt.h:111
tree_command * command(void)
Definition: pt-stmt.h:81
tree_expression * expr
Definition: pt-stmt.h:114
bool is_anon_function_body(void) const
Definition: pt-stmt.h:158
tree_statement_list(tree_statement *s)
Definition: pt-stmt.h:136
octave_comment_list * comm
Definition: pt-stmt.h:117
std::list< tree_statement * >::iterator iterator
Definition: base-list.h:36
static llvm::LLVMContext & context
Definition: jit-typeinfo.cc:76
std::map< int, int > intmap
Definition: debug.h:48
void set_command(tree_command *c)
Definition: pt-stmt.h:97
void mark_as_anon_function_body(void)
Definition: pt-stmt.h:152
void set_expression(tree_expression *e)
Definition: pt-stmt.h:99
bool is_script_body(void) const
Definition: pt-stmt.h:160
bool is_command(void) const
Definition: pt-stmt.h:64
tree_expression * expression(void)
Definition: pt-stmt.h:83
Definition: pt.h:35
void mark_as_function_body(void)
Definition: pt-stmt.h:150
bool is_expression(void) const
Definition: pt-stmt.h:66
size_t context_id
Definition: symtab.h:51
bool is_function_body(void) const
Definition: pt-stmt.h:156
bool is_null_statement(void) const
Definition: pt-stmt.h:87
void mark_as_script_body(void)
Definition: pt-stmt.h:154
tree_statement(tree_command *c, octave_comment_list *cl)
Definition: pt-stmt.h:52
tree_walker & operator=(const tree_walker &)
tree_statement_list(void)
Definition: pt-stmt.h:132
~tree_statement_list(void)
Definition: pt-stmt.h:140