Context.st
changeset 8284 e73710353292
parent 8242 594cfd2150f7
child 8357 64be78ef1e77
--- a/Context.st	Thu Apr 01 15:33:51 2004 +0200
+++ b/Context.st	Thu Apr 01 16:19:13 2004 +0200
@@ -1635,6 +1635,59 @@
 
 !Context methodsFor:'searching'!
 
+findExceptional
+    "walk along the sender chain (starting with the sender), 
+     for a context which is marked as handle or raise context.
+     This non-standard interface is only to be used by exception"
+
+    "/ this could have been (actually: was) implemented as:
+    "/
+    "/  |con|
+    "/
+    "/  con := self.
+    "/  [con notNil] whileTrue:[
+    "/      [con isHandleContext] ifTrue:[^con].
+    "/      [con isRaiseContext] ifTrue:[^con].
+    "/      con := con sender.
+    "/  ].
+    "/  ^ nil
+    "/
+    "/ and the code below does exactly this (somewhat faster, though).
+    "/
+    "/ (it avoids referencing all intermediate contexts, which would mark them special,
+    "/  although they aren't really - this is expert knowledge, no need to understand that ...)
+
+%{  /* NOCONTEXT */
+
+    OBJ theContext;
+
+    theContext = self;
+    while (__isNonNilObject(theContext)) {
+        if ((INT)(__ContextInstPtr(theContext)->c_flags) & __MASKSMALLINT(__HANDLE_MARK|__RAISE_MARK)) {
+            if (__isLazy(theContext)) {
+                __PATCHUPCONTEXT(theContext);
+            }
+
+            if (! __isNonLIFO(theContext)) {
+                /* 
+                 * to be prepared for the worst situation 
+                 * (the sender is not stored, so the trap won't catch it)
+                 * make the writeBarrier trigger manually.
+                 * We'll see, if this is really required.
+                 */
+                theContext->o_space |= CATCHMARK;
+#if 0
+                _markNonLIFO(theContext);
+#endif
+            }
+            RETURN (theContext);
+        }
+        theContext = __ContextInstPtr(theContext)->c_sender;
+    }
+%}.
+    ^ nil
+!
+
 findNextContextWithSelector:selector1 or:selector2 or:selector3
     "walk along the sender chain (starting with the sender), 
      for a context with either one of the given selectors.
@@ -1793,8 +1846,6 @@
 %{  /* NOCONTEXT */
 
     OBJ theContext;
-    OBJ sel;
-    OBJ __FETCHSELECTOR();
     int flagMask = 0;
     INT mask;
 
@@ -2116,7 +2167,7 @@
 !Context class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Context.st,v 1.124 2004-03-20 13:43:21 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Context.st,v 1.125 2004-04-01 14:19:13 stefan Exp $'
 ! !
 
 Context initialize!