diff src/toplev.h @ 5744:1c36a2e82266

[project @ 2006-04-06 19:38:34 by jwe]
author jwe
date Thu, 06 Apr 2006 19:38:35 +0000
parents a527e0f77aa5
children 93c65f2a5668
line wrap: on
line diff
--- a/src/toplev.h
+++ b/src/toplev.h
@@ -32,7 +32,7 @@
 class octave_value;
 class octave_value_list;
 class octave_function;
-class octave_user_function;
+class octave_user_script;
 class tree_statement_list;
 class charMatrix;
 
@@ -86,10 +86,7 @@
   }
 
   // Current function (top of stack).
-  static octave_function *current (void)
-  {
-    return instance_ok () ? instance->do_current (): 0;
-  }
+  static octave_function *current (void) { return top (); }
 
   // Caller function, may be built-in.
   static octave_function *caller (void)
@@ -97,10 +94,22 @@
     return instance_ok () ? instance->do_caller (): 0;
   }
 
-  // First scripting language function on the stack.
-  static octave_user_function *caller_script (void)
+  // First script on the stack.
+  static octave_user_script *caller_script (void)
   {
-    return instance_ok () ? instance->do_caller_script (): 0;
+    return instance_ok () ? instance->do_caller_user_script (): 0;
+  }
+
+  // First user-defined function on the stack.
+  static octave_user_function *caller_user_function (void)
+  {
+    return instance_ok () ? instance->do_caller_user_function (): 0;
+  }
+
+  // First user-defined function on the stack.
+  static octave_function *caller_user_script_or_function (void)
+  {
+    return instance_ok () ? instance->do_caller_user_script_or_function (): 0;
   }
 
   static void push (octave_function *f)
@@ -109,6 +118,11 @@
       instance->do_push (f);
   }
 
+  static octave_function *top (void)
+  {
+    return instance_ok () ? instance->do_top (): 0;
+  }
+
   static void pop (void)
   {
     if (instance_ok ())
@@ -119,6 +133,10 @@
   // for use as an unwind_protect handler.
   static void unwind_pop (void *) { pop (); }
 
+  // A function for popping an octave_user_script from the top of the
+  // call stack that is suitable for use as an unwind_protect handler.
+  static void unwind_pop_script (void *);
+
   static void clear (void)
   {
     if (instance_ok ())
@@ -132,14 +150,18 @@
 
   static octave_call_stack *instance;
 
-  octave_function *do_current (void) { return cs.empty () ? 0 : cs.front (); }
-
   octave_function *do_caller (void);
 
-  octave_user_function *do_caller_script (void);
+  octave_user_script *do_caller_user_script (void);
+
+  octave_user_function *do_caller_user_function (void);
+
+  octave_function *do_caller_user_script_or_function (void);
 
   void do_push (octave_function *f) { cs.push_front (f); }
 
+  octave_function *do_top (void) { return cs.empty () ? 0 : cs.front (); }
+
   void do_pop (void)
   {
     if (! cs.empty ())