Context.st
changeset 8284 e73710353292
parent 8242 594cfd2150f7
child 8357 64be78ef1e77
equal deleted inserted replaced
8283:8fe0314f8d5a 8284:e73710353292
  1632     __INST(flags) = (OBJ)((INT)__INST(flags) & ~__MASKSMALLINT(__UNWIND_MARK));
  1632     __INST(flags) = (OBJ)((INT)__INST(flags) & ~__MASKSMALLINT(__UNWIND_MARK));
  1633 %}
  1633 %}
  1634 ! !
  1634 ! !
  1635 
  1635 
  1636 !Context methodsFor:'searching'!
  1636 !Context methodsFor:'searching'!
       
  1637 
       
  1638 findExceptional
       
  1639     "walk along the sender chain (starting with the sender), 
       
  1640      for a context which is marked as handle or raise context.
       
  1641      This non-standard interface is only to be used by exception"
       
  1642 
       
  1643     "/ this could have been (actually: was) implemented as:
       
  1644     "/
       
  1645     "/  |con|
       
  1646     "/
       
  1647     "/  con := self.
       
  1648     "/  [con notNil] whileTrue:[
       
  1649     "/      [con isHandleContext] ifTrue:[^con].
       
  1650     "/      [con isRaiseContext] ifTrue:[^con].
       
  1651     "/      con := con sender.
       
  1652     "/  ].
       
  1653     "/  ^ nil
       
  1654     "/
       
  1655     "/ and the code below does exactly this (somewhat faster, though).
       
  1656     "/
       
  1657     "/ (it avoids referencing all intermediate contexts, which would mark them special,
       
  1658     "/  although they aren't really - this is expert knowledge, no need to understand that ...)
       
  1659 
       
  1660 %{  /* NOCONTEXT */
       
  1661 
       
  1662     OBJ theContext;
       
  1663 
       
  1664     theContext = self;
       
  1665     while (__isNonNilObject(theContext)) {
       
  1666         if ((INT)(__ContextInstPtr(theContext)->c_flags) & __MASKSMALLINT(__HANDLE_MARK|__RAISE_MARK)) {
       
  1667             if (__isLazy(theContext)) {
       
  1668                 __PATCHUPCONTEXT(theContext);
       
  1669             }
       
  1670 
       
  1671             if (! __isNonLIFO(theContext)) {
       
  1672                 /* 
       
  1673                  * to be prepared for the worst situation 
       
  1674                  * (the sender is not stored, so the trap won't catch it)
       
  1675                  * make the writeBarrier trigger manually.
       
  1676                  * We'll see, if this is really required.
       
  1677                  */
       
  1678                 theContext->o_space |= CATCHMARK;
       
  1679 #if 0
       
  1680                 _markNonLIFO(theContext);
       
  1681 #endif
       
  1682             }
       
  1683             RETURN (theContext);
       
  1684         }
       
  1685         theContext = __ContextInstPtr(theContext)->c_sender;
       
  1686     }
       
  1687 %}.
       
  1688     ^ nil
       
  1689 !
  1637 
  1690 
  1638 findNextContextWithSelector:selector1 or:selector2 or:selector3
  1691 findNextContextWithSelector:selector1 or:selector2 or:selector3
  1639     "walk along the sender chain (starting with the sender), 
  1692     "walk along the sender chain (starting with the sender), 
  1640      for a context with either one of the given selectors.
  1693      for a context with either one of the given selectors.
  1641      This non-standard interface is only to be used by exception"
  1694      This non-standard interface is only to be used by exception"
  1791     "/  although they aren't really - this is expert knowledge, no need to understand that ...)
  1844     "/  although they aren't really - this is expert knowledge, no need to understand that ...)
  1792 
  1845 
  1793 %{  /* NOCONTEXT */
  1846 %{  /* NOCONTEXT */
  1794 
  1847 
  1795     OBJ theContext;
  1848     OBJ theContext;
  1796     OBJ sel;
       
  1797     OBJ __FETCHSELECTOR();
       
  1798     int flagMask = 0;
  1849     int flagMask = 0;
  1799     INT mask;
  1850     INT mask;
  1800 
  1851 
  1801     if (findHandleContext == true)
  1852     if (findHandleContext == true)
  1802         flagMask = __HANDLE_MARK;
  1853         flagMask = __HANDLE_MARK;
  2114 ! !
  2165 ! !
  2115 
  2166 
  2116 !Context class methodsFor:'documentation'!
  2167 !Context class methodsFor:'documentation'!
  2117 
  2168 
  2118 version
  2169 version
  2119     ^ '$Header: /cvs/stx/stx/libbasic/Context.st,v 1.124 2004-03-20 13:43:21 cg Exp $'
  2170     ^ '$Header: /cvs/stx/stx/libbasic/Context.st,v 1.125 2004-04-01 14:19:13 stefan Exp $'
  2120 ! !
  2171 ! !
  2121 
  2172 
  2122 Context initialize!
  2173 Context initialize!