~ubuntu-branches/debian/sid/octave3.0/sid

« back to all changes in this revision

Viewing changes to src/pt-stmt.h

  • Committer: Bazaar Package Importer
  • Author(s): Rafael Laboissiere
  • Date: 2007-12-23 16:04:15 UTC
  • Revision ID: james.westby@ubuntu.com-20071223160415-n4gk468dihy22e9v
Tags: upstream-3.0.0
ImportĀ upstreamĀ versionĀ 3.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 
 
3
Copyright (C) 1996, 1997, 2000, 2001, 2002, 2004, 2005, 2006, 2007
 
4
              John W. Eaton
 
5
 
 
6
This file is part of Octave.
 
7
 
 
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.
 
12
 
 
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
 
16
for more details.
 
17
 
 
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/>.
 
21
 
 
22
*/
 
23
 
 
24
#if !defined (octave_tree_stmt_h)
 
25
#define octave_tree_stmt_h 1
 
26
 
 
27
class octave_value_list;
 
28
 
 
29
class tree_command;
 
30
class tree_expression;
 
31
 
 
32
class tree_walker;
 
33
 
 
34
#include "base-list.h"
 
35
#include "comment-list.h"
 
36
 
 
37
// A statement is either a command to execute or an expression to
 
38
// evaluate.
 
39
 
 
40
class
 
41
tree_statement
 
42
{
 
43
public:
 
44
 
 
45
  tree_statement (void)
 
46
    : cmd (0), expr (0), comm (0), print_flag (true) { }
 
47
 
 
48
  tree_statement (tree_command *c, octave_comment_list *cl)
 
49
    : cmd (c), expr (0), comm (cl), print_flag (true) { }
 
50
 
 
51
  tree_statement (tree_expression *e, octave_comment_list *cl)
 
52
    : cmd (0), expr (e), comm (cl), print_flag (true) { }
 
53
 
 
54
  ~tree_statement (void);
 
55
 
 
56
  void set_print_flag (bool print) { print_flag = print; }
 
57
 
 
58
  bool is_command (void) { return cmd != 0; }
 
59
 
 
60
  bool is_expression (void) { return expr != 0; }
 
61
 
 
62
  int line (void);
 
63
  int column (void);
 
64
 
 
65
  void maybe_echo_code (bool in_function_body);
 
66
 
 
67
  bool print_result (void) { return print_flag; }
 
68
 
 
69
  tree_command *command (void) { return cmd; }
 
70
 
 
71
  octave_value_list eval (bool silent, int nargout, bool in_function_body);
 
72
 
 
73
  tree_expression *expression (void) { return expr; }
 
74
 
 
75
  octave_comment_list *comment_text (void) { return comm; }
 
76
 
 
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
 
79
  // doing?
 
80
 
 
81
  void set_command (tree_command *c) { cmd = c; }
 
82
 
 
83
  void set_expression (tree_expression *e) { expr = e; }
 
84
 
 
85
  tree_statement *dup (symbol_table *sym_tab);
 
86
 
 
87
  void accept (tree_walker& tw);
 
88
 
 
89
private:
 
90
 
 
91
  // Only one of cmd or expr can be valid at once.
 
92
 
 
93
  // Command to execute.
 
94
  tree_command *cmd;
 
95
 
 
96
  // Expression to evaluate.
 
97
  tree_expression *expr;
 
98
 
 
99
  // Comment associated with this statement.
 
100
  octave_comment_list *comm;
 
101
 
 
102
  // Print result of eval for this command?
 
103
  bool print_flag;
 
104
 
 
105
  // No copying!
 
106
  tree_statement (const tree_statement&);
 
107
 
 
108
  tree_statement& operator = (const tree_statement&);
 
109
};
 
110
 
 
111
// A list of statements to evaluate.
 
112
 
 
113
class
 
114
tree_statement_list : public octave_base_list<tree_statement *>
 
115
{
 
116
public:
 
117
 
 
118
  tree_statement_list (void)
 
119
    : function_body (false) { }
 
120
 
 
121
  tree_statement_list (tree_statement *s)
 
122
    : function_body (false) { append (s); }
 
123
 
 
124
  ~tree_statement_list (void)
 
125
    {
 
126
      while (! empty ())
 
127
        {
 
128
          iterator p = begin ();
 
129
          delete *p;
 
130
          erase (p);
 
131
        }
 
132
    }
 
133
 
 
134
  void mark_as_function_body (void) { function_body = true; }
 
135
 
 
136
  octave_value_list eval (bool silent = false, int nargout = 0);
 
137
 
 
138
  int set_breakpoint (int line);
 
139
 
 
140
  void delete_breakpoint (int line);
 
141
 
 
142
  octave_value_list list_breakpoints (void);
 
143
 
 
144
  tree_statement_list *dup (symbol_table *sym_tab);
 
145
 
 
146
  void accept (tree_walker& tw);
 
147
 
 
148
private:
 
149
 
 
150
  // Does this list of statements make up the body of a function?
 
151
  bool function_body;
 
152
 
 
153
  // No copying!
 
154
 
 
155
  tree_statement_list (const tree_statement_list&);
 
156
 
 
157
  tree_statement_list& operator = (const tree_statement_list&);
 
158
};
 
159
 
 
160
// Pointer to the current statement being executed.
 
161
extern tree_statement *curr_statement;
 
162
 
 
163
// Pointer to the current statement being executed in the calling function.
 
164
extern tree_statement *curr_caller_statement;
 
165
 
 
166
#endif
 
167
 
 
168
/*
 
169
;;; Local Variables: ***
 
170
;;; mode: C++ ***
 
171
;;; End: ***
 
172
*/