Mercurial > octave-nkf
annotate src/toplev.h @ 7733:bb614b3883a9
octave_call_stack::unwind_pop_script: delete unused function
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 24 Apr 2008 16:18:44 -0400 |
parents | 87eda1f8faaa |
children | 2dee19385d32 |
rev | line source |
---|---|
1 | 1 /* |
2 | |
7017 | 3 Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 2000, 2001, 2002, |
4 2003, 2004, 2005, 2006, 2007 John W. Eaton | |
1 | 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 | |
7016 | 10 Free Software Foundation; either version 3 of the License, or (at your |
11 option) any later version. | |
1 | 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 | |
7016 | 19 along with Octave; see the file COPYING. If not, see |
20 <http://www.gnu.org/licenses/>. | |
1 | 21 |
22 */ | |
23 | |
1670 | 24 #if !defined (octave_toplev_h) |
25 #define octave_toplev_h 1 | |
1 | 26 |
1355 | 27 #include <cstdio> |
1 | 28 |
7552
6070c3bd69c4
Arbitrary call stack access for external debuggers changeset
ryanru@PrinceHumperdinck
parents:
7409
diff
changeset
|
29 #include <deque> |
3503 | 30 #include <string> |
31 | |
2086 | 32 class octave_value; |
2796 | 33 class octave_value_list; |
5743 | 34 class octave_function; |
5744 | 35 class octave_user_script; |
578 | 36 class tree_statement_list; |
1572 | 37 class charMatrix; |
1 | 38 |
7250 | 39 extern OCTINTERP_API void |
2796 | 40 clean_up_and_exit (int) GCC_ATTR_NORETURN; |
574 | 41 |
7250 | 42 extern OCTINTERP_API void recover_from_exception (void); |
7202 | 43 |
5189 | 44 extern int main_loop (void); |
1907 | 45 |
7250 | 46 extern OCTINTERP_API void |
2796 | 47 do_octave_atexit (void); |
2077 | 48 |
7409 | 49 extern OCTINTERP_API void |
50 octave_add_atexit_function (const std::string& fname); | |
51 | |
52 extern OCTINTERP_API bool | |
53 octave_remove_atexit_function (const std::string& fname); | |
54 | |
1 | 55 // Current command to execute. |
7250 | 56 extern OCTINTERP_API tree_statement_list *global_command; |
1 | 57 |
4238 | 58 // Pointer to parent function that is currently being evaluated. |
7250 | 59 extern OCTINTERP_API octave_function *curr_parent_function; |
4238 | 60 |
4217 | 61 // TRUE means we are ready to interpret commands, but not everything |
62 // is ready for interactive use. | |
7185 | 63 extern OCTINTERP_API bool octave_interpreter_ready; |
4217 | 64 |
4172 | 65 // TRUE means we've processed all the init code and we are good to go. |
7185 | 66 extern OCTINTERP_API bool octave_initialized; |
4172 | 67 |
5743 | 68 class |
69 octave_call_stack | |
70 { | |
71 protected: | |
72 | |
73 octave_call_stack (void) : cs () { } | |
74 | |
75 public: | |
76 | |
7552
6070c3bd69c4
Arbitrary call stack access for external debuggers changeset
ryanru@PrinceHumperdinck
parents:
7409
diff
changeset
|
77 typedef std::deque<octave_function *>::iterator iterator ; |
5743 | 78 |
79 static bool instance_ok (void) | |
80 { | |
81 bool retval = true; | |
82 | |
83 if (! instance) | |
84 instance = new octave_call_stack (); | |
85 | |
86 if (! instance) | |
87 { | |
88 ::error ("unable to create call stack object!"); | |
89 | |
90 retval = false; | |
91 } | |
92 | |
93 return retval; | |
94 } | |
95 | |
96 // Current function (top of stack). | |
5744 | 97 static octave_function *current (void) { return top (); } |
5743 | 98 |
99 // Caller function, may be built-in. | |
100 static octave_function *caller (void) | |
101 { | |
7552
6070c3bd69c4
Arbitrary call stack access for external debuggers changeset
ryanru@PrinceHumperdinck
parents:
7409
diff
changeset
|
102 return element (1); |
5743 | 103 } |
104 | |
7552
6070c3bd69c4
Arbitrary call stack access for external debuggers changeset
ryanru@PrinceHumperdinck
parents:
7409
diff
changeset
|
105 // 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
|
106 // be built-in. |
6070c3bd69c4
Arbitrary call stack access for external debuggers changeset
ryanru@PrinceHumperdinck
parents:
7409
diff
changeset
|
107 static octave_function *element (size_t n) |
6070c3bd69c4
Arbitrary call stack access for external debuggers changeset
ryanru@PrinceHumperdinck
parents:
7409
diff
changeset
|
108 { |
6070c3bd69c4
Arbitrary call stack access for external debuggers changeset
ryanru@PrinceHumperdinck
parents:
7409
diff
changeset
|
109 return instance_ok () ? instance->do_element (n) : 0; |
6070c3bd69c4
Arbitrary call stack access for external debuggers changeset
ryanru@PrinceHumperdinck
parents:
7409
diff
changeset
|
110 } |
6070c3bd69c4
Arbitrary call stack access for external debuggers changeset
ryanru@PrinceHumperdinck
parents:
7409
diff
changeset
|
111 |
5744 | 112 // First script on the stack. |
113 static octave_user_script *caller_script (void) | |
5743 | 114 { |
7552
6070c3bd69c4
Arbitrary call stack access for external debuggers changeset
ryanru@PrinceHumperdinck
parents:
7409
diff
changeset
|
115 return instance_ok () ? instance->do_caller_user_script () : 0; |
5744 | 116 } |
117 | |
118 // First user-defined function on the stack. | |
119 static octave_user_function *caller_user_function (void) | |
120 { | |
7552
6070c3bd69c4
Arbitrary call stack access for external debuggers changeset
ryanru@PrinceHumperdinck
parents:
7409
diff
changeset
|
121 return instance_ok () ? instance->do_caller_user_function () : 0; |
5744 | 122 } |
123 | |
124 // First user-defined function on the stack. | |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7552
diff
changeset
|
125 static octave_user_code *caller_user_code (void) |
5744 | 126 { |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7552
diff
changeset
|
127 return instance_ok () ? instance->do_caller_user_code () : 0; |
5743 | 128 } |
129 | |
130 static void push (octave_function *f) | |
131 { | |
132 if (instance_ok ()) | |
133 instance->do_push (f); | |
134 } | |
135 | |
5744 | 136 static octave_function *top (void) |
137 { | |
138 return instance_ok () ? instance->do_top (): 0; | |
139 } | |
140 | |
5743 | 141 static void pop (void) |
142 { | |
143 if (instance_ok ()) | |
144 instance->do_pop (); | |
145 } | |
146 | |
147 // A function for popping the top of the call stack that is suitable | |
148 // for use as an unwind_protect handler. | |
149 static void unwind_pop (void *) { pop (); } | |
150 | |
151 static void clear (void) | |
152 { | |
153 if (instance_ok ()) | |
154 instance->do_clear (); | |
155 } | |
7552
6070c3bd69c4
Arbitrary call stack access for external debuggers changeset
ryanru@PrinceHumperdinck
parents:
7409
diff
changeset
|
156 |
5743 | 157 private: |
158 | |
159 // The current call stack. | |
7552
6070c3bd69c4
Arbitrary call stack access for external debuggers changeset
ryanru@PrinceHumperdinck
parents:
7409
diff
changeset
|
160 std::deque<octave_function *> cs; |
5743 | 161 |
162 static octave_call_stack *instance; | |
163 | |
7552
6070c3bd69c4
Arbitrary call stack access for external debuggers changeset
ryanru@PrinceHumperdinck
parents:
7409
diff
changeset
|
164 octave_function *do_element (size_t n) { return cs.size () > n ? cs[n] : 0; } |
5743 | 165 |
5744 | 166 octave_user_script *do_caller_user_script (void); |
167 | |
168 octave_user_function *do_caller_user_function (void); | |
169 | |
7719
87eda1f8faaa
octave_user_code: new base class for octave_user_script and octave_user_function
John W. Eaton <jwe@octave.org>
parents:
7552
diff
changeset
|
170 octave_user_code *do_caller_user_code (void); |
5743 | 171 |
172 void do_push (octave_function *f) { cs.push_front (f); } | |
173 | |
5744 | 174 octave_function *do_top (void) { return cs.empty () ? 0 : cs.front (); } |
175 | |
5743 | 176 void do_pop (void) |
177 { | |
178 if (! cs.empty ()) | |
179 cs.pop_front (); | |
180 } | |
181 | |
182 void do_clear (void) { cs.clear (); } | |
183 }; | |
184 | |
1 | 185 #endif |
186 | |
187 /* | |
188 ;;; Local Variables: *** | |
189 ;;; mode: C++ *** | |
190 ;;; End: *** | |
191 */ |