comparison src/toplev.cc @ 7752:40c428ea3408

initial implementation of dbup and dbdown
author John W. Eaton <jwe@octave.org>
date Sun, 04 May 2008 03:42:19 -0400
parents a059b5679fbb
children 6b521b1e3631
comparison
equal deleted inserted replaced
7751:7c020c067a60 7752:40c428ea3408
179 { 179 {
180 Octave_map retval; 180 Octave_map retval;
181 181
182 int nframes = cs.size () - n; 182 int nframes = cs.size () - n;
183 183
184 if (nframes > 0) 184 if (n >= 0 && nframes > 0)
185 { 185 {
186 Cell keys (4, 1); 186 Cell keys (6, 1);
187 187
188 keys(0) = "file"; 188 keys(0) = "file";
189 keys(1) = "name"; 189 keys(1) = "name";
190 keys(2) = "line"; 190 keys(2) = "line";
191 keys(3) = "column"; 191 keys(3) = "column";
192 keys(4) = "scope";
193 keys(5) = "context";
192 194
193 Cell file (nframes, 1); 195 Cell file (nframes, 1);
194 Cell name (nframes, 1); 196 Cell name (nframes, 1);
195 Cell line (nframes, 1); 197 Cell line (nframes, 1);
196 Cell column (nframes, 1); 198 Cell column (nframes, 1);
199 Cell scope (nframes, 1);
200 Cell context (nframes, 1);
197 201
198 octave_idx_type k = 0; 202 octave_idx_type k = 0;
199 203
200 for (const_iterator p = cs.begin () + n; p != cs.end (); p++) 204 for (const_iterator p = cs.begin () + n; p != cs.end (); p++)
201 { 205 {
202 const call_stack_elt& elt = *p; 206 const call_stack_elt& elt = *p;
207
208 scope(k) = elt.scope;
209 context(k) = elt.context;
203 210
204 octave_function *f = elt.fcn; 211 octave_function *f = elt.fcn;
205 212
206 if (f) 213 if (f)
207 { 214 {
234 241
235 retval.assign ("file", file); 242 retval.assign ("file", file);
236 retval.assign ("name", name); 243 retval.assign ("name", name);
237 retval.assign ("line", line); 244 retval.assign ("line", line);
238 retval.assign ("column", column); 245 retval.assign ("column", column);
239 } 246 retval.assign ("scope", scope);
247 retval.assign ("context", context);
248 }
249
250 return retval;
251 }
252
253 bool
254 octave_call_stack::do_goto_frame (size_t n, bool verbose)
255 {
256 bool retval = false;
257
258 if (n < cs.size ())
259 {
260 retval = true;
261
262 curr_frame = n;
263
264 const call_stack_elt& elt = cs[n];
265
266 symbol_table::set_scope_and_context (elt.scope, elt.context);
267
268 if (verbose)
269 {
270 octave_function *f = elt.fcn;
271 std::string nm = f ? f->name () : std::string ("<unknown>");
272
273 tree_statement *s = elt.stmt;
274 int l = -1;
275 int c = -1;
276 if (s)
277 {
278 l = s->line ();
279 c = s->column ();
280 }
281
282 octave_stdout << "stopped in " << nm
283 << " at line " << l << " column " << c
284 << " (" << elt.scope << "[" << elt.context << "])"
285 << std::endl;
286 }
287 }
288
289 return retval;
290 }
291
292 bool
293 octave_call_stack::do_goto_frame_relative (int n, bool verbose)
294 {
295 bool retval = false;
296
297 size_t sz = cs.size ();
298
299 if (n == 0)
300 retval = true;
301 else if ((n > 0 && static_cast<size_t> (n) < sz - curr_frame)
302 || (n < 0 && static_cast<size_t> (-n) < curr_frame))
303 retval = goto_frame (curr_frame + n, verbose);
240 304
241 return retval; 305 return retval;
242 } 306 }
243 307
244 void 308 void