annotate src/toplev.h @ 9218:00ce0ae4ec63

add missing OCTINTERP_API tag
author Jaroslav Hajek <highegg@gmail.com>
date Wed, 20 May 2009 11:29:08 +0200
parents ee7cf4d963f3
children 659657942ba6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
1 /*
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
2
7017
a1dbe9d80eee [project @ 2007-10-12 21:27:11 by jwe]
jwe
parents: 7016
diff changeset
3 Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 2000, 2001, 2002,
8920
eb63fbe60fab update copyright notices
John W. Eaton <jwe@octave.org>
parents: 8013
diff changeset
4 2003, 2004, 2005, 2006, 2007, 2008 John W. Eaton
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
5
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
6 This file is part of Octave.
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
7
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
8 Octave is free software; you can redistribute it and/or modify it
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
9 under the terms of the GNU General Public License as published by the
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5744
diff changeset
10 Free Software Foundation; either version 3 of the License, or (at your
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5744
diff changeset
11 option) any later version.
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
12
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
13 Octave is distributed in the hope that it will be useful, but WITHOUT
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
16 for more details.
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
17
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
18 You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5744
diff changeset
19 along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5744
diff changeset
20 <http://www.gnu.org/licenses/>.
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
21
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
22 */
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
23
1670
6708c53892c1 [project @ 1995-12-27 04:33:00 by jwe]
jwe
parents: 1613
diff changeset
24 #if !defined (octave_toplev_h)
6708c53892c1 [project @ 1995-12-27 04:33:00 by jwe]
jwe
parents: 1613
diff changeset
25 #define octave_toplev_h 1
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
26
1355
94697d007075 [project @ 1995-09-05 20:04:15 by jwe]
jwe
parents: 1315
diff changeset
27 #include <cstdio>
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
28
7552
6070c3bd69c4 Arbitrary call stack access for external debuggers changeset
ryanru@PrinceHumperdinck
parents: 7409
diff changeset
29 #include <deque>
3503
d14c483b3c12 [project @ 2000-02-01 04:06:07 by jwe]
jwe
parents: 3216
diff changeset
30 #include <string>
d14c483b3c12 [project @ 2000-02-01 04:06:07 by jwe]
jwe
parents: 3216
diff changeset
31
2086
bfb775fb6fe8 [project @ 1996-04-25 05:55:19 by jwe]
jwe
parents: 2077
diff changeset
32 class octave_value;
2796
74bc1ede3c3d [project @ 1997-03-07 06:55:47 by jwe]
jwe
parents: 2440
diff changeset
33 class octave_value_list;
5743
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
34 class octave_function;
5744
1c36a2e82266 [project @ 2006-04-06 19:38:34 by jwe]
jwe
parents: 5743
diff changeset
35 class octave_user_script;
7734
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
36 class tree_statement;
578
d169be9237fb [project @ 1994-08-03 20:06:54 by jwe]
jwe
parents: 574
diff changeset
37 class tree_statement_list;
1572
0d9e10d10bd7 [project @ 1995-10-19 04:31:30 by jwe]
jwe
parents: 1516
diff changeset
38 class charMatrix;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
39
9217
ee7cf4d963f3 smarter handling of quit()
Jaroslav Hajek <highegg@gmail.com>
parents: 9144
diff changeset
40 #include "quit.h"
ee7cf4d963f3 smarter handling of quit()
Jaroslav Hajek <highegg@gmail.com>
parents: 9144
diff changeset
41
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
42 #include "input.h"
7734
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
43 #include "oct-map.h"
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
44
9217
ee7cf4d963f3 smarter handling of quit()
Jaroslav Hajek <highegg@gmail.com>
parents: 9144
diff changeset
45
9218
00ce0ae4ec63 add missing OCTINTERP_API tag
Jaroslav Hajek <highegg@gmail.com>
parents: 9217
diff changeset
46 extern OCTINTERP_API void (*octave_exit) (int);
9217
ee7cf4d963f3 smarter handling of quit()
Jaroslav Hajek <highegg@gmail.com>
parents: 9144
diff changeset
47
ee7cf4d963f3 smarter handling of quit()
Jaroslav Hajek <highegg@gmail.com>
parents: 9144
diff changeset
48 // quit is a lot like an interrupt, so we subclass it to simplify possible
ee7cf4d963f3 smarter handling of quit()
Jaroslav Hajek <highegg@gmail.com>
parents: 9144
diff changeset
49 // handling.
ee7cf4d963f3 smarter handling of quit()
Jaroslav Hajek <highegg@gmail.com>
parents: 9144
diff changeset
50 class octave_quit_exception
ee7cf4d963f3 smarter handling of quit()
Jaroslav Hajek <highegg@gmail.com>
parents: 9144
diff changeset
51 : public octave_interrupt_exception
ee7cf4d963f3 smarter handling of quit()
Jaroslav Hajek <highegg@gmail.com>
parents: 9144
diff changeset
52 {
ee7cf4d963f3 smarter handling of quit()
Jaroslav Hajek <highegg@gmail.com>
parents: 9144
diff changeset
53 public:
ee7cf4d963f3 smarter handling of quit()
Jaroslav Hajek <highegg@gmail.com>
parents: 9144
diff changeset
54 int status;
ee7cf4d963f3 smarter handling of quit()
Jaroslav Hajek <highegg@gmail.com>
parents: 9144
diff changeset
55 octave_quit_exception (int s) : status (s) { }
ee7cf4d963f3 smarter handling of quit()
Jaroslav Hajek <highegg@gmail.com>
parents: 9144
diff changeset
56 };
ee7cf4d963f3 smarter handling of quit()
Jaroslav Hajek <highegg@gmail.com>
parents: 9144
diff changeset
57
7250
0ff0883fb121 [project @ 2007-12-04 18:12:32 by jwe]
jwe
parents: 7202
diff changeset
58 extern OCTINTERP_API void
9217
ee7cf4d963f3 smarter handling of quit()
Jaroslav Hajek <highegg@gmail.com>
parents: 9144
diff changeset
59 clean_up_and_exit (int);
574
a10f1c8ab10f [project @ 1994-07-29 18:29:13 by jwe]
jwe
parents: 383
diff changeset
60
7250
0ff0883fb121 [project @ 2007-12-04 18:12:32 by jwe]
jwe
parents: 7202
diff changeset
61 extern OCTINTERP_API void recover_from_exception (void);
7202
ffdbdf53665c [project @ 2007-11-27 20:14:41 by jwe]
jwe
parents: 7185
diff changeset
62
5189
85b315ad5f7d [project @ 2005-03-04 02:46:08 by jwe]
jwe
parents: 4975
diff changeset
63 extern int main_loop (void);
1907
8c6cea97eb80 [project @ 1996-02-10 01:12:46 by jwe]
jwe
parents: 1884
diff changeset
64
7250
0ff0883fb121 [project @ 2007-12-04 18:12:32 by jwe]
jwe
parents: 7202
diff changeset
65 extern OCTINTERP_API void
2796
74bc1ede3c3d [project @ 1997-03-07 06:55:47 by jwe]
jwe
parents: 2440
diff changeset
66 do_octave_atexit (void);
2077
2d03b8eb891d [project @ 1996-04-24 00:21:21 by jwe]
jwe
parents: 1996
diff changeset
67
7409
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7250
diff changeset
68 extern OCTINTERP_API void
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7250
diff changeset
69 octave_add_atexit_function (const std::string& fname);
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7250
diff changeset
70
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7250
diff changeset
71 extern OCTINTERP_API bool
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7250
diff changeset
72 octave_remove_atexit_function (const std::string& fname);
73036cdd855d [project @ 2008-01-22 20:31:59 by jwe]
jwe
parents: 7250
diff changeset
73
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
74 // Current command to execute.
7250
0ff0883fb121 [project @ 2007-12-04 18:12:32 by jwe]
jwe
parents: 7202
diff changeset
75 extern OCTINTERP_API tree_statement_list *global_command;
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
76
4217
301cc4cf87e9 [project @ 2002-12-05 03:33:01 by jwe]
jwe
parents: 4172
diff changeset
77 // TRUE means we are ready to interpret commands, but not everything
301cc4cf87e9 [project @ 2002-12-05 03:33:01 by jwe]
jwe
parents: 4172
diff changeset
78 // is ready for interactive use.
7185
83cbff53bc96 [project @ 2007-11-26 18:53:54 by jwe]
jwe
parents: 7017
diff changeset
79 extern OCTINTERP_API bool octave_interpreter_ready;
4217
301cc4cf87e9 [project @ 2002-12-05 03:33:01 by jwe]
jwe
parents: 4172
diff changeset
80
4172
2e94b2abfe6d [project @ 2002-11-12 21:14:04 by jwe]
jwe
parents: 3834
diff changeset
81 // TRUE means we've processed all the init code and we are good to go.
7185
83cbff53bc96 [project @ 2007-11-26 18:53:54 by jwe]
jwe
parents: 7017
diff changeset
82 extern OCTINTERP_API bool octave_initialized;
4172
2e94b2abfe6d [project @ 2002-11-12 21:14:04 by jwe]
jwe
parents: 3834
diff changeset
83
5743
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
84 class
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
85 octave_call_stack
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
86 {
7734
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
87 private:
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
88
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
89 struct call_stack_elt
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
90 {
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
91 call_stack_elt (octave_function *f, symbol_table::scope_id s,
7901
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
92 symbol_table::context_id c, size_t p = 0)
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
93 : fcn (f), stmt (0), scope (s), context (c), prev (p) { }
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
94
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
95 call_stack_elt (const call_stack_elt& elt)
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
96 : fcn (elt.fcn), stmt (elt.stmt), scope (elt.scope),
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
97 context (elt.context), prev (elt.prev) { }
7734
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
98
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
99 octave_function *fcn;
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
100 tree_statement *stmt;
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
101 symbol_table::scope_id scope;
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
102 symbol_table::context_id context;
7901
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
103 size_t prev;
7734
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
104 };
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
105
5743
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
106 protected:
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
107
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
108 octave_call_stack (void) : cs (), curr_frame (0) { }
5743
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
109
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
110 public:
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
111
7734
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
112 typedef std::deque<call_stack_elt>::iterator iterator;
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
113 typedef std::deque<call_stack_elt>::const_iterator const_iterator;
7901
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
114
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
115 typedef std::deque<call_stack_elt>::reverse_iterator reverse_iterator;
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
116 typedef std::deque<call_stack_elt>::const_reverse_iterator const_reverse_iterator;
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
117
5743
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
118 static bool instance_ok (void)
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
119 {
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
120 bool retval = true;
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
121
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
122 if (! instance)
7912
75df1f0b4c9d toplev.h (octave_call_stack::instance_ok): push top scope when creating instance
John W. Eaton <jwe@octave.org>
parents: 7901
diff changeset
123 {
75df1f0b4c9d toplev.h (octave_call_stack::instance_ok): push top scope when creating instance
John W. Eaton <jwe@octave.org>
parents: 7901
diff changeset
124 instance = new octave_call_stack ();
5743
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
125
7912
75df1f0b4c9d toplev.h (octave_call_stack::instance_ok): push top scope when creating instance
John W. Eaton <jwe@octave.org>
parents: 7901
diff changeset
126 if (instance)
75df1f0b4c9d toplev.h (octave_call_stack::instance_ok): push top scope when creating instance
John W. Eaton <jwe@octave.org>
parents: 7901
diff changeset
127 instance->do_push (0, symbol_table::top_scope (), 0);
75df1f0b4c9d toplev.h (octave_call_stack::instance_ok): push top scope when creating instance
John W. Eaton <jwe@octave.org>
parents: 7901
diff changeset
128 else
75df1f0b4c9d toplev.h (octave_call_stack::instance_ok): push top scope when creating instance
John W. Eaton <jwe@octave.org>
parents: 7901
diff changeset
129 {
75df1f0b4c9d toplev.h (octave_call_stack::instance_ok): push top scope when creating instance
John W. Eaton <jwe@octave.org>
parents: 7901
diff changeset
130 ::error ("unable to create call stack object!");
5743
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
131
7912
75df1f0b4c9d toplev.h (octave_call_stack::instance_ok): push top scope when creating instance
John W. Eaton <jwe@octave.org>
parents: 7901
diff changeset
132 retval = false;
75df1f0b4c9d toplev.h (octave_call_stack::instance_ok): push top scope when creating instance
John W. Eaton <jwe@octave.org>
parents: 7901
diff changeset
133 }
5743
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
134 }
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
135
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
136 return retval;
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
137 }
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
138
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
139 // Current function (top of stack).
5744
1c36a2e82266 [project @ 2006-04-06 19:38:34 by jwe]
jwe
parents: 5743
diff changeset
140 static octave_function *current (void) { return top (); }
5743
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
141
7734
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
142 // Current statement (top of stack).
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
143 static tree_statement *current_statement (void) { return top_statement (); }
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
144
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
145 // Current line in current function.
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
146 static int current_line (void)
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
147 {
7877
59031cfe331b lasterror fixes
John W. Eaton <jwe@octave.org>
parents: 7787
diff changeset
148 return instance_ok () ? instance->do_current_line () : -1;
7734
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
149 }
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
150
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
151 // Current column in current function.
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
152 static int current_column (void)
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
153 {
7877
59031cfe331b lasterror fixes
John W. Eaton <jwe@octave.org>
parents: 7787
diff changeset
154 return instance_ok () ? instance->do_current_column () : -1;
59031cfe331b lasterror fixes
John W. Eaton <jwe@octave.org>
parents: 7787
diff changeset
155 }
59031cfe331b lasterror fixes
John W. Eaton <jwe@octave.org>
parents: 7787
diff changeset
156
59031cfe331b lasterror fixes
John W. Eaton <jwe@octave.org>
parents: 7787
diff changeset
157 // Line in user code caller.
7923
c3d21b9b94b6 eliminate octave_call_stack member functions caller_user_script and caller_user_function, and unused difference_type args
John W. Eaton <jwe@octave.org>
parents: 7912
diff changeset
158 static int caller_user_code_line (void)
7877
59031cfe331b lasterror fixes
John W. Eaton <jwe@octave.org>
parents: 7787
diff changeset
159 {
7923
c3d21b9b94b6 eliminate octave_call_stack member functions caller_user_script and caller_user_function, and unused difference_type args
John W. Eaton <jwe@octave.org>
parents: 7912
diff changeset
160 return instance_ok () ? instance->do_caller_user_code_line () : -1;
7877
59031cfe331b lasterror fixes
John W. Eaton <jwe@octave.org>
parents: 7787
diff changeset
161 }
59031cfe331b lasterror fixes
John W. Eaton <jwe@octave.org>
parents: 7787
diff changeset
162
59031cfe331b lasterror fixes
John W. Eaton <jwe@octave.org>
parents: 7787
diff changeset
163 // Column in user code caller.
7923
c3d21b9b94b6 eliminate octave_call_stack member functions caller_user_script and caller_user_function, and unused difference_type args
John W. Eaton <jwe@octave.org>
parents: 7912
diff changeset
164 static int caller_user_code_column (void)
7877
59031cfe331b lasterror fixes
John W. Eaton <jwe@octave.org>
parents: 7787
diff changeset
165 {
7923
c3d21b9b94b6 eliminate octave_call_stack member functions caller_user_script and caller_user_function, and unused difference_type args
John W. Eaton <jwe@octave.org>
parents: 7912
diff changeset
166 return instance_ok () ? instance->do_caller_user_code_column () : -1;
7734
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
167 }
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
168
5743
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
169 // Caller function, may be built-in.
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
170 static octave_function *caller (void)
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
171 {
7942
db6478d9c669 out_of_date_check_internal: make it work for class methods
John W. Eaton <jwe@octave.org>
parents: 7923
diff changeset
172 return instance_ok () ? instance->do_caller () : 0;
5743
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
173 }
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
174
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
175 static size_t current_frame (void)
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
176 {
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
177 return instance_ok () ? instance->do_current_frame () : 0;
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
178 }
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
179
7890
73ef513855e7 dbstack fixes
John W. Eaton <jwe@octave.org>
parents: 7877
diff changeset
180 static size_t size (void)
73ef513855e7 dbstack fixes
John W. Eaton <jwe@octave.org>
parents: 7877
diff changeset
181 {
73ef513855e7 dbstack fixes
John W. Eaton <jwe@octave.org>
parents: 7877
diff changeset
182 return instance_ok () ? instance->do_size () : 0;
73ef513855e7 dbstack fixes
John W. Eaton <jwe@octave.org>
parents: 7877
diff changeset
183 }
73ef513855e7 dbstack fixes
John W. Eaton <jwe@octave.org>
parents: 7877
diff changeset
184
7901
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
185 static size_t num_user_code_frames (octave_idx_type& curr_user_frame)
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
186 {
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
187 return instance_ok ()
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
188 ? instance->do_num_user_code_frames (curr_user_frame) : 0;
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
189 }
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
190
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
191 static symbol_table::scope_id current_scope (void)
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
192 {
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
193 return instance_ok () ? instance->do_current_scope () : 0;
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
194 }
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
195
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
196 static symbol_table::context_id current_context (void)
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
197 {
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
198 return instance_ok () ? instance->do_current_context () : 0;
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
199 }
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
200
7552
6070c3bd69c4 Arbitrary call stack access for external debuggers changeset
ryanru@PrinceHumperdinck
parents: 7409
diff changeset
201 // Function at location N on the call stack (N == 0 is current), may
6070c3bd69c4 Arbitrary call stack access for external debuggers changeset
ryanru@PrinceHumperdinck
parents: 7409
diff changeset
202 // be built-in.
6070c3bd69c4 Arbitrary call stack access for external debuggers changeset
ryanru@PrinceHumperdinck
parents: 7409
diff changeset
203 static octave_function *element (size_t n)
6070c3bd69c4 Arbitrary call stack access for external debuggers changeset
ryanru@PrinceHumperdinck
parents: 7409
diff changeset
204 {
6070c3bd69c4 Arbitrary call stack access for external debuggers changeset
ryanru@PrinceHumperdinck
parents: 7409
diff changeset
205 return instance_ok () ? instance->do_element (n) : 0;
6070c3bd69c4 Arbitrary call stack access for external debuggers changeset
ryanru@PrinceHumperdinck
parents: 7409
diff changeset
206 }
6070c3bd69c4 Arbitrary call stack access for external debuggers changeset
ryanru@PrinceHumperdinck
parents: 7409
diff changeset
207
7923
c3d21b9b94b6 eliminate octave_call_stack member functions caller_user_script and caller_user_function, and unused difference_type args
John W. Eaton <jwe@octave.org>
parents: 7912
diff changeset
208 // First user-defined function on the stack.
c3d21b9b94b6 eliminate octave_call_stack member functions caller_user_script and caller_user_function, and unused difference_type args
John W. Eaton <jwe@octave.org>
parents: 7912
diff changeset
209 static octave_user_code *caller_user_code (size_t nskip = 0)
5743
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
210 {
7923
c3d21b9b94b6 eliminate octave_call_stack member functions caller_user_script and caller_user_function, and unused difference_type args
John W. Eaton <jwe@octave.org>
parents: 7912
diff changeset
211 return instance_ok () ? instance->do_caller_user_code (nskip) : 0;
5743
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
212 }
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
213
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
214 static void
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
215 push (octave_function *f,
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
216 symbol_table::scope_id scope = symbol_table::current_scope (),
7901
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
217 symbol_table::context_id context = symbol_table::current_context ())
5743
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
218 {
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
219 if (instance_ok ())
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
220 instance->do_push (f, scope, context);
5743
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
221 }
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
222
9144
c6463412aebb eliminate symbol_table::scope_stack; fix scoping issue with evalin
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
223 static void
c6463412aebb eliminate symbol_table::scope_stack; fix scoping issue with evalin
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
224 push (symbol_table::scope_id scope = symbol_table::current_scope (),
c6463412aebb eliminate symbol_table::scope_stack; fix scoping issue with evalin
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
225 symbol_table::context_id context = symbol_table::current_context ())
c6463412aebb eliminate symbol_table::scope_stack; fix scoping issue with evalin
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
226 {
c6463412aebb eliminate symbol_table::scope_stack; fix scoping issue with evalin
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
227 if (instance_ok ())
c6463412aebb eliminate symbol_table::scope_stack; fix scoping issue with evalin
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
228 instance->do_push (0, scope, context);
c6463412aebb eliminate symbol_table::scope_stack; fix scoping issue with evalin
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
229 }
c6463412aebb eliminate symbol_table::scope_stack; fix scoping issue with evalin
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
230
5744
1c36a2e82266 [project @ 2006-04-06 19:38:34 by jwe]
jwe
parents: 5743
diff changeset
231 static octave_function *top (void)
1c36a2e82266 [project @ 2006-04-06 19:38:34 by jwe]
jwe
parents: 5743
diff changeset
232 {
1c36a2e82266 [project @ 2006-04-06 19:38:34 by jwe]
jwe
parents: 5743
diff changeset
233 return instance_ok () ? instance->do_top (): 0;
1c36a2e82266 [project @ 2006-04-06 19:38:34 by jwe]
jwe
parents: 5743
diff changeset
234 }
1c36a2e82266 [project @ 2006-04-06 19:38:34 by jwe]
jwe
parents: 5743
diff changeset
235
7734
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
236 static tree_statement *top_statement (void)
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
237 {
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
238 return instance_ok () ? instance->do_top_statement (): 0;
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
239 }
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
240
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
241 static void set_statement (tree_statement *s)
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
242 {
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
243 if (instance_ok ())
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
244 instance->do_set_statement (s);
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
245 }
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
246
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
247 static bool goto_frame (size_t n = 0, bool verbose = false)
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
248 {
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
249 return instance_ok () ? instance->do_goto_frame (n, verbose) : false;
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
250 }
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
251
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
252 static bool goto_frame_relative (int n, bool verbose = false)
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
253 {
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
254 return instance_ok ()
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
255 ? instance->do_goto_frame_relative (n, verbose) : false;
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
256 }
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
257
7901
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
258 static void goto_caller_frame (void)
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
259 {
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
260 if (instance_ok ())
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
261 instance->do_goto_caller_frame ();
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
262 }
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
263
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
264 static void goto_base_frame (void)
7734
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
265 {
7901
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
266 if (instance_ok ())
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
267 instance->do_goto_base_frame ();
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
268 }
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
269
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
270 static Octave_map backtrace (size_t nskip, octave_idx_type& curr_user_frame)
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
271 {
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
272 return instance_ok ()
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
273 ? instance->do_backtrace (nskip, curr_user_frame) : Octave_map ();
7734
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
274 }
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
275
5743
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
276 static void pop (void)
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
277 {
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
278 if (instance_ok ())
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
279 instance->do_pop ();
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
280 }
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
281
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
282 // A function for popping the top of the call stack that is suitable
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
283 // for use as an unwind_protect handler.
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
284 static void unwind_pop (void *) { pop (); }
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
285
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
286 static void clear (void)
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
287 {
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
288 if (instance_ok ())
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
289 instance->do_clear ();
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
290 }
7552
6070c3bd69c4 Arbitrary call stack access for external debuggers changeset
ryanru@PrinceHumperdinck
parents: 7409
diff changeset
291
8013
b3e667f1ab4c call backtrace_error_message in eval functions, not when popping stack
John W. Eaton <jwe@octave.org>
parents: 8011
diff changeset
292 static void backtrace_error_message (void)
b3e667f1ab4c call backtrace_error_message in eval functions, not when popping stack
John W. Eaton <jwe@octave.org>
parents: 8011
diff changeset
293 {
b3e667f1ab4c call backtrace_error_message in eval functions, not when popping stack
John W. Eaton <jwe@octave.org>
parents: 8011
diff changeset
294 if (instance_ok ())
b3e667f1ab4c call backtrace_error_message in eval functions, not when popping stack
John W. Eaton <jwe@octave.org>
parents: 8011
diff changeset
295 instance->do_backtrace_error_message ();
b3e667f1ab4c call backtrace_error_message in eval functions, not when popping stack
John W. Eaton <jwe@octave.org>
parents: 8011
diff changeset
296 }
b3e667f1ab4c call backtrace_error_message in eval functions, not when popping stack
John W. Eaton <jwe@octave.org>
parents: 8011
diff changeset
297
5743
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
298 private:
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
299
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
300 // The current call stack.
7734
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
301 std::deque<call_stack_elt> cs;
5743
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
302
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
303 size_t curr_frame;
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
304
5743
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
305 static octave_call_stack *instance;
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
306
7734
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
307 int do_current_line (void) const;
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
308
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
309 int do_current_column (void) const;
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
310
7923
c3d21b9b94b6 eliminate octave_call_stack member functions caller_user_script and caller_user_function, and unused difference_type args
John W. Eaton <jwe@octave.org>
parents: 7912
diff changeset
311 int do_caller_user_code_line (void) const;
7877
59031cfe331b lasterror fixes
John W. Eaton <jwe@octave.org>
parents: 7787
diff changeset
312
7923
c3d21b9b94b6 eliminate octave_call_stack member functions caller_user_script and caller_user_function, and unused difference_type args
John W. Eaton <jwe@octave.org>
parents: 7912
diff changeset
313 int do_caller_user_code_column (void) const;
7877
59031cfe331b lasterror fixes
John W. Eaton <jwe@octave.org>
parents: 7787
diff changeset
314
7942
db6478d9c669 out_of_date_check_internal: make it work for class methods
John W. Eaton <jwe@octave.org>
parents: 7923
diff changeset
315 octave_function *do_caller (void) const
db6478d9c669 out_of_date_check_internal: make it work for class methods
John W. Eaton <jwe@octave.org>
parents: 7923
diff changeset
316 {
db6478d9c669 out_of_date_check_internal: make it work for class methods
John W. Eaton <jwe@octave.org>
parents: 7923
diff changeset
317 return curr_frame > 1 ? cs[curr_frame-1].fcn : cs[0].fcn;
db6478d9c669 out_of_date_check_internal: make it work for class methods
John W. Eaton <jwe@octave.org>
parents: 7923
diff changeset
318 }
db6478d9c669 out_of_date_check_internal: make it work for class methods
John W. Eaton <jwe@octave.org>
parents: 7923
diff changeset
319
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
320 size_t do_current_frame (void) { return curr_frame; }
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
321
7890
73ef513855e7 dbstack fixes
John W. Eaton <jwe@octave.org>
parents: 7877
diff changeset
322 size_t do_size (void) { return cs.size (); }
73ef513855e7 dbstack fixes
John W. Eaton <jwe@octave.org>
parents: 7877
diff changeset
323
7901
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
324 size_t do_num_user_code_frames (octave_idx_type& curr_user_frame) const;
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
325
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
326 symbol_table::scope_id do_current_scope (void) const
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
327 {
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
328 return curr_frame > 0 && curr_frame < cs.size ()
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
329 ? cs[curr_frame].scope : 0;
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
330 }
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
331
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
332 symbol_table::context_id do_current_context (void) const
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
333 {
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
334 return curr_frame > 0 && curr_frame < cs.size ()
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
335 ? cs[curr_frame].context : 0;
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
336 }
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
337
7734
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
338 octave_function *do_element (size_t n)
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
339 {
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
340 octave_function *retval = 0;
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
341
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
342 if (cs.size () > n)
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
343 {
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
344 call_stack_elt& elt = cs[n];
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
345 retval = elt.fcn;
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
346 }
5743
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
347
7734
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
348 return retval;
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
349 }
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
350
7923
c3d21b9b94b6 eliminate octave_call_stack member functions caller_user_script and caller_user_function, and unused difference_type args
John W. Eaton <jwe@octave.org>
parents: 7912
diff changeset
351 octave_user_code *do_caller_user_code (size_t nskip) const;
5744
1c36a2e82266 [project @ 2006-04-06 19:38:34 by jwe]
jwe
parents: 5743
diff changeset
352
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
353 void do_push (octave_function *f, symbol_table::scope_id scope,
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
354 symbol_table::context_id context)
7734
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
355 {
7901
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
356 size_t prev_frame = curr_frame;
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
357 curr_frame = cs.size ();
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
358 cs.push_back (call_stack_elt (f, scope, context, prev_frame));
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
359 symbol_table::set_scope_and_context (scope, context);
7734
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
360 }
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
361
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
362 octave_function *do_top (void) const
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
363 {
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
364 octave_function *retval = 0;
5744
1c36a2e82266 [project @ 2006-04-06 19:38:34 by jwe]
jwe
parents: 5743
diff changeset
365
7734
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
366 if (! cs.empty ())
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
367 {
7890
73ef513855e7 dbstack fixes
John W. Eaton <jwe@octave.org>
parents: 7877
diff changeset
368 const call_stack_elt& elt = cs.back ();
7734
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
369 retval = elt.fcn;
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
370 }
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
371
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
372 return retval;
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
373 }
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
374
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
375 tree_statement *do_top_statement (void) const
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
376 {
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
377 tree_statement *retval = 0;
5743
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
378
7734
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
379 if (! cs.empty ())
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
380 {
7890
73ef513855e7 dbstack fixes
John W. Eaton <jwe@octave.org>
parents: 7877
diff changeset
381 const call_stack_elt& elt = cs.back ();
7734
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
382 retval = elt.stmt;
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
383 }
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
384
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
385 return retval;
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
386 }
5743
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
387
7734
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
388 void do_set_statement (tree_statement *s)
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
389 {
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
390 if (! cs.empty ())
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
391 {
7890
73ef513855e7 dbstack fixes
John W. Eaton <jwe@octave.org>
parents: 7877
diff changeset
392 call_stack_elt& elt = cs.back ();
7734
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
393 elt.stmt = s;
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
394 }
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
395 }
2dee19385d32 eliminate tree_statement_stack; handle current statement info in octave_call_stack
John W. Eaton <jwe@octave.org>
parents: 7733
diff changeset
396
7901
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
397 Octave_map do_backtrace (size_t nskip,
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
398 octave_idx_type& curr_user_frame) const;
5744
1c36a2e82266 [project @ 2006-04-06 19:38:34 by jwe]
jwe
parents: 5743
diff changeset
399
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
400 bool do_goto_frame (size_t n, bool verbose);
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
401
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
402 bool do_goto_frame_relative (int n, bool verbose);
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
403
7901
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
404 void do_goto_caller_frame (void);
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
405
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
406 void do_goto_base_frame (void);
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
407
5743
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
408 void do_pop (void)
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
409 {
7901
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
410 if (cs.size () > 1)
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
411 {
7901
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
412 const call_stack_elt& elt = cs.back ();
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
413 curr_frame = elt.prev;
7890
73ef513855e7 dbstack fixes
John W. Eaton <jwe@octave.org>
parents: 7877
diff changeset
414 cs.pop_back ();
7901
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
415 const call_stack_elt& new_elt = cs[curr_frame];
3e4c9b69069d call stack changes
John W. Eaton <jwe@octave.org>
parents: 7890
diff changeset
416 symbol_table::set_scope_and_context (new_elt.scope, new_elt.context);
7752
40c428ea3408 initial implementation of dbup and dbdown
John W. Eaton <jwe@octave.org>
parents: 7736
diff changeset
417 }
5743
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
418 }
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
419
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
420 void do_clear (void) { cs.clear (); }
8011
3100283874d7 improve backtrace error messages
John W. Eaton <jwe@octave.org>
parents: 7968
diff changeset
421
8013
b3e667f1ab4c call backtrace_error_message in eval functions, not when popping stack
John W. Eaton <jwe@octave.org>
parents: 8011
diff changeset
422 void do_backtrace_error_message (void) const;
5743
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
423 };
a527e0f77aa5 [project @ 2006-04-06 08:20:21 by jwe]
jwe
parents: 5307
diff changeset
424
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
425 #endif
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
426
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
427 /*
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
428 ;;; Local Variables: ***
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
429 ;;; mode: C++ ***
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
430 ;;; End: ***
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
431 */