Context.st
changeset 2205 ef9bf05e4bc8
parent 2201 db0f6e86c8bb
child 2212 be31fd0cea4d
equal deleted inserted replaced
2204:0ec2bd49dd82 2205:ef9bf05e4bc8
   427 
   427 
   428     /*
   428     /*
   429      * this special nil test is for the very first context (startup-context);
   429      * this special nil test is for the very first context (startup-context);
   430      * actually, its cosmetics, to avoid a visible nil>>nil context in the debugger.
   430      * actually, its cosmetics, to avoid a visible nil>>nil context in the debugger.
   431      */
   431      */
   432 
   432     theContext = __INST(sender);
   433     if (__isNonNilObject(theContext = __INST(sender))) {
   433     if (__isNonNilObject(theContext)) {
       
   434 
   434 	if (__isLazy(theContext)) {
   435 	if (__isLazy(theContext)) {
   435 	    /*
   436 	    /*
   436 	     * this cannot happen
   437 	     * this cannot happen
   437 	     */
   438 	     */
   438 	    _PATCHUPCONTEXT(theContext);
   439 	    _PATCHUPCONTEXT(theContext);
   560      unrestartable or of a block (which is never restartable)
   561      unrestartable or of a block (which is never restartable)
   561     "
   562     "
   562     ^ InvalidReturnSignal 
   563     ^ InvalidReturnSignal 
   563 	  raiseRequestWith:value
   564 	  raiseRequestWith:value
   564 	  errorString:(how , ': context cannot be restarted/returned from')
   565 	  errorString:(how , ': context cannot be restarted/returned from')
       
   566 ! !
       
   567 
       
   568 !Context methodsFor:'exception support'!
       
   569 
       
   570 findContextWithSelector:selector1 or:selector2
       
   571     "walk along the sender chain, for a context with
       
   572      the given selector.
       
   573      This non-standard interface is only to be used by exception"
       
   574 
       
   575     "/ this could have been implemented as:
       
   576     "/
       
   577     "/	|sender|
       
   578     "/
       
   579     "/	self selector == aSelector ifTrue:[^ self].
       
   580     "/	sender := self sender.
       
   581     "/	sender notNil ifTrue:[^ sender findContextWithSelector:aSelector].
       
   582     "/	^ nil
       
   583     "/
       
   584     "/ and the code below actually does this (somewhat faster, though).
       
   585 
       
   586 %{  /* NOCONTEXT */
       
   587 
       
   588     OBJ theContext;
       
   589     OBJ sel;
       
   590 
       
   591     /*
       
   592      * this special nil test is for the very first context (startup-context);
       
   593      * actually, its cosmetics, to avoid a visible nil>>nil context in the debugger.
       
   594      */
       
   595 
       
   596     sel = __INST(selector);
       
   597     if ((sel == selector1)
       
   598      || ((selector2 != nil) && (sel == selector2))) {
       
   599 	RETURN (self);
       
   600     }
       
   601 
       
   602     theContext = __INST(sender);
       
   603     while (__isNonNilObject(theContext)) {
       
   604         if (__isLazy(theContext)) {
       
   605             /*
       
   606              * this cannot happen
       
   607              */
       
   608             _PATCHUPCONTEXT(theContext);
       
   609         }
       
   610 
       
   611 	sel = __ContextInstPtr(theContext)->c_selector;
       
   612 	if ((sel == selector1)
       
   613 	 || ((selector2 != nil) && (sel == selector2))) {
       
   614             /* 
       
   615              * to be prepared for the worst situation 
       
   616              * (the sender is not stored, so the trap wont catch it)
       
   617              * make the writeBarrier trigger manually.
       
   618              * We'll see, if this is really required.
       
   619              */
       
   620             theContext->o_space |= CATCHMARK;
       
   621 	    _markNonLIFO(theContext);
       
   622 	    RETURN (theContext);
       
   623 	}
       
   624 	theContext = __ContextInstPtr(theContext)->c_sender;
       
   625     }
       
   626 %}.
       
   627     ^ nil
   565 ! !
   628 ! !
   566 
   629 
   567 !Context methodsFor:'minidebugger printing'!
   630 !Context methodsFor:'minidebugger printing'!
   568 
   631 
   569 fullPrint
   632 fullPrint
  1295 ! !
  1358 ! !
  1296 
  1359 
  1297 !Context class methodsFor:'documentation'!
  1360 !Context class methodsFor:'documentation'!
  1298 
  1361 
  1299 version
  1362 version
  1300     ^ '$Header: /cvs/stx/stx/libbasic/Context.st,v 1.71 1997-01-17 23:29:55 cg Exp $'
  1363     ^ '$Header: /cvs/stx/stx/libbasic/Context.st,v 1.72 1997-01-18 19:22:31 cg Exp $'
  1301 ! !
  1364 ! !
  1302 Context initialize!
  1365 Context initialize!