23 #if !defined (octave_toplev_h)
24 #define octave_toplev_h 1
85 : fcn (f),
line (-1), column (-1), scope (s),
context (c), prev (p)
89 : fcn (elt.fcn),
line (elt.
line), column (elt.column),
107 typedef std::deque<call_stack_elt>::iterator
iterator;
110 typedef std::deque<call_stack_elt>::reverse_iterator
112 typedef std::deque<call_stack_elt>::const_reverse_iterator
115 static void create_instance (
void);
117 static bool instance_ok (
void)
126 ::error (
"unable to create call stack object!");
137 return instance_ok () ? instance->do_current () : 0;
141 static int current_line (
void)
143 return instance_ok () ? instance->do_current_line () : -1;
147 static int current_column (
void)
149 return instance_ok () ? instance->do_current_column () : -1;
153 static int caller_user_code_line (
void)
155 return instance_ok () ? instance->do_caller_user_code_line () : -1;
159 static int caller_user_code_column (
void)
161 return instance_ok () ? instance->do_caller_user_code_column () : -1;
167 return instance_ok () ? instance->do_caller () : 0;
170 static size_t current_frame (
void)
172 return instance_ok () ? instance->do_current_frame () : 0;
177 return instance_ok () ? instance->do_size () : 0;
182 return instance_ok ()
183 ? instance->do_num_user_code_frames (curr_user_frame) : 0;
188 return instance_ok () ? instance->do_current_scope () : 0;
193 return instance_ok () ? instance->do_current_context () : 0;
200 return instance_ok () ? instance->do_element (n) : 0;
206 return instance_ok () ? instance->do_caller_user_code (nskip) : 0;
215 instance->do_push (f, scope,
context);
223 instance->do_push (0, scope,
context);
226 static void set_location (
int l,
int c)
229 instance->do_set_location (l, c);
232 static void set_line (
int l)
235 instance->do_set_line (l);
238 static void set_column (
int c)
241 instance->do_set_column (c);
244 static bool goto_frame (
size_t n = 0,
bool verbose =
false)
246 return instance_ok () ? instance->do_goto_frame (n, verbose) :
false;
249 static void restore_frame (
size_t n)
254 static bool goto_frame_relative (
int n,
bool verbose =
false)
256 return instance_ok ()
257 ? instance->do_goto_frame_relative (n, verbose) :
false;
260 static void goto_caller_frame (
void)
263 instance->do_goto_caller_frame ();
266 static void goto_base_frame (
void)
269 instance->do_goto_base_frame ();
274 return instance_ok ()
275 ? instance->do_backtrace (nskip, curr_user_frame) :
octave_map ();
280 static void pop (
void)
289 instance->do_clear ();
292 static void backtrace_error_message (
void)
295 instance->do_backtrace_error_message ();
301 std::deque<call_stack_elt>
cs;
309 int do_current_line (
void)
const;
311 int do_current_column (
void)
const;
313 int do_caller_user_code_line (
void)
const;
315 int do_caller_user_code_column (
void)
const;
319 return curr_frame > 1 ? cs[curr_frame-1].fcn : cs[0].fcn;
326 size_t do_num_user_code_frames (
octave_idx_type& curr_user_frame)
const;
330 return curr_frame > 0 && curr_frame < cs.size ()
331 ? cs[curr_frame].scope : 0;
336 return curr_frame > 0 && curr_frame < cs.size ()
337 ? cs[curr_frame].context : 0;
358 size_t prev_frame = curr_frame;
359 curr_frame = cs.size ();
377 void do_set_location (
int l,
int c)
388 void do_set_line (
int l)
398 void do_set_column (
int c)
411 bool do_goto_frame (
size_t n,
bool verbose);
413 bool do_goto_frame_relative (
int n,
bool verbose);
415 void do_goto_caller_frame (
void);
417 void do_goto_base_frame (
void);
424 curr_frame = elt.
prev;
433 void do_backtrace_error_message (
void)
const;
439 #define OCTAVE_IGNORE_EXCEPTION(E) \
442 std::cerr << "error: ignoring " #E " while preparing to exit" << std::endl; \
443 recover_from_exception (); \
446 #define OCTAVE_SAFE_CALL(F, ARGS) \
451 unwind_protect frame; \
453 frame.protect_var (Vdebug_on_error); \
454 frame.protect_var (Vdebug_on_warning); \
456 Vdebug_on_error = false; \
457 Vdebug_on_warning = false; \
461 OCTAVE_IGNORE_EXCEPTION (octave_interrupt_exception) \
462 OCTAVE_IGNORE_EXCEPTION (octave_execution_exception) \
463 OCTAVE_IGNORE_EXCEPTION (std::bad_alloc) \